Skip to content

Commit

Permalink
docs(autoscaling): use latestAmazonLinux2() instead of latestAmazonLi…
Browse files Browse the repository at this point in the history
…nux() 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*
  • Loading branch information
tam0ri authored Sep 21, 2023
1 parent 2a9f5b5 commit b881b82
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions packages/aws-cdk-lib/aws-autoscaling/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@ new autoscaling.AutoScalingGroup(this, 'ASG', {
vpc,
instanceType: ec2.InstanceType.of(ec2.InstanceClass.BURSTABLE2, ec2.InstanceSize.MICRO),

// The latest Amazon Linux image of a particular generation
machineImage: ec2.MachineImage.latestAmazonLinux({
generation: ec2.AmazonLinuxGeneration.AMAZON_LINUX_2,
}),
// The latest Amazon Linux 2 image
machineImage: ec2.MachineImage.latestAmazonLinux2(),
});
```

Expand Down Expand Up @@ -53,9 +51,7 @@ const mySecurityGroup = new ec2.SecurityGroup(this, 'SecurityGroup', { vpc });
new autoscaling.AutoScalingGroup(this, 'ASG', {
vpc,
instanceType: ec2.InstanceType.of(ec2.InstanceClass.BURSTABLE2, ec2.InstanceSize.MICRO),
machineImage: ec2.MachineImage.latestAmazonLinux({
generation: ec2.AmazonLinuxGeneration.AMAZON_LINUX_2,
}),
machineImage: ec2.MachineImage.latestAmazonLinux2(),
securityGroup: mySecurityGroup,
});
```
Expand Down Expand Up @@ -577,9 +573,7 @@ new autoscaling.AutoScalingGroup(this, 'ASG', {
instanceType: ec2.InstanceType.of(ec2.InstanceClass.T3, ec2.InstanceSize.MICRO),

// Amazon Linux 2 comes with SSM Agent by default
machineImage: ec2.MachineImage.latestAmazonLinux({
generation: ec2.AmazonLinuxGeneration.AMAZON_LINUX_2,
}),
machineImage: ec2.MachineImage.latestAmazonLinux2(),

// Turn on SSM
ssmSessionPermissions: true,
Expand Down

0 comments on commit b881b82

Please sign in to comment.