Skip to content

Commit 7c645aa

Browse files
authored
Merge branch 'main' into huijbers/cfnspec-rejections
2 parents 9d5ecef + 99831b0 commit 7c645aa

13 files changed

Lines changed: 2756 additions & 176 deletions

File tree

packages/@aws-cdk/aws-ec2/README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -529,11 +529,14 @@ the connection specifier:
529529
ec2.Port.tcp(80)
530530
ec2.Port.tcpRange(60000, 65535)
531531
ec2.Port.allTcp()
532+
ec2.Port.allIcmp()
533+
ec2.Port.allIcmpV6()
532534
ec2.Port.allTraffic()
533535
```
534536

535-
> NOTE: This set is not complete yet; for example, there is no library support for ICMP at the moment.
536-
> However, you can write your own classes to implement those.
537+
> NOTE: Not all protocols have corresponding helper methods. In the absence of a helper method,
538+
> you can instantiate `Port` yourself with your own settings. You are also welcome to contribute
539+
> new helper methods.
537540
538541
### Default Ports
539542

packages/@aws-cdk/aws-ec2/lib/port.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,18 @@ export class Port {
307307
});
308308
}
309309

310+
/**
311+
* All ICMPv6 traffic
312+
*/
313+
public static allIcmpV6() {
314+
return new Port({
315+
protocol: Protocol.ICMPV6,
316+
fromPort: -1,
317+
toPort: -1,
318+
stringRepresentation: 'ALL ICMPv6',
319+
});
320+
}
321+
310322
/**
311323
* All traffic
312324
*/
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import * as cdk from '@aws-cdk/core';
2+
import { IntegTest } from '@aws-cdk/integ-tests';
3+
import * as ec2 from '../lib/index';
4+
5+
const app = new cdk.App();
6+
7+
class TestStack extends cdk.Stack {
8+
constructor(scope: cdk.App, id: string, props?: cdk.StackProps) {
9+
super(scope, id, props);
10+
11+
const vpc = new ec2.Vpc(this, 'VPC');
12+
13+
const sg = new ec2.SecurityGroup(this, 'SecGroup', {
14+
vpc,
15+
});
16+
sg.addIngressRule(
17+
ec2.Peer.anyIpv6(),
18+
ec2.Port.allIcmpV6(),
19+
'allow ICMP6',
20+
);
21+
}
22+
}
23+
24+
new TestStack(app, 'TestStack');
25+
26+
new IntegTest(app, 'Ports', {
27+
testCases: [
28+
new TestStack(app, 'PortsTestStack', {}),
29+
],
30+
});
31+
32+
app.synth();
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

0 commit comments

Comments
 (0)