Skip to content

Commit

Permalink
chore(aws-ec2): add ICMPv6 protocol method
Browse files Browse the repository at this point in the history
This allows creation of a security group rule that permits
ICMPv6.
  • Loading branch information
philipmw committed Jun 16, 2022
1 parent 8931f11 commit 2a20ee9
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/@aws-cdk/aws-ec2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -529,11 +529,14 @@ the connection specifier:
ec2.Port.tcp(80)
ec2.Port.tcpRange(60000, 65535)
ec2.Port.allTcp()
ec2.Port.allIcmp()
ec2.Port.allIcmpV6()
ec2.Port.allTraffic()
```

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

Expand Down
12 changes: 12 additions & 0 deletions packages/@aws-cdk/aws-ec2/lib/port.ts
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,18 @@ export class Port {
});
}

/**
* All ICMPv6 traffic
*/
public static allIcmpV6() {
return new Port({
protocol: Protocol.ICMPV6,
fromPort: -1,
toPort: -1,
stringRepresentation: 'ALL ICMPv6',
});
}

/**
* All traffic
*/
Expand Down
16 changes: 16 additions & 0 deletions packages/@aws-cdk/aws-ec2/test/port.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { Port, Protocol } from '../lib';

describe('port', () => {
describe('Port class', () => {
describe('.allIcmpV6', () => {
it('returns expected instance of Port', () => {
expect(Port.allIcmpV6()).toEqual(new Port({
protocol: Protocol.ICMPV6,
fromPort: -1,
toPort: -1,
stringRepresentation: 'ALL ICMPv6',
}));
});
});
});
});

0 comments on commit 2a20ee9

Please sign in to comment.