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.Documentation Index
Fetch the complete documentation index at: https://notes.kodekloud.com/llms.txt
Use this file to discover all available pages before exploring further.
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
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
| Benefit | What it enables | Example |
|---|---|---|
| Flexibility | Same template for multiple environments | Use a parameter to switch between production and development settings |
| Ease of use | Operators specify values during stack creation | Provide an instance type or bucket name at launch time |
| Safety | Restrict or default inputs to reduce mistakes | Use AllowedValues and Default to limit choices |

How parameters work
Workflow summary:- Declare parameter entries in the template’s
Parameterssection. - Choose a
Typefor each parameter (e.g.,String,Number,CommaDelimitedList, or AWS-specific types). - Optionally set
Default,AllowedValues, or other constraints. - Provide parameter values when launching or updating the stack.
- Reference parameter values elsewhere using the intrinsic function
Ref(YAML shorthand:!Ref).
| Parameter Type | Use case |
|---|---|
| String | Freeform text (names, ARNs, paths) |
| Number | Numeric inputs (counts, sizes) |
| CommaDelimitedList | Lists of simple values (subnets, CIDRs) |
AWS-specific types (e.g., AWS::EC2::KeyPair::KeyName) | Validate against existing AWS resources |

Example: S3 bucket name parameter
Below is a minimal CloudFormation YAML example that declares a parameter namedInputBucketName and uses !Ref to set the BucketName property of an S3 bucket resource.
- When you launch the stack, provide a value for the
InputBucketNameparameter (for example,my-app-bucket-prod). - CloudFormation creates the
MyS3Bucketresource. - The template uses
!Ref InputBucketNameto insert the parameter value as theBucketNameproperty. 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
| Attribute | Purpose | Example |
|---|---|---|
| Type | Defines input type (String, Number, List, or AWS-specific) | Type: String |
| Description | Human-friendly explanation shown in consoles and tools | Description: Enter the bucket name |
| Default | Value used when no input is supplied | Default: dev-bucket |
| AllowedValues | Restricts inputs to a set of valid options | AllowedValues: [production, staging, development] |
| NoEcho | Hides sensitive values from logs and console | NoEcho: true |
| ConstraintDescription | Custom message shown if validation fails | ConstraintDescription: Must be a valid EC2 instance type |
Links and references
- AWS CloudFormation Parameters — Documentation
- AWS S3 Bucket Naming Rules
- Intrinsic function Ref — AWS CloudFormation