/terraform-aws-lambda-example

Example code to showcase a (Go 1.1x) AWS Lambda function deployed via Terraform

Primary LanguageHCLApache License 2.0Apache-2.0

AWS Lambda function with Terraform

Example of Terraform configuration that showcase a two-steps (Go 1.1x) AWS Lambda function deployment.

Blog post: https://a.l3x.in/blog/terrafom-lambda-no-archive-in-git/

Why two steps

The main reason is to avoid shipping the archive together with the configuration (that is, in Git). We only store the hash(es) of the last-built archive instead.

Might be useful when Terraform configuration is shared by multiple users.

Usage

  1. clone this repository and cd into its working directory

  2. optional: edit lambda/main.go

  3. run make build to create the build archive

  4. setup your AWS environment (e.g. export AWS_PROFILE=my-profile)

  5. run terraform init

  6. run terraform apply: will prompt for

    • the bucket name to be created and used to host the build archive
    • the AWS region where the resources will be created