@@ -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,30 +102,22 @@ 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" ,
97- reason : "Bedrock Knowledge Base requires these permissions to access S3 documents and OpenSearch collection." ,
98- appliesTo : [
99- "Action::bedrock:Delete*" ,
100- "Resource::<StorageDocsBucketepsamDocsF25F63F1.Arn>/*" ,
101- "Resource::<StorageDocsBucketepsampr30Docs3C1F6B95.Arn>/*" ,
102- `Resource::arn:aws:bedrock:eu-west-2:${ account } :knowledge-base/*` ,
103- `Resource::arn:aws:aoss:eu-west-2:${ account } :collection/*` ,
104- "Resource::*"
105- ]
112+ reason : "Bedrock Knowledge Base requires these permissions to access S3 documents and OpenSearch collection."
106113 }
107114 ]
108115 )
109116
110- // Suppress wildcard permissions for CreateIndex managed policy
117+ // Suppress wildcard permissions for CreateIndex policy
111118 safeAddNagSuppression (
112119 stack ,
113- "/EpsAssistMeStack/IamResources/CreateIndexManagedPolicy /Resource" ,
120+ "/EpsAssistMeStack/RuntimePolicies/CreateIndexPolicy /Resource" ,
114121 [
115122 {
116123 id : "AwsSolutions-IAM5" ,
@@ -123,18 +130,16 @@ export const nagSuppressions = (stack: Stack) => {
123130 ]
124131 )
125132
126- // Suppress wildcard permissions for SlackBot managed policy
133+ // Suppress wildcard permissions for SlackBot policy
127134 safeAddNagSuppression (
128135 stack ,
129- "/EpsAssistMeStack/IamResources/SlackBotManagedPolicy /Resource" ,
136+ "/EpsAssistMeStack/RuntimePolicies/SlackBotPolicy /Resource" ,
130137 [
131138 {
132139 id : "AwsSolutions-IAM5" ,
133- reason : "SlackBot Lambda needs access to all guardrails, knowledge bases, and functions for content filtering and self-invocation." ,
140+ reason : "SlackBot Lambda needs wildcard access for Lambda functions ( self-invocation) and KMS operations ." ,
134141 appliesTo : [
135142 `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/*` ,
138143 "Action::kms:GenerateDataKey*" ,
139144 "Action::kms:ReEncrypt*"
140145 ]
@@ -177,6 +182,40 @@ export const nagSuppressions = (stack: Stack) => {
177182 ]
178183 )
179184
185+ // Suppress AWS managed policy usage in BucketNotificationsHandler (wildcard for any hash)
186+ const bucketNotificationHandlers = stack . node . findAll ( ) . filter ( node =>
187+ node . node . id . startsWith ( "BucketNotificationsHandler" )
188+ )
189+
190+ bucketNotificationHandlers . forEach ( handler => {
191+ safeAddNagSuppression (
192+ stack ,
193+ `${ handler . node . path } /Role/Resource` ,
194+ [
195+ {
196+ id : "AwsSolutions-IAM4" ,
197+ reason : "Auto-generated CDK role uses AWS managed policy for basic Lambda execution." ,
198+ appliesTo : [
199+ "Policy::arn:<AWS::Partition>:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
200+ ]
201+ }
202+ ]
203+ )
204+
205+ safeAddNagSuppression (
206+ stack ,
207+ `${ handler . node . path } /Role/DefaultPolicy/Resource` ,
208+ [
209+ {
210+ id : "AwsSolutions-IAM5" ,
211+ reason : "Auto-generated CDK role requires wildcard permissions for S3 bucket notifications." ,
212+ appliesTo : [
213+ "Resource::*"
214+ ]
215+ }
216+ ]
217+ )
218+ } )
180219}
181220
182221const safeAddNagSuppression = ( stack : Stack , path : string , suppressions : Array < NagPackSuppression > ) => {
0 commit comments