DEV Community

Omkar Sharma
Omkar Sharma

Posted on

1 1

CloudFormation or CLI? When to Script and When to Stack?

omkarsharma2821

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

AssemblyAI Challenge

AssemblyAI Voice Agents Challenge 🗣️

Running through July 27, the AssemblyAI Voice Agents is all about building with Universal-Streaming, AssemblyAI's most advanced real-time transcription API. Universal-Streaming is ultra fast (300ms latency!), ultra accurate, and offers intelligent endpointing to keep conversations flowing naturally.

Start building 🏗️

Top comments (0)

Feature flag article image

Create a feature flag in your IDE in 5 minutes with LaunchDarkly’s MCP server 🏁

How to create, evaluate, and modify flags from within your IDE or AI client using natural language with LaunchDarkly's new MCP server. Follow along with this tutorial for step by step instructions.

Read full post

World's Largest Hackathon Awards Ceremony

Join us for the World’s Largest Hackathon Award Ceremony as we announce the winners and recognize the amazing work from this community!

Tune in to the full event

DEV is partnering to bring live events to the community. Join us or dismiss this billboard if you're not interested. ❤️