Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ec2): internet gateway is created even if public subnets are reserved #28607

Merged
merged 9 commits into from Mar 1, 2024

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

@@ -0,0 +1,283 @@
{
"Resources": {
"VPCB9E5F0B4": {
"Type": "AWS::EC2::VPC",
"Properties": {
"CidrBlock": "10.0.0.0/16",
"EnableDnsHostnames": true,
"EnableDnsSupport": true,
"InstanceTenancy": "default",
"Tags": [
{
"Key": "Name",
"Value": "aws-cdk-ec2-vpc-reserved-public-subnet/VPC"
}
]
}
},
"VPCisolatedSubnet1Subnet84AF7038": {
"Type": "AWS::EC2::Subnet",
"Properties": {
"AvailabilityZone": {
"Fn::Select": [
0,
{
"Fn::GetAZs": ""
}
]
},
"CidrBlock": "10.0.128.0/18",
"MapPublicIpOnLaunch": false,
"Tags": [
{
"Key": "aws-cdk:subnet-name",
"Value": "isolated"
},
{
"Key": "aws-cdk:subnet-type",
"Value": "Isolated"
},
{
"Key": "Name",
"Value": "aws-cdk-ec2-vpc-reserved-public-subnet/VPC/isolatedSubnet1"
}
],
"VpcId": {
"Ref": "VPCB9E5F0B4"
}
}
},
"VPCisolatedSubnet1RouteTable2BB88525": {
"Type": "AWS::EC2::RouteTable",
"Properties": {
"Tags": [
{
"Key": "Name",
"Value": "aws-cdk-ec2-vpc-reserved-public-subnet/VPC/isolatedSubnet1"
}
],
"VpcId": {
"Ref": "VPCB9E5F0B4"
}
}
},
"VPCisolatedSubnet1RouteTableAssociation2886DD39": {
"Type": "AWS::EC2::SubnetRouteTableAssociation",
"Properties": {
"RouteTableId": {
"Ref": "VPCisolatedSubnet1RouteTable2BB88525"
},
"SubnetId": {
"Ref": "VPCisolatedSubnet1Subnet84AF7038"
}
}
},
"VPCisolatedSubnet2Subnet8AE9E765": {
"Type": "AWS::EC2::Subnet",
"Properties": {
"AvailabilityZone": {
"Fn::Select": [
1,
{
"Fn::GetAZs": ""
}
]
},
"CidrBlock": "10.0.192.0/18",
"MapPublicIpOnLaunch": false,
"Tags": [
{
"Key": "aws-cdk:subnet-name",
"Value": "isolated"
},
{
"Key": "aws-cdk:subnet-type",
"Value": "Isolated"
},
{
"Key": "Name",
"Value": "aws-cdk-ec2-vpc-reserved-public-subnet/VPC/isolatedSubnet2"
}
],
"VpcId": {
"Ref": "VPCB9E5F0B4"
}
}
},
"VPCisolatedSubnet2RouteTable1EDFC77F": {
"Type": "AWS::EC2::RouteTable",
"Properties": {
"Tags": [
{
"Key": "Name",
"Value": "aws-cdk-ec2-vpc-reserved-public-subnet/VPC/isolatedSubnet2"
}
],
"VpcId": {
"Ref": "VPCB9E5F0B4"
}
}
},
"VPCisolatedSubnet2RouteTableAssociation8A6ECC3C": {
"Type": "AWS::EC2::SubnetRouteTableAssociation",
"Properties": {
"RouteTableId": {
"Ref": "VPCisolatedSubnet2RouteTable1EDFC77F"
},
"SubnetId": {
"Ref": "VPCisolatedSubnet2Subnet8AE9E765"
}
}
},
"VPCRestrictDefaultSecurityGroupCustomResource59474679": {
"Type": "Custom::VpcRestrictDefaultSG",
"Properties": {
"ServiceToken": {
"Fn::GetAtt": [
"CustomVpcRestrictDefaultSGCustomResourceProviderHandlerDC833E5E",
"Arn"
]
},
"DefaultSecurityGroupId": {
"Fn::GetAtt": [
"VPCB9E5F0B4",
"DefaultSecurityGroup"
]
},
"Account": {
"Ref": "AWS::AccountId"
}
},
"UpdateReplacePolicy": "Delete",
"DeletionPolicy": "Delete"
},
"CustomVpcRestrictDefaultSGCustomResourceProviderRole26592FE0": {
"Type": "AWS::IAM::Role",
"Properties": {
"AssumeRolePolicyDocument": {
"Version": "2012-10-17",
"Statement": [
{
"Action": "sts:AssumeRole",
"Effect": "Allow",
"Principal": {
"Service": "lambda.amazonaws.com"
}
}
]
},
"ManagedPolicyArns": [
{
"Fn::Sub": "arn:${AWS::Partition}:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
}
],
"Policies": [
{
"PolicyName": "Inline",
"PolicyDocument": {
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"ec2:AuthorizeSecurityGroupIngress",
"ec2:AuthorizeSecurityGroupEgress",
"ec2:RevokeSecurityGroupIngress",
"ec2:RevokeSecurityGroupEgress"
],
"Resource": [
{
"Fn::Join": [
"",
[
"arn:",
{
"Ref": "AWS::Partition"
},
":ec2:",
{
"Ref": "AWS::Region"
},
":",
{
"Ref": "AWS::AccountId"
},
":security-group/",
{
"Fn::GetAtt": [
"VPCB9E5F0B4",
"DefaultSecurityGroup"
]
}
]
]
}
]
}
]
}
}
]
}
},
"CustomVpcRestrictDefaultSGCustomResourceProviderHandlerDC833E5E": {
"Type": "AWS::Lambda::Function",
"Properties": {
"Code": {
"S3Bucket": {
"Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}"
},
"S3Key": "4554b47be6f57b68c6c7a7391dcc73894866d2377fe174883351e7639097f292.zip"
},
"Timeout": 900,
"MemorySize": 128,
"Handler": "__entrypoint__.handler",
"Role": {
"Fn::GetAtt": [
"CustomVpcRestrictDefaultSGCustomResourceProviderRole26592FE0",
"Arn"
]
},
"Runtime": "nodejs18.x",
"Description": "Lambda function for removing all inbound/outbound rules from the VPC default security group"
},
"DependsOn": [
"CustomVpcRestrictDefaultSGCustomResourceProviderRole26592FE0"
]
}
},
"Parameters": {
"BootstrapVersion": {
"Type": "AWS::SSM::Parameter::Value<String>",
"Default": "/cdk-bootstrap/hnb659fds/version",
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]"
}
},
"Rules": {
"CheckBootstrapVersion": {
"Assertions": [
{
"Assert": {
"Fn::Not": [
{
"Fn::Contains": [
[
"1",
"2",
"3",
"4",
"5"
],
{
"Ref": "BootstrapVersion"
}
]
}
]
},
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI."
}
]
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.