Terraform AWS Lambda API Gateway
Features
- Uploads lambda zip bundle to AWS S3 during
terraform apply
- Creates VPC with private and public subnets
- Deploys lambda function into private subnet (behind NAT Gateway)
Example Usage
Deployment
- Run build process to create lambda zip bundle locally
- Update terraform variable
lambda_zip_path
with path to zip bundle on local machine
- Provide values for other required terraform variables
- Create/Select terraform workspace on 1st/subsequent deployments
- Deploy with
$ terraform apply
Example Deployment Script
#!/usr/bin/env bash
if [[ ! -d .terraform ]]; then
terraform init
fi
if ! terraform workspace list 2>&1 | grep -qi "$ENVIRONMENT"; then
terraform workspace new "$ENVIRONMENT"
fi
terraform workspace select "$ENVIRONMENT"
terraform get
terraform apply \
-var "lambda_zip_path=$LAMBDA_ZIP_PATH" \
-var "region=$REGION" \
-var "account_id=$ACCOUNT_ID"