hey team, n00b pulumi question, when running `pulu...
# getting-started
l
hey team, n00b pulumi question, when running
pulumi up
to deploy a stack, is there any rules/guidelines to which directory of a repo that cmd needs to be run from? e.g for the below structure, if I want to deploy resources defined in
./resources/s3/index.ts
where do I use
pulumi up?
Copy code
resources
├── index.ts
└── s3
    └── index.ts
l
The same directory as your Pulumi.yaml and Pulumi.stack.yaml files.
l
right gotcha. Main reason this came about was that my outputs weren't getting printed to cli once I had moved
index.ts
from root dir into a deeper dir was wondering why/how the directory restructure would impact the outputs getting printed or not
l
You need to have your project entrypoint (index.ts) in the same directory as your project (Pulumi.yaml). The entrypoint can call to code anywhere. It could be in the same directory, other directories, NPM packages, whatever.
You can have any number of Pulumi projects in a repo. It'd probably be best not to nest them though. Maybe put them in sibling directories.
If you nest them, you run the risk of mixing up your tsconfigs, node_modules, etc.
Not Pulumi considerations, just js/ts ones.
l
good call. I initially started with my main definitions in
index.ts
and am now splitting up resources per services, such as
Copy code
./s3/index.ts
./cognito/index.ts
./lambda/index.ts
l
I wouldn't do that. You should group them based on deployment cycle. For example, if you need an S3 bucket for you VPC logging, and one for your webapp upload storage area, then every time you destroy an instance of your webapp upload bucket (once per integration test run, probably), then your VPC logging bucket will be destroyed.
If you put all the resources of any type that are associate with your webapp, then when you destroy your webapp, all your VPC/firewall resources will remain untouched.
And if you've only got one deployment "thing", and all your resources get deployed at once (per stack), then you don't want separate projects. You want component resources.
l
argh, my confusion remains as to how best to organise the folders is there a recommended guide I can point to? I have a nested
index.ts
which I want to use to import all my other resource definitions, but unclear of the approach as I seem to be getting it wrong
l
Yes, Pulumi has published a couple. Here's the most recent: https://www.pulumi.com/blog/iac-recommended-practices-structuring-pulumi-projects/ There is at least one more, but I can't find it right now.