Complete AWS CloudFormation Guide In 2026

What is AWS CloudFormation

AWS CloudFormation is an Infrastructure as Code (IaC) service provided by Amazon Web Services that enables developers and system administrators to define, provision and manage cloud infrastructure using code templates. These templates describe the required AWS resources and their configurations in JSON or YAML format.

Why we Use AWS CloudFormation

AWS CloudFormation is used to automate the creation and management of AWS infrastructure using code instead of manually configuring resources through the AWS Management Console. In traditional cloud management, developers need to create resources such as EC2 instances, S3 buckets, databases, and networking components one by one, which can be time-consuming and prone to human errors.

By using CloudFormation, all infrastructure components can be defined in a template file (JSON or YAML). Once the template is executed, CloudFormation automatically provisions and configures all the required resources in the correct order.

Components of AWS CloudFormation

1. Templates

A template is the main component of CloudFormation. It is a file written in JSON or YAML format that defines the AWS resources and their configurations.

2. Stacks

A stack is a collection of AWS resources that are created and managed together using a CloudFormation template.

When a template is executed, CloudFormation creates a stack that includes all the resources defined in the template. Users can create, update, or delete stacks to manage infrastructure.

3. Parameters

Parameters allow users to pass input values into templates when creating or updating stacks.

4. Resources:

The Resources section defines the actual AWS services that will be created by the stack.

Examples include:

5. Outputs

Outputs allow users to display or export useful information after the stack is created.

For example:

  • Public IP of an EC2 instance
  • Website URL of an S3 bucket
  • Database endpoint

What is Rollback in AWS CloudFormation?

Rollback in AWS CloudFormation is a feature that automatically reverts the stack to its previous stable state if stack creation or update fails. This helps prevent partially created or broken infrastructure.

During stack creation or update, CloudFormation provisions multiple AWS resources such as EC2 instances, S3 buckets, databases, and networking components. If any resource fails to be created or configured correctly, CloudFormation automatically initiates a rollback process.

CloudFormation vs Terraform

Feature AWS CloudFormation Terraform
Provider Amazon Web Services HashiCorp
Cloud Support AWS only Multi-cloud (AWS, Azure, GCP, etc.)
Configuration Language JSON, YAML HCL (HashiCorp Configuration Language)
State Management Managed by AWS automatically Uses a state file (terraform.tfstate)
Open Source No Yes (Open-source tool)
Deployment Uses stacks to deploy resources Uses plans and apply commands
Integration Deep integration with AWS services Supports many providers and tools
Best For AWS-only environments Multi-cloud infrastructure

Limitations of AWS CloudFormation

  • AWS-Only Support CloudFormation works only with AWS services and cannot manage infrastructure in other cloud platforms like Azure or Google Cloud.
  • Complex Templates For large infrastructures, templates can become very long and difficult to manage.
  • Slow Stack Operations Creating or updating large stacks may take more time compared to some other Infrastructure as Code tools.
  • Difficult Debugging Error messages are sometimes not very clear, making troubleshooting harder.
  • Limited Flexibility Some advanced configurations or new AWS services may not be immediately supported.

How to Setup?

Step-1

AWS Console → Search → CloudFormation

Step-2

CloudFormation → Create Stack

Step-3

Upload Template

1. Amazon S3 URL

2. Upload a template file

3. Sync from Git

Step-4

Enter the Name of Stack

Step-5:

Review and Submit

Template resource:

Conclusion

AWS CloudFormation helps automate the creation and management of cloud resources using templates. It ensures consistent and efficient deployment of infrastructure. By using stacks and features like rollback and parameters, it simplifies cloud management. Overall, it plays an important role in building scalable cloud systems in Amazon Web Services.

Related Solutions

Terraform state locking with S3 and DynamoDB explained

Introduction 

When managing infrastructure-as-code using Terraform, the state file is a key component, as it keeps track of what resources are associated with your configuration and how they are configured relative to one another. Teams will suffer from corrupted state and conflicting updates if they are left on their own to store and coordinate state.As teams compete for overall dominance, resources are neglected.  Continue reading “Terraform state locking with S3 and DynamoDB explained”

Nifi and Zookeeper Cluster Setup with Terraform

Recently while trying to set up Apache Nifi in cluster mode manually, I faced the challenge of performing same tasks on all nodes manually. In addition configuring the right cluster configurations was not easy. In my last blog here, I have covered the advantages of having nifi cluster over standalone and the manual steps to configure a Nifi cluster with external zookeeper.
In this article, I will show you how you can set up a three-node Zookeeper and Nifi cluster with terraform which will minimize the steps we have to perform with manual setup.

Apache NiFi is an open-source data integration and automation tool that enables the automation of data flow between different systems. NiFi provides a user-friendly interface to design, control, and manage the flow of data between various sources and destinations. The tool is particularly useful in handling data from different sources, applying transformations, and routing it to different systems in real-time.

Advantage of Using Terraform for Nifi

Terraform allows you to define your NiFi cluster infrastructure as code, making it easily versioned, shareable, and easy to understand. This ensures that your infrastructure is consistent across different environments. This helps in maintaining consistency and reducing the chances of configuration drift. As your NiFi cluster requirements evolve, Terraform makes it simple to scale your infrastructure up or down by adjusting the configuration.

Setting Up Apache Nifi Cluster with External Zookeeper

Continue reading “Nifi and Zookeeper Cluster Setup with Terraform”

Deploying Azure Policy using Terraform Module

While working on Azure, you might come across a requirement that says the resources being deployed should be in accordance with the organization’s policies. Suppose you might want to grant a particular or a set of permissions on the resource group or on the management group so that the owner of it should be restricted like denying deploying of resources by enforcing resource tagging, region enforcement, allowing approved Virtual machines (VM) images, and many more. 

In this blog, we will try to resolve these issues by applying Azure policies. 

First, let’s get familiar with the azure policy.

The azure policy is a service that has been designed to help you enforce different rules and to act based on the rule’s effect on your Azure resources. You can use it to create, assign and manage policies. Azure policy evaluates your resources for non-compliance with assigned policies and performs the assigned effect. 

Continue reading “Deploying Azure Policy using Terraform Module”

Deploying Terraform IAC Using Azure DevOps Runtime Parameters

Introduction

While deploying your same terraform code manually multiple times you must have got through the thoughts:

  • If we can automate the whole deployment process and replace the whole tedious process with few clicks.
  • If we can dynamically change the values of terraform.tfvars.
  • If we can restrict the regions of deployments.
  • If we can limit our VM types to maintain better cost optimization.

In this article, we will touch upon these problems and try to resolve them in a way that the same concepts can also be applied to similar requirements. Continue reading “Deploying Terraform IAC Using Azure DevOps Runtime Parameters”