Create the template
Create a file nameddrift.yaml in your project and paste the following CloudFormation template. It defines a single EC2 instance and a small region-to-AMI mapping. Save the file before creating the stack.
Create the CloudFormation stack (Console)
- Open the AWS CloudFormation console and choose Create stack.
- Select Upload a template file and pick your
drift.yaml. - Continue through the wizard, give the stack a name (for example
DemoStack), and create the stack.

View and detect drift
After the stack reaches CREATE_COMPLETE:- Select the stack (for example
DemoStack) in the CloudFormation console. - From Stack actions (or Stack options), choose View drift results and then click Detect stack drift to start the comparison.

t3.micro, and the AMI is chosen from the mapping for the selected region.
When detection completes you should see each resource’s drift status. If you haven’t changed the instance outside CloudFormation, the EC2 resource will show IN_SYNC.

Make an out-of-band change (EC2 console)
To demonstrate drift, modify the EC2 instance directly in the EC2 console (outside CloudFormation). For example, change the instance type:- Open the EC2 Instances page and select the instance created by the stack.
- Choose Instance state → Stop and wait for the instance to stop.
- With the instance selected, go to Actions → Instance settings → Change instance type and select a new type (e.g.,
t3.small). - Apply the change and start the instance again if needed.

t3.micro vs. t3.small). If you revert the instance type back to t3.micro and detect drift again, the resource will return to IN_SYNC.
Drift detection workflow (summary)
| Step | Action | Console / Example |
|---|---|---|
| 1 | Create resource with CloudFormation | Upload template and create stack (e.g., DemoStack) |
| 2 | Modify resource out-of-band | Change instance type from EC2 console to t3.small |
| 3 | Detect stack drift | CloudFormation → View drift results → Detect stack drift |
| 4 | Reconcile | Update resource to match template or update template and perform stack update |
Drift detection helps identify configuration differences but not every resource property is supported for drift detection. Always consult the CloudFormation documentation on Resources that support drift detection for details on which properties are checked: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-stack-drift.html
Clean up
When you finish the demo, delete the stack from the CloudFormation console. Deleting the stack will remove the EC2 instance and any other resources created by the template.
References
- AWS CloudFormation — Drift detection: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-stack-drift.html
- Amazon EC2 — Instances documentation: https://docs.aws.amazon.com/ec2/index.html