Skip to content
This repository has been archived by the owner on May 5, 2022. It is now read-only.

Terraform Module for simplifying the deployment of Lambda Functions to API Gateway.

License

Notifications You must be signed in to change notification settings

salte-io/terraform-aws-serverless

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Terraform

Terraform Module: Serverless

This repository is a Terraform Module for simplifying the deployment of Lambda Functions to API Gateway.

Table of Contents

Requirements

This module requires Terraform version 0.10.x or newer.

Dependencies

This module depends on a correctly configured AWS Provider in your Terraform codebase.

Usage

# ...

data "aws_iam_role" "role" {
  name = "example-role"
}

data "aws_api_gateway_rest_api" "default" {
  name = "example-api"
}

resource "aws_api_gateway_resource" "resource" {
  rest_api_id = "${data.aws_api_gateway_rest_api.default.id}"
  parent_id   = "${data.aws_api_gateway_rest_api.default.root_resource_id}"
  path_part   = "example-resource"
}

resource "aws_lambda_function" "function" {
  filename         = "example-zip-file-name.zip"
  function_name    = "example-function-name"
  role             = "${data.aws_iam_role.role.arn}"
  handler          = "src/example-file-name.handler"
  source_code_hash = "${base64sha256(file("example-zip-file-name.zip"))}"
  runtime          = "nodejs8.10"

  environment {
    variables {
      some_variable = "some_value"
    }
  }
}

module "serverless" {
  source  = "salte-io/serverless/aws"
  version = "1.0.0"

  api_id        = "${data.aws_api_gateway_rest_api.default.id}"
  resource_id   = "${aws_api_gateway_resource.resource.id}"
  http_method   = "GET"
  function_name = "${aws_lambda_function.function.function_name}"
  invoke_arn    = "${aws_lambda_function.function.invoke_arn}"
}

Then, load the module using terraform get.

Module Variables

Available variables are listed below, along with their default values:

variable description
api_id The ID of the API Gateway to deploy to.
resource_id The ID of the API Gateway Resource.
http_method The HTTP method the resource will be available at.
function_name The name of the lambda function.
invoke_arn The ARN used by the API Gateway for invocation.

Author Information

This module is currently maintained by the individuals listed below.

About

Terraform Module for simplifying the deployment of Lambda Functions to API Gateway.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages