Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/apparentlymart/terraform-aws-serverless-webapp

Terraform module for deploying "serverless" applications to AWS Lambda and Amazon API Gateway
https://github.com/apparentlymart/terraform-aws-serverless-webapp

Last synced: 11 days ago
JSON representation

Terraform module for deploying "serverless" applications to AWS Lambda and Amazon API Gateway

Awesome Lists containing this project

README

        

# Terraform AWS Lambda Serverless Application Module

This repository contains an opinionated Terraform module for deploying
"serverless" web applications to AWS Lambda and exposing them publicly using
AWS API Gateway running in its proxy mode.

The main "opinion" of this module is that the AWS Lambda versioning and
API Gateway "stage" concepts are not important when you are using Terraform,
since your Terraform configuration ought to be under version control and so you
can easily recover older versions and apply them. This module expects that
you will upload code packages to S3 and treat them as immutable once uploaded,
and thus the S3 object key will change for each new version to be deployed.

A less significant "opinion" is that if you use a custom domain name then you
will use ACM for its TLS certificate.

## Usage

The following example deploys a NodeJS-based Lambda function and creates a
public-facing API Gateway proxy in front of it.

```hcl
provider "aws" {
region = "us-east-1"
}

module "app" {
source = "apparentlymart/serverless-webapp/aws"

lambda_function_name = "TerraformServerlessExample"
lambda_execution_role = "${aws_iam_role.lambda_exec.arn}"
lambda_runtime = "nodejs4.3"
lambda_handler = "main.handler"

api_gateway_name = "TerraformServerlessExample"

artifact_s3_bucket = "terraform-serverless-example"
artifact_s3_object_key = "v1.0.0/example.zip"
}

resource "aws_iam_role" "lambda_exec" {
name = "serverless_example_lambda"

assume_role_policy = <