Skip to content

Commit 6cb2106

Browse files
committed
Removed public IP mapping from Subnets
1 parent 008f044 commit 6cb2106

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

PetAdoptions/cdk/pet_stack/lib/services.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,20 @@ export class Services extends Stack {
109109
// The VPC where all the microservices will be deployed into
110110
const theVPC = new ec2.Vpc(this, 'Microservices', {
111111
ipAddresses: ec2.IpAddresses.cidr(cidrRange),
112-
// cidr: cidrRange,
113112
natGateways: 1,
114113
maxAzs: 2
115114
});
116115

116+
// Disable Map IP on launch for all public subnets
117+
const publicSubnets = theVPC.selectSubnets({
118+
subnetType: ec2.SubnetType.PUBLIC,
119+
});
120+
121+
for (const subnet of publicSubnets.subnets) {
122+
const cfnSubnet = subnet.node.defaultChild as ec2.CfnSubnet;
123+
cfnSubnet.mapPublicIpOnLaunch = false;
124+
}
125+
117126
// Create RDS Aurora PG cluster
118127
const rdssecuritygroup = new ec2.SecurityGroup(this, 'petadoptionsrdsSG', {
119128
vpc: theVPC

0 commit comments

Comments
 (0)