Template language and composition

AWS CloudFormation · 60 minutes · 8 modules
AWS CloudFormationAWS CLI v2Core hour
Learning objectives
  • Work through concepts, commands and troubleshooting in all eight modules.
  • Review changesets and verify resource lifecycle behavior in a sandbox.
  • Explain deployment results using stack events, outputs and service evidence.

1-hour schedule

#TimeModuleCore contentLearning views
100–06 · 6 minYAML and JSON structureChoose a format and understand sections, indentation, intrinsic syntax and parser limits.Concepts, commands, lab, production and troubleshooting
206–13 · 7 minParameters and constraintsDesign typed deployment inputs with allowed values, patterns and descriptions.Concepts, commands, lab, production and troubleshooting
313–21 · 8 minPseudo parameters and substitutionUse AWS pseudo parameters and Fn::Sub to construct environment-aware values.Concepts, commands, lab, production and troubleshooting
421–29 · 8 minReferences and attributesUse Ref and Fn::GetAtt correctly, and understand implicit dependencies.Concepts, commands, lab, production and troubleshooting
529–37 · 8 minMappings and conditionsModel fixed lookup data and intentionally include or omit resources.Concepts, commands, lab, production and troubleshooting
637–45 · 8 minOutputs and exportsExpose non-secret deployment results and manage cross-stack export contracts.Concepts, commands, lab, production and troubleshooting
745–52 · 7 minTransforms and reusable fragmentsUnderstand transforms, macros and when a higher-level framework is appropriate.Concepts, commands, lab, production and troubleshooting
852–60 · 8 minLinting and template validationCombine cfn-lint, service validation and change review without confusing their guarantees.Concepts, commands, lab, production and troubleshooting

How to use this course

Each module includes concepts, a diagram, a walkthrough, commands, a lab, a production case, troubleshooting, a quiz, narration and official references. Progress is saved in this browser.

Lab requirements: AWS CLI v2, a sandbox account and least-privilege permissions. Verify account/Region before labs and clean up afterward.

Setup

Prepare AWS CLI v2, a sandbox account and deployment permissions. Verify identity and Region; do not run labs in a production account.

aws --version
aws sts get-caller-identity --profile sandbox
aws configure list --profile sandbox

Labs may create resources. Follow each lab's cleanup steps and verify stack status when finished.

YAML and JSON structure

Hour 2 · 1 / 8

Core concepts

Choose a format and understand sections, indentation, intrinsic syntax and parser limits.

  • Check the resource reference for properties and update behavior.
  • Make the relationship between template, parameters, execution identity and target environment explicit.
  • Record an observable expected result and cleanup method.

Request path

Focus: YAML and JSON structure
Template → Validate → Change set → Review → Execute → YAML and JSON structure → Verify events

Keep reviewable inputs and results at each stage; a change set does not apply proposed changes until execution.

Deployment state sequence

  1. Identify the requirement: YAML and JSON structure
  2. Validate the inputs and inspect the proposed resource action
  3. Execute in a sandbox and verify the resulting stack events

Commands and notes

cfn-lint template.yaml

Confirm profile, account and Region first. Replace example names with sandbox resources.

Hands-on lab

Apply this module to a disposable sandbox stack. Record the input, command, expected CloudFormation event or result, and cleanup step. Verify the outcome before moving to the next module: Choose a format and understand sections, indentation, intrinsic syntax and parser limits.

  1. Run the command and save its output.
  2. Compare it with the expected result and record differences.
  3. Delete the lab stack and confirm there are no leftover resources.

Production case review

Production review: make this behavior explicit in the template and change review. Confirm ownership, blast radius, rollback or retention behavior, and the evidence an operator can use during an incident. Topic: Choose a format and understand sections, indentation, intrinsic syntax and parser limits.

Release gate Inspect replacements and deletions; confirm approval, backups and rollback ownership.

Troubleshooting path

If the operation fails, capture the stack status, logical resource ID and earliest failed event. Separate template, permission, quota, service stabilization and dependency causes; fix the source, then create a fresh change set before retrying. Topic: Choose a format and understand sections, indentation, intrinsic syntax and parser limits.

aws cloudformation describe-stack-events --stack-name app-dev --region us-east-1

Narration script

Choose a format and understand sections, indentation, intrinsic syntax and parser limits.

The key is to record the desired state in a template, execute it through a stack, and use event evidence to verify the result.

Official learning resources

Work through the AWS User Guide and CloudFormation Workshop. This lesson emphasizes reviewable text-based labs.

AWS CloudFormation User Guide ↗

Parameters and constraints

Hour 2 · 2 / 8

Core concepts

Design typed deployment inputs with allowed values, patterns and descriptions.

  • Check the resource reference for properties and update behavior.
  • Make the relationship between template, parameters, execution identity and target environment explicit.
  • Record an observable expected result and cleanup method.

Request path

Focus: Parameters and constraints
Template → Validate → Change set → Review → Execute → Parameters and constraints → Verify events

Keep reviewable inputs and results at each stage; a change set does not apply proposed changes until execution.

Deployment state sequence

  1. Identify the requirement: Parameters and constraints
  2. Validate the inputs and inspect the proposed resource action
  3. Execute in a sandbox and verify the resulting stack events

Commands and notes

aws cloudformation get-template-summary --template-body file://template.yaml

Confirm profile, account and Region first. Replace example names with sandbox resources.

Hands-on lab

Apply this module to a disposable sandbox stack. Record the input, command, expected CloudFormation event or result, and cleanup step. Verify the outcome before moving to the next module: Design typed deployment inputs with allowed values, patterns and descriptions.

  1. Run the command and save its output.
  2. Compare it with the expected result and record differences.
  3. Delete the lab stack and confirm there are no leftover resources.

Production case review

Production review: make this behavior explicit in the template and change review. Confirm ownership, blast radius, rollback or retention behavior, and the evidence an operator can use during an incident. Topic: Design typed deployment inputs with allowed values, patterns and descriptions.

Release gate Inspect replacements and deletions; confirm approval, backups and rollback ownership.

Troubleshooting path

If the operation fails, capture the stack status, logical resource ID and earliest failed event. Separate template, permission, quota, service stabilization and dependency causes; fix the source, then create a fresh change set before retrying. Topic: Design typed deployment inputs with allowed values, patterns and descriptions.

aws cloudformation describe-stack-events --stack-name app-dev --region us-east-1

Narration script

Design typed deployment inputs with allowed values, patterns and descriptions.

The key is to record the desired state in a template, execute it through a stack, and use event evidence to verify the result.

Official learning resources

Work through the AWS User Guide and CloudFormation Workshop. This lesson emphasizes reviewable text-based labs.

AWS CloudFormation User Guide ↗

Pseudo parameters and substitution

Hour 2 · 3 / 8

Core concepts

Use AWS pseudo parameters and Fn::Sub to construct environment-aware values.

  • Check the resource reference for properties and update behavior.
  • Make the relationship between template, parameters, execution identity and target environment explicit.
  • Record an observable expected result and cleanup method.

Request path

Focus: Pseudo parameters and substitution
Template → Validate → Change set → Review → Execute → Pseudo parameters and substitution → Verify events

Keep reviewable inputs and results at each stage; a change set does not apply proposed changes until execution.

Deployment state sequence

  1. Identify the requirement: Pseudo parameters and substitution
  2. Validate the inputs and inspect the proposed resource action
  3. Execute in a sandbox and verify the resulting stack events

Commands and notes

aws cloudformation get-template-summary --template-body file://template.yaml --parameters ParameterKey=Environment,ParameterValue=dev

Confirm profile, account and Region first. Replace example names with sandbox resources.

Hands-on lab

Apply this module to a disposable sandbox stack. Record the input, command, expected CloudFormation event or result, and cleanup step. Verify the outcome before moving to the next module: Use AWS pseudo parameters and Fn::Sub to construct environment-aware values.

  1. Run the command and save its output.
  2. Compare it with the expected result and record differences.
  3. Delete the lab stack and confirm there are no leftover resources.

Production case review

Production review: make this behavior explicit in the template and change review. Confirm ownership, blast radius, rollback or retention behavior, and the evidence an operator can use during an incident. Topic: Use AWS pseudo parameters and Fn::Sub to construct environment-aware values.

Release gate Inspect replacements and deletions; confirm approval, backups and rollback ownership.

Troubleshooting path

If the operation fails, capture the stack status, logical resource ID and earliest failed event. Separate template, permission, quota, service stabilization and dependency causes; fix the source, then create a fresh change set before retrying. Topic: Use AWS pseudo parameters and Fn::Sub to construct environment-aware values.

aws cloudformation describe-stack-events --stack-name app-dev --region us-east-1

Narration script

Use AWS pseudo parameters and Fn::Sub to construct environment-aware values.

The key is to record the desired state in a template, execute it through a stack, and use event evidence to verify the result.

Official learning resources

Work through the AWS User Guide and CloudFormation Workshop. This lesson emphasizes reviewable text-based labs.

AWS CloudFormation User Guide ↗

References and attributes

Hour 2 · 4 / 8

Core concepts

Use Ref and Fn::GetAtt correctly, and understand implicit dependencies.

  • Check the resource reference for properties and update behavior.
  • Make the relationship between template, parameters, execution identity and target environment explicit.
  • Record an observable expected result and cleanup method.

Request path

Focus: References and attributes
Template → Validate → Change set → Review → Execute → References and attributes → Verify events

Keep reviewable inputs and results at each stage; a change set does not apply proposed changes until execution.

Deployment state sequence

  1. Identify the requirement: References and attributes
  2. Validate the inputs and inspect the proposed resource action
  3. Execute in a sandbox and verify the resulting stack events

Commands and notes

aws cloudformation get-template-summary --template-body file://template.yaml --region us-east-1

Confirm profile, account and Region first. Replace example names with sandbox resources.

Hands-on lab

Apply this module to a disposable sandbox stack. Record the input, command, expected CloudFormation event or result, and cleanup step. Verify the outcome before moving to the next module: Use Ref and Fn::GetAtt correctly, and understand implicit dependencies.

  1. Run the command and save its output.
  2. Compare it with the expected result and record differences.
  3. Delete the lab stack and confirm there are no leftover resources.

Production case review

Production review: make this behavior explicit in the template and change review. Confirm ownership, blast radius, rollback or retention behavior, and the evidence an operator can use during an incident. Topic: Use Ref and Fn::GetAtt correctly, and understand implicit dependencies.

Release gate Inspect replacements and deletions; confirm approval, backups and rollback ownership.

Troubleshooting path

If the operation fails, capture the stack status, logical resource ID and earliest failed event. Separate template, permission, quota, service stabilization and dependency causes; fix the source, then create a fresh change set before retrying. Topic: Use Ref and Fn::GetAtt correctly, and understand implicit dependencies.

aws cloudformation describe-stack-events --stack-name app-dev --region us-east-1

Narration script

Use Ref and Fn::GetAtt correctly, and understand implicit dependencies.

The key is to record the desired state in a template, execute it through a stack, and use event evidence to verify the result.

Official learning resources

Work through the AWS User Guide and CloudFormation Workshop. This lesson emphasizes reviewable text-based labs.

AWS CloudFormation User Guide ↗

Mappings and conditions

Hour 2 · 5 / 8

Core concepts

Model fixed lookup data and intentionally include or omit resources.

  • Check the resource reference for properties and update behavior.
  • Make the relationship between template, parameters, execution identity and target environment explicit.
  • Record an observable expected result and cleanup method.

Request path

Focus: Mappings and conditions
Template → Validate → Change set → Review → Execute → Mappings and conditions → Verify events

Keep reviewable inputs and results at each stage; a change set does not apply proposed changes until execution.

Deployment state sequence

  1. Identify the requirement: Mappings and conditions
  2. Validate the inputs and inspect the proposed resource action
  3. Execute in a sandbox and verify the resulting stack events

Commands and notes

aws cloudformation list-exports --region us-east-1

Confirm profile, account and Region first. Replace example names with sandbox resources.

Hands-on lab

Apply this module to a disposable sandbox stack. Record the input, command, expected CloudFormation event or result, and cleanup step. Verify the outcome before moving to the next module: Model fixed lookup data and intentionally include or omit resources.

  1. Run the command and save its output.
  2. Compare it with the expected result and record differences.
  3. Delete the lab stack and confirm there are no leftover resources.

Production case review

Production review: make this behavior explicit in the template and change review. Confirm ownership, blast radius, rollback or retention behavior, and the evidence an operator can use during an incident. Topic: Model fixed lookup data and intentionally include or omit resources.

Release gate Inspect replacements and deletions; confirm approval, backups and rollback ownership.

Troubleshooting path

If the operation fails, capture the stack status, logical resource ID and earliest failed event. Separate template, permission, quota, service stabilization and dependency causes; fix the source, then create a fresh change set before retrying. Topic: Model fixed lookup data and intentionally include or omit resources.

aws cloudformation describe-stack-events --stack-name app-dev --region us-east-1

Narration script

Model fixed lookup data and intentionally include or omit resources.

The key is to record the desired state in a template, execute it through a stack, and use event evidence to verify the result.

Official learning resources

Work through the AWS User Guide and CloudFormation Workshop. This lesson emphasizes reviewable text-based labs.

AWS CloudFormation User Guide ↗

Outputs and exports

Hour 2 · 6 / 8

Core concepts

Expose non-secret deployment results and manage cross-stack export contracts.

  • Check the resource reference for properties and update behavior.
  • Make the relationship between template, parameters, execution identity and target environment explicit.
  • Record an observable expected result and cleanup method.

Request path

Focus: Outputs and exports
Template → Validate → Change set → Review → Execute → Outputs and exports → Verify events

Keep reviewable inputs and results at each stage; a change set does not apply proposed changes until execution.

Deployment state sequence

  1. Identify the requirement: Outputs and exports
  2. Validate the inputs and inspect the proposed resource action
  3. Execute in a sandbox and verify the resulting stack events

Commands and notes

aws cloudformation describe-stacks --stack-name app-dev --query Stacks[0].Outputs

Confirm profile, account and Region first. Replace example names with sandbox resources.

Hands-on lab

Apply this module to a disposable sandbox stack. Record the input, command, expected CloudFormation event or result, and cleanup step. Verify the outcome before moving to the next module: Expose non-secret deployment results and manage cross-stack export contracts.

  1. Run the command and save its output.
  2. Compare it with the expected result and record differences.
  3. Delete the lab stack and confirm there are no leftover resources.

Production case review

Production review: make this behavior explicit in the template and change review. Confirm ownership, blast radius, rollback or retention behavior, and the evidence an operator can use during an incident. Topic: Expose non-secret deployment results and manage cross-stack export contracts.

Release gate Inspect replacements and deletions; confirm approval, backups and rollback ownership.

Troubleshooting path

If the operation fails, capture the stack status, logical resource ID and earliest failed event. Separate template, permission, quota, service stabilization and dependency causes; fix the source, then create a fresh change set before retrying. Topic: Expose non-secret deployment results and manage cross-stack export contracts.

aws cloudformation describe-stack-events --stack-name app-dev --region us-east-1

Narration script

Expose non-secret deployment results and manage cross-stack export contracts.

The key is to record the desired state in a template, execute it through a stack, and use event evidence to verify the result.

Official learning resources

Work through the AWS User Guide and CloudFormation Workshop. This lesson emphasizes reviewable text-based labs.

AWS CloudFormation User Guide ↗

Transforms and reusable fragments

Hour 2 · 7 / 8

Core concepts

Understand transforms, macros and when a higher-level framework is appropriate.

  • Check the resource reference for properties and update behavior.
  • Make the relationship between template, parameters, execution identity and target environment explicit.
  • Record an observable expected result and cleanup method.

Request path

Focus: Transforms and reusable fragments
Template → Validate → Change set → Review → Execute → Transforms and reusable fragments → Verify events

Keep reviewable inputs and results at each stage; a change set does not apply proposed changes until execution.

Deployment state sequence

  1. Identify the requirement: Transforms and reusable fragments
  2. Validate the inputs and inspect the proposed resource action
  3. Execute in a sandbox and verify the resulting stack events

Commands and notes

aws cloudformation get-template-summary --template-body file://template.yaml

Confirm profile, account and Region first. Replace example names with sandbox resources.

Hands-on lab

Apply this module to a disposable sandbox stack. Record the input, command, expected CloudFormation event or result, and cleanup step. Verify the outcome before moving to the next module: Understand transforms, macros and when a higher-level framework is appropriate.

  1. Run the command and save its output.
  2. Compare it with the expected result and record differences.
  3. Delete the lab stack and confirm there are no leftover resources.

Production case review

Production review: make this behavior explicit in the template and change review. Confirm ownership, blast radius, rollback or retention behavior, and the evidence an operator can use during an incident. Topic: Understand transforms, macros and when a higher-level framework is appropriate.

Release gate Inspect replacements and deletions; confirm approval, backups and rollback ownership.

Troubleshooting path

If the operation fails, capture the stack status, logical resource ID and earliest failed event. Separate template, permission, quota, service stabilization and dependency causes; fix the source, then create a fresh change set before retrying. Topic: Understand transforms, macros and when a higher-level framework is appropriate.

aws cloudformation describe-stack-events --stack-name app-dev --region us-east-1

Narration script

Understand transforms, macros and when a higher-level framework is appropriate.

The key is to record the desired state in a template, execute it through a stack, and use event evidence to verify the result.

Official learning resources

Work through the AWS User Guide and CloudFormation Workshop. This lesson emphasizes reviewable text-based labs.

AWS CloudFormation User Guide ↗

Linting and template validation

Hour 2 · 8 / 8

Core concepts

Combine cfn-lint, service validation and change review without confusing their guarantees.

  • Check the resource reference for properties and update behavior.
  • Make the relationship between template, parameters, execution identity and target environment explicit.
  • Record an observable expected result and cleanup method.

Request path

Focus: Linting and template validation
Template → Validate → Change set → Review → Execute → Linting and template validation → Verify events

Keep reviewable inputs and results at each stage; a change set does not apply proposed changes until execution.

Deployment state sequence

  1. Identify the requirement: Linting and template validation
  2. Validate the inputs and inspect the proposed resource action
  3. Execute in a sandbox and verify the resulting stack events

Commands and notes

aws cloudformation validate-template --template-body file://template.yaml

Confirm profile, account and Region first. Replace example names with sandbox resources.

Hands-on lab

Apply this module to a disposable sandbox stack. Record the input, command, expected CloudFormation event or result, and cleanup step. Verify the outcome before moving to the next module: Combine cfn-lint, service validation and change review without confusing their guarantees.

  1. Run the command and save its output.
  2. Compare it with the expected result and record differences.
  3. Delete the lab stack and confirm there are no leftover resources.

Production case review

Production review: make this behavior explicit in the template and change review. Confirm ownership, blast radius, rollback or retention behavior, and the evidence an operator can use during an incident. Topic: Combine cfn-lint, service validation and change review without confusing their guarantees.

Release gate Inspect replacements and deletions; confirm approval, backups and rollback ownership.

Troubleshooting path

If the operation fails, capture the stack status, logical resource ID and earliest failed event. Separate template, permission, quota, service stabilization and dependency causes; fix the source, then create a fresh change set before retrying. Topic: Combine cfn-lint, service validation and change review without confusing their guarantees.

aws cloudformation describe-stack-events --stack-name app-dev --region us-east-1

Narration script

Combine cfn-lint, service validation and change review without confusing their guarantees.

The key is to record the desired state in a template, execute it through a stack, and use event evidence to verify the result.

Official learning resources

Work through the AWS User Guide and CloudFormation Workshop. This lesson emphasizes reviewable text-based labs.

AWS CloudFormation User Guide ↗

Cheat sheet

Command card

aws sts get-caller-identity
aws cloudformation validate-template --template-body file://template.yaml
aws cloudformation deploy --template-file template.yaml --stack-name app-dev
aws cloudformation describe-stacks --stack-name app-dev
aws cloudformation describe-stack-events --stack-name app-dev
aws cloudformation detect-stack-drift --stack-name app-dev
aws cloudformation delete-stack --stack-name app-dev

Before an update

  • Confirm account, Region, profile and execution role.
  • Review replacements, deletions and retention behavior in the change set.
  • Check drift, backups, alarms and rollback ownership.

Capstone lab and final quiz

Lab: review and deploy a controlled stack

Open the runnable SQS capstone lab and template ↗

  1. Write a template with a low-risk resource and parameterize the environment name.
  2. Run template checks, create a change set and review resource actions.
  3. Execute the change set in a sandbox and inspect stack events and outputs.
  4. Run drift detection, then clean up resources according to retention policy.

Final quiz

Sources and version notes

CloudFormation resource properties and CLI behavior evolve. Check current AWS documentation before deployment.