This example creates a "team" EC2 Instance with tags set from upstream "company" and "department" stacks via StackReference.
/**
* company
* └─ department
* └─ team
*/
This directory contains three Pulumi projects that must be deployed in order:
- company/ — exports the company name.
- department/ — exports the department name.
- team/ — creates an EC2 instance tagged with values read from the company and department stacks.
-
Change to the
companydirectory and install dependencies:cd company npm install -
Create a new stack:
pulumi stack init dev
-
Set the required configuration variables:
pulumi config set companyName 'ACME Widget Company'
-
Deploy the stack with
pulumi up:pulumi up
Updating (dev): Type Name Status + pulumi:pulumi:Stack aws-ts-stackreference-company-dev created Outputs: companyName: "ACME Widget Company" Resources: + 1 created Duration: 1s -
Change to the
departmentdirectory and install dependencies:cd ../department npm install -
Create a new stack:
pulumi stack init dev
-
Set the required configuration variables:
pulumi config set departmentName 'E-Commerce'
-
Deploy the stack with
pulumi up:pulumi up
Updating (dev): Type Name Status + pulumi:pulumi:Stack aws-ts-stackreference-department-dev created Outputs: departmentName: "E-Commerce" Resources: + 1 created Duration: 1s -
Change to the
teamdirectory and install dependencies:cd ../team npm install -
Create a new stack:
pulumi stack init dev
-
Set the required configuration variables, replacing
YOUR_ORGwith the name of your Pulumi organization:pulumi config set companyStack YOUR_ORG/aws-ts-stackreference-company/dev pulumi config set departmentStack YOUR_ORG/aws-ts-stackreference-department/dev pulumi config set teamName 'Frontend Dev' pulumi config set aws:region us-west-2 # any valid AWS region works
-
Deploy the stack with
pulumi up:pulumi up
Updating (dev): Type Name Status + pulumi:pulumi:Stack aws-ts-stackreference-team-dev created >- ├─ pulumi:pulumi:StackReference clstokes/aws-ts-stackreference-company/dev read >- ├─ pulumi:pulumi:StackReference clstokes/aws-ts-stackreference-department/dev read + └─ aws:ec2:Instance tagged created Outputs: instanceId : "i-0a9ede9c446503903" instanceTags: { Managed By: "Pulumi" company : "ACME Widget Company" department: "E-Commerce" team : "Frontend Dev" } Resources: + 2 created Duration: 28s
Once you are done, destroy the resources and remove the stack. Repeat this in each of the
company, department, and team directories that you ran pulumi up within:
pulumi destroy
pulumi stack rm