Skip to main content
AWS Lambda 0.21.18Last updated in version 0.20.0

API Gateway Lambda Function Proxy Methods Module

View SourceRelease Notes

This module must be used in conjunction with the api-gateway-proxy module to configure an API Gateway REST API to route all requests from a root path to a lambda function.

Refer to the module docs for the api-gateway-proxy module for more details on how to use this module. Specifically, see the section Can I expose additional lambda functions in a decentralized manner?

Sample Usage

main.tf

# ------------------------------------------------------------------------------------------------------
# DEPLOY GRUNTWORK'S API-GATEWAY-PROXY-METHODS MODULE
# ------------------------------------------------------------------------------------------------------

module "api_gateway_proxy_methods" {

source = "git::git@github.com:gruntwork-io/terraform-aws-lambda.git//modules/api-gateway-proxy-methods?ref=v0.21.18"

# ----------------------------------------------------------------------------------------------------
# REQUIRED VARIABLES
# ----------------------------------------------------------------------------------------------------

# The API Gateway REST API resource as returned by the terraform resource or
# data source. This can also be able arbitrary object that has the keys id,
# root_resource_id, and execution_arn of the API Gateway REST API.
api_gateway_rest_api = <any>

# Name of the AWS Lambda function that is being invoked for the API requests.
lambda_function_name = <string>

# ----------------------------------------------------------------------------------------------------
# OPTIONAL VARIABLES
# ----------------------------------------------------------------------------------------------------

# The URL path prefix to proxy. Requests to any path under this path prefix
# will be routed to the lambda function. Note that if the path prefix is empty
# string (default), all requests (including to the root path) will be proxied.
# Note that this only supports single levels for now (e.g., you can configure
# to route `foo` and everything below that path like `foo/api/v1`, but you
# cannot configure to route something like `api/foo/*`). Example: api will
# route all requests under api/, such as /api, /api/v1,
# /api/v2/myresource/action, etc.
path_prefix = ""

# Configures only the root path to route to the lambda function, and not the
# other subpaths. When true, the path_prefix must be empty string or no
# resources will be created.
root_only = false

}


Reference

Required

The API Gateway REST API resource as returned by the terraform resource or data source. This can also be able arbitrary object that has the keys id, root_resource_id, and execution_arn of the API Gateway REST API.

Any types represent complex values of variable type. For details, please consult `variables.tf` in the source repo.
Details

Ideally we can define an object type, but that would require defining every attribute of the API Gateway REST API
resource, which can be painful if you can't pass through the entire resource (e.g., as in terragrunt dependencies).

lambda_function_namestringrequired

Name of the AWS Lambda function that is being invoked for the API requests.

Optional

path_prefixstringoptional

The URL path prefix to proxy. Requests to any path under this path prefix will be routed to the lambda function. Note that if the path prefix is empty string (default), all requests (including to the root path) will be proxied. Note that this only supports single levels for now (e.g., you can configure to route foo and everything below that path like foo/api/v1, but you cannot configure to route something like api/foo/*). Example: api will route all requests under api/, such as /api, /api/v1, /api/v2/myresource/action, etc.

""
root_onlybooloptional

Configures only the root path to route to the lambda function, and not the other subpaths. When true, the path_prefix must be empty string or no resources will be created.

false