billions-ghost-96421
07/26/2021, 6:30 AMplay
, dev
, and prod
.
play
can contain anything - it's a place for experimentation
dev
contains dev deployments of our API (perhaps different feature/hotfix branches), other internal dev tools
prod
contains the tested version of our API
How should I be organizing my code?
1) Use a single project and create the following stacks:
<org>/<project>/prod/infra
<org>/<project>/prod/api
<org>/<project>/dev/infra
<org>/<project>/dev/api/featureX
<org>/<project>/dev/api/featureY
<org>/<project>/dev/api/bugA
<org>/<project>/dev/api/bugB
<org>/<project>/play
But then I would have to add a lot of conditional statements in my program so that they are only deployed into the right stack.
2) Use a separate project for each environment and concern. Define my API and infrastructure as separate Component Resources (https://www.pulumi.com/docs/intro/concepts/resources/#components) and 'import' them into each project.
| project | sub-project | stack |
|---------|-------------|----------|
| prod | infra | infra |
| prod | api | api |
| dev | infra | infra |
| dev | api | featureX |
| dev | api | featureY |
| dev | api | bugA |
| play | infra | infra |
| play | any | any |
I understand that projects and stacks are designed to be flexible, but I would appreciate a bit of guidance. I get the feeling that the examples in the documentation expects parity between dev and prod - you deploy this project in dev, and then deploy the same project in prod. How do you organize the code when dev and prod are somewhat different (e.g. internal tools only deployed in dev) but also somewhat similar (e.g. networking)?
Thanks in advance for any help you can provide πgreat-sunset-355
07/26/2021, 6:53 AMConfig
object.
my current approach is
core-project # for shared infra, vpc network..
app-project/
__main__.py
Pulumi.dev.yaml
Pulumi.staging.yaml
environments
βββ client-test
βΒ Β βββ <http://backend.tf|backend.tf>
βΒ Β βββ <http://global-vars.tf|global-vars.tf>
βΒ Β βββ <http://main.tf|main.tf>
βΒ Β βββ terraform.tfvars
βΒ Β βββ <http://variables.tf|variables.tf>
βββ dev
βΒ Β βββ <http://backend.tf|backend.tf>
βΒ Β βββ <http://global-vars.tf|global-vars.tf>
βΒ Β βββ <http://main.tf|main.tf>
βΒ Β βββ terraform.tfvars
βΒ Β βββ <http://variables.tf|variables.tf>
βββ prod
βΒ Β βββ <http://backend.tf|backend.tf>
βΒ Β βββ <http://global-vars.tf|global-vars.tf>
βΒ Β βββ <http://main.tf|main.tf>
βΒ Β βββ terraform.tfvars
βΒ Β βββ <http://variables.tf|variables.tf>
βββ shared
βΒ Β βββ <http://backend.tf|backend.tf>
βΒ Β βββ <http://global-vars.tf|global-vars.tf>
βΒ Β βββ <http://main.tf|main.tf>
βΒ Β βββ terraform.tfvars
βΒ Β βββ <http://variables.tf|variables.tf>
βββ staging
βββ <http://backend.tf|backend.tf>
βββ <http://global-vars.tf|global-vars.tf>
βββ <http://main.tf|main.tf>
βββ terraform.tfvars
βββ <http://variables.tf|variables.tf>
witty-candle-66007
07/26/2021, 1:27 PMplay
is itβs own project since it seems it can be anything and is not all that aligned with the production environment. Maybe itβs a single stack or maybe different stacks for different users to test in? Not 100% sure.
β’ It seems like the dev
and prod
stacks are based on the same project. And you may want to think of making dev
to be multiple stacks - one for each branch/PR before being merged to main and that main drives the prod
stack.
β’ As far as the question of deploying internal tools in dev vs prod, then you probably want a different project for those non-prod tools. You can use stack references to allow the main application stack to find information it needs from the internal tools stack or perhaps more likely, vice versa.
β’ So in the end, if the above is valid, you may have a project for the play
environment(s). And then one or more stacks to instantiate that/those play environment(s). Then a project for the dev/branch-PR/prod environments that represent the system you are deploying for your business. And then a separate project to deploy the internal tooling needed for the non-prod environments with one or more stacks depending on what makes sense.billions-ghost-96421
07/26/2021, 5:53 PMprojects | stacks:
- infra
- <org>/infra/prod
- <org>/infra/dev
- <org>/infra/play
- api
- <org>/api/prod
- <org>/api/dev/main
- <org>/api/dev/featureX
- <org>/api/dev/featureY
- <org>/api/dev/bugA
- quota
- <org>/quota/prod
- <org>/quota/dev/main
- <org>/quota/dev/featureZ
- play
- <org>/play/default
(play
is meant to be a free-for-all, anything-goes sandbox so it makes sense that that particular environment is its own project)witty-candle-66007
07/26/2021, 5:55 PMgreat-sunset-355
07/26/2021, 7:15 PMdamp-rain-39201
10/24/2022, 7:21 AM