Skip to content

Commit 086c861

Browse files
committed
Create SlackAskEpsEndpoint and integrate it with the SlackBotLambda
1 parent 73a3b11 commit 086c861

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

packages/cdk/stacks/EpsAssistMeStack.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
} from "aws-cdk-lib/aws-bedrock"
2222
import {RestApiGateway} from "../constructs/RestApiGateway"
2323
import {LambdaFunction} from "../constructs/LambdaFunction"
24+
import {LambdaEndpoint} from "../constructs/RestApiGateway/LambdaEndpoint"
2425
import {PolicyStatement} from "aws-cdk-lib/aws-iam"
2526
import * as cdk from "aws-cdk-lib"
2627
import * as iam from "aws-cdk-lib/aws-iam"
@@ -465,7 +466,7 @@ export class EpsAssistMeStack extends Stack {
465466
slackBotLambda.function.addToRolePolicy(lambdaGRinvokePolicy)
466467
slackBotLambda.function.addToRolePolicy(lambdaSSMPolicy)
467468

468-
// Define the API Gateway resource and associate the trigger for Industrial Query Lambda function=
469+
// Define the API Gateway and connect the '/slack/ask-eps' POST endpoint to the SlackBot Lambda function
469470
const apiGateway = new RestApiGateway(this, "EpsAssistApiGateway", {
470471
stackName: props.stackName,
471472
logRetentionInDays,
@@ -474,9 +475,16 @@ export class EpsAssistMeStack extends Stack {
474475
truststoreVersion: "unused"
475476
})
476477

477-
// Define the '/industrial/query' API resource with a POST method
478-
const slackRoute = apiGateway.api.root.addResource("slack").addResource("ask-eps")
479-
slackRoute.addMethod("POST")
478+
const slackResource = apiGateway.api.root.addResource("slack")
479+
480+
// Create the '/slack/ask-eps' POST endpoint and integrate it with the SlackBot Lambda
481+
new LambdaEndpoint(this, "SlackAskEpsEndpoint", {
482+
parentResource: slackResource,
483+
resourceName: "ask-eps",
484+
method: "POST",
485+
restApiGatewayRole: apiGateway.role,
486+
lambdaFunction: slackBotLambda
487+
})
480488

481489
// ==== Output: SlackBot Endpoint ====
482490
new CfnOutput(this, "SlackBotEndpoint", {

0 commit comments

Comments
 (0)