Dung (Donny) Nguyen

Senior Software Engineer

AWS CloudFormation

AWS CloudFormation is Amazon’s native Infrastructure as Code (IaC) service. It lets you model, provision, and manage AWS (and some third-party) resources by describing them in a template. CloudFormation reads the template, works out the correct order to create resources based on their dependencies, and provisions them as a single, manageable unit called a stack.

Core Concepts

Template Structure

A CloudFormation template is organized into several sections, most of which are optional except Resources:

AWSTemplateFormatVersion: '2010-09-09'
Description: Provision an S3 bucket with configurable environment

Parameters:
  EnvironmentName:
    Type: String
    Default: Production
    AllowedValues:
      - Development
      - Staging
      - Production

Resources:
  AppBucket:
    Type: AWS::S3::Bucket
    Properties:
      BucketName: my-application-bucket
      Tags:
        - Key: Environment
          Value: !Ref EnvironmentName
        - Key: ManagedBy
          Value: CloudFormation

Outputs:
  BucketArn:
    Description: The ARN of the created bucket
    Value: !GetAtt AppBucket.Arn

Intrinsic Functions

CloudFormation provides intrinsic functions to add dynamic behavior to templates:

The CloudFormation Workflow

You can deploy templates through the AWS Management Console, the AWS CLI, or CI/CD pipelines.

# Preview changes with a change set
aws cloudformation create-change-set \
  --stack-name my-app-stack \
  --template-body file://template.yaml \
  --change-set-name my-changes

# Deploy or update a stack
aws cloudformation deploy \
  --stack-name my-app-stack \
  --template-file template.yaml \
  --parameter-overrides EnvironmentName=Production

# Delete a stack and all its resources
aws cloudformation delete-stack --stack-name my-app-stack

Advantages

Considerations

Conclusion

AWS CloudFormation is a powerful, fully managed IaC service for teams committed to AWS. By declaring resources in templates and managing them as stacks, you get reliable provisioning, automatic state management, rollback on failure, and multi-account deployment—all without maintaining separate state infrastructure.