Skip to content

Latest commit

 

History

History
75 lines (56 loc) · 2.34 KB

deploy-to-aws-lambda.md

File metadata and controls

75 lines (56 loc) · 2.34 KB

Building and Deploying to AWS Lambda

AWS Lambda with API Gateway and DynamoDB would give us a flexible way to deploy the bot.

This requires Nodejs 8.10+/npm, and we recommend using nvm to install nodejs/npm.

*Be aware that AWS Lambda ONLY works in linux on an x64 architecture. For non-linux os, we need docker to build dependencies -- thus you should install docker first.

Get an AWS account, create aws_access_key_id and aws_secret_access_key and place them in ~/.aws/credentials, like this:

[default]
aws_access_key_id = <your aws_access_key_id>
aws_secret_access_key = <your aws_secret_access_key>

For more information, refer to https://docs.aws.amazon.com/general/latest/gr/aws-security-credentials.html.

Start by installing serverless and copying a sample config file for it.

npm i
cp dev/lambda/serverless.sample.yml dev/lambda/serverless.yml

Edit dev/lambda/serverless.yml, and make sure you set the proper name and required env.

  environment:
    ENV: production
    # ringcentral apps

    ## for bots auth, required
    RINGCENTRAL_BOT_CLIENT_ID:
    RINGCENTRAL_BOT_CLIENT_SECRET:

    ## for user auth, could be empty if do not need user auth
    RINGCENTRAL_USER_CLIENT_ID:
    RINGCENTRAL_USER_CLIENT_SECRET:

    ## common
    RINGCENTRAL_SERVER: https://platform.devtest.ringcentral.com
    RINGCENTRAL_BOT_SERVER: https://xxxxx.execute-api.us-east-1.amazonaws.com/dev

    # db
    DB_TYPE: dynamodb
    DYNAMODB_TABLE_PREFIX: ringcentral-bot
    DYNAMODB_REGION: us-east-1
    DYNAMODB_ReadCapacityUnits: 1
    DYNAMODB_WriteCapacityUnits: 1

Deploy to AWS Lambda with bin/deploy and should observe the following:

./bin/deploy
Service Information
service: ringcentral-bot
stage: dev
region: us-east-1
stack: ringcentral-bot-dev
api keys:
  None
endpoints:
  ANY - https://dddddd.execute-api.us-east-1.amazonaws.com/dev/{action+}
  GET - https://dddddd.execute-api.us-east-1.amazonaws.com/dev/

You may watch the Lambda server log by running:

bin/watch

Do not forget to set your RingCentral app's redirect URL to Lambda's API Gateway URL, https://dddddd.execute-api.us-east-1.amazonaws.com/dev/bot-oauth for bot app.