Skip to content

Commit 7f88449

Browse files
committed
Move lambdaSelfInvokePolicy block to after the Lambda is created
1 parent 8f7bf5b commit 7f88449

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,14 +376,6 @@ export class EpsAssistMeStack extends Stack {
376376
]
377377
})
378378

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-
})
386-
387379
// ==== Lambda environment variables ====
388380
const lambdaEnv: {[key: string]: string} = {
389381
RAG_MODEL_ID: "anthropic.claude-3-sonnet-20240229-v1:0",
@@ -413,6 +405,14 @@ export class EpsAssistMeStack extends Stack {
413405
additionalPolicies: []
414406
})
415407

408+
// ==== IAM Policy for Lambda to invoke itself ====
409+
const lambdaSelfInvokePolicy = new PolicyStatement({
410+
actions: ["lambda:InvokeFunction"],
411+
resources: [
412+
`arn:aws:lambda:${this.region}:${this.account}:function:${slackBotLambda.function.functionName}`
413+
]
414+
})
415+
416416
// ==== Attach all policies to SlackBot Lambda role ====
417417
slackBotLambda.function.addToRolePolicy(slackLambdaSSMPolicy)
418418
slackBotLambda.function.addToRolePolicy(lambdaSelfInvokePolicy)

0 commit comments

Comments
 (0)