4

I have CFT that have in the parameter section:

  LatestAmiId:
    Type:  'AWS::SSM::Parameter::Value<AWS::EC2::Image::Id>'
    Default: '/aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-gp2'

in the Resource section for EC2:

EC2Instance:
    Type: AWS::EC2::Instance
    Properties:
      InstanceType: !Ref 'InstanceType'
      SecurityGroups: [!Ref 'InstanceSecurityGroup']
      KeyName: !Ref 'KeyName'
      ImageId: !Ref 'LatestAmiId'

Such setup gives me always the latest AMI image to Amazon Linux distribution - I want to start using Ubuntu 18.x -

What I should put in Default Section (or as Parameter)?

bensiu
  • 24,660
  • 56
  • 77
  • 117
  • Seems like only Amazon Linux and Windows are available in SSM public parameters at this point: https://docs.aws.amazon.com/systems-manager/latest/userguide/parameter-store-public-parameters.html – Anton Mar 29 '20 at 01:12
  • 1
    Does this answer your question? [CloudFormation - always use latest AMI](https://stackoverflow.com/questions/55479945/cloudformation-always-use-latest-ami) – kichik Mar 29 '20 at 06:03
  • The latest Ubuntu AMI IDs are now available as SSM public parameters, too https://discourse.ubuntu.com/t/finding-ubuntu-images-with-the-aws-ssm-parameter-store/15507 – Marcel Hernandez Jun 12 '21 at 11:01

1 Answers1

3

Recently Canonical started storing the latest Ubuntu AMI IDs in public SSM parameters, much like Amazon does for Amazon Linux:

Parameters:
  LatestUbuntuFocalAMI:
    Type: AWS::SSM::Parameter::Value<AWS::EC2::Image::Id>
    Default: /aws/service/canonical/ubuntu/server/focal/stable/current/amd64/hvm/ebs-gp2/ami-id

Resources:
  UbuntuInstance:
    Type: AWS::EC2::Instance
    Properties:
      ImageId: !Ref LatestUbuntuFocalAMI

Source: https://discourse.ubuntu.com/t/finding-ubuntu-images-with-the-aws-ssm-parameter-store/15507

Marcel Hernandez
  • 1,371
  • 13
  • 22