Skip to content

Commit 8f7bf5b

Browse files
committed
Add IAM Policy for Lambda to invoke itself
1 parent 3d949fd commit 8f7bf5b

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

packages/cdk/stacks/EpsAssistMeStack.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -376,13 +376,13 @@ export class EpsAssistMeStack extends Stack {
376376
]
377377
})
378378

379-
// ==== Lambda self-invoke policy (needed for Slack Bolt lazy handlers) ====
380-
// const slackLambdaSelfInvokePolicy = new PolicyStatement({
381-
// actions: ["lambda:InvokeFunction"],
382-
// resources: [
383-
// slackBotLambda.function.functionArn
384-
// ]
385-
// })
379+
// ==== IAM Policy for Lambda to invoke itself ====
380+
const lambdaSelfInvokePolicy = new PolicyStatement({
381+
actions: ["lambda:InvokeFunction"],
382+
resources: [
383+
`arn:aws:lambda:${this.region}:${this.account}:function:${slackBotLambda.function.functionName}`
384+
]
385+
})
386386

387387
// ==== Lambda environment variables ====
388388
const lambdaEnv: {[key: string]: string} = {
@@ -415,7 +415,7 @@ export class EpsAssistMeStack extends Stack {
415415

416416
// ==== Attach all policies to SlackBot Lambda role ====
417417
slackBotLambda.function.addToRolePolicy(slackLambdaSSMPolicy)
418-
// slackBotLambda.function.addToRolePolicy(slackLambdaSelfInvokePolicy)
418+
slackBotLambda.function.addToRolePolicy(lambdaSelfInvokePolicy)
419419

420420
// ==== API Gateway & Slack Route ====
421421
const apiGateway = new RestApiGateway(this, "EpsAssistApiGateway", {

0 commit comments

Comments
 (0)