CloudFormation vs AWS CLI: What’s the Difference?
CloudFormation (CFT) is used to create the infrastructure in the cloud (IAC).
We know that AWS CLI can also be used to manage and create infrastructure, so how is it different from CloudFormation?
Usually, you write code to develop something using Java, Python, C, and many more languages — but CFT is basically used to create infrastructure in the cloud.
When to Use AWS CLI and When to Use CloudFormation
- CLI is used when you have to perform a task very quickly and take short actions.
- CFT is used to create a whole stack of infrastructure in a structured, repeatable, and automated way.
Use Case | Use AWS CLI | Use CloudFormation (CFT) |
---|---|---|
Quick actions | ✅ Yes | ❌ Overkill |
Full environment setup | ❌ Tedious manually | ✅ Ideal with reusable templates |
Automation & repeatability | ❌ Difficult to track | ✅ Version-controlled & reproducible |
One-time config | ✅ Great | ❌ Unnecessary complexity |
Team collaboration | ❌ Hard to share commands | ✅ Easy to share YAML/JSON templates |
YAML vs JSON
- YAML allows commenting, which is useful for documentation and clarity more readable.
- JSON does not support comments.
Features of CloudFormation
✅ Drift Detection
Drift detection is used to identify if any manual changes have been made to the resources that were provisioned by a CloudFormation stack.
Example 1:
- You deployed an S3 bucket with versioning enabled using CFT.
- Someone disabled versioning manually.
- Drift detection will show a mismatch.
Example 2:
- Your CFT enabled detailed monitoring for an EC2 instance.
- Someone disabled it manually.
- Drift detection will alert you.
✍️ Final Thoughts
- Use CLI for short, quick tasks or scripting.
- Use CFT when you need structure, automation, and team collaboration.
- YAML is easier to read and maintain compared to JSON.
- CFT gives you visibility and consistency over your infrastructure.
Stayed Tuned for Next Part
✍️ Author: Omkar Sharma
📬 Feel free to connect on LinkedIn or explore more on GitHub
Top comments (0)