Skip to content

Commit

Permalink
fix(ec2): cannot deploy SecurityGroup with allowAllIpv6Outbound (aws#…
Browse files Browse the repository at this point in the history
…22414)

Introduced this functionality in aws#22279, but I didn't add an integration test so it didn't actually work. This PR fixes the mistake _and_ adds an integration test like I should have done the first time.

fixes aws#22407


----

### All Submissions:

* [ ] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md)

### Adding new Unconventional Dependencies:

* [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-new-unconventional-dependencies)

### New Features

* [ ] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)?
	* [ ] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)?

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
corymhall authored and madeline-k committed Oct 10, 2022
1 parent 41948d3 commit 8ba453f
Show file tree
Hide file tree
Showing 11 changed files with 419 additions and 183 deletions.
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-ec2/lib/security-group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,7 @@ export class SecurityGroup extends SecurityGroupBase {
} else {
this.directEgressRules.push({
ipProtocol: '-1',
cidrIp: peer.uniqueId,
cidrIpv6: peer.uniqueId,
description,
});
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"version":"17.0.0"}
{"version":"21.0.0"}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"version": "21.0.0",
"files": {
"21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": {
"source": {
"path": "instancetestDefaultTestDeployAssert5516EAF1.template.json",
"packaging": "file"
},
"destinations": {
"current_account-current_region": {
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
"objectKey": "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22.json",
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
}
}
}
},
"dockerImages": {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"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."
}
]
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"version": "21.0.0",
"files": {
"07dc2cd10d2741c8de44a54c2c57da82c0dc28b18e74ae53bfdb0eb3d8f26eff": {
"source": {
"path": "integ-ec2-instance.template.json",
"packaging": "file"
},
"destinations": {
"current_account-current_region": {
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
"objectKey": "07dc2cd10d2741c8de44a54c2c57da82c0dc28b18e74ae53bfdb0eb3d8f26eff.json",
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
}
}
}
},
"dockerImages": {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"Tags": [
{
"Key": "Name",
"Value": "TestStack/VPC"
"Value": "integ-ec2-instance/VPC"
}
]
}
Expand Down Expand Up @@ -42,7 +42,7 @@
},
{
"Key": "Name",
"Value": "TestStack/VPC/PublicSubnet1"
"Value": "integ-ec2-instance/VPC/PublicSubnet1"
}
]
}
Expand All @@ -56,7 +56,7 @@
"Tags": [
{
"Key": "Name",
"Value": "TestStack/VPC/PublicSubnet1"
"Value": "integ-ec2-instance/VPC/PublicSubnet1"
}
]
}
Expand Down Expand Up @@ -94,7 +94,7 @@
"Tags": [
{
"Key": "Name",
"Value": "TestStack/VPC/PublicSubnet1"
"Value": "integ-ec2-instance/VPC/PublicSubnet1"
}
]
}
Expand All @@ -114,10 +114,14 @@
"Tags": [
{
"Key": "Name",
"Value": "TestStack/VPC/PublicSubnet1"
"Value": "integ-ec2-instance/VPC/PublicSubnet1"
}
]
}
},
"DependsOn": [
"VPCPublicSubnet1DefaultRoute91CEF279",
"VPCPublicSubnet1RouteTableAssociation0B0896DC"
]
},
"VPCPublicSubnet2Subnet74179F39": {
"Type": "AWS::EC2::Subnet",
Expand Down Expand Up @@ -146,7 +150,7 @@
},
{
"Key": "Name",
"Value": "TestStack/VPC/PublicSubnet2"
"Value": "integ-ec2-instance/VPC/PublicSubnet2"
}
]
}
Expand All @@ -160,7 +164,7 @@
"Tags": [
{
"Key": "Name",
"Value": "TestStack/VPC/PublicSubnet2"
"Value": "integ-ec2-instance/VPC/PublicSubnet2"
}
]
}
Expand Down Expand Up @@ -198,7 +202,7 @@
"Tags": [
{
"Key": "Name",
"Value": "TestStack/VPC/PublicSubnet2"
"Value": "integ-ec2-instance/VPC/PublicSubnet2"
}
]
}
Expand All @@ -218,10 +222,14 @@
"Tags": [
{
"Key": "Name",
"Value": "TestStack/VPC/PublicSubnet2"
"Value": "integ-ec2-instance/VPC/PublicSubnet2"
}
]
}
},
"DependsOn": [
"VPCPublicSubnet2DefaultRouteB7481BBA",
"VPCPublicSubnet2RouteTableAssociation5A808732"
]
},
"VPCPrivateSubnet1Subnet8BCA10E0": {
"Type": "AWS::EC2::Subnet",
Expand Down Expand Up @@ -250,7 +258,7 @@
},
{
"Key": "Name",
"Value": "TestStack/VPC/PrivateSubnet1"
"Value": "integ-ec2-instance/VPC/PrivateSubnet1"
}
]
}
Expand All @@ -264,7 +272,7 @@
"Tags": [
{
"Key": "Name",
"Value": "TestStack/VPC/PrivateSubnet1"
"Value": "integ-ec2-instance/VPC/PrivateSubnet1"
}
]
}
Expand Down Expand Up @@ -319,7 +327,7 @@
},
{
"Key": "Name",
"Value": "TestStack/VPC/PrivateSubnet2"
"Value": "integ-ec2-instance/VPC/PrivateSubnet2"
}
]
}
Expand All @@ -333,7 +341,7 @@
"Tags": [
{
"Key": "Name",
"Value": "TestStack/VPC/PrivateSubnet2"
"Value": "integ-ec2-instance/VPC/PrivateSubnet2"
}
]
}
Expand Down Expand Up @@ -367,7 +375,7 @@
"Tags": [
{
"Key": "Name",
"Value": "TestStack/VPC"
"Value": "integ-ec2-instance/VPC"
}
]
}
Expand All @@ -383,15 +391,20 @@
}
}
},
"InstanceInstanceSecurityGroupF0E2D5BE": {
"IntegSg68DC2C7E": {
"Type": "AWS::EC2::SecurityGroup",
"Properties": {
"GroupDescription": "TestStack/Instance/InstanceSecurityGroup",
"GroupDescription": "integ-ec2-instance/IntegSg",
"SecurityGroupEgress": [
{
"CidrIp": "0.0.0.0/0",
"Description": "Allow all outbound traffic by default",
"IpProtocol": "-1"
},
{
"CidrIpv6": "::/0",
"Description": "Allow all outbound ipv6 traffic by default",
"IpProtocol": "-1"
}
],
"SecurityGroupIngress": [
Expand All @@ -403,12 +416,6 @@
"ToPort": -1
}
],
"Tags": [
{
"Key": "Name",
"Value": "TestStack/Instance"
}
],
"VpcId": {
"Ref": "VPCB9E5F0B4"
}
Expand Down Expand Up @@ -442,7 +449,7 @@
"Tags": [
{
"Key": "Name",
"Value": "TestStack/Instance"
"Value": "integ-ec2-instance/Instance"
}
]
}
Expand Down Expand Up @@ -500,7 +507,7 @@
"SecurityGroupIds": [
{
"Fn::GetAtt": [
"InstanceInstanceSecurityGroupF0E2D5BE",
"IntegSg68DC2C7E",
"GroupId"
]
}
Expand All @@ -511,7 +518,7 @@
"Tags": [
{
"Key": "Name",
"Value": "TestStack/Instance"
"Value": "integ-ec2-instance/Instance"
}
],
"UserData": {
Expand All @@ -528,6 +535,38 @@
"SsmParameterValueawsserviceamiamazonlinuxlatestamzn2amihvmx8664gp2C96584B6F00A464EAD1953AFF4B05118Parameter": {
"Type": "AWS::SSM::Parameter::Value<AWS::EC2::Image::Id>",
"Default": "/aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-gp2"
},
"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."
}
]
}
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
{
"version": "20.0.0",
"version": "21.0.0",
"testCases": {
"integ.instance": {
"instance-test/DefaultTest": {
"stacks": [
"*"
"integ-ec2-instance"
],
"diffAssets": false,
"stackUpdateWorkflow": true
"assertionStack": "instance-test/DefaultTest/DeployAssert",
"assertionStackName": "instancetestDefaultTestDeployAssert5516EAF1"
}
},
"synthContext": {},
"enableLookups": false
}
}
Loading

0 comments on commit 8ba453f

Please sign in to comment.