0
votes

I created a small service using serveless framework by following this guide https://serverless.com/blog/how-to-create-a-rest-api-in-java-using-dynamodb-and-serverless/. I'm using "AWS Lambda", "APIGateway" and "DynamoDB". I want to be able to deploy my service to a docker container so I can test my api and dynamodb locally. I want to be able to send curl commands to my localhost and be able to see the response. How do I go about doing this? Are there any tutorials or step by step guide?

2
For the DynamoDB part, you can use the DynamoDB local Docker image from Docker hub. hub.docker.com/r/amazon/dynamodb-local This is a test/dev version for exactly the kinds of things you are doing.Kirk
I suggest that you use AWS Cloud9 which is a cloud IDE for writing, running and debugging code. You could run the lambda function as local environment. Here is their website: aws.amazon.com/cloud9troy
BTW, it has no sense to use both Lambda and Docker.troy

2 Answers

3
votes

I don't understand your purpose. The whole purpose of Serverless is to "not manage servers". Why would you do that then? Rather create a separate test environment on AWS itself to test the Serverless. API gateways, Lambda and DynamoDB are all AWS specific services. You are making your task more complex than easier by thinking of creating a clone of DynamoDB, Lambda, API gateway inside docker. You really have to work a lot on creating similar integration as of API Gateway-> Lambda integration even if you use MongoDB or Cassandra in place of DynamoDB. (Even if you just take such scalability in picture). If you rather want to learn creating such web services in docker then you may use something like mongo db docker image(Directly from docker hub) in place of DynamoDB

Update: You can use https://hub.docker.com/r/amazon/dynamodb-local/ for DynamoDB though. First image push was six months back.

For Lambda you can try https://github.com/lambci/docker-lambda and see if it works.

0
votes

Use Sam local for the lambda piece and DynamoDB local for the DynamoDB piece.

Also, once in AWS you might be able to get away without api gateway by hook up ELBs to Lambda functions.