This example reimplements AWS developer guide tutorial (Process New Items with DynamoDB Streams and Lambda
) with slight modification through Serverless Framework.
First, clone the project to local:
> git clone [email protected]:m-sureshraj/serverless-examples.git
> cd dynamodb-streams
Configure environment variables:
> cp .env.sample.yml .env.dev.yml
Add your email address to the EMAIL_SUBSCRIBER: [email protected]
variable.
> sls deploy
A successful deployment print a similar output:
✔ Service deployed to stack dynamodb-streams-dev (163s)
endpoint: POST - https://xxxxxxx.execute-api.ap-south-1.amazonaws.com/
functions:
bark: dynamodb-streams-dev-bark (46 kB)
dbChangeListener: dynamodb-streams-dev-dbChangeListener (46 kB)
After successful deployment, SNS
sends a subscription confirmation email to the configured email address.
Click confirm subscription link to subscribe to that topic.
Get the endpoint from the sls deploy output and send a POST
request to it.
curl -X POST https://xxxxxxx.execute-api.ap-south-1.amazonaws.com/ \
-H 'Content-Type: application/json' -d '{ "username": "bar" }'
You should receive the notification email to the configured email address.