From c1073bf6a2c2d897696c013fbbae387574cd8e51 Mon Sep 17 00:00:00 2001 From: Gagan Date: Thu, 17 Aug 2023 11:19:33 +0530 Subject: [PATCH] feat: configurable nat gateway Subnets (#11) --- API.md | 11 +++++++++++ src/constructs/network.ts | 6 ++++++ 2 files changed, 17 insertions(+) diff --git a/API.md b/API.md index d8248bc..dbb0654 100644 --- a/API.md +++ b/API.md @@ -483,6 +483,7 @@ public readonly peeringConfigs: {[ key: string ]: PeeringConfig}; | ingressNetworkACL | NetworkACL[] | *No description.* | | routes | AddRouteOptions[] | *No description.* | | tags | {[ key: string ]: string} | *No description.* | +| useSubnetForNAT | boolean | *No description.* | --- @@ -566,3 +567,13 @@ public readonly tags: {[ key: string ]: string}; --- +##### `useSubnetForNAT`Optional + +```typescript +public readonly useSubnetForNAT: boolean; +``` + +- *Type:* boolean + +--- + diff --git a/src/constructs/network.ts b/src/constructs/network.ts index 6192736..3a90daf 100644 --- a/src/constructs/network.ts +++ b/src/constructs/network.ts @@ -56,6 +56,7 @@ export interface ISubnetsProps { readonly egressNetworkACL?: NetworkACL[]; readonly routes?: AddRouteOptions[]; readonly tags?: Record; + readonly useSubnetForNAT?: boolean; } export interface VPCProps { readonly vpc: ec2.VpcProps; @@ -115,6 +116,11 @@ export class Network extends Construct { sb instanceof ec2.PublicSubnet ) { this.natSubnets.push(sb); + } else if ( + sb instanceof ec2.PublicSubnet && + subnetProps.useSubnetForNAT == true + ) { + this.natSubnets.push(sb); } }); });