go-lambda-localstack-example

module
v0.0.0-...-baf0d59 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 21, 2023 License: MIT

README

Go Lambda

This repository demonstrates an example on how to run a simple Go lambda with an AWS API Gateway on localstack. Here localstack is provisioned using tflocal (a localstack specific wrapper around Terraform). In addition, the repository contains an example on levaraging localstack in combination with ory/dockertest in order to integration test your Go Lambda.

On my virtual machine

Pre-requisites

  • Docker

Run integration tests

Run make ci-init && make ci-test-integration

On my machine

Pre-requisites

Start the Lambda

  • Run make localstack
  • Run make terraform
  • Use the output api_gw_id to compose the url
  • Curl the hello world endpoint: curl --location --request GET "http://localhost:4566/restapis/$(tflocal -chdir=infra/terraform output -raw api_gw_id)/test/_user_request_/hello-world"

Run integration tests

Make sure you don't have a running localstack container.

  • Run make test-integration

Directories

Path Synopsis
cmd
api
Package main starts the example Go Lambda
Package main starts the example Go Lambda
internal
api
Package api provides api handlers for the Lambda
Package api provides api handlers for the Lambda
lambda
Package lambda defines top level Lambda handlers
Package lambda defines top level Lambda handlers

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL