Part 1: The Updated Template
Explanation
You already have a stack running from Lab 1.0 with a single EC2 instance. In this lab you will replace that template with a richer one that adds:
- A Parameter — so you can pass a custom value at deploy time
- An Elastic IP — a static public IP address attached to the instance
- Two Security Groups — one for SSH access, one for web traffic
- An updated EC2 instance — now referencing the security groups above
The file you will use is 1-ec2-with-sg-eip.yaml. Open it in your editor and read through it before uploading. Notice:
- The
Parameters section at the top defines a SecurityGroupDescription input
- The EC2 instance now has a
SecurityGroups property that references the two groups defined below it
- The
!Ref function connects resources together — e.g. the Elastic IP references the instance
Key Concepts
- Parameters let you make templates reusable. Instead of hardcoding a value, you define a placeholder and provide the real value at deploy time.
!Ref on a resource returns its ID or name depending on the resource type — this is how resources link to each other inside a template.
- Adding new resources to an existing template does not mean rebuilding everything from scratch — CloudFormation calculates only what changed.
Part 2: Start the Update
- Open the CloudFormation Console and click on your running stack (
EC2InstanceDemo).
- Click Update in the top-right.