Skip to content

Commit dc287e5

Browse files
authored
chore: deprecate latestAmazonLinux2022() (#26284)
SSM parameter is not offering any al2022 AMIs as described in #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 #26274 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 0e16c90 commit dc287e5

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

packages/aws-cdk-lib/aws-ec2/README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1086,18 +1086,18 @@ new ec2.Instance(this, 'Instance3', {
10861086
}),
10871087
});
10881088

1089-
// AWS Linux 2022
1089+
// Amazon Linux 2023
10901090
new ec2.Instance(this, 'Instance4', {
10911091
vpc,
10921092
instanceType,
1093-
machineImage: ec2.MachineImage.latestAmazonLinux2022(),
1093+
machineImage: ec2.MachineImage.latestAmazonLinux2023(),
10941094
});
10951095

10961096
// Graviton 3 Processor
10971097
new ec2.Instance(this, 'Instance5', {
10981098
vpc,
10991099
instanceType: ec2.InstanceType.of(ec2.InstanceClass.C7G, ec2.InstanceSize.LARGE),
1100-
machineImage: ec2.MachineImage.latestAmazonLinux2022({
1100+
machineImage: ec2.MachineImage.latestAmazonLinux2023({
11011101
cpuType: ec2.AmazonLinuxCpuType.ARM_64,
11021102
}),
11031103
});
@@ -1301,7 +1301,7 @@ declare const instanceType: ec2.InstanceType;
13011301
new ec2.Instance(this, 'Instance', {
13021302
vpc,
13031303
instanceType,
1304-
machineImage: ec2.MachineImage.latestAmazonLinux2022(),
1304+
machineImage: ec2.MachineImage.latestAmazonLinux2023(),
13051305

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

18741874
const template = new ec2.LaunchTemplate(this, 'LaunchTemplate', {
1875-
machineImage: ec2.MachineImage.latestAmazonLinux2022(),
1875+
machineImage: ec2.MachineImage.latestAmazonLinux2023(),
18761876
securityGroup: new ec2.SecurityGroup(this, 'LaunchTemplateSG', {
18771877
vpc: vpc,
18781878
}),
@@ -1905,7 +1905,7 @@ const sg2 = new ec2.SecurityGroup(this, 'sg2', {
19051905
});
19061906

19071907
const launchTemplate = new ec2.LaunchTemplate(this, 'LaunchTemplate', {
1908-
machineImage: ec2.MachineImage.latestAmazonLinux2022(),
1908+
machineImage: ec2.MachineImage.latestAmazonLinux2023(),
19091909
securityGroup: sg1,
19101910
});
19111911

@@ -1931,7 +1931,7 @@ declare const instanceType: ec2.InstanceType;
19311931
new ec2.Instance(this, 'Instance1', {
19321932
vpc,
19331933
instanceType,
1934-
machineImage: ec2.MachineImage.latestAmazonLinux2022(),
1934+
machineImage: ec2.MachineImage.latestAmazonLinux2023(),
19351935
detailedMonitoring: true,
19361936
});
19371937
```
@@ -1961,8 +1961,8 @@ new ec2.Instance(this, 'Instance1', {
19611961
vpc,
19621962
instanceType,
19631963

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

19671967
// Turn on SSM
19681968
ssmSessionPermissions: true,

packages/aws-cdk-lib/aws-ec2/lib/machine-image/machine-image.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ export abstract class MachineImage {
5050
* deployment. Be aware this will cause your instances to be replaced when a
5151
* new version of the image becomes available. Do not store stateful information
5252
* on the instance if you are using this image.
53+
*
54+
* @deprecated - use latestAmazonLinux2023() instead
5355
*/
5456
public static latestAmazonLinux2022(props?: AmazonLinux2022ImageSsmParameterProps): IMachineImage {
5557
return new AmazonLinux2022ImageSsmParameter({

0 commit comments

Comments
 (0)