Skip to content

Commit 6602300

Browse files
committed
Adding relevant cdk-nag exception
1 parent 8e1a439 commit 6602300

File tree

1 file changed

+35
-19
lines changed

1 file changed

+35
-19
lines changed
Lines changed: 35 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,49 @@
11
import * as cdk from "aws-cdk-lib";
22
import * as cdkConstructs from 'constructs';
33
import * as ec2 from "aws-cdk-lib/aws-ec2";
4+
import * as nag from "cdk-nag";
45

56
export interface SuiNodeSecurityGroupConstructProps {
67
vpc: cdk.aws_ec2.IVpc;
78
}
89

9-
export class SuiNodeSecurityGroupConstruct extends cdkConstructs.Construct {
10-
public securityGroup: cdk.aws_ec2.ISecurityGroup;
10+
export class SuiNodeSecurityGroupConstruct extends cdkConstructs.Construct {
11+
public securityGroup: cdk.aws_ec2.ISecurityGroup;
1112

12-
constructor(scope: cdkConstructs.Construct, id: string, props: SuiNodeSecurityGroupConstructProps) {
13-
super(scope, id);
13+
constructor(scope: cdkConstructs.Construct, id: string, props: SuiNodeSecurityGroupConstructProps) {
14+
super(scope, id);
1415

15-
const {
16-
vpc,
17-
} = props;
16+
const {
17+
vpc,
18+
} = props;
1819

19-
const sg = new ec2.SecurityGroup(this, `rpc-node-security-group`, {
20-
vpc,
21-
description: "Security Group for Blockchain nodes",
22-
allowAllOutbound: true,
23-
});
20+
const sg = new ec2.SecurityGroup(this, `rpc-node-security-group`, {
21+
vpc,
22+
description: "Security Group for Blockchain nodes",
23+
allowAllOutbound: true,
24+
});
2425

25-
// Private port
26-
sg.addIngressRule(ec2.Peer.anyIpv4(), ec2.Port.udp(8084), "Sui P2P");
27-
sg.addIngressRule(ec2.Peer.anyIpv4(), ec2.Port.tcp(9184), "Sui Metrics");
28-
sg.addIngressRule(ec2.Peer.ipv4(vpc.vpcCidrBlock), ec2.Port.tcp(9000), "JSON-RPC");
29-
sg.addIngressRule(ec2.Peer.ipv4(vpc.vpcCidrBlock), ec2.Port.tcp(22), "SSH");
26+
// Private port
27+
sg.addIngressRule(ec2.Peer.anyIpv4(), ec2.Port.udp(8084), "Sui P2P");
28+
sg.addIngressRule(ec2.Peer.anyIpv4(), ec2.Port.tcp(9184), "Sui Metrics");
29+
sg.addIngressRule(ec2.Peer.ipv4(vpc.vpcCidrBlock), ec2.Port.tcp(9000), "JSON-RPC");
30+
sg.addIngressRule(ec2.Peer.ipv4(vpc.vpcCidrBlock), ec2.Port.tcp(22), "SSH");
3031

31-
this.securityGroup = sg
32-
}
32+
this.securityGroup = sg
33+
34+
/**
35+
* cdk-nag suppressions
36+
*/
37+
nag.NagSuppressions.addResourceSuppressions(
38+
this,
39+
[
40+
{
41+
id: "AwsSolutions-EC23",
42+
reason: "Sui requires wildcard inbound for specific ports",
43+
},
44+
],
45+
true
46+
);
47+
3348
}
49+
}

0 commit comments

Comments
 (0)