AWS Cloudformation Template: Benefits, Format Example

AWS Cloudformation Template: Benefits, Format Example

July 1, 2020 / Nirav Shah

Cloud formation is a service that allows you to manage, configure and provision your AWS infrastructure as code and all resources are defined using cloud formation template. This template interacts with API calls and creates resources that you define.

It supports YAML and JSON.

Benefits Of Cloudfromation Templates

  1. Less time as compared to when the configuration is done manually.
  2. Free to use (however you are charged for what you create and usage of AWS services).
  3. Can be used to manage updates & dependencies.
  4. Can be used to rollback and delete entire stack as well.

What is a cloud formation template

Now let’s see what is a cloud formation template.
YAML or JSON template used to describe the end state of the infrastructure you are either provisioning or changing.
You can upload the cloud formation template on s3 bucket.
Cloud formation reads the temples and makes the API call on your behalf.

Cloudformation template yaml example

The resulting resources are called a stack.

AWS Cloudformation Template format is shown in the following YAML template.

AWSTemplateFormatVersion: "2010-09-09"
Description: A sample template
  MyEC2Instance: #An inline comment
    Type: "AWS::EC2::Instance"
      ImageId: "ami-0ff8a91507f77f867" #Another comment -- This is a Linux AMI
      InstanceType: t2.micro
      KeyName: testkey
          DeviceName: /dev/sdm
            VolumeType: io1
            Iops: 200
            DeleteOnTermination: false
            VolumeSize: 20

So from the above example, you can see that this template is about creating an EC2 instance and the size is t2 micro, and we have set the permission to delete on termination. And the keyname is testkey.

Cloudformation template JSON example

So it’s very easy to understand. Here we have defined the JSON format.

"Metadata": {
  "AWS::CloudFormation::Designer": {
    "6b56eaae-0bb6-4215-aad6-12345EXAMPLE": {
      "size": {
        "width": 60,
        "height": 60
      "position": {
        "x": 340,
        "y": 430
      "z": 2,
      "parent": "21ccc9b0-29e9-4a86-9cf2-12345EXAMPLE",
      "embeds": [],
      "ismemberof": [

Learn more about Cloudformation Template anatomy from AWS documentation

What is Template Snippets

It provides a number of example scenarios that you can use to understand how to declare various AWS CloudFormation template parts.


Please visit the links to get more information.

Also Read: AWS Elastic Beanstalk vs OpsWorks vs CloudFormation

Talk to AWS Certified Consultant

    Spread Love By Sharing:

    Let Us Talk About Your AWS Development Requirements

    Have queries about your AWS project ideas and concepts? Please drop in your project details to discuss with our AWS experts, professionals and consultants.

    • Swift Hiring and Onboarding
    • Experienced and Trained AWS Team
    • Quality Consulting and Programming
    Let’s Connect and Discuss Your Project