/go-lambda

Simple kickstart for a Golang JSON API using AWS Lambdas

Primary LanguageHCL

go-lambda λ

Repository for a Golang HTTP JSON API running on AWS lambda and configured via Terraform.

Setup

  1. Install the AWS CLI.
  2. Create an IAM role with adequate permissions in AWS.
  3. Run the aws configure command.
  4. Run export AWS_PROFILE=your_configured_user to source the identity into the shell.
  5. Install the Terraform CLI.
  6. Run terraform init in the root directory to download the providers.

Development

  1. Run make to build the binary.
  2. Change into the infrastructure folder: cd infrastructure
  3. Run terraform apply to apply the changes and upload the binary. Confirm.
  4. POST to the endpoint: curl -X POST https://mq4s9j0l8b.execute-api.us-east-2.amazonaws.com/test/hello -d '{ "name": "Harry" }'
  5. Rip down the infrastructure (still in the infrastructure folder): terraform destroy

Helper Script

  1. Run . bin/deploy from the root repo (make sure to run within the existing shell with . or source)
  2. curl -X POST "$TF_URL/hello" -d '{ "name": "Harry" }'