AWS Cloudformation (original) (raw)

Last Updated : 9 Jun, 2026

AWS CloudFormation is an Infrastructure as Code (IaC) service that helps users create and manage AWS resources using code templates.

Templates and Stacks

CloudFormation works using two main concepts:

AWS CloudFormation Working

Amazon Web Services (AWS) provides cloud services such as EC2, S3, Auto Scaling, and Load Balancing. AWS CloudFormation helps automate the provisioning of these services using Infrastructure as Code (IaC), reducing manual configuration.

**Step-by-step process:

  1. Define infrastructure in a template.
  2. CloudFormation reads the template configuration.
  3. AWS APIs are called to create resources.
  4. Resources are deployed as a stack.
  5. Future updates safely modify the existing stack.

AWS-Cloud-Formation

Benefits

**Getting Started with AWS CloudFormation

CloudFormation templates are written in JSON or YAML format. In this article, we focus on the JSON template format.

JSON (JavaScript Object Notation) is a text-based format used to represent structured data. In AWS CloudFormation, JSON templates define AWS resources and their configurations in a structured way, which CloudFormation uses to create and manage the AWS infrastructure.

**Structure of CloudFormation JSON Template

Template Terms and Concepts

Understanding The Core Concepts That CloudFormation templates use to organize resources, settings, and functions is key to managing AWS infrastructure efficiently.

Template Anatomy

A CloudFormation template consists of several standard sections. The most important are:

1. Resources (Mandatory)

The Resources section defines the AWS resources to be created in the stack.

Resources: MyBucket: Type: AWS::S3::Bucket Properties: BucketName: my-app-logs-2025

The Parameters section makes your template flexible by allowing user input during stack creation.

Parameters: InstanceType: Type: String Default: t2.micro AllowedValues: [t2.micro, m5.large]

3. Outputs (Optional)

The **Outputs section displays values after stack creation, such as a server IP address or Load Balancer URL.

4. Mappings (Optional)

The Mappings section stores fixed values, often used for Region-specific configurations like AMI IDs.

Deploy a CloudFormation Template

Deploying a CloudFormation template can be done through multiple methods, each catering to different preferences and workflows

1. AWS Management Console

2. CloudFormation Designer

3. **AWS CLI (Command Line Interface)

Create an AWS CloudFormation Template

There are two main ways to create an AWS CloudFormation template:

1. Use Pre-Built Templates

2. Build Your Own Template from Scratch

**Steps to Provision an EC2 Instance and LAMP Package Using AWS CloudFormation

An AWS CloudFormation template that provisions an EC2 instance and automatically installs the LAMP stack (Linux, Apache, MySQL, PHP) on it.

If you don’t have an AWS Free Tier account, you can refer to the Amazon Web Services (AWS) – Free Tier Account Set up.

**Step 1: Go to the AWS CloudFormation Dashboard

img1-660x293

**Step 2: Choose a Template

Sample Template

**Step 3: Customize the Template in the Designer

Cloudformation

**Step 4: Rename the Template

jason formate

**Step 5: Review the Template Code

paramenters

**Step 6: Exit the Designer

Resources

**Step 7: Configure Stack Settings

Template of AWS

**Step 8: Name the Stack

Configuration

**Step 9: Configure Database Settings

Paramenters of AWS Cloudformation

**Step 10: Choose Instance Type

AWS Cloudformation 10

**Step 11: Skip Advanced Settings

Advanced options

**Step 12: Create the Stack

Create stack

Alternatives to CloudFormation

AWS CloudFormation is a very Famous infrastructure-as-code tool for managing AWS resources several alternatives offer different features and support for multi-cloud environments. Listing out some of very popular alternatives.

CloudFormation vs. Terraform

A common question for DevOps engineers is which tool to use.

**AWS CloudFormation **Terraform
AWS Only. Deep integration with AWS features. Multi-Cloud. Supports AWS, Azure, Google, etc.
Managed. AWS manages the state file for you. Manual. You must manage the state file (e.g., in S3).
JSON or YAML. HCL (HashiCorp Configuration Language).
Official AWS Support plan covers it. Community support (unless you pay for Terraform Cloud).
Built-in feature. Requires running terraform plan.

Advanced Features

1. CloudFormation Hooks

2. Drift Detection

3. Change Sets