Skip to content

Commit f8fe9cf

Browse files
committed
Reduce number of unnecessary elastic IPs
1 parent dc77eb2 commit f8fe9cf

3 files changed

+16
-3
lines changed

tests/ci/cdk/cdk/aws_lc_ec2_test_framework_ci_stack.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,12 @@ def __init__(
9494
)
9595

9696
# create vpc for ec2s
97-
vpc = ec2.Vpc(self, id="{}-ec2-vpc".format(id))
97+
vpc = ec2.Vpc(
98+
self,
99+
id="{}-ec2-vpc".format(id),
100+
nat_gateways=1 # minimize the number of idle NAT gateways and thus elastic IPs
101+
)
102+
98103
selected_subnets = vpc.select_subnets(
99104
subnet_type=ec2.SubnetType.PRIVATE_WITH_EGRESS
100105
)

tests/ci/cdk/cdk/linux_docker_image_batch_build_stack.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,11 @@ def __init__(
8989
}
9090

9191
# Define VPC
92-
vpc = ec2.Vpc(self, id="{}-ec2-vpc".format(id))
92+
vpc = ec2.Vpc(
93+
self,
94+
id="{}-ec2-vpc".format(id),
95+
nat_gateways=1 # minimize the number of idle NAT gateways and thus elastic IPs
96+
)
9397

9498
# Define CodeBuild project.
9599
project = codebuild.Project(

tests/ci/cdk/cdk/windows_docker_image_build_stack.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,11 @@ def __init__(
102102
machine_image = ec2.MachineImage.latest_windows(
103103
ec2.WindowsVersion.WINDOWS_SERVER_2019_ENGLISH_FULL_BASE
104104
)
105-
vpc = ec2.Vpc(scope=self, id="{}-vpc".format(id))
105+
vpc = ec2.Vpc(
106+
scope=self,
107+
id="{}-vpc".format(id),
108+
nat_gateways=1 # minimize the number of idle NAT gateways and thus elastic IPs
109+
)
106110
block_device_volume = ec2.BlockDeviceVolume.ebs(
107111
volume_size=200, delete_on_termination=True
108112
)

0 commit comments

Comments
 (0)