This post is part of a series of introductory articles related to building AWS services using AWS CloudFormation. You can read about CloudFormation Conditions and the DependsOn attribute in earlier posts
While Parameters are technically optional, they are essential to building flexible CloudFormation templates.
Think of Parameters as variables; they are interpreted by CloudFormation when performing actions on your CloudFormation stacks.
Here’s a simple example of creating a parameter for setting a tag value:
|
|
Each defined parameter must have the following components assigned:
In addition to the required components referenced above, parameters may also contain several optional properties. For a complete list, have a look at the CloudFormation documentation.
Here are few properties we’d typically include in our templates to help ensure our CloudFormation deployment is successful:
Outside of the custom parameters you define, there are several built-in parameter types included in CloudFormation.
Typically, used to refer to existing AWS resources - there are AWS parameters for Key Pairs, Security Groups, and Subnets - to name just a few.
You can find a complete list within the CloudFormation documentation.
Here’s an example of using AWS Parameter Types for subnets within a VPC:
|
|
You may want to provide information to a sensitive template - maybe a user name/password combination for an RDS DB Instance. Instead of placing this type of information directly in a CloudFormation template, you could instead refer to key-value pairs stored in the Parameter Store in Systems Manager. Here’s a simple example:
|
|
Pseudo Parameters are built-in CloudFormation Parameter types and are a crucial part of building flexible templates. Although these are Parameters, you use them when defining Resources (no reference in the Parameter section).
Pseudo Parameters begin with the prefix ‘AWS:’ and allow for the creation of multi-account, multi-region CloudFormation templates.
Here’s an example of dynamically setting a tag value based on the name of the CloudFormation Stack and the AWS Region.
|
|
You can see a complete list of Pseudo Parameters in the CloudFormation documentation.
Like what you read? Why not subscribe to the weekly Orbit newsletter and get content before everyone else?