- Lab
- A Cloud Guru
Using CloudFormation Drift Detection
This lab discusses CloudFormation drift detection. CloudFormation stack drift occurs when the resources in a stack have drifted from their original creation template. This can become a major problem — and drift detection can be used to identify it. After the problem is identified, the lab covers the stack update steps that can be taken to bring the CloudFormation stack back into sync with the original template.
Path Info
Table of Contents
-
Challenge
Create CloudFormation Stack
- In EC2, create a key pair called
driftlab
. - Create a CloudFormation stack using the
ec24drift.json
template file linked in the lab instructions. Use the following stack details:- Stack name: driftlab
- InstanceType: t2.micro
- KeyName: driftlab
- MySubnet: Select any one of the listed subnets
- myVPC: Select the only listed VPC
- Give the stack a "name" tag of "driftlab"
- In EC2, create a key pair called
-
Challenge
Terminate an EC2 Instance to Introduce Stack Drift
- In EC2, select Instance3, and under Actions > Security > Change security groups, remove the currently selected security group, and add the default security group.
- Select Instance 1, and terminate the instance.
- Go to Networking & Security > Security Groups. For the security group with
driftlab-InstanceSecurityGroup
in the name, add HTTP and HTTPS inbound rules. - In S3, disable static website hosting for the bucket that was created (it will have
driftlab
in the name). - In CloudFormation, detect drift and view the results.
-
Challenge
Eliminate Drift from Stack
- In EC2, select Instance3. Under Actions > Security > Change security groups, remove the default security group, and reassign the driftlab- security group.
- In CloudFormation, select EC2Instance3, detect drift, and view the results for the resource to see that it is now in sync.
- Still in CloudFormation, update the driftlab stack by uploading the
afterdriftupdate.json
file (link available in the lab instructions) as the template file. - Detect drift and view the results to see that all resources are in sync.
What's a lab?
Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.
Provided environment for hands-on practice
We will provide the credentials and environment necessary for you to practice right within your browser.
Guided walkthrough
Follow along with the author’s guided walkthrough and build something new in your provided environment!
Did you know?
On average, you retain 75% more of your learning if you get time for practice.