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: http://www.hashjoin.com/t/aws-golang-lambda-s3-xray-terraform.html
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
[testing]
aws_access_key_id=********************
aws_secret_access_key=****************************************
[production]
aws_access_key_id=********************
aws_secret_access_key=****************************************
- 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.
- Setup CloudWatch Alarm to monitor execution errors.
- Incorporate all of the above in the Terraform module.
- Move Terraform state file to S3.
PRs are welcome.