Skip to content

Resource: awsLambdaFunctionUrl

Provides a Lambda function URL resource. A function URL is a dedicated HTTP(S) endpoint for a Lambda function.

See the AWS Lambda documentation for more information.

Example Usage

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as aws from "./.gen/providers/aws";
new aws.lambdaFunctionUrl.LambdaFunctionUrl(this, "test_latest", {
  authorizationType: "NONE",
  functionName: "${aws_lambda_function.test.function_name}",
});
new aws.lambdaFunctionUrl.LambdaFunctionUrl(this, "test_live", {
  authorizationType: "AWS_IAM",
  cors: {
    allowCredentials: true,
    allowHeaders: ["date", "keep-alive"],
    allowMethods: ["*"],
    allowOrigins: ["*"],
    exposeHeaders: ["keep-alive", "date"],
    maxAge: 86400,
  },
  functionName: "${aws_lambda_function.test.function_name}",
  qualifier: "my_alias",
});

Argument Reference

  • authorizationType - (Required) The type of authentication that the function URL uses. Set to "AWS_IAM" to restrict access to authenticated IAM users only. Set to "none" to bypass IAM authentication and create a public endpoint. See the AWS documentation for more details.
  • cors - (Optional) The cross-origin resource sharing (CORS) settings for the function URL. Documented below.
  • functionName - (Required) The name (or ARN) of the Lambda function.
  • qualifier - (Optional) The alias name or "$latest".

cors

This configuration block supports the following attributes:

  • allowCredentials - (Optional) Whether to allow cookies or other credentials in requests to the function URL. The default is false.
  • allowHeaders - (Optional) The HTTP headers that origins can include in requests to the function URL. For example: ["date", "keepAlive", "xCustomHeader"].
  • allowMethods - (Optional) The HTTP methods that are allowed when calling the function URL. For example: ["get", "post", "delete"], or the wildcard character (["*"]).
  • allowOrigins - (Optional) The origins that can access the function URL. You can list any number of specific origins (or the wildcard character ("*")), separated by a comma. For example: ["https://wwwExampleCom", "http://localhost:60905"].
  • exposeHeaders - (Optional) The HTTP headers in your function response that you want to expose to origins that call the function URL.
  • maxAge - (Optional) The maximum amount of time, in seconds, that web browsers can cache results of a preflight request. By default, this is set to 0, which means that the browser doesn't cache results. The maximum value is 86400.

Attributes Reference

In addition to all arguments above, the following attributes are exported:

  • functionArn - The Amazon Resource Name (ARN) of the function.
  • functionUrl - The HTTP URL endpoint for the function in the format https://<urlId>LambdaUrl.<region>OnAws.
  • urlId - A generated ID for the endpoint.

Import

Lambda function URLs can be imported using the functionName or functionName/qualifier, e.g.,

$ terraform import aws_lambda_function_url.test_lambda_url my_test_lambda_function