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

feat(ec2): ESP and AH IPsec protocols for Security Groups #13471

Merged
merged 2 commits into from
Mar 9, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
26 changes: 26 additions & 0 deletions packages/@aws-cdk/aws-ec2/lib/port.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ export enum Protocol {
UDP = 'udp',
ICMP = 'icmp',
ICMPV6 = '58',
ESP = 'esp',
AH = 'ah',
Copy link
Contributor

Choose a reason for hiding this comment

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

This needs to be ESP = ‘50’ and AH = ‘51’

Copy link
Contributor

Choose a reason for hiding this comment

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

Also there are many other protocols that need to be added to this enum
https://en.wikipedia.org/wiki/List_of_IP_protocol_numbers

}

/**
Expand Down Expand Up @@ -171,6 +173,30 @@ export class Port {
});
}

/**
* A single ESP port
*/
public static esp(): Port {
return new Port({
protocol: Protocol.ESP,
fromPort: 50,
toPort: 50,
stringRepresentation: 'ESP 50',
});
}

/**
* A single AH port
*/
public static ah(): Port {
return new Port({
protocol: Protocol.AH,
fromPort: 51,
toPort: 51,
Copy link
Contributor

Choose a reason for hiding this comment

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

fromPort and toPort both need to be unset for both protocols

stringRepresentation: 'AH 51',
});
}

/**
* Whether the rule containing this port range can be inlined into a securitygroup or not.
*/
Expand Down
2 changes: 2 additions & 0 deletions packages/@aws-cdk/aws-ec2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,8 @@
"docs-public-apis:@aws-cdk/aws-ec2.Protocol.UDP",
"docs-public-apis:@aws-cdk/aws-ec2.Protocol.ICMP",
"docs-public-apis:@aws-cdk/aws-ec2.Protocol.ICMPV6",
"docs-public-apis:@aws-cdk/aws-ec2.Protocol.ESP",
"docs-public-apis:@aws-cdk/aws-ec2.Protocol.AH",
"docs-public-apis:@aws-cdk/aws-ec2.WindowsVersion.WINDOWS_SERVER_2008_SP2_ENGLISH_64BIT_SQL_2008_SP4_EXPRESS",
"docs-public-apis:@aws-cdk/aws-ec2.WindowsVersion.WINDOWS_SERVER_2012_R2_RTM_CHINESE_SIMPLIFIED_64BIT_BASE",
"docs-public-apis:@aws-cdk/aws-ec2.WindowsVersion.WINDOWS_SERVER_2012_R2_RTM_CHINESE_TRADITIONAL_64BIT_BASE",
Expand Down
16 changes: 15 additions & 1 deletion packages/@aws-cdk/aws-ec2/test/integ.vpc.expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,20 @@
"FromPort": 800,
"IpProtocol": "udp",
"ToPort": 801
},
{
"CidrIp": "0.0.0.0/0",
"Description": "from 0.0.0.0/0:ESP 50",
"FromPort": 50,
"IpProtocol": "esp",
"ToPort": 50
},
{
"CidrIp": "0.0.0.0/0",
"Description": "from 0.0.0.0/0:AH 51",
"FromPort": 51,
"IpProtocol": "ah",
"ToPort": 51
}
],
"VpcId": {
Expand All @@ -575,4 +589,4 @@
}
}
}
}
}
2 changes: 2 additions & 0 deletions packages/@aws-cdk/aws-ec2/test/integ.vpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ const rules = [
ec2.Port.allUdp(),
ec2.Port.udp(123),
ec2.Port.udpRange(800, 801),
ec2.Port.esp(),
ec2.Port.ah(),
];

for (const rule of rules) {
Expand Down