Skip to content

Commit

Permalink
vpc: handle referencing VPCs without NAT
Browse files Browse the repository at this point in the history
  • Loading branch information
fwang committed Aug 15, 2024
1 parent 8c34627 commit 8ddefa5
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions platform/src/components/aws/vpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ export class Vpc extends Component {
ec2
.getSecurityGroupsOutput({
filters: [
{ name: "group-name", values: ["*SecurityGroup*"] },
{ name: "group-name", values: ["default"] },
{ name: "vpc-id", values: [vpc.id] },
],
})
Expand Down Expand Up @@ -573,14 +573,20 @@ export class Vpc extends Component {
),
),
);
const natGateways = publicSubnets.apply((subnets) =>
subnets.map((subnet, i) =>
ec2.NatGateway.get(
`${name}NatGateway${i + 1}`,
ec2.getNatGatewayOutput({ subnetId: subnet.id }).id,
),
),
);
const natGateways = publicSubnets.apply((subnets) => {
const natGatewayIds = subnets.map((subnet, i) =>
ec2
.getNatGatewaysOutput({
filters: [{ name: "subnet-id", values: [subnet.id] }],
})
.ids.apply((ids) => ids[0]),
);
return output(natGatewayIds).apply((ids) =>
ids
.filter((id) => id)
.map((id, i) => ec2.NatGateway.get(`${name}NatGateway${i + 1}`, id)),
);
});
const elasticIps = natGateways.apply((nats) =>
nats.map((nat, i) =>
ec2.Eip.get(
Expand Down

0 comments on commit 8ddefa5

Please sign in to comment.