(AWS) CloudFormation stack with Amazon Linux 2

Viewed 228

Is it possible to use the AWS CloudFormation stack with Amazon Linux 2? Currently, I only found Amazon docs that are pointing to Amazon Linux AMI. Unfortunately, AMI would stop being supported in 2023 (and is marked as deprecated already).

1 Answers

In CloudFormation you create AWS::EC2::Instance. To have the latest AMI of Amazon Linux 2, you can use dynamic references.

The basic example of them:

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
      InstanceType: t2.micro
Related