IoT button data is stored into dynamoDB and published to SNS
- press IoT button
- trigger Lambda which sends SNS push
- store the IoT data into DynamoDB
https://serverless.com/framework/docs/providers/aws/guide/installation/
- install
$ npm install -g serverless
- configure serverless.yml
Note : write your email correctly
provider:
name: aws
runtime: nodejs4.3
region: ap-northeast-2
stage: prod
profile: team #${opt:stage, self:provider.stage}
timeout: 10
environment:
EMAIL: [email protected]
STAGE: ${opt:stage, self:provider.stage}
REGION: ${opt:region, self:provider.region}
DYNAMODB_TABLE_BUTTON: ${self:service}-button-${opt:stage, self:provider.stage}
- Deploy
$ sls deploy
The result should be similar to :
Serverless: Bundling with Webpack...
Time: 88ms
Asset Size Chunks Chunk Names
handler.js 6.95 kB 0 [emitted] handler
Serverless: Packaging service...
Serverless: Uploading CloudFormation file to S3...
Serverless: Uploading service .zip file to S3 (2.62 KB)...
Serverless: Updating Stack...
Serverless: Checking Stack update progress...
..............
Serverless: Stack update finished...
Service Information
service: r1-core
stage: prod
region: ap-northeast-2
api keys:
None
endpoints:
POST - https://xxxxxxx.execute-api.ap-northeast-2.amazonaws.com/prod/test
functions:
pubSNS: r1-core-prod-pubSNS