Skip to content

Commit

Permalink
chore: deprecate latestAmazonLinux2022() (aws#26284)
Browse files Browse the repository at this point in the history
SSM parameter is not offering any al2022 AMIs as described in aws#26274. This PR marks `latestAmazonLinux2022()` as deprecated and uses `latestAmazonLinux2023()` instead. 

- [x] mark latestAmazonLinux2022 as deprecated
- [x] update the aws-ec2 README to use latestAmazonLinux2023 instead


Closes aws#26274 

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
pahud authored and bmoffatt committed Jul 28, 2023
1 parent 030c413 commit 955f936
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
18 changes: 9 additions & 9 deletions packages/aws-cdk-lib/aws-ec2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1086,18 +1086,18 @@ new ec2.Instance(this, 'Instance3', {
}),
});

// AWS Linux 2022
// Amazon Linux 2023
new ec2.Instance(this, 'Instance4', {
vpc,
instanceType,
machineImage: ec2.MachineImage.latestAmazonLinux2022(),
machineImage: ec2.MachineImage.latestAmazonLinux2023(),
});

// Graviton 3 Processor
new ec2.Instance(this, 'Instance5', {
vpc,
instanceType: ec2.InstanceType.of(ec2.InstanceClass.C7G, ec2.InstanceSize.LARGE),
machineImage: ec2.MachineImage.latestAmazonLinux2022({
machineImage: ec2.MachineImage.latestAmazonLinux2023({
cpuType: ec2.AmazonLinuxCpuType.ARM_64,
}),
});
Expand Down Expand Up @@ -1301,7 +1301,7 @@ declare const instanceType: ec2.InstanceType;
new ec2.Instance(this, 'Instance', {
vpc,
instanceType,
machineImage: ec2.MachineImage.latestAmazonLinux2022(),
machineImage: ec2.MachineImage.latestAmazonLinux2023(),

init: ec2.CloudFormationInit.fromElements(
// Create a simple config file that runs a Python web server
Expand Down Expand Up @@ -1872,7 +1872,7 @@ const instanceProfile = new iam.InstanceProfile(this, 'InstanceProfile', {
});

const template = new ec2.LaunchTemplate(this, 'LaunchTemplate', {
machineImage: ec2.MachineImage.latestAmazonLinux2022(),
machineImage: ec2.MachineImage.latestAmazonLinux2023(),
securityGroup: new ec2.SecurityGroup(this, 'LaunchTemplateSG', {
vpc: vpc,
}),
Expand Down Expand Up @@ -1905,7 +1905,7 @@ const sg2 = new ec2.SecurityGroup(this, 'sg2', {
});

const launchTemplate = new ec2.LaunchTemplate(this, 'LaunchTemplate', {
machineImage: ec2.MachineImage.latestAmazonLinux2022(),
machineImage: ec2.MachineImage.latestAmazonLinux2023(),
securityGroup: sg1,
});

Expand All @@ -1931,7 +1931,7 @@ declare const instanceType: ec2.InstanceType;
new ec2.Instance(this, 'Instance1', {
vpc,
instanceType,
machineImage: ec2.MachineImage.latestAmazonLinux2022(),
machineImage: ec2.MachineImage.latestAmazonLinux2023(),
detailedMonitoring: true,
});
```
Expand Down Expand Up @@ -1961,8 +1961,8 @@ new ec2.Instance(this, 'Instance1', {
vpc,
instanceType,

// Amazon Linux 2 comes with SSM Agent by default
machineImage: ec2.MachineImage.latestAmazonLinux2022(),
// Amazon Linux 2023 comes with SSM Agent by default
machineImage: ec2.MachineImage.latestAmazonLinux2023(),

// Turn on SSM
ssmSessionPermissions: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ export abstract class MachineImage {
* deployment. Be aware this will cause your instances to be replaced when a
* new version of the image becomes available. Do not store stateful information
* on the instance if you are using this image.
*
* @deprecated - use latestAmazonLinux2023() instead
*/
public static latestAmazonLinux2022(props?: AmazonLinux2022ImageSsmParameterProps): IMachineImage {
return new AmazonLinux2022ImageSsmParameter({
Expand Down

0 comments on commit 955f936

Please sign in to comment.