Skip to content
This repository was archived by the owner on May 30, 2023. It is now read-only.

AWS Lambda Support

Yuichi Morimichi edited this page Nov 20, 2018 · 7 revisions

Custom Extension on AWS Lambda

Make custom extensions work with AWS API Gateway + Lambda.

Custom Extension

Refer to Quick start Spring Boot · awslabs/aws-serverless-java-container Wiki and edit custom extensions.

This repository also contains a sample that you can refer to.

Properties

This is the setting required to run the test with API Gateway and Lambda Function.

cek.verifier.signature.enabled: false

Set true when testing from a Clova device or the Clova Developer Center.

AWS

API Gateway

Create API Gateway resource as a proxy resource.

Lambda Function

Create a Lambda Function.

Upload echo-lambda as a function package.

$ ./mvnw clean package -Plambda -f samples/echo-lambda/pom.xml 

Upload the newly created samples/echo-lambda/target/echo-lambda-1.0.0.jar and set com.linecorp.clova.extension.sample.echo_lambda.StreamLambdaHandler::handleRequest as Handler.

Set API Gateway as the trigger and specify the api you created.

Test

Create a test event. Edit the JSON of API Gateway AWS Proxy template.

path value
.body CEK Request
.headers.Content-Type application/json;charset=utf-8
.httpMethod POST
.path / (=${cek.api-path})

The JSON of CEK Request is obtained as follows.

  1. In the Clova Developer Center, access 対話モデル(Dialogue model) -> テスト(Test)
  2. Run test
  3. Copy JSONのサービスリクエスト(JSON of a service request)
  4. Format it by jq command. Here is an example of Mac OS command.
$ pbpaste | jq -c ". | @json" | pbcopy

Run the test event. It will succeed if .statusCode is 200. If you get an error, try the following.

  • Remove spring-boot-starter-actuator from the dependencies.
  • Fix if there is a warning when generating the jar file
    • Make the scope of lombok provided.
  • Try to change the value of cek.api-path.

Clova Developer Center

In the Clova Developer Center, access 基本情報(Basic Information) -> サーバー設定(Server Settings) and set the URL of the resource registered in API Gateway as ExtensionサーバーのURL(Extension server URL).

Clone this wiki locally