Lambda Function URL Module
This module used to create a AWS Lambda function URLs for existing Lambda function. A function URL is a dedicated HTTP(S) endpoint for a Lambda function.
When you create a function URL, Lambda automatically generates a unique URL endpoint for you. Once you create a function URL, its URL endpoint never changes. Function URLs are dual stack-enabled, supporting IPv4 and IPv6. After you configure a function URL for your function, you can invoke your function through its HTTP(S) endpoint via a web browser, curl, Postman, or any HTTP client.
Function URL endpoints have the following format:
https://<url-id>.lambda-url.<region>.on.aws
Background info
For more information on AWS Lambda, how it works, and how to configure your functions, check out the lambda module documentation.
Sample Usage
- Terraform
- Terragrunt
# ------------------------------------------------------------------------------------------------------
# DEPLOY GRUNTWORK'S LAMBDA-FUNCTION-URL MODULE
# ------------------------------------------------------------------------------------------------------
module "lambda_function_url" {
source = "git::git@github.com:gruntwork-io/terraform-aws-lambda.git//modules/lambda-function-url?ref=v1.0.2"
# ----------------------------------------------------------------------------------------------------
# REQUIRED VARIABLES
# ----------------------------------------------------------------------------------------------------
# Alias name of the lambda function
alias = <string>
# Autherisation type of genrating function url
authorization_type = <string>
# The AWS region in which all resources will be created
aws_region = <string>
# Name of the CloudFront Origin Access Control
cloudfront_oac_name = <string>
# CORS configuration for the Lambda function URL
cors_config = <object(
allow_credentials = bool
allow_origins = list(string)
allow_methods = list(string)
allow_headers = list(string)
expose_headers = list(string)
max_age = number
)>
# The name of the iam role to be created
iam_role_name = <string>
# The name of the Lambda function. Used to generate function url
lambda_function_name = <string>
# Specifies which requests CloudFront signs. Specify always for the most
# common use case. Allowed values: always, never, and no-override.
oac_signing_behavior = <string>
# Determines how CloudFront signs (authenticates) requests. The only valid
# value is sigv4.
oac_signing_protocol = <string>
# ----------------------------------------------------------------------------------------------------
# OPTIONAL VARIABLES
# ----------------------------------------------------------------------------------------------------
# The type of origin that this Origin Access Control is for. Valid values are
# lambda, mediapackagev2, mediastore, and s3
oac_origin_type = "lambda"
}
# ------------------------------------------------------------------------------------------------------
# DEPLOY GRUNTWORK'S LAMBDA-FUNCTION-URL MODULE
# ------------------------------------------------------------------------------------------------------
terraform {
source = "git::git@github.com:gruntwork-io/terraform-aws-lambda.git//modules/lambda-function-url?ref=v1.0.2"
}
inputs = {
# ----------------------------------------------------------------------------------------------------
# REQUIRED VARIABLES
# ----------------------------------------------------------------------------------------------------
# Alias name of the lambda function
alias = <string>
# Autherisation type of genrating function url
authorization_type = <string>
# The AWS region in which all resources will be created
aws_region = <string>
# Name of the CloudFront Origin Access Control
cloudfront_oac_name = <string>
# CORS configuration for the Lambda function URL
cors_config = <object(
allow_credentials = bool
allow_origins = list(string)
allow_methods = list(string)
allow_headers = list(string)
expose_headers = list(string)
max_age = number
)>
# The name of the iam role to be created
iam_role_name = <string>
# The name of the Lambda function. Used to generate function url
lambda_function_name = <string>
# Specifies which requests CloudFront signs. Specify always for the most
# common use case. Allowed values: always, never, and no-override.
oac_signing_behavior = <string>
# Determines how CloudFront signs (authenticates) requests. The only valid
# value is sigv4.
oac_signing_protocol = <string>
# ----------------------------------------------------------------------------------------------------
# OPTIONAL VARIABLES
# ----------------------------------------------------------------------------------------------------
# The type of origin that this Origin Access Control is for. Valid values are
# lambda, mediapackagev2, mediastore, and s3
oac_origin_type = "lambda"
}
Reference
- Inputs
- Outputs
Required
alias
stringAlias name of the lambda function
authorization_type
stringAutherisation type of genrating function url
aws_region
stringThe AWS region in which all resources will be created
cloudfront_oac_name
stringName of the CloudFront Origin Access Control
cors_config
object(…)CORS configuration for the Lambda function URL
object({
allow_credentials = bool
allow_origins = list(string)
allow_methods = list(string)
allow_headers = list(string)
expose_headers = list(string)
max_age = number
})
iam_role_name
stringThe name of the iam role to be created
lambda_function_name
stringThe name of the Lambda function. Used to generate function url
oac_signing_behavior
stringSpecifies which requests CloudFront signs. Specify always for the most common use case. Allowed values: always, never, and no-override.
oac_signing_protocol
stringDetermines how CloudFront signs (authenticates) requests. The only valid value is sigv4.
Optional
oac_origin_type
stringThe type of origin that this Origin Access Control is for. Valid values are lambda, mediapackagev2, mediastore, and s3
"lambda"
The Amazon Resource Name (ARN) of the function.
The HTTP URL endpoint for the function in the format https://<url_id>.lambda-url.<region>.on.aws/
The unique identifier of Origin Access Control
A generated ID for the endpoint.