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(aws-ec2): fix code generation of IcmpPing #1235

Merged
merged 2 commits into from
Nov 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/@aws-cdk/aws-ec2/lib/security-group-rule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@ export class IcmpPing implements IPortRange {
return {
ipProtocol: Protocol.Icmp,
fromPort: 8,
toPort: -1
};
}

Expand Down
84 changes: 72 additions & 12 deletions packages/@aws-cdk/aws-ec2/test/integ.vpc.expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,6 @@
},
"MyVpcPublicSubnet1DefaultRoute95FDF9EB": {
"Type": "AWS::EC2::Route",
"DependsOn": [
"MyVpcVPCGW488ACE0D"
],
"Properties": {
"RouteTableId": {
"Ref": "MyVpcPublicSubnet1RouteTableC46AB2F4"
Expand All @@ -78,7 +75,10 @@
"GatewayId": {
"Ref": "MyVpcIGW5C4A4F63"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kind of expected to see this -1 here somewhere

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right. Stale build probably.

}
}
},
"DependsOn": [
"MyVpcVPCGW488ACE0D"
]
},
"MyVpcPublicSubnet1EIP096967CB": {
"Type": "AWS::EC2::EIP",
Expand Down Expand Up @@ -158,9 +158,6 @@
},
"MyVpcPublicSubnet2DefaultRoute052936F6": {
"Type": "AWS::EC2::Route",
"DependsOn": [
"MyVpcVPCGW488ACE0D"
],
"Properties": {
"RouteTableId": {
"Ref": "MyVpcPublicSubnet2RouteTable1DF17386"
Expand All @@ -169,7 +166,10 @@
"GatewayId": {
"Ref": "MyVpcIGW5C4A4F63"
}
}
},
"DependsOn": [
"MyVpcVPCGW488ACE0D"
]
},
"MyVpcPublicSubnet2EIP8CCBA239": {
"Type": "AWS::EC2::EIP",
Expand Down Expand Up @@ -249,9 +249,6 @@
},
"MyVpcPublicSubnet3DefaultRoute3A83AB36": {
"Type": "AWS::EC2::Route",
"DependsOn": [
"MyVpcVPCGW488ACE0D"
],
"Properties": {
"RouteTableId": {
"Ref": "MyVpcPublicSubnet3RouteTable15028F08"
Expand All @@ -260,7 +257,10 @@
"GatewayId": {
"Ref": "MyVpcIGW5C4A4F63"
}
}
},
"DependsOn": [
"MyVpcVPCGW488ACE0D"
]
},
"MyVpcPublicSubnet3EIPC5ACADAB": {
"Type": "AWS::EC2::EIP",
Expand Down Expand Up @@ -495,6 +495,66 @@
"Ref": "MyVpcIGW5C4A4F63"
}
}
},
"SGADB53937": {
"Type": "AWS::EC2::SecurityGroup",
"Properties": {
"GroupDescription": "aws-cdk-ec2-vpc/SG",
"SecurityGroupEgress": [
{
"CidrIp": "0.0.0.0/0",
"Description": "Allow all outbound traffic by default",
"IpProtocol": "-1"
}
],
"SecurityGroupIngress": [
{
"CidrIp": "0.0.0.0/0",
"Description": "from 0.0.0.0/0:ICMP PING",
"FromPort": 8,
"IpProtocol": "icmp",
"ToPort": -1
},
{
"CidrIp": "0.0.0.0/0",
"Description": "from 0.0.0.0/0:ICMP Type 128",
"FromPort": 128,
"IpProtocol": "icmp",
"ToPort": -1
},
{
"CidrIp": "0.0.0.0/0",
"Description": "from 0.0.0.0/0:ALL ICMP",
"FromPort": -1,
"IpProtocol": "icmp",
"ToPort": -1
},
{
"CidrIp": "0.0.0.0/0",
"Description": "from 0.0.0.0/0:UDP ALL PORTS",
"FromPort": 0,
"IpProtocol": "udp",
"ToPort": 65535
},
{
"CidrIp": "0.0.0.0/0",
"Description": "from 0.0.0.0/0:UDP 123",
"FromPort": 123,
"IpProtocol": "udp",
"ToPort": 123
},
{
"CidrIp": "0.0.0.0/0",
"Description": "from 0.0.0.0/0:UDP 800-801",
"FromPort": 800,
"IpProtocol": "udp",
"ToPort": 801
}
],
"VpcId": {
"Ref": "MyVpcF9F0CA6F"
}
}
}
}
}
25 changes: 20 additions & 5 deletions packages/@aws-cdk/aws-ec2/test/integ.vpc.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,25 @@
import { App, Stack } from '@aws-cdk/cdk';
import { VpcNetwork } from '../lib';
import cdk = require('@aws-cdk/cdk');
import ec2 = require('../lib');

const app = new App();
const app = new cdk.App();
const stack = new cdk.Stack(app, 'aws-cdk-ec2-vpc');

const stack = new Stack(app, 'aws-cdk-ec2-vpc');
const vpc = new ec2.VpcNetwork(stack, 'MyVpc');

new VpcNetwork(stack, 'MyVpc');
// Test Security Group Rules
const sg = new ec2.SecurityGroup(stack, 'SG', { vpc });

const rules = [
new ec2.IcmpPing(),
new ec2.IcmpAllTypeCodes(128),
new ec2.IcmpAllTypesAndCodes(),
new ec2.UdpAllPorts(),
new ec2.UdpPort(123),
new ec2.UdpPortRange(800, 801),
];

for (const rule of rules) {
sg.addIngressRule(new ec2.AnyIPv4(), rule);
}

app.run();