FunctionUrl class

Manages a Lambda function URL. Creates a dedicated HTTP(S) endpoint for a Lambda function to enable direct invocation via HTTP requests.

> NOTE: When authorizationType is "NONE" the lambda:InvokeFunctionUrl permission allowing a public endpoint and lambda:InvokeFunction permission with the InvokedViaFunctionUrl flag set to true are automatically added to the Lambda function on creation. These policies are NOT removed from AWS when the resource is destroyed.

Example Usage

Basic Function URL with No Authentication

import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const example = new aws.lambda.FunctionUrl("example", {
    functionName: exampleAwsLambdaFunction.functionName,
    authorizationType: "NONE",
});
import pulumi
import pulumi_aws as aws

example = aws.lambda_.FunctionUrl("example",
    function_name=example_aws_lambda_function["functionName"],
    authorization_type="NONE")
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;

return await Deployment.RunAsync(() =>
{
    var example = new Aws.Lambda.FunctionUrl("example", new()
    {
        FunctionName = exampleAwsLambdaFunction.FunctionName,
        AuthorizationType = "NONE",
    });

});
package main

import (
	"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/lambda"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := lambda.NewFunctionUrl(ctx, "example", &lambda.FunctionUrlArgs{
			FunctionName:      pulumi.Any(exampleAwsLambdaFunction.FunctionName),
			AuthorizationType: pulumi.String("NONE"),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
pulumi {
  required_providers {
    aws = {
      source = "pulumi/aws"
    }
  }
}

resource "aws_lambda_functionurl" "example" {
  function_name      = exampleAwsLambdaFunction.functionName
  authorization_type = "NONE"
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.lambda.FunctionUrl;
import com.pulumi.aws.lambda.FunctionUrlArgs;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        var example = new FunctionUrl("example", FunctionUrlArgs.builder()
            .functionName(exampleAwsLambdaFunction.functionName())
            .authorizationType("NONE")
            .build());

    }
}
resources:
  example:
    type: aws:lambda:FunctionUrl
    properties:
      functionName: ${exampleAwsLambdaFunction.functionName}
      authorizationType: NONE

Function URL with IAM Authentication and CORS Configuration

import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const example = new aws.lambda.FunctionUrl("example", {
    cors: {
        allowCredentials: true,
        allowOrigins: ["https://example.com"],
        allowMethods: [
            "GET",
            "POST",
        ],
        allowHeaders: [
            "date",
            "keep-alive",
        ],
        exposeHeaders: [
            "keep-alive",
            "date",
        ],
        maxAge: 86400,
    },
    functionName: exampleAwsLambdaFunction.functionName,
    qualifier: "my_alias",
    authorizationType: "AWS_IAM",
    invokeMode: "RESPONSE_STREAM",
});
import pulumi
import pulumi_aws as aws

example = aws.lambda_.FunctionUrl("example",
    cors={
        "allow_credentials": True,
        "allow_origins": ["https://example.com"],
        "allow_methods": [
            "GET",
            "POST",
        ],
        "allow_headers": [
            "date",
            "keep-alive",
        ],
        "expose_headers": [
            "keep-alive",
            "date",
        ],
        "max_age": 86400,
    },
    function_name=example_aws_lambda_function["functionName"],
    qualifier="my_alias",
    authorization_type="AWS_IAM",
    invoke_mode="RESPONSE_STREAM")
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;

return await Deployment.RunAsync(() =>
{
    var example = new Aws.Lambda.FunctionUrl("example", new()
    {
        Cors = new Aws.Lambda.Inputs.FunctionUrlCorsArgs
        {
            AllowCredentials = true,
            AllowOrigins = new[]
            {
                "https://example.com",
            },
            AllowMethods = new[]
            {
                "GET",
                "POST",
            },
            AllowHeaders = new[]
            {
                "date",
                "keep-alive",
            },
            ExposeHeaders = new[]
            {
                "keep-alive",
                "date",
            },
            MaxAge = 86400,
        },
        FunctionName = exampleAwsLambdaFunction.FunctionName,
        Qualifier = "my_alias",
        AuthorizationType = "AWS_IAM",
        InvokeMode = "RESPONSE_STREAM",
    });

});
package main

import (
	"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/lambda"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := lambda.NewFunctionUrl(ctx, "example", &lambda.FunctionUrlArgs{
			Cors: &lambda.FunctionUrlCorsArgs{
				AllowCredentials: pulumi.Bool(true),
				AllowOrigins: pulumi.StringArray{
					pulumi.String("https://example.com"),
				},
				AllowMethods: pulumi.StringArray{
					pulumi.String("GET"),
					pulumi.String("POST"),
				},
				AllowHeaders: pulumi.StringArray{
					pulumi.String("date"),
					pulumi.String("keep-alive"),
				},
				ExposeHeaders: pulumi.StringArray{
					pulumi.String("keep-alive"),
					pulumi.String("date"),
				},
				MaxAge: pulumi.Int(86400),
			},
			FunctionName:      pulumi.Any(exampleAwsLambdaFunction.FunctionName),
			Qualifier:         pulumi.String("my_alias"),
			AuthorizationType: pulumi.String("AWS_IAM"),
			InvokeMode:        pulumi.String("RESPONSE_STREAM"),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
pulumi {
  required_providers {
    aws = {
      source = "pulumi/aws"
    }
  }
}

resource "aws_lambda_functionurl" "example" {
  cors = {
    allow_credentials = true
    allow_origins     = ["https://example.com"]
    allow_methods     = ["GET", "POST"]
    allow_headers     = ["date", "keep-alive"]
    expose_headers    = ["keep-alive", "date"]
    max_age           = 86400
  }
  function_name      = exampleAwsLambdaFunction.functionName
  qualifier          = "my_alias"
  authorization_type = "AWS_IAM"
  invoke_mode        = "RESPONSE_STREAM"
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.lambda.FunctionUrl;
import com.pulumi.aws.lambda.FunctionUrlArgs;
import com.pulumi.aws.lambda.inputs.FunctionUrlCorsArgs;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        var example = new FunctionUrl("example", FunctionUrlArgs.builder()
            .cors(FunctionUrlCorsArgs.builder()
                .allowCredentials(true)
                .allowOrigins("https://example.com")
                .allowMethods(
                    "GET",
                    "POST")
                .allowHeaders(
                    "date",
                    "keep-alive")
                .exposeHeaders(
                    "keep-alive",
                    "date")
                .maxAge(86400)
                .build())
            .functionName(exampleAwsLambdaFunction.functionName())
            .qualifier("my_alias")
            .authorizationType("AWS_IAM")
            .invokeMode("RESPONSE_STREAM")
            .build());

    }
}
resources:
  example:
    type: aws:lambda:FunctionUrl
    properties:
      cors:
        allowCredentials: true
        allowOrigins:
          - https://example.com
        allowMethods:
          - GET
          - POST
        allowHeaders:
          - date
          - keep-alive
        exposeHeaders:
          - keep-alive
          - date
        maxAge: 86400
      functionName: ${exampleAwsLambdaFunction.functionName}
      qualifier: my_alias
      authorizationType: AWS_IAM
      invokeMode: RESPONSE_STREAM

Import

Using pulumi import, import Lambda function URLs using the functionName or function_name/qualifier. For example:

$ pulumi import aws:lambda/functionUrl:FunctionUrl example example

Constructors

FunctionUrl(String name, {FunctionUrlArgs? args, CustomResourceOptions? options})
Creates a new FunctionUrl. name The Pulumi resource name. args Arguments used to configure this FunctionUrl. The set of arguments for FunctionUrl. options Resource options controlling this resource's behavior.
FunctionUrl.reference(String urn)
Creates a typed reference to an existing FunctionUrl resource.

Properties

authorizationType ↔ Output<String>
Type of authentication that the function URL uses. Valid values are AWS_IAM and NONE.
latefinal
childResources Set<Resource>
finalinherited
completionSources Map<String, IOutputCompletionSource>
latefinalinherited
cors ↔ Output<FunctionUrlCors?>
Cross-origin resource sharing (CORS) settings for the function URL. See below.
latefinal
functionArn ↔ Output<String>
ARN of the Lambda function.
latefinal
functionName ↔ Output<String>
Name or ARN of the Lambda function.
latefinal
functionUrl ↔ Output<String>
HTTP URL endpoint for the function in the format https://&lt;url_id&gt;.lambda-url.&lt;region&gt;.on.aws/.
latefinal
hashCode int
The hash code for this object.
no setterinherited
id ↔ Output<String>
getter/setter pairinherited
invokeMode ↔ Output<String?>
How the Lambda function responds to an invocation. Valid values are BUFFERED (default) and RESPONSE_STREAM.
latefinal
isCustom bool
Returns whether this resource is provider-managed.
no setterinherited
isProtected bool
Returns whether this resource is protected from deletion.
no setterinherited
isRemote bool
Whether this resource is registered as remote.
no setterinherited
isResourceReference bool
Whether this instance represents a resource value returned over RPC.
finalinherited
qualifier ↔ Output<String?>
Alias name or $LATEST.
latefinal
region ↔ Output<String>
Region where this resource will be managed. Defaults to the Region set in the provider configuration.
latefinal
resourceTransforms List<ResourceTransform>
Inherited/explicit async transforms.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
transformations List<ResourceTransformation>
Inherited/explicit legacy transformations.
no setterinherited
urlId ↔ Output<String>
Generated ID for the endpoint.
latefinal
urn ↔ Output<String>
latefinalinherited

Methods

failId(Object error) → void
Completes this resource ID with an error when registration fails.
inherited
failOutputs(Object error) → void
Completes all output properties with error.
inherited
failUrn(Object error) → void
Completes this resource URN with an error when registration fails.
inherited
getProvider(String moduleMember) → ProviderResource?
Returns provider for moduleMember's package, if configured.
inherited
getResourceName() String
Returns this resource's logical name.
inherited
getResourceType() String
Returns this resource's Pulumi type token.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
registerOutput<T>(String propertyName, {Object? decoder(Object?)?, bool isSecret = false}) → Output<T>
Registers a dynamic output property for this resource.
inherited
resolveId(String? value, {required bool isKnown}) → void
Resolves the provider-assigned ID for this resource.
inherited
resolveOutputs(Struct outputs) → void
Resolves all output properties from a monitor response payload.
inherited
resolveUrn(String value) → void
Resolves this resource's URN once assigned by the engine.
inherited
serializeProperties(Map<String, dynamic> properties) Future<Struct>
Serializes resource properties for RPC transmission.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

get(String name, Input<String> id, {FunctionUrlState? state, CustomResourceOptions? options}) FunctionUrl
Gets an existing FunctionUrl resource's state with the given name and id.