Skip to content

Commit b881b82

Browse files
authored
docs(autoscaling): use latestAmazonLinux2() instead of latestAmazonLinux() due to deprecation (#27230)
Currently, the following document regarding AutoScalingGroup uses `ec2.MachineImage.latestAmazonLinux()` method as examples. https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_autoscaling-readme.html However, this method has been already deprecated as below. https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.MachineImage.html#static-latestwbramazonwbrlinuxpropsspan-classapi-icon-api-icon-deprecated-titlethis-api-element-is-deprecated-its-use-is-not-recommended%EF%B8%8Fspan > ⚠️ Deprecated: use MachineImage.latestAmazonLinux2 instead This PR solves the issue by replacing this method with `latestAmazonLinux2()`. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 2a9f5b5 commit b881b82

File tree

1 file changed

+4
-10
lines changed
  • packages/aws-cdk-lib/aws-autoscaling

1 file changed

+4
-10
lines changed

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

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,8 @@ new autoscaling.AutoScalingGroup(this, 'ASG', {
1616
vpc,
1717
instanceType: ec2.InstanceType.of(ec2.InstanceClass.BURSTABLE2, ec2.InstanceSize.MICRO),
1818

19-
// The latest Amazon Linux image of a particular generation
20-
machineImage: ec2.MachineImage.latestAmazonLinux({
21-
generation: ec2.AmazonLinuxGeneration.AMAZON_LINUX_2,
22-
}),
19+
// The latest Amazon Linux 2 image
20+
machineImage: ec2.MachineImage.latestAmazonLinux2(),
2321
});
2422
```
2523

@@ -53,9 +51,7 @@ const mySecurityGroup = new ec2.SecurityGroup(this, 'SecurityGroup', { vpc });
5351
new autoscaling.AutoScalingGroup(this, 'ASG', {
5452
vpc,
5553
instanceType: ec2.InstanceType.of(ec2.InstanceClass.BURSTABLE2, ec2.InstanceSize.MICRO),
56-
machineImage: ec2.MachineImage.latestAmazonLinux({
57-
generation: ec2.AmazonLinuxGeneration.AMAZON_LINUX_2,
58-
}),
54+
machineImage: ec2.MachineImage.latestAmazonLinux2(),
5955
securityGroup: mySecurityGroup,
6056
});
6157
```
@@ -577,9 +573,7 @@ new autoscaling.AutoScalingGroup(this, 'ASG', {
577573
instanceType: ec2.InstanceType.of(ec2.InstanceClass.T3, ec2.InstanceSize.MICRO),
578574

579575
// Amazon Linux 2 comes with SSM Agent by default
580-
machineImage: ec2.MachineImage.latestAmazonLinux({
581-
generation: ec2.AmazonLinuxGeneration.AMAZON_LINUX_2,
582-
}),
576+
machineImage: ec2.MachineImage.latestAmazonLinux2(),
583577

584578
// Turn on SSM
585579
ssmSessionPermissions: true,

0 commit comments

Comments
 (0)