Please see Chunk 1 to see how we got here
What's needed for the CRC chunk 2
Chunk 3, is the "back end" of the CRC challenge. Here are the pieces needed:
- A database to store the hit count - I chose DynamoDB.
- An API to retrieve/update the hit count in the database. I chose to use a Lambda function using Python.
- A way to trigger the Lambda function as a REST API. I chose to use Apigateway.
Getting started
I used the aws console at first to get reacquainted with dynamodb, lambda and apigateway. After getting everything to work, I used Terraform to deploy all of the infrastructure pieces. The Github repo can be found here.
Using boto3 and python in Lambda functions was nothing new. I was not that familiar with APIGateway though.
The function to update the hit count in the dynamodb table is pretty straight forward
The APIGateway pieces took a bit longer. It required some time reading the docs to understand staged, deployments, CORS configuration, etc. But, in the end, I got it all working and was able to use CURL and Postman to test out the API and successfully update the hit counter.
Here is all of the code
It was now time to glue it all together.
Top comments (0)