patternbashpulumiTip
Pulumi stack management: dev, staging, and prod as separate stacks
Viewed 0 times
pulumi stackstack initstack selectPulumi.stack.yamlenvironment isolationstack configstack output
Problem
Pulumi programs run against a single active stack at a time. Without a consistent stack-per-environment convention, teams accidentally deploy dev configuration to prod or conflate stack names across projects.
Solution
Create one stack per environment. Use
pulumi.Config to drive environment-specific values. Store stack configuration in Pulumi.<stack>.yaml files committed to source control.# Create stacks
pulumi stack init dev
pulumi stack init staging
pulumi stack init prod
# Set stack-specific config
pulumi stack select dev
pulumi config set aws:region us-east-1
pulumi config set instanceType t3.micro
pulumi stack select prod
pulumi config set aws:region us-east-1
pulumi config set instanceType m5.large
# Deploy to selected stack
pulumi upPulumi.prod.yaml:config:
aws:region: us-east-1
myapp:instanceType: m5.large
myapp:enableMonitoring: "true"Why
Stacks provide complete isolation of state, configuration, and resources. The
pulumi stack select command makes the current context explicit, reducing the risk of deploying to the wrong environment.Gotchas
- Stack names are global within a Pulumi organization — use a consistent naming convention like
org/project/env pulumi stack lsshows all stacks and their last update time — useful for auditing- Stack outputs (
pulumi stack output) can be consumed by other stacks or CI pipelines - Destroying a stack (
pulumi destroy --remove) deletes both resources and state — not reversible
Context
Managing multiple deployment environments with Pulumi
Revisions (0)
No revisions yet.