AWS CloudFormation Parameters
Parameters in AWS CloudFormation are inputs that users can provide when they create or update a stack. They are an essential part of making templates reusable and dynamic.
When to Use Parameters
- If a resource configuration is likely to change in the future, make it a parameter.
- If the input value cannot be determined ahead of time, it should be a parameter.
Parameter Settings
- Type: Can be String, Number, CommaDelimitedList, List<Number>, AWS-specific types, or SSM Parameter types.
- Description: A text description of the parameter.
- ConstraintDescription: Describes constraints for the parameter.
- MinLength/MaxLength: Minimum and maximum length for a string parameter.
- MinValue/MaxValue: Minimum and maximum value for a number parameter.
- Default: A default value for the parameter.
- AllowedValues: A list of allowed values for the parameter.
- AllowedPattern: A regex that specifies the allowed pattern.
- NoEcho: If set to true, the parameter value is masked in the output.
Important Parameter Examples
- AllowedValues: Restricts the user to select from predefined options.
- Example:
InstanceType with allowed values t2.micro, t2.small, t2.medium, and default t2.micro.
- NoEcho: Used for sensitive information like passwords to prevent them from being displayed in outputs.
Referencing Parameters
- Use the
!Ref function to reference parameters within the template.