It is easy to create multiple instances of the same project. This is called a stack. This is handy for multiple development or test environments, staging versus production, and scaling a given infrastructure across many regions.
Create a new stack:
pulumi stack init prod
Next, configure its two required variables:
pulumi config set aws:region eu-west-1
pulumi config set iac-workshop:siteDir wwwprod
If you are ever curious to see the list of stacks for your current project, run this command:
pulumi stack ls
It will print all stacks for this project that are available to you:
NAME LAST UPDATE RESOURCE COUNT URL
dev 30 minutes ago 5 https://app.pulumi.com/joeduffy/iac-workshop/dev
prod* 3 minutes ago 0 https://app.pulumi.com/joeduffy/iac-workshop/prod
It would have been possible to use the existing www
directory for the siteDir
. In this example, you will use a different wwwprod
directory, to demonstrate the value of having configurability.
Create this new directory:
mkdir wwwprod
Add a new index.html
file to it:
<html>
<body>
<h1>Hello Pulumi</h1>
<p>(in production!)</p>
</body>
</html>
Now deploy all of the changes:
pulumi up
This will create an entirely new set of resources from scratch, unrelated to the existing dev
stack's resources.
Updating (prod):
Type Name Status
+ pulumi:pulumi:Stack iac-workshop-prod created
+ ├─ aws:s3:Bucket my-bucket created
+ └─ aws:s3:BucketObject index.html created
Outputs:
bucket_endpoint: "http://my-bucket-c7318c1.s3-website-eu-west-1.amazonaws.com"
bucket_name : "my-bucket-c7318c1"
Resources:
+ 3 created
Duration: 28s
Permalink: https://app.pulumi.com/joeduffy/iac-workshop/prod/updates/1
Now fetch your new website:
curl $(pulumi stack output bucket_endpoint)
Notice that it's the new production version of your content:
<html>
<body>
<h1>Hello Pulumi</h1>
<p>(in production!)</p>
</body>
</html>