https://github.com/mcred/lambda-http-example
https://github.com/mcred/lambda-http-example
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/mcred/lambda-http-example
- Owner: mcred
- Created: 2024-02-03T04:13:15.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-04-22T23:12:14.000Z (about 2 years ago)
- Last Synced: 2025-02-02T02:16:21.667Z (over 1 year ago)
- Language: Go
- Size: 30.3 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Lambda HTTP Router Example
This is a simple example to test the performance of a simple HTTP router using AWS Lambda.
## Requirements
* [go](https://golang.org/)
* [docker](https://www.docker.com/)
* [docker-compose](https://docs.docker.com/compose/install/)
* [awslocal-cli](https://github.com/localstack/awscli-local)
* [tflocal-cli](https://github.com/localstack/terraform-local)
## Running the example
1. Set LOCALSTACK_API_KEY to the env
```bash
echo LOCALSTACK_API_KEY=xxxxxxx >> .env
```
2. Start the stack
```bash
make start
```
3. Running the example for the first time
```bash
make init
make apply
```
4. Refreshing the code after the first time
```bash
make refresh
```
5. Destroying the example
```bash
make destroy
```
6. Stopping the stack
```bash
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.
```bash
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
```