1+ /* eslint-disable max-len */
12import { Stack } from "aws-cdk-lib"
23import { NagPackSuppression , NagSuppressions } from "cdk-nag"
34
45export const nagSuppressions = ( stack : Stack ) => {
6+ // Suppress wildcard log permissions for SlackBot
57 safeAddNagSuppressionGroup (
68 stack ,
79 [
8- "/EpsAssistMeStack/LogRetentionaae0aa3c5b4d4f87b02d85b201efdd8a/ServiceRole/DefaultPolicy /Resource" ,
9- "/EpsAssistMeStack/SlackBotLambda/SlackBotFunctionPutLogsPolicy /Resource"
10+ "/EpsAssistMeStack/SlackBotLambda/SlackBotFunctionPutLogsPolicy /Resource" ,
11+ "/EpsAssistMeStack/SlackBotLambda/LambdaPutLogsManagedPolicy /Resource"
1012 ] ,
1113 [
1214 {
@@ -16,9 +18,25 @@ export const nagSuppressions = (stack: Stack) => {
1618 ]
1719 )
1820
21+ // Suppress wildcard log permissions for CreateIndex Lambda
22+ safeAddNagSuppressionGroup (
23+ stack ,
24+ [
25+ "/EpsAssistMeStack/CreateIndexFunction/CreateIndexFunctionPutLogsPolicy/Resource" ,
26+ "/EpsAssistMeStack/CreateIndexFunction/LambdaPutLogsManagedPolicy/Resource"
27+ ] ,
28+ [
29+ {
30+ id : "AwsSolutions-IAM5" ,
31+ reason : "Wildcard permissions are required for log stream access under known paths."
32+ }
33+ ]
34+ )
35+
36+ // Suppress API Gateway validation warning
1937 safeAddNagSuppression (
2038 stack ,
21- "/EpsAssistMeStack/EpsAssistApiGateway/RestApi /Resource" ,
39+ "/EpsAssistMeStack/EpsAssistApiGateway/ApiGateway /Resource" ,
2240 [
2341 {
2442 id : "AwsSolutions-APIG2" ,
@@ -27,9 +45,10 @@ export const nagSuppressions = (stack: Stack) => {
2745 ]
2846 )
2947
48+ // Suppress AWS managed policy warning for default CDK log retention resource
3049 safeAddNagSuppression (
3150 stack ,
32- "/EpsAssistMeStack/LogRetentionaae0aa3c5b4d4f87b02d85b201efdd8a /ServiceRole/Resource" ,
51+ "/EpsAssistMeStack/AWS679f53fac002430cb0da5b7982bd2287 /ServiceRole/Resource" ,
3352 [
3453 {
3554 id : "AwsSolutions-IAM4" ,
@@ -38,10 +57,11 @@ export const nagSuppressions = (stack: Stack) => {
3857 ]
3958 )
4059
60+ // Suppress unauthenticated API Gateway route warnings
4161 safeAddNagSuppressionGroup (
4262 stack ,
4363 [
44- "/EpsAssistMeStack/EpsAssistApiGateway/RestApi /Default/slack/ask-eps/POST/Resource"
64+ "/EpsAssistMeStack/EpsAssistApiGateway/ApiGateway /Default/slack/ask-eps/POST/Resource"
4565 ] ,
4666 [
4767 {
@@ -55,7 +75,7 @@ export const nagSuppressions = (stack: Stack) => {
5575 ]
5676 )
5777
58- // 🔒 Suppress missing S3 access logs (AwsSolutions-S1)
78+ // Suppress missing S3 access logs (AwsSolutions-S1)
5979 safeAddNagSuppression (
6080 stack ,
6181 "/EpsAssistMeStack/EpsAssistDocsBucket/Resource" ,
@@ -82,10 +102,10 @@ export const nagSuppressions = (stack: Stack) => {
82102 ]
83103 )
84104
85- // 🛡️ Suppress lack of WAF on API Gateway stage
105+ // Suppress lack of WAF on API Gateway stage
86106 safeAddNagSuppression (
87107 stack ,
88- "/EpsAssistMeStack/EpsAssistApiGateway/RestApi /DeploymentStage.prod/Resource" ,
108+ "/EpsAssistMeStack/EpsAssistApiGateway/ApiGateway /DeploymentStage.prod/Resource" ,
89109 [
90110 {
91111 id : "AwsSolutions-APIG3" ,
@@ -94,7 +114,7 @@ export const nagSuppressions = (stack: Stack) => {
94114 ]
95115 )
96116
97- // ⚠️ Suppress non-latest Lambda runtime
117+ // Suppress non-latest Lambda runtime
98118 safeAddNagSuppression (
99119 stack ,
100120 "/EpsAssistMeStack/SlackBotLambda/SlackBotFunction/Resource" ,
@@ -110,13 +130,15 @@ export const nagSuppressions = (stack: Stack) => {
110130const safeAddNagSuppression = ( stack : Stack , path : string , suppressions : Array < NagPackSuppression > ) => {
111131 try {
112132 NagSuppressions . addResourceSuppressionsByPath ( stack , path , suppressions )
133+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
113134 } catch ( err ) {
114135 console . log ( `Could not find path ${ path } ` )
115136 }
116137}
117138
118- const safeAddNagSuppressionGroup = ( stack : Stack , paths : string [ ] , suppressions : Array < NagPackSuppression > ) => {
119- for ( const path of paths ) {
120- safeAddNagSuppression ( stack , path , suppressions )
139+ // Apply the same nag suppression to multiple resources
140+ const safeAddNagSuppressionGroup = ( stack : Stack , path : Array < string > , suppressions : Array < NagPackSuppression > ) => {
141+ for ( const p of path ) {
142+ safeAddNagSuppression ( stack , p , suppressions )
121143 }
122144}
0 commit comments