API Gateway Lambda Function Proxy Methods Module
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
- Terraform
- Terragrunt
# ------------------------------------------------------------------------------------------------------
# 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=v1.0.2"
# ----------------------------------------------------------------------------------------------------
# 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
}
# ------------------------------------------------------------------------------------------------------
# DEPLOY GRUNTWORK'S API-GATEWAY-PROXY-METHODS MODULE
# ------------------------------------------------------------------------------------------------------
terraform {
source = "git::git@github.com:gruntwork-io/terraform-aws-lambda.git//modules/api-gateway-proxy-methods?ref=v1.0.2"
}
inputs = {
# ----------------------------------------------------------------------------------------------------
# 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
- Inputs
- Outputs
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_name
stringName of the AWS Lambda function that is being invoked for the API requests.
Optional
path_prefix
stringThe 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_only
boolConfigures 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
ID of the API Gateway integration for the root method of the path_prefix resource.
HTTP method of the API Gateway method for the root of the path_prefix resource.
ID of the API Gateway method for the root of the path_prefix resource.
ID of the API Gateway method for the root of the path_prefix resource.
ID of the API Gateway integration for the proxy method.
HTTP method of the API Gateway method for the proxy.
ID of the API Gateway method for the proxy.
ID of the API Gateway method for the proxy resource.
ID of the API Gateway integration for the root method (only created if path_prefix is empty string).
HTTP method of the API Gateway method for the root proxy (only created if path_prefix is empty string).
ID of the API Gateway method for the root proxy (only created if path_prefix is empty string).