-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
…rved (#28607) This PR fixes that Internet Gateway will be created even if (all) public subnets are reserved. The `reserved` option is for not actually creating subnet resources. So IGW should not be created if all public subnets are reserved, because there is no public subnets in the VPC. It would be appropriate to consider the `reserved` option since [we originally did not want to create an IGW if there was no public subnets](https://github.com/aws/aws-cdk/blob/v2.118.0/packages/aws-cdk-lib/aws-ec2/lib/vpc.ts#L1493-L1497). Also, if this bug is not fixed, it will go to the [code where the NatGateway is created](https://github.com/aws/aws-cdk/blob/v2.118.0/packages/aws-cdk-lib/aws-ec2/lib/vpc.ts#L1513-L1517) without public subnets. (This will be stopped with another error, but...) Closes #28593. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
- Loading branch information
There are no files selected for viewing
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.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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.