From a8b1340bd433914293946682ec3e4e001a92c871 Mon Sep 17 00:00:00 2001 From: Gavin Zhang Date: Thu, 22 Feb 2024 15:15:02 +0800 Subject: [PATCH] Added comments --- packages/aws-cdk-lib/aws-ec2/lib/nat.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/aws-cdk-lib/aws-ec2/lib/nat.ts b/packages/aws-cdk-lib/aws-ec2/lib/nat.ts index 69c12824e8765..d8463c742b9fd 100644 --- a/packages/aws-cdk-lib/aws-ec2/lib/nat.ts +++ b/packages/aws-cdk-lib/aws-ec2/lib/nat.ts @@ -78,7 +78,8 @@ export abstract class NatProvider { * * @see https://docs.aws.amazon.com/vpc/latest/userguide/VPC_NAT_Instance.html * - * @deprecated use instanceV2 + * @deprecated use instanceV2. 'instance' is deprecated since NatInstanceProvider + * uses a instance image that has reached EOL on Dec 31 2023 */ public static instance(props: NatInstanceProps): NatInstanceProvider { return new NatInstanceProvider(props); @@ -299,7 +300,8 @@ class NatGatewayProvider extends NatProvider { /** * NAT provider which uses NAT Instances * - * @deprecated use NatInstanceProviderV2 + * @deprecated use NatInstanceProviderV2. NatInstanceProvider is deprecated since + * the instance image used has reached EOL on Dec 31 2023 */ export class NatInstanceProvider extends NatProvider implements IConnectable { private gateways: PrefSet = new PrefSet(); @@ -323,7 +325,7 @@ export class NatInstanceProvider extends NatProvider implements IConnectable { (this.props.allowAllTraffic ?? true ? NatTrafficDirection.INBOUND_AND_OUTBOUND : NatTrafficDirection.OUTBOUND_ONLY); // Create the NAT instances. They can share a security group and a Role. - const machineImage = this.props.machineImage || new NatInstanceImage(); + const machineImage = this.props.machineImage ?? new NatInstanceImage(); this._securityGroup = this.props.securityGroup ?? new SecurityGroup(options.vpc, 'NatSecurityGroup', { vpc: options.vpc, description: 'Security Group for NAT instances', @@ -454,7 +456,9 @@ export class NatInstanceProviderV2 extends NatProvider implements IConnectable { const defaultDirection = this.props.defaultAllowedTraffic ?? (this.props.allowAllTraffic ?? true ? NatTrafficDirection.INBOUND_AND_OUTBOUND : NatTrafficDirection.OUTBOUND_ONLY); - // Create the NAT instances. They can share a security group and a Role. + // Create the NAT instances. They can share a security group and a Role. The new NAT instance created uses latest + // Amazon Linux 2023 image. This is important since the original NatInstanceProvider uses an instance image that has + // reached EOL on Dec 31 2023 const machineImage = this.props.machineImage || new AmazonLinuxImage({ generation: AmazonLinuxGeneration.AMAZON_LINUX_2023 }); this._securityGroup = this.props.securityGroup ?? new SecurityGroup(options.vpc, 'NatSecurityGroup', { vpc: options.vpc,