Search code examples
amazon-web-servicesaws-cloudformationamazon-ami

How to write cloudformation using private AMI rather than public AMI


I want to write a cloudformation using yaml file. I know the format for a public AMI. But I get lost in how to add a private AMI in the yaml file. I searched the solution online and someone recommend to use AWS system manager service. I want to ask is there a way to avoid using the system manager service to achieve setting up my yaml file. Here is my yaml file for your reference.

AmiId:
  Type: 'AWS::SSM::Parameter::Value<AWS::EC2::Image::Id>'
  AllowedValues: ['%list of my public AMI%
                 '/aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-gp2',
                 '/aws/service/ami-windows-latest/Windows_Server-2017-English',
                 'ami-id']
                  'ami-id' this is where to insert my private Ami .
                  Default: 'ami-id'

Solution

  • You can't mix the AllowedValues like you do now. You either use ami-ids or parameter store values. If you don't want to use parameter store values, then you just use ami-ids:

    AmiId:
      Type: AWS::EC2::Image::Id
      AllowedValues: [ami-id1, ami-id2, ami-id3]
      Default: ami-id1