Conversation
…h AvailabilityZoneAddresses
|
|
||||||||||||||
|
|
||||||||||||||
| * Required for zonal NAT gateways, not used for regional NAT gateways. | ||
| */ | ||
| readonly natSubnets: PublicSubnet[]; | ||
| readonly natSubnets?: PublicSubnet[]; |
There was a problem hiding this comment.
Because RegionalNatGateway.configureNat() doesn't use natSubnets, I made natSubnets optional.
There was a problem hiding this comment.
Cleaner if it doesn't break type declarations and/or requires deprecation.
export interface ConfigureRegionalNatOptions {
readonly vpc: Vpc;
readonly privateSubnets: PrivateSubnet[];
}
export interface ConfigureNatOptions extends ConfigureRegionalNatOptions {
readonly natSubnets: PublicSubnet[];
}| * Maximum amount of time to wait before forcibly releasing IP addresses | ||
| * if connections are still in progress. | ||
| * | ||
| * @default Duration.seconds(350) |
There was a problem hiding this comment.
Default value is described in the docs.
| /** | ||
| * The allocation ID of the Elastic IP address to use for this NAT gateway. | ||
| * | ||
| * Cannot be specified together with `eip`. | ||
| * Ignored when `availabilityZoneAddresses` is specified. | ||
| * | ||
| * @default - A new EIP is automatically allocated by AWS | ||
| */ | ||
| readonly allocationId?: string; | ||
|
|
||
| /** | ||
| * Reference to an existing EIP to use for this NAT gateway. | ||
| * | ||
| * Cannot be specified together with `allocationId`. | ||
| * Ignored when `availabilityZoneAddresses` is specified. | ||
| * | ||
| * @default - A new EIP is automatically allocated by AWS | ||
| */ | ||
| readonly eip?: IEIPRef; |
There was a problem hiding this comment.
The allocationId of the L1 construct can accept not only string but also IEIPRef. I wanted to make L2 similarly accept both of these types.
As implementation approaches, there are two options: (i) define the L2 argument as a union, or (ii) provide separate arguments for string and IEIPRef types. Since I was unsure whether union definitions are allowed in L2 arguments due to any type problem in go language, I adopted approach (ii). I will modify it to implementation (i) if necessary.
(i) union type
redaonly eip?: string | IETPRef;(ii) separate argument
readonly allocationId?: string;
redaonly eip?: IETPRef;There was a problem hiding this comment.
- Union type is against the guidelines.
readonly eip?: CfnEIPseems the right type declaration (CfnEIP)
There was a problem hiding this comment.
Due to a recent L1 fix, CfnXxx now extends IXxxRef, and all L2 constructs also extend IXxxRef. While there is currently no L2 construct for EIP, if we use IEipRef as the argument type, it will work seamlessly even when an L2 construct is implemented in the future, without requiring any code changes. For this reason, I believe it would be preferable to use IEipRef as the argument type. What do you think?
There was a problem hiding this comment.
Agree. Thanks for clarifying!
- Created assets JSON for the integration test of the regional NAT gateway. - Added CloudFormation template for the regional NAT gateway integration test. - Generated tree structure JSON for the regional NAT gateway stack, detailing VPC, subnets, NAT gateways, and associated resources.
✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.
…or Regional NAT Gateway
… Gateway provider
…kticks for clarity
…IP based on availabilityZoneAddresses
|
@badmintoncryer
Doesn't look right. A middle ground solution could be:
That would save some |
…atSubnets for Regional NAT Gateway
lpizzinidev
left a comment
There was a problem hiding this comment.
Watch out for the build error:
aws-cdk-lib: /codebuild/output/src2783507564/src/actions-runner/_work/aws-cdk/aws-cdk/packages/aws-cdk-lib/aws-ec2/lib/nat.ts
aws-cdk-lib: 18:1 error Imports "Duration" are only used as type @typescript-eslint/consistent-type-imports
aws-cdk-lib: 19:1 error All imports in the declaration are only used as types. Use `import type` @typescript-eslint/consistent-type-imports
aws-cdk-lib: /codebuild/output/src2783507564/src/actions-runner/_work/aws-cdk/aws-cdk/packages/aws-cdk-lib/aws-ec2/lib/vpc.ts
aws-cdk-lib: 33:1 error Imports "ConfigureNatOptions" are only used as type @typescript-eslint/consistent-type-imports
aws-cdk-lib: ✖ 3 problems (3 errors, 0 warnings)
aws-cdk-lib: 3 errors and 0 warnings potentially fixable with the `--fix` option.Seems like a lint issue so should be easy to fix.
|
@lpizzinidev Thanks. I've resolved CI failure. |
|
@lpizzinidev Thanks!! |
a48b045 to
df895f1
Compare
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Issue # (if applicable)
Closes #36198
Reason for this change
AWS NAT Gateway now supports regional availability in 2025 November.
https://aws.amazon.com/about-aws/whats-new/2025/11/aws-nat-gateway-regional-availability/
https://docs.aws.amazon.com/vpc/latest/userguide/nat-gateways-regional.html
Description of changes
NatProvider.regionalGateway()static method to create Regional NAT Gateway providersRegionalNatGatewayProviderclass that creates a single NAT gateway covering all AZs with availabilityMode: 'regional'maxDrainDuration: Maximum wait time before forcibly releasing IP addressesallocationId/eip: Use an existing Elastic IP allocationavailabilityZoneAddresses: Manual control over per-AZ EIP allocationDescribe any new or updated permissions being added
None
Description of how you validated changes
Add both unit and integ tests.
Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license