From b881b82a03fa0fbdd81d6727bccbe567b5e34cb3 Mon Sep 17 00:00:00 2001 From: Tatsuya Mori Date: Thu, 21 Sep 2023 23:27:59 +0900 Subject: [PATCH] docs(autoscaling): use latestAmazonLinux2() instead of latestAmazonLinux() due to deprecation (#27230) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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* --- packages/aws-cdk-lib/aws-autoscaling/README.md | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/packages/aws-cdk-lib/aws-autoscaling/README.md b/packages/aws-cdk-lib/aws-autoscaling/README.md index d066e2bb24d71..4dacd47f1baa2 100644 --- a/packages/aws-cdk-lib/aws-autoscaling/README.md +++ b/packages/aws-cdk-lib/aws-autoscaling/README.md @@ -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(), }); ``` @@ -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, }); ``` @@ -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,