Course contentsShow
← Cloud and Infrastructure
Lesson 847 of 2,98916. AWS CloudFormationFree lesson

Template Structure and Sections

Explore the main sections of a CloudFormation template: Resources, Parameters, Outputs, Mappings, and Conditions.

Template Structure and Sections

What you'll learn: You'll understand the five core sections that make up a CloudFormation template and how they work together to define your infrastructure.

Understanding Template Anatomy

A CloudFormation template is like a blueprint for your AWS infrastructure, organized into distinct sections. Think of it as a house plan where different sections describe the rooms (Resources), the customizable options (Parameters), what you can show visitors (Outputs), reference tables (Mappings), and decision rules (Conditions).

The Five Main Sections

Resources — The only required section. This defines the AWS components you want to create, like EC2 instances, S3 buckets, or VPCs. Without resources, you have nothing to build.

Parameters — Allow you to pass custom values into your template at stack creation time. This makes templates reusable across environments (like choosing "small" vs "large" instance types).

Outputs — Export values from your stack that you might need later or want to share with other stacks. For example, outputting a load balancer's DNS name after creation.

Mappings — Static lookup tables within your template. Think of these as reference charts, like mapping AWS regions to specific AMI IDs.

Conditions — Control whether certain resources are created based on logic. For instance, only create a database replica if the environment is "production."

How They Work Together

These sections communicate with each other through references. Parameters feed values to Resources, Resources can be conditionally created using Conditions, Mappings provide region-specific values, and Outputs expose information about what was created.

Key Takeaway: CloudFormation templates use five main sections—Resources (required), Parameters, Outputs, Mappings, and Conditions—that work together to create flexible, reusable infrastructure definitions.