Skip to content

Commit

Permalink
More isolated subnet missing behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewpatto committed Sep 12, 2023
1 parent 96ddf50 commit 5ede2c2
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 8 deletions.
28 changes: 24 additions & 4 deletions packages/client/infrastructure-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,30 @@ export class InfrastructureClient {

// try to bring in this private subnets if present
try {
vpcAttrs.privateSubnetIds = getStringListLookup(
vpcAttrs.privateSubnetIds = undefined;
vpcAttrs.privateSubnetRouteTableIds = undefined;

const privateSubs = getStringListLookup(
vpcPrivateSubnetIdsParameterName(this.infrastructureStackId),
);
vpcAttrs.privateSubnetRouteTableIds = getStringListLookup(
vpcPrivateSubnetRouteTableIdsParameterName(this.infrastructureStackId),
);

// sometimes even if the private subnets parameter does not exist - what comes back is a string
// error message - hence our test here to really really establish we have real subnets
// this handles various "empty" private subs cases
if (
privateSubs &&
privateSubs.length > 0 &&
privateSubs[0].includes("subnet-")
) {
vpcAttrs.privateSubnetIds = privateSubs;

// the assumption is that if private subnets was set - so was its routing
vpcAttrs.privateSubnetRouteTableIds = getStringListLookup(
vpcPrivateSubnetRouteTableIdsParameterName(
this.infrastructureStackId,
),
);
}
} catch (e) {}

// try to bring in the isolated subnets if present
Expand All @@ -119,13 +137,15 @@ export class InfrastructureClient {

// sometimes even if the isolated subnets parameter does not exist - what comes back is a string
// error message - hence our test here to really really establish we have real subnets
// this handles various "empty" private subs cases
if (
isolatedSubs &&
isolatedSubs.length > 0 &&
isolatedSubs[0].includes("subnet-")
) {
vpcAttrs.isolatedSubnetIds = isolatedSubs;

// the assumption is that if isolated subnets was set - so was its routing
vpcAttrs.isolatedSubnetRouteTableIds = getStringListLookup(
vpcIsolatedSubnetRouteTableIdsParameterName(
this.infrastructureStackId,
Expand Down
8 changes: 4 additions & 4 deletions packages/stack/infrastructure-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,12 @@ export class InfrastructureStack extends Stack {
});
} else {
// CDK has strange behaviour when looking up "optional" parameters - so instead
// we create a parameter of zero length to indicate that we do not have any
// we create a parameter with a single empty string to indicate that we do not have any
// private subnets
// our infrastructure client handles the other end of this behaviour
new StringListParameter(this, "PrivateSubnetIdsParameter", {
parameterName: vpcPrivateSubnetIdsParameterName(id),
stringListValue: [],
stringListValue: [""],
});
}

Expand All @@ -135,12 +135,12 @@ export class InfrastructureStack extends Stack {
});
} else {
// CDK has strange behaviour when looking up "optional" parameters - so instead
// we create a parameter of zero length to indicate that we do not have any
// we create a parameter with a single empty string to indicate that we do not have any
// isolated subnets
// our infrastructure client handles the other end of this behaviour
new StringListParameter(this, "IsolatedSubnetIdsParameter", {
parameterName: vpcIsolatedSubnetIdsParameterName(id),
stringListValue: [],
stringListValue: [""],
});
}

Expand Down

0 comments on commit 5ede2c2

Please sign in to comment.