@@ -18,6 +18,8 @@ export interface IamResourcesProps {
1818 readonly kbDocsBucket : Bucket
1919 readonly slackBotTokenParameterName : string
2020 readonly slackSigningSecretParameterName : string
21+ readonly conversationTableArn : string
22+ readonly conversationKeyArn : string
2123}
2224
2325export class IamResources extends Construct {
@@ -148,14 +150,42 @@ export class IamResources extends Construct {
148150 resources : [ `arn:aws:bedrock:${ props . region } :${ props . account } :guardrail/*` ]
149151 } )
150152
153+ // DynamoDB permissions for conversation session storage
154+ const slackBotDynamoPolicy = new PolicyStatement ( {
155+ actions : [
156+ "dynamodb:GetItem" ,
157+ "dynamodb:PutItem" ,
158+ "dynamodb:UpdateItem" ,
159+ "dynamodb:DeleteItem" ,
160+ "dynamodb:Query"
161+ ] ,
162+ resources : [
163+ props . conversationTableArn ,
164+ `${ props . conversationTableArn } /index/*`
165+ ]
166+ } )
167+
168+ // KMS permissions for conversation table encryption
169+ const slackBotConversationKmsPolicy = new PolicyStatement ( {
170+ actions : [
171+ "kms:Decrypt" ,
172+ "kms:DescribeKey" ,
173+ "kms:Encrypt" ,
174+ "kms:GenerateDataKey"
175+ ] ,
176+ resources : [ props . conversationKeyArn ]
177+ } )
178+
151179 this . slackBotManagedPolicy = new ManagedPolicy ( this , "SlackBotManagedPolicy" , {
152- description : "Policy for SlackBot Lambda to access Bedrock, SSM, and Lambda " ,
180+ description : "Policy for SlackBot Lambda to access Bedrock, SSM, Lambda, and DynamoDB " ,
153181 statements : [
154182 slackBotPolicy ,
155183 slackBotKnowledgeBasePolicy ,
156184 slackBotSSMPolicy ,
157185 slackBotLambdaPolicy ,
158- slackBotGuardrailPolicy
186+ slackBotGuardrailPolicy ,
187+ slackBotDynamoPolicy ,
188+ slackBotConversationKmsPolicy
159189 ]
160190 } )
161191 }
0 commit comments