Lambda HTTP Router Example

This is a simple example to test the performance of a simple HTTP router using AWS Lambda.

Requirements

Running the example

  1. Set LOCALSTACK_API_KEY to the env
echo LOCALSTACK_API_KEY=xxxxxxx >> .env
  1. Start the stack
make start
  1. Running the example for the first time
make init
make apply
  1. Refreshing the code after the first time
make refresh
  1. Destroying the example
make destroy
  1. Stopping the stack
make stop

Testing the router

The output from the make apply command will show the URL of the API Gateway. Export this value to the API_URL environment variable. Then use curl to test the router.

export API_URL=http://{API_ID}.execute-api.localhost.localstack.cloud:4566
curl -X GET $API_URL
curl -X GET $API_URL/users
curl -X GET $API_URL/users/1
curl -X DELETE $API_URL/users/1