Skip to content

[aws-ec2] Support Amazon Linux 2 #1062

@0xdevalias

Description

@0xdevalias

Currently we can use AmazonLinuxEdition with options of Standard or Minimal:

This doesn't seem to allow us to use Amazon Linux 2 though:

When I deployed a test ec2 instance using machineImage: new ec2.AmazonLinuxImage(), then attempted to use amazon-linux-extras I got an error:

/var/lib/cloud/instance/scripts/part-001: line 4: amazon-linux-extras: command not found

The reported versions were:

Amazon Linux AMI release 2018.03
Kernel 4.14.62-65.117.amzn1.x86_64 on an x86_64

The used AMI ID was ami-09b42976632b27e9b, which maps to:

The Amazon Linux 2 AMI ID's are listed here:

It would seem we can probable use GenericLinuxImage, passing it an appropriate amiMap, but it isn't immediately obvious what this amiMap should look like (region to AMI ID perhaps?).

It looks like older versions of the documentation actually had better usage text for this..

It looks like in the latest version, that now lives under autoscaling:

Perhaps some better documentation cross references to make discoverability easier? I wouldn't immediately think I need to go look at autoscaling when I am thinking about setting up an EC2 instance for example.

So with that, it seems that I could get my Amazon Linux 2 images with code such as the following:

// amzn2-ami-hvm-2.0.20181024-x86_64-gp2
// Ref: https://aws.amazon.com/amazon-linux-2/release-notes/#Amazon_Linux_2_AMI_IDs
const amazonLinux2Gp2 = new ec2.GenericLinuxImage({
    'ap-northeast-1': 'ami-00f9d04b3b3092052',
    'ap-northeast-2': 'ami-0c764df09c35858b8',
    'ap-northeast-3': 'ami-0f4865fb90390aeec',
    'ap-south-1': 'ami-00796998f258969fd',
    'ap-southeast-1': 'ami-085fd1bd447be68e8',
    'ap-southeast-2': 'ami-0b8dea0e70b969adc',
    'ca-central-1': 'ami-05cac140c6a1fb960',
    'cn-north-1': 'ami-0bcb2d94a820e559c',
    'cn-northwest-1': 'ami-0d82dd087e5eea5af',
    'eu-central-1': 'ami-02ea8f348fa28c108',
    'eu-west-1': 'ami-0a5e707736615003c',
    'eu-west-2': 'ami-017b0e29fac27906b',
    'eu-west-3': 'ami-04992646d54c69ef4',
    'sa-east-1': 'ami-0160a8b6087883cb6',
    'us-east-1': 'ami-013be31976ca2c322',
    'us-east-2': 'ami-0350c5670171b5391',
    'us-gov-west-1': 'ami-d263f9b3',
    'us-west-1': 'ami-01beb64058d271bc4',
    'us-west-2': 'ami-061e7ebbc234015fe',
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions