Skip to content

Commit 840ecef

Browse files
authored
Do not throw an exception when NAT gateway strategy is None. (pulumi#907)
1 parent f1efc48 commit 840ecef

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

awsx/ec2/vpc.test.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,12 @@ describe("validateNatGatewayStrategy", () => {
9191
);
9292

9393
describe("strategy is None", () => {
94-
it("should throw an exception if any private subnets are specified", () =>
95-
runTest("None", ["Private"], true, "cannot be 'None'"));
94+
// We cannot throw an exception in this case because egress for the private
95+
// subnets may be accomplished by methods other than a NAT gateway. Examples
96+
// include: NAT instances and centralized egress via TGW in a hub-and-spoke
97+
// architecture.
98+
it("should not throw an exception if any private subnets are specified", () =>
99+
runTest("None", ["Private"], false));
96100

97101
it("should succeed if only public and isolated subnets are specified", () =>
98102
runTest("None", ["Public", "Isolated"], false));

awsx/ec2/vpc.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -347,9 +347,6 @@ export function validateNatGatewayStrategy(
347347
"If NAT Gateway strategy is 'OnePerAz' or 'Single', both private and public subnets must be declared. The private subnet creates the need for a NAT Gateway, and the public subnet is required to host the NAT Gateway resource.",
348348
);
349349
case "none":
350-
if (subnets.some((x) => x.type.toLowerCase() === "private")) {
351-
throw new Error("If private subnets are specified, NAT Gateway strategy cannot be 'None'.");
352-
}
353350
break;
354351
default:
355352
throw new Error(`Unknown NAT Gateway strategy '${natGatewayStrategy}'`);

0 commit comments

Comments
 (0)