๐Ÿ“‘
docs
  • Initial page
  • Golang Shippets
    • PII Data Check
  • Docker
    • Concepts
  • NGINX Web Server Deep Dive
    • What's NGINX
  • AWS CloudFormation
    • Introduction
    • Infrastructure as Code
    • What's CloudFormation?
    • CloudFormation - Lab #1
    • CloudFormation Concepts
  • Kubernetes
    • Introduction
    • Untitled
  • Jenkins Engineer - (CJE)
    • Topics
  • Microsoft Azure - AZ-104
    • ๐Ÿ““Manage Azure AD Users
  • Terraform - Certified Associate
  • ๐Ÿฆ What is Terraform?
  • ๐ŸงฌInfrastructure as Code
  • ๐Ÿ“ฎGetting Started
    • ๐ŸงซBuild Infrastructure
    • ๐ŸงชChange Infrastructure
    • ๐ŸงบDefine Input Variables
    • ๐ŸšฐQuery Data with Outputs
    • ๐Ÿ’พStore Remote State
  • ๐ŸŽƒConfiguration Language
    • ๐ŸงผTerraform Resources
    • ๐Ÿ’ŠTerraform Variables
  • ๐Ÿ”ŽOverview
    • ๐Ÿ—ƒ๏ธConfiguration Syntax
  • ๐ŸŽฒCheat Sheet
  • GCP - Data Engineer
    • Overview
    • Big Data and Machine Learning Fundamentals
Powered by GitBook
On this page
  • Topics
  • Templates
  • Stacks
  • Change sets
  • Summary

Was this helpful?

Edit on GitHub
  1. AWS CloudFormation

CloudFormation Concepts

PreviousCloudFormation - Lab #1NextIntroduction

Last updated 4 years ago

Was this helpful?

When you use AWS CloudFormation, you work with templates and stacks. You create templates to describe your AWS resources and their properties. Whenever you create a stack, AWS CloudFormation provisions the resources that are described in your template.

Topics

  1. Templates

  2. Stacks

  3. Changesets

Templates

An AWS CloudFormation template is a JSON or YAML formatted text file. You can save these files with any extension, such as .json, .yaml, .template, or .txt. AWS CloudFormation uses these templates as blueprints for building your AWS resources. For example, in a template, you can describe an Amazon EC2 instance, such as the instance type, the AMI ID, block device mappings, and its Amazon EC2 key pair name. Whenever you create a stack, you also specify a template that AWS CloudFormation uses to create whatever you described in the template.

For example, if you created a stack with the following template, AWS CloudFormation provisions an instance with an ami-0ff8a91507f77f867 AMI ID, t2.micro instance type, testkey key pair name, and an Amazon EBS volume.

{
  "AWSTemplateFormatVersion" : "2010-09-09",
  "Description" : "A sample template",
  "Resources" : {
    "MyEC2Instance" : {
      "Type" : "AWS::EC2::Instance",
      "Properties" : {
        "ImageId" : "ami-0ff8a91507f77f867",
        "InstanceType" : "t2.micro",
        "KeyName" : "testkey",
        "BlockDeviceMappings" : [
          {
            "DeviceName" : "/dev/sdm",
            "Ebs" : {
              "VolumeType" : "io1",
              "Iops" : "200",
              "DeleteOnTermination" : "false",
              "VolumeSize" : "20"
            }
          }
        ]
      }
    }
  }
}
AWSTemplateFormatVersion: "2010-09-09"
Description: A sample template
Resources:
  MyEC2Instance:
    Type: "AWS::EC2::Instance"
    Properties: 
      ImageId: "ami-0ff8a91507f77f867"
      InstanceType: t2.micro
      KeyName: testkey
      BlockDeviceMappings:
        -
          DeviceName: /dev/sdm
          Ebs:
            VolumeType: io1
            Iops: 200
            DeleteOnTermination: false
            VolumeSize: 20

The previous templates are centered around a single Amazon EC2 instance; however, AWS CloudFormation templates have additional capabilities that you can use to build complex sets of resources and reuse those templates in multiple contexts. For example, you can add input parameters whose values are specified when you create an AWS CloudFormation stack. In other words, you can specify a value like an instance type when you create a stack instead of when you create the template, making the template easier to reuse in different situations.

Stacks

Change sets

If you need to make changes to the running resources in a stack, you update the stack. Before making changes to your resources, you can generate a change set, which is a summary of your proposed changes. Change sets allow you to see how your changes might impact your running resources, especially for critical resources, before implementing them.

Summary

For more information about template creation and capabilities, see .

When you use AWS CloudFormation, you manage related resources as a single unit called a stack. You create, update, and delete a collection of resources by creating, updating, and deleting stacks. All the resources in a stack are defined by the stack's AWS CloudFormation template. Suppose you created a template that includes an Auto Scaling group, Elastic Load Balancing load balancer, and an Amazon Relational Database Service (Amazon RDS) database instance. To create those resources, you create a stack by submitting the template that you created, and AWS CloudFormation provisions all those resources for you. You can work with stacks by using the AWS CloudFormation , , or .

For more information about creating, updating, or deleting stacks, see .

For example, if you change the name of an Amazon RDS database instance, AWS CloudFormation will create a new database and delete the old one. You will lose the data in the old database unless you've already backed it up. If you generate a change set, you will see that your change will cause your database to be replaced, and you will be able to plan accordingly before you update your stack. For more information, see .

Template anatomy
console
API
AWS CLI
Working with stacks
Updating stacks using change sets