Skip to content

Commit 48533f6

Browse files
committed
collapse allocateSubnetResources calls
1 parent 795fbc2 commit 48533f6

File tree

1 file changed

+7
-7
lines changed
  • packages/aws-cdk-lib/aws-ec2/lib

1 file changed

+7
-7
lines changed

packages/aws-cdk-lib/aws-ec2/lib/vpc.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1767,7 +1767,7 @@ export class Vpc extends VpcBase {
17671767
},
17681768
)));
17691769

1770-
const { allocatedSubnets } = this.ipAddresses.allocateSubnetsCidr({
1770+
let { allocatedSubnets } = this.ipAddresses.allocateSubnetsCidr({
17711771
vpcCidr: this.vpcCidrBlock,
17721772
requestedSubnets,
17731773
});
@@ -1795,9 +1795,13 @@ export class Vpc extends VpcBase {
17951795
ipv6Cidrs: subnetIpv6Cidrs,
17961796
});
17971797

1798-
// call the create function with the updated allocated subnet list
1799-
this.createSubnetResources(requestedSubnets, allocatedSubnetsIpv6.allocatedSubnets);
1798+
// assign allocated subnets to list with IPv6 addresses
1799+
allocatedSubnets = allocatedSubnetsIpv6.allocatedSubnets;
1800+
}
1801+
1802+
this.createSubnetResources(requestedSubnets, allocatedSubnets);
18001803

1804+
if (this.useIpv6) {
18011805
// add dependencies
18021806
(this.publicSubnets as PublicSubnet[]).forEach(publicSubnet => {
18031807
if (this.ipv6CidrBlock !== undefined) {
@@ -1809,11 +1813,7 @@ export class Vpc extends VpcBase {
18091813
privateSubnet.node.addDependency(this.ipv6CidrBlock);
18101814
}
18111815
});
1812-
} else {
1813-
// keep default behavior without IPv6 CIDRs if not using IPv6
1814-
this.createSubnetResources(requestedSubnets, allocatedSubnets);
18151816
}
1816-
18171817
}
18181818

18191819
/**

0 commit comments

Comments
 (0)