AWS GoLang Lambda Terraform Template for S3/Dynamo/Xray with GoLang Sample Code
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
deploy/terraform genesis Apr 17, 2018
job matched rule name Apr 17, 2018
.gitignore genesis Apr 17, 2018
Makefile genesis Apr 17, 2018
main.go fixed import path Apr 17, 2018


This is an example of AWS GoLang Lambda function that receives an AWS S3 Event and integrates with AWS XRAY.

For a full explanation you can visit my blog post:

The Lambda function and it's IAM Policies and Permissions are fully provisioned by Terraform module (see deploy/terraform/modules/lambda/ dir). And terraform init and apply phases are in turn managed by the Makefile:

$ make
build/linux                    Build a linux binary ready to be zip'ed for AWS Lambda Deployment
build/release                  Zip linux binary as AWS Deployment archive
clean                          Remove all build artifacts
clean/linux                    Remove linux build artifacts
deploy/production              Deploy zip'ed archive to AWS production account
deploy/testing                 Deploy zip'ed archive to AWS testing account
help                           Display this help message
test/integration               Integration Testing


Setup production and testing profiles in ~/.aws/credentials. For example:

$ cat ~/.aws/credentials



  1. Setup DLQ Resource. AWS Lambda will automatically retry failed executions for asynchronous invocations. But to really make it bulletproof, you can forward payloads that were not processed to a dead-letter queue (DLQ), such as an SQS queue or an SNS topic.
  2. Setup CloudWatch Alarm to monitor execution errors.
  3. Incorporate all of the above in the Terraform module.
  4. Move Terraform state file to S3.

PRs are welcome.