https://pulumi.com logo
#general
Title
# general
c

cold-coat-35200

10/26/2018, 3:38 PM
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

boundless-monkey-50243

10/26/2018, 4:09 PM
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

cold-coat-35200

10/26/2018, 6:59 PM
yeah, but if I understand correcty the different environment are not separated, right? I mean just on the stack level
b

boundless-monkey-50243

10/26/2018, 7:55 PM
Environments that are singular are separated.
That's how
infra
is set up.
If it's actually a per-deployment stack, then no.
c

cold-coat-35200

10/26/2018, 7:58 PM
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

boundless-monkey-50243

10/26/2018, 8:01 PM
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

cold-coat-35200

10/26/2018, 8:05 PM
and you have env specific condition(like if-s) in "infra"?
b

boundless-monkey-50243

10/26/2018, 8:12 PM
no?
We just have exactly one of them, so it gets its own entry-point file.
c

cold-coat-35200

10/26/2018, 8:14 PM
so you just run "pulumi up" from the infra directory, right?
b

boundless-monkey-50243

10/26/2018, 9:31 PM
Correct.
c

cold-coat-35200

10/27/2018, 1:16 PM
thanks for your help