Exercises to learn how to use Pulumi (4th session)
This exercise starts where we finished the previous session (a VPC and a VM) but dive deeper on Pulumi reusability patterns at scale. You'll learn how to create your own Component Resource, use your own resource providers across different regions, apply some tags and use stack references along the way.
For a better learning experience, you way want to start with your wn code from the previous training session.
- Switch to the
exercise
folder, create a new stack and install the node modules (npm install
) - Create 2 folders named
network
andapp
- Switch to the
network
folder, create a new stack and install the node modules (npm install
) - Disable all default providers
- Deploy a fully functional VPC in 2 or more configurable AWS regions (Component Resource)
- Leverage
pulumi config set
- Leverage
- Programmatically apply tags to your resources so it's easy to create an AWS Budget later on
- Determine the necessary stack outputs for the
app
project to use:
For this part of the exercise, using Component Resource is NOT required.
- Switch to the
app
folder - Disable all default providers
- Use stack references and programmatic provider declaration throughout
- Deploy a VM you can SSH into in the previously created subnets
- Use stack references
- using a free-tier instance type (reminder only - so your account doesn't get charged)
- using the most recent Debian 11 AMI for the region
- ensure you can SSH into each VM
- Create stack outputs for:
- the VMs hostname
- the SSH private key as secret
- the SSH public key
- Set tags on your VMs but apply the tags on 1 VM at a time when running
pulumi up
(no code or config changes between updates)- Requires inspecting the stack state file
- Requires a specific
pulumi up
option (see --help)
- Use Pulumi runtime functions to determine the current stack name
- Your component resource doesn't rely on pulumi.Config()
- Your component resource args use strong typing
- Pulumi examples
- taggable.ts and autotag.ts
You will find all the answers here.