AWS Lambda, DynamoDB & SNS

Services

Platform

Domain

Services

Platform

Domain

AWS Lambda, DynamoDB & SNS

November 20, 2017

In this blog post, I will provide an overview of how multiple services of AWS can seamlessly work together and cater for a variety of different scenarios. In this particular case, I have a developed a simple Android App which will be using the AWS DynamoDB for basic CRUD operations. AWS Lambda Functions will be used to generate a SNS topic which would then send an email notification to an endpoint.

AWS Services used in the demo

AWS mobile SDK for android provides client side libraries to easily interact with majority of the AWS services such as dynamoDB , Amazon S3 , etc. In order to be able to use AWS services in our mobile application we need to be authenticated by getting AWS credentials using Amazon Cognito Identity. This will allow the mobile application to access AWS services without having to incorporate the private credentials into the application and also allows to set permissions for users to have access to specific services.

DynamoDB is a flexible NoSQL database service which provides high availability, extremely low latency and automatic scaling of throughput capacity. The AWS Mobile SDK comes with libraries that allows the app to easily integrate with DynamoDB. The Library makes use of the DynamoDB object mapper which maps the client side classes with the DynamoDB and allows execution of CRUD operations and queries

AWS Lambda was launched by Amazon in November 2014 at its re:INVENTConference and was one of their most innovative technology. In a nutshell, AWS Lambda is a server-less technology which allows users to run code without having to manage any servers at all and providing continuous scaling without having to worry about infrastructure.

Amazon CloudWatch is used as a monitoring and tracking service for all the AWS Cloud application and services. It provides real time log files and tracking metric for different services and also allows users set alarms.

Simple Notification Service (SNS) is a Pub/Sub messaging service which allows a publisher to publish an SNS Topic (Message) to a multiple endpoint and clients.

Solution Architecture

App in Action

A very simple android app is used to get input from the user for a new book and save it in the AWS dynamoDB using the DynamoDB Object Mapper library. Tapping the ‘submit’ button would first authenticate the user from AWS Cognito which will allow the app to access AWS Services. Once authenticated, It creates a DynamoDB client which would map the client side classes to the cloud database and save the data inserted by user as a new row.

A Lambda function is created with the DynamoDB set as its trigger. The function will poll the DB stream and invoke the code synchronously as soon as the database is updated.

In this particular case, the functions responds to any update in the DB stream and publishes a new SNS topic with the message “A new book has been published to DynamoDB” and sends an email out to my address.

A new SNS topic needs to be created which would have a subscription to a particular endpoint. In our case it will be an email address to which it will publish the message to.

This would publish the SNS topic to my email address with the specified message and topic details as seen in the below picture.

Related Insights

Stay up-to-date with FAIR

Connect with FAIR today and get the latest tips and tricks on improving your CX tools and eCommerce platforms. Once you subscribe you will get access to workshops, webinars, recent projects and so much more.