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): add ICMPv6 protocol #20626

Merged
merged 2 commits into from
Jul 19, 2022
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
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 @@ -307,6 +307,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
32 changes: 32 additions & 0 deletions packages/@aws-cdk/aws-ec2/test/integ.ports.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import * as cdk from '@aws-cdk/core';
import { IntegTest } from '@aws-cdk/integ-tests';
import * as ec2 from '../lib/index';

const app = new cdk.App();

class TestStack extends cdk.Stack {
constructor(scope: cdk.App, id: string, props?: cdk.StackProps) {
super(scope, id, props);

const vpc = new ec2.Vpc(this, 'VPC');

const sg = new ec2.SecurityGroup(this, 'SecGroup', {
vpc,
});
sg.addIngressRule(
ec2.Peer.anyIpv6(),
ec2.Port.allIcmpV6(),
'allow ICMP6',
);
}
}

new TestStack(app, 'TestStack');

new IntegTest(app, 'Ports', {
testCases: [
new TestStack(app, 'PortsTestStack', {}),
],
});

app.synth();
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
Loading