Skip to content

Commit 2e41fdb

Browse files
committed
clean up useIpv4 usage + add docstring
1 parent a5a9fb0 commit 2e41fdb

File tree

1 file changed

+9
-6
lines changed
  • packages/aws-cdk-lib/aws-ec2/lib

1 file changed

+9
-6
lines changed

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

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1527,10 +1527,6 @@ export class Vpc extends VpcBase {
15271527
const ipProtocol = props.ipProtocol ?? IpProtocol.IPV4_ONLY;
15281528
// this property can be set to false if an IPv6_ONLY VPC is implemented in the future
15291529
this.useIpv4 = ipProtocol === IpProtocol.IPV4_ONLY || ipProtocol === IpProtocol.DUAL_STACK;
1530-
// use property to avoid lint errors
1531-
if (this.useIpv4) {
1532-
; // pass
1533-
}
15341530

15351531
this.useIpv6 = ipProtocol === IpProtocol.DUAL_STACK;
15361532

@@ -1639,8 +1635,10 @@ export class Vpc extends VpcBase {
16391635
});
16401636

16411637
(this.publicSubnets as PublicSubnet[]).forEach(publicSubnet => {
1642-
publicSubnet.addDefaultInternetRoute(igw.ref, att);
1643-
1638+
// configure IPv4 route
1639+
if (this.useIpv4) {
1640+
publicSubnet.addDefaultInternetRoute(igw.ref, att);
1641+
}
16441642
// configure IPv6 route if VPC is dual stack
16451643
if (this.useIpv6) {
16461644
publicSubnet.addIpv6DefaultInternetRoute(igw.ref);
@@ -2213,6 +2211,11 @@ export class Subnet extends Resource implements ISubnet {
22132211
});
22142212
}
22152213

2214+
/**
2215+
* Adds an entry to this subnets route table that points to the passed NATGatewayId.
2216+
* Uses the known 64:ff9b::/96 prefix.
2217+
* @param natGatewayId The ID of the NAT gateway
2218+
*/
22162219
public addIpv6Nat64Route(natGatewayId: string) {
22172220
this.addRoute('Nat64', {
22182221
routerType: RouterType.NAT_GATEWAY,

0 commit comments

Comments
 (0)