Skip to main content
Welcome to the lesson on CloudFormation parameters. This guide explains what parameters are, why they’re important, and how to declare and reference them in a CloudFormation template. By the end you’ll understand how to make templates configurable and reusable across environments.

What are parameters?

Parameters are input values you declare in the Parameters section of a CloudFormation template. They act like template variables that let users or automation customize a stack at creation or update time. Common parameter uses:
  • Environment selectors (production, staging, development)
  • Resource names (S3 bucket names, database identifiers)
  • Instance sizes and counts (t3.micro, t3.small)
  • Region- or account-specific options
Examples: an instance type (t3.micro), an environment label (production), or an S3 bucket name.

Why use parameters

Parameters make templates flexible and reusable. They let you:
  • Configure stacks at deployment time without editing the template
  • Reuse the same template across multiple environments
  • Enforce allowed values or defaults to reduce errors
A presentation slide titled "Why Use Parameters?" showing three numbered boxes with icons. Each box lists a benefit: make templates flexible and reusable, allow users to configure stack settings at deployment time, and avoid modifying the template for small changes.

How parameters work

Workflow summary:
  1. Declare parameter entries in the template’s Parameters section.
  2. Choose a Type for each parameter (e.g., String, Number, CommaDelimitedList, or AWS-specific types).
  3. Optionally set Default, AllowedValues, or other constraints.
  4. Provide parameter values when launching or updating the stack.
  5. Reference parameter values elsewhere using the intrinsic function Ref (YAML shorthand: !Ref).
Common parameter types and purpose: For full details on supported types and AWS-specific parameter types, see the official AWS CloudFormation documentation.
A presentation slide titled "How Do Parameters Work?" showing a simple flow for parameter setup: define parameters, choose input type, set default/restricted values, provide values when launching a stack, and use !Ref in templates.

Example: S3 bucket name parameter

Below is a minimal CloudFormation YAML example that declares a parameter named InputBucketName and uses !Ref to set the BucketName property of an S3 bucket resource.
How this works (step-by-step)
  1. When you launch the stack, provide a value for the InputBucketName parameter (for example, my-app-bucket-prod).
  2. CloudFormation creates the MyS3Bucket resource.
  3. The template uses !Ref InputBucketName to insert the parameter value as the BucketName property. The resulting bucket will have the name you provided.
Remember: S3 bucket names must be globally unique and comply with AWS naming rules (lowercase letters, numbers, hyphens, no uppercase or underscores, etc.). If the provided name is invalid or already taken, stack creation will fail.

Quick reference: common parameter attributes

Watch Video