This repository is a Terraform Module for simplifying the deployment of Lambda Functions to API Gateway.
This module requires Terraform version 0.10.x
or newer.
This module depends on a correctly configured AWS Provider in your Terraform codebase.
# ...
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
.
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. |
This module is currently maintained by the individuals listed below.