@@ -35,6 +35,21 @@ export const nagSuppressions = (stack: Stack) => {
3535 ]
3636 )
3737
38+ // Suppress wildcard log permissions for SyncKnowledgeBase Lambda
39+ safeAddNagSuppression (
40+ stack ,
41+ "/EpsAssistMeStack/Functions/SyncKnowledgeBaseFunction/LambdaPutLogsManagedPolicy/Resource" ,
42+ [
43+ {
44+ id : "AwsSolutions-IAM5" ,
45+ reason : "Wildcard permissions are required for log stream access under known paths." ,
46+ appliesTo : [
47+ "Resource::<FunctionsSyncKnowledgeBaseFunctionLambdaLogGroupB19BE2BE.Arn>:log-stream:*"
48+ ]
49+ }
50+ ]
51+ )
52+
3853 // Suppress API Gateway validation warning for Apis construct
3954 safeAddNagSuppression (
4055 stack ,
@@ -87,18 +102,18 @@ export const nagSuppressions = (stack: Stack) => {
87102 ]
88103 )
89104
90- // Suppress IAM wildcard permissions for Bedrock execution managed policy
105+ // Suppress IAM wildcard permissions for Bedrock execution role policy
91106 safeAddNagSuppression (
92107 stack ,
93- "/EpsAssistMeStack/IamResources/BedrockExecutionManagedPolicy /Resource" ,
108+ "/EpsAssistMeStack/BedrockExecutionRole/Policy /Resource" ,
94109 [
95110 {
96111 id : "AwsSolutions-IAM5" ,
97112 reason : "Bedrock Knowledge Base requires these permissions to access S3 documents and OpenSearch collection." ,
98113 appliesTo : [
99- "Action::bedrock:Delete*" ,
100114 "Resource::<StorageDocsBucketepsamDocsF25F63F1.Arn>/*" ,
101- "Resource::<StorageDocsBucketepsampr16Docs240CC945.Arn>/*" ,
115+ "Resource::<StorageDocsBucketepsampr20Docs075F648F.Arn>/*" ,
116+ "Action::bedrock:Delete*" ,
102117 `Resource::arn:aws:bedrock:eu-west-2:${ account } :knowledge-base/*` ,
103118 `Resource::arn:aws:aoss:eu-west-2:${ account } :collection/*` ,
104119 "Resource::*"
@@ -107,10 +122,10 @@ export const nagSuppressions = (stack: Stack) => {
107122 ]
108123 )
109124
110- // Suppress wildcard permissions for CreateIndex managed policy
125+ // Suppress wildcard permissions for CreateIndex policy
111126 safeAddNagSuppression (
112127 stack ,
113- "/EpsAssistMeStack/IamResources/CreateIndexManagedPolicy /Resource" ,
128+ "/EpsAssistMeStack/RuntimePolicies/CreateIndexPolicy /Resource" ,
114129 [
115130 {
116131 id : "AwsSolutions-IAM5" ,
@@ -123,18 +138,16 @@ export const nagSuppressions = (stack: Stack) => {
123138 ]
124139 )
125140
126- // Suppress wildcard permissions for SlackBot managed policy
141+ // Suppress wildcard permissions for SlackBot policy
127142 safeAddNagSuppression (
128143 stack ,
129- "/EpsAssistMeStack/IamResources/SlackBotManagedPolicy /Resource" ,
144+ "/EpsAssistMeStack/RuntimePolicies/SlackBotPolicy /Resource" ,
130145 [
131146 {
132147 id : "AwsSolutions-IAM5" ,
133- reason : "SlackBot Lambda needs access to all guardrails, knowledge bases, and functions for content filtering and self-invocation." ,
148+ reason : "SlackBot Lambda needs wildcard access for Lambda functions ( self-invocation) and KMS operations ." ,
134149 appliesTo : [
135150 `Resource::arn:aws:lambda:eu-west-2:${ account } :function:*` ,
136- `Resource::arn:aws:bedrock:eu-west-2:${ account } :guardrail/*` ,
137- `Resource::arn:aws:bedrock:eu-west-2:${ account } :knowledge-base/*` ,
138151 "Action::kms:GenerateDataKey*" ,
139152 "Action::kms:ReEncrypt*"
140153 ]
@@ -177,6 +190,40 @@ export const nagSuppressions = (stack: Stack) => {
177190 ]
178191 )
179192
193+ // Suppress AWS managed policy usage in BucketNotificationsHandler (wildcard for any hash)
194+ const bucketNotificationHandlers = stack . node . findAll ( ) . filter ( node =>
195+ node . node . id . startsWith ( "BucketNotificationsHandler" )
196+ )
197+
198+ bucketNotificationHandlers . forEach ( handler => {
199+ safeAddNagSuppression (
200+ stack ,
201+ `${ handler . node . path } /Role/Resource` ,
202+ [
203+ {
204+ id : "AwsSolutions-IAM4" ,
205+ reason : "Auto-generated CDK role uses AWS managed policy for basic Lambda execution." ,
206+ appliesTo : [
207+ "Policy::arn:<AWS::Partition>:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
208+ ]
209+ }
210+ ]
211+ )
212+
213+ safeAddNagSuppression (
214+ stack ,
215+ `${ handler . node . path } /Role/DefaultPolicy/Resource` ,
216+ [
217+ {
218+ id : "AwsSolutions-IAM5" ,
219+ reason : "Auto-generated CDK role requires wildcard permissions for S3 bucket notifications." ,
220+ appliesTo : [
221+ "Resource::*"
222+ ]
223+ }
224+ ]
225+ )
226+ } )
180227}
181228
182229const safeAddNagSuppression = ( stack : Stack , path : string , suppressions : Array < NagPackSuppression > ) => {
0 commit comments