Skip to content

Commit

Permalink
collapse allocateSubnetResources calls
Browse files Browse the repository at this point in the history
  • Loading branch information
scanlonp committed Jan 11, 2024
1 parent 795fbc2 commit 48533f6
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions packages/aws-cdk-lib/aws-ec2/lib/vpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1767,7 +1767,7 @@ export class Vpc extends VpcBase {
},
)));

const { allocatedSubnets } = this.ipAddresses.allocateSubnetsCidr({
let { allocatedSubnets } = this.ipAddresses.allocateSubnetsCidr({
vpcCidr: this.vpcCidrBlock,
requestedSubnets,
});
Expand Down Expand Up @@ -1795,9 +1795,13 @@ export class Vpc extends VpcBase {
ipv6Cidrs: subnetIpv6Cidrs,
});

// call the create function with the updated allocated subnet list
this.createSubnetResources(requestedSubnets, allocatedSubnetsIpv6.allocatedSubnets);
// assign allocated subnets to list with IPv6 addresses
allocatedSubnets = allocatedSubnetsIpv6.allocatedSubnets;
}

this.createSubnetResources(requestedSubnets, allocatedSubnets);

if (this.useIpv6) {
// add dependencies
(this.publicSubnets as PublicSubnet[]).forEach(publicSubnet => {
if (this.ipv6CidrBlock !== undefined) {
Expand All @@ -1809,11 +1813,7 @@ export class Vpc extends VpcBase {
privateSubnet.node.addDependency(this.ipv6CidrBlock);
}
});
} else {
// keep default behavior without IPv6 CIDRs if not using IPv6
this.createSubnetResources(requestedSubnets, allocatedSubnets);
}

}

/**
Expand Down

0 comments on commit 48533f6

Please sign in to comment.