3 Answers
- Newest
- Most votes
- Most comments
2
I assume you are using this for EC2 resource, e.g.
Parameters:
LatestAmiId:
Type: 'AWS::SSM::Parameter::Value<AWS::EC2::Image::Id>'
Default: '/aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-gp2'
Resources:
Instance:
Type: 'AWS::EC2::Instance'
Properties:
ImageId: !Ref LatestAmiId
An option is not to specify it as a parameter. Instead use resolve:ssm
function as per below
Resources:
Instance:
Type: 'AWS::EC2::Instance'
Properties:
ImageId: "{{resolve:ssm:/aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-gp2}}"
1
Hi
You can probably use the AllowedValues
in CloudFormation to create a list of allowed values. Only the values in this list can be used, so if you have a list with only one value the user must use that.
AmiID:
Type: AWS::SSM::Parameter::Value<AWS::EC2::Image::Id>
Description: Only the following image is supported currently.
Default: /aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-gp2
AllowedValues:
- /aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-gp2
ConstraintDescription: Must be a supported AMI ID.
0
Not sure if possible but one approach could be to look into the Cloudformation Conditions and apply to the input: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/conditions-section-structure.html
Relevant content
- AWS OFFICIALUpdated 10 months ago
- AWS OFFICIALUpdated a year ago