StackReference Example
This example lives in the pulumi/examples repository. Check out just this directory to use it:
git clone --filter=blob:none --sparse https://github.com/pulumi/examples pulumi-examplesgit -C pulumi-examples sparse-checkout set aws-py-stackreferencecd pulumi-examples/aws-py-stackreferenceThis example creates a “team” EC2 Instance with tags set from upstream “company” and “department” stacks via StackReference.
/** * company * └─ department * └─ team */Getting Started#
-
Change directory to
companyand install dependencies.Terminal window cd company -
Create a new stack:
Terminal window pulumi stack init dev -
Set the required configuration variables:
Terminal window pulumi config set companyName 'ACME Widget Company' -
Deploy everything with the
pulumi upcommand.Terminal window pulumi upPreviewing update (dev):Type Name Plan+ pulumi:pulumi:Stack aws-py-stackreference-company-dev createResources:+ 1 to createDo you want to perform this update? yesUpdating (dev):Type Name Status+ pulumi:pulumi:Stack aws-py-stackreference-company-dev createdOutputs:companyName: "ACME Widget Company"Resources:+ 1 createdDuration: 1sPermalink: https://app.pulumi.com/clstokes/aws-py-stackreference-company/dev/updates/1 -
Change directory to
departmentand install dependencies.Terminal window cd ../department -
Create a new stack:
Terminal window pulumi stack init dev -
Set the required configuration variables:
Terminal window pulumi config set departmentName 'E-Commerce' -
Deploy everything with the
pulumi upcommand.Terminal window pulumi upPreviewing update (dev):Type Name Plan+ pulumi:pulumi:Stack aws-py-stackreference-department-dev createResources:+ 1 to createDo you want to perform this update? yesUpdating (dev):Type Name Status+ pulumi:pulumi:Stack aws-py-stackreference-department-dev createdOutputs:departmentName: "E-Commerce"Resources:+ 1 createdDuration: 1sPermalink: https://app.pulumi.com/clstokes/aws-py-stackreference-department/dev/updates/1 -
Change directory to
teamand install dependencies.Terminal window cd ../team -
Create a new stack:
Terminal window pulumi stack init dev -
Set the required configuration variables, replacing
YOUR_ORGwith the name of your Pulumi organization:Terminal window pulumi config set companyStack YOUR_ORG/aws-py-stackreference-company/devpulumi config set departmentStack YOUR_ORG/aws-py-stackreference-department/devpulumi config set teamName 'Frontend Dev'pulumi config set aws:region us-west-2 # any valid AWS zone works -
Deploy everything with the
pulumi upcommand.Terminal window envchain aws pulumi upPreviewing update (dev):Type Name Plan+ pulumi:pulumi:Stack aws-py-stackreference-team-dev create>- ├─ pulumi:pulumi:StackReference clstokes/aws-py-stackreference-department/dev read>- ├─ pulumi:pulumi:StackReference clstokes/aws-py-stackreference-company/dev read+ └─ aws:ec2:Instance tagged createResources:+ 2 to createDo you want to perform this update? yesUpdating (dev):Type Name Status+ pulumi:pulumi:Stack aws-py-stackreference-team-dev created>- ├─ pulumi:pulumi:StackReference clstokes/aws-py-stackreference-company/dev read>- ├─ pulumi:pulumi:StackReference clstokes/aws-py-stackreference-department/dev read+ └─ aws:ec2:Instance tagged createdOutputs:instanceId : "i-0a9ede9c446503903"instanceTags: {Managed By: "Pulumi"company : "ACME Widget Company"department: "E-Commerce"team : "Frontend Dev"}Resources:+ 2 createdDuration: 28sPermalink: https://app.pulumi.com/clstokes/aws-py-stackreference-team/dev/updates/1
Clean Up#
-
Once you are done, destroy all of the resources and the stack. Repeat this in each of the
company,department, andteamdirectories from above that you ranpulumi upwithin.Terminal window pulumi destroypulumi stack rm
