AWS CloudFormation is Amazon's infrastructure as code (IaC) service for provisioning and managing AWS resources through declarative templates. Templates written in JSON or YAML define the desired state of resources, and CloudFormation handles creation, updates, and dependency management automatically. Unlike imperative scripting, CloudFormation's declarative approach lets you specify what infrastructure you need rather than how to build it, with built-in rollback on failure and drift detection to ensure deployed resources match the template definition. The AWS::LanguageExtensions transform (2022+), Git sync, Stack Refactoring, IaC Generator, and pre-deployment change set validation represent the latest capabilities that significantly improve the template authoring and deployment lifecycle.
What This Cheat Sheet Covers
This topic spans 18 focused tables and 127 indexed concepts. Below is a complete table-by-table outline of this topic, spanning foundational concepts through advanced details.
Table 1: Template Sections
| Section | Example | Description |
|---|---|---|
Resources: MyBucket: Type: AWS::S3::Bucket | • Required section — defines every AWS resource to create • each entry has a logical ID, Type, and Properties. | |
Parameters: InstanceType: Type: String Default: t3.micro | • Input values passed at stack creation/update • supports validation constraints, defaults, and AWS-specific types for reusability. | |
Outputs: BucketName: Value: !Ref MyBucket Export: Name: MyBucketName | • Values returned after stack creation • can be exported for cross-stack references via !ImportValue. | |
Mappings: RegionMap: us-east-1: AMI: ami-12345 | • Static key-value lookup tables for region-specific or environment-specific values • accessed with Fn::FindInMap. | |
Conditions: IsProd: !Equals [!Ref Env, prod] | • Boolean logic evaluated at deployment time • used to conditionally create resources or set property values. |