Skip to content

Commit 559d666

Browse files
committed
add nag supression
1 parent 21945a4 commit 559d666

File tree

2 files changed

+119
-0
lines changed

2 files changed

+119
-0
lines changed

packages/cdk/nagSuppressions.ts

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
2+
import {Stack} from "aws-cdk-lib"
3+
import {NagPackSuppression, NagSuppressions} from "cdk-nag"
4+
5+
export const nagSuppressions = (stack: Stack) => {
6+
safeAddNagSuppression(
7+
stack,
8+
"/VpcResourcesStack/ECRDockerEndpoint-tags/CustomResourcePolicy/Resource",
9+
[
10+
{
11+
id: "AwsSolutions-IAM5",
12+
reason: "Suppress error for wildcard permissions. This is fine here"
13+
}
14+
]
15+
)
16+
17+
safeAddNagSuppression(
18+
stack,
19+
"/VpcResourcesStack/AWS679f53fac002430cb0da5b7982bd2287/ServiceRole/Resource",
20+
[
21+
{
22+
id: "AwsSolutions-IAM4",
23+
reason: "Suppress error for using AWS managed policy. This is fine here"
24+
}
25+
]
26+
)
27+
28+
safeAddNagSuppression(
29+
stack,
30+
"/VpcResourcesStack/AWS679f53fac002430cb0da5b7982bd2287/Resource",
31+
[
32+
{
33+
id: "AwsSolutions-L1",
34+
reason: "Suppress error for using not using latest runtime. This is fine here"
35+
}
36+
]
37+
)
38+
39+
safeAddNagSuppression(
40+
stack,
41+
"/VpcResourcesStack/ECREndpoint-tags/CustomResourcePolicy/Resource",
42+
[
43+
{
44+
id: "AwsSolutions-IAM5",
45+
reason: "Suppress error for wildcard permissions. This is fine here"
46+
}
47+
]
48+
)
49+
50+
safeAddNagSuppression(
51+
stack,
52+
"/VpcResourcesStack/SecretManagerEndpoint-tags/CustomResourcePolicy/Resource",
53+
[
54+
{
55+
id: "AwsSolutions-IAM5",
56+
reason: "Suppress error for wildcard permissions. This is fine here"
57+
}
58+
]
59+
)
60+
61+
safeAddNagSuppression(
62+
stack,
63+
"/VpcResourcesStack/CloudWatchEndpoint-tags/CustomResourcePolicy/Resource",
64+
[
65+
{
66+
id: "AwsSolutions-IAM5",
67+
reason: "Suppress error for wildcard permissions. This is fine here"
68+
}
69+
]
70+
)
71+
72+
safeAddNagSuppression(
73+
stack,
74+
"/VpcResourcesStack/CloudWatchLogsEndpoint-tags/CustomResourcePolicy/Resource",
75+
[
76+
{
77+
id: "AwsSolutions-IAM5",
78+
reason: "Suppress error for wildcard permissions. This is fine here"
79+
}
80+
]
81+
)
82+
83+
safeAddNagSuppression(
84+
stack,
85+
"/VpcResourcesStack/CloudWatchEventsEndpoint-tags/CustomResourcePolicy/Resource",
86+
[
87+
{
88+
id: "AwsSolutions-IAM5",
89+
reason: "Suppress error for wildcard permissions. This is fine here"
90+
}
91+
]
92+
)
93+
94+
safeAddNagSuppression(
95+
stack,
96+
"/VpcResourcesStack/SSMEndpoint-tags/CustomResourcePolicy/Resource",
97+
[
98+
{
99+
id: "AwsSolutions-IAM5",
100+
reason: "Suppress error for wildcard permissions. This is fine here"
101+
}
102+
]
103+
)
104+
105+
}
106+
107+
const safeAddNagSuppression = (stack: Stack, path: string, suppressions: Array<NagPackSuppression>) => {
108+
try {
109+
NagSuppressions.addResourceSuppressionsByPath(stack, path, suppressions)
110+
111+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
112+
} catch(err){
113+
console.log(`Could not find path ${path}`)
114+
}
115+
}

packages/cdk/stacks/VpcResourcesStack.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ import {Key} from "aws-cdk-lib/aws-kms"
2222
import {LogGroup} from "aws-cdk-lib/aws-logs"
2323
import {AwsCustomResource, AwsCustomResourcePolicy, PhysicalResourceId} from "aws-cdk-lib/custom-resources"
2424

25+
import {nagSuppressions} from "../nagSuppressions"
26+
2527
export interface VpcResourcesStackProps extends StackProps{
2628
readonly version: string
2729
readonly availabilityZones: [string]
@@ -147,6 +149,8 @@ export class VpcResourcesStack extends Stack {
147149
exportName: `${props.stackName}:PrivateSubnets`
148150
})
149151

152+
nagSuppressions(this)
153+
150154
}
151155

152156
private addInterfaceEndpoint(name: string, awsService: InterfaceVpcEndpointAwsService): void {

0 commit comments

Comments
 (0)