Simple Serverless MicroService API with Lambda
+ API Gateway
+ Web Socket
+ SNS
+ SQS
+ KMS
, and DynamoDB
.
-
Sample DevOps with
babel
+eslint
+jest
+supertest
+codecov
+travis
-
Sample Integrated with
Slack
+CloudWatch Alarm
- Standard devops by lemon based on
Nodejs
+Typescript
- Support sending message to
Slack
from AWS CloudWatch. (seelemon-hello-sns
AWS SNS after deploying) - Save slack message to
S3
bucket as json object - Use
DynamoDB
to manage the route-rules per each channels.
-
Fork and Customize the code, and run
npm install
# STEP.1 install packages. (using ci) $ npm ci # STEP.2 customize profile in env/<profile>.yml # STEP.3 add profile infor to env/config.js # STEP.4 deploy into your AWS account. $ npm run deploy
-
Example Screenshot of
slack
when receiving message.
[Overrall]
- Copy and customise the main config files:
env/lemon.yml
,env/config.js
- Change
SLACK_PUBLIC
address by slack webhook. - Encrypt
slack
webhook url withKMS
, and updateSLACK_PUBLIC
- Deploy to AWS cloud
$ npm run deploy
- Enjoy~
-
Create master kms-id for 1st time (at first time).
# create initial master-key in KMS (example) $ aws kms create-key --profile <profile> --description 'hello master key' { "KeyMetadata": { "KeyId": "0039d20d-112233445566-387b887b4783", } } # create Alias as `lemon-hello-api` $ aws kms create-alias --profile <profile> --alias-name alias/lemon-hello-api --target-key-id 0039d20d-112233445566-387b887b4783
-
Test encryptioin with KMS
# run encrypt $ aws kms encrypt --profile <profile> --key-id alias/lemon-hello-api --cli-binary-format raw-in-base64-out --plaintext "hello lemon" --query CiphertextBlob --output text
-
Make AWS Lambda, and API Endpoint with
serverless
# run npm command (if profile is `lemon`, or make your own script) $ npm run deploy.lemon
-
Run for local development.
# run express service in local (if profile is `lemon`, or make your own script) $ npm run express.lemon # test encrypt via api $ http ':8888/hello/0/test-encrypt'
- Get NPM Token via tokens
# install travis-cli (MacOS)
$ brew install travis
# encrypt npm token
$ travis encrypt <NPM Token> --add deploy.api_key
- request via
PR
, or useIssue
.
- support dummy restfull api w/ dummy-storage.
Version History
Version | Description |
---|---|
2.4.0 | use DynamoDB to manage route-rules. |
2.3.2 | optimized with lemon-core#3.1.2 , and nodejs16 runtime. |
2.3.1 | optimized with lemon-core#3.1.1 . |
2.2.3 | optimized notification message. |
2.2.2 | use direct to post slack hook directly. |
2.1.4 | optimized with lemon-core#2.1.4 . |
1.3.1 | refactoring with lemon-core. |
1.2.3 | fix: iota of NS in sns-service. |
1.1.0 | Release version with npm run release . |
1.0.3 | support SQS with handling SQS message. |
1.0.2 | support WSS with API Gateway + WebSocket. |
1.0.1 | support SNS with CloudWatch Event, and post to Slack |
1.0.0 | initial version with full deploy by profile+stage |