Setting up a REST-based Lambda function
AWS provides us with Lambda. AWS Lambda is a serverless computing offering that can be integrated and invoked in various ways. One way it can be utilized is by using it as a backend for REST APIs.
The REST-based Lambda function that we shall implement will receive a JSON payload and store it in DynamoDB.
This can be easily simulated locally, since AWS provides docker-lambda
.
By using docker-lambda
, we can create a container image that can simulate our AWS Lambda function. AWS provides images for this purpose that also include a runtime interface client that facilitates the interaction between our function code and Lambda (https://github.com/lambci/docker-lambda).
Furthermore, this makes it feasible to simulate calls to the Lambda function locally.
Let’s start with the function’s code base.
Initially, we shall persist the request in DynamoDB:
type Subscribe struct { Email string `json:"email"` Topic...