Search code examples
amazon-web-servicesaws-cloudformationamazon-ecsaws-auto-scalingaws-ssm

Cloudformation parameter for list of AMIs


I'm creating a cloudformation for ecs cluster over an auto scaling group. In the launch configurations for the auto scaling group, i want to have a choice in specifying the ECS optimized AMI Id. Right now I have the following parameter:

"AutoScalingGroupImageId": {
   "Default" : "/aws/service/ami-windows-latest/Windows_Server-2016-English-Full-SQL_2017_Standard",
   "Description" : "The AMI Id to be specified for the ASG",
   "Type": "AWS::SSM::Parameter::Value<AWS::EC2::Image::Id>"            
}

It needs to be something like List<AWS::SSM::Parameter::Value<AWS::EC2::Image::Id>> from which i could choose the AMI Id for the required windows server.


Solution

  • Construct such as List<AWS::SSM::Parameter::Value<AWS::EC2::Image::Id>> is officially not supported. From docs:

    AWS CloudFormation doesn't support the following SSM parameter type: Lists of SSM parameter types—for example:

    List<AWS::SSM::Parameter::Value<String>>
    

    AMI for ECS instance

      ECSOptmizedAMI:
        Type: AWS::SSM::Parameter::Value<AWS::EC2::Image::Id>
        Default: /aws/service/ecs/optimized-ami/amazon-linux-2/recommended/image_id
    

    The above is based on AWS docs.