Hi, I think it's maybe more like a typescript ques...
# general
c
Hi, I think it's maybe more like a typescript question then pulumi, but what is the recommended way to structure the infrastructure code? I'm thinking in a similar structure like the attached, the main pont to share "node_modules" and custom "modules" directories, those doesn't have env specific code and use separate directories for the env codes. Would be the best if I could tie the envs to stacks somehow and run pulumi commands from the env directories or maybe run from the root with an index.ts file, which get the stack name programatically and import the code from the correct env. Is there other recommended way to do this?
b
Ours is structured:
Copy code
- components
  - aws-dns-root-zone
  - aws-network
  - aws-postgresql
  - azure-rbms
  - [etc.]
- services
  - gitlab
  - gitlab-runner
  - jira
  - [etc.]
- environments [for singletons, like our infra env that hosts gitlab etc.]
  - infra
- deployables
  - app [which is deployed to prod, preprod, qa1, qa2, dev-foobar, etc.]
They all live in a single Yarn workspace.
c
yeah, but if I understand correcty the different environment are not separated, right? I mean just on the stack level
b
Environments that are singular are separated.
That's how
infra
is set up.
If it's actually a per-deployment stack, then no.
c
what do you mean by singular? where do you have the pulumi specific configs like Pulumi.yaml?
I tried to put those to the env specific dirs(dev,prod), but then it's unable to find the modules from "node_modules" when running "pulumi up"
b
When I mean singular, I mean exactly that - we have one "infra" env because it's where gitlab, jira, etc. live. Their stack state is commingled in with the others.
(we have a prefix for them)
c
and you have env specific condition(like if-s) in "infra"?
b
no?
We just have exactly one of them, so it gets its own entry-point file.
c
so you just run "pulumi up" from the infra directory, right?
b
Correct.
c
thanks for your help