Giter VIP home page Giter VIP logo

terraform-aws-serverless's Introduction

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.

terraform-aws-serverless's People

Contributors

kpitzen avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.