Skip to content
v2.278.0

FunctionUrlOrigin Class ​

An Origin for a Lambda Function URL.

Example ​

ts
import * as lambda from 'aws-cdk-lib/aws-lambda';

declare const fn: lambda.Function;
const fnUrl = fn.addFunctionUrl({ authType: lambda.FunctionUrlAuthType.NONE });

new cloudfront.Distribution(this, 'Distribution', {
  defaultBehavior: {
    origin: new origins.FunctionUrlOrigin(fnUrl, {
      readTimeout: Duration.seconds(30),
      responseCompletionTimeout: Duration.seconds(90),
      keepaliveTimeout: Duration.seconds(45),
    }),
  },
});
python
import aws_cdk.aws_lambda as lambda_

# fn: lambda.Function

fn_url = fn.add_function_url(auth_type=lambda_.FunctionUrlAuthType.NONE)

cloudfront.Distribution(self, "Distribution",
    default_behavior=cloudfront.BehaviorOptions(
        origin=origins.FunctionUrlOrigin(fn_url,
            read_timeout=Duration.seconds(30),
            response_completion_timeout=Duration.seconds(90),
            keepalive_timeout=Duration.seconds(45)
        )
    )
)
java
import software.amazon.awscdk.services.lambda.*;

Function fn;

FunctionUrl fnUrl = fn.addFunctionUrl(FunctionUrlOptions.builder().authType(FunctionUrlAuthType.NONE).build());

Distribution.Builder.create(this, "Distribution")
        .defaultBehavior(BehaviorOptions.builder()
                .origin(FunctionUrlOrigin.Builder.create(fnUrl)
                        .readTimeout(Duration.seconds(30))
                        .responseCompletionTimeout(Duration.seconds(90))
                        .keepaliveTimeout(Duration.seconds(45))
                        .build())
                .build())
        .build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
using Amazon.CDK.AWS.Lambda;

Function fn;

var fnUrl = fn.AddFunctionUrl(new FunctionUrlOptions { AuthType = FunctionUrlAuthType.NONE });

new Distribution(this, "Distribution", new DistributionProps {
    DefaultBehavior = new BehaviorOptions {
        Origin = new FunctionUrlOrigin(fnUrl, new FunctionUrlOriginProps {
            ReadTimeout = Duration.Seconds(30),
            ResponseCompletionTimeout = Duration.Seconds(90),
            KeepaliveTimeout = Duration.Seconds(45)
        })
    }
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
import lambda "github.com/aws/aws-cdk-go/awscdk"

var fn Function

fnUrl := fn.AddFunctionUrl(&FunctionUrlOptions{
	AuthType: lambda.FunctionUrlAuthType_NONE,
})

cloudfront.NewDistribution(this, jsii.String("Distribution"), &DistributionProps{
	DefaultBehavior: &BehaviorOptions{
		Origin: origins.NewFunctionUrlOrigin(fnUrl, &FunctionUrlOriginProps{
			ReadTimeout: awscdk.Duration_Seconds(jsii.Number(30)),
			ResponseCompletionTimeout: awscdk.Duration_*Seconds(jsii.Number(90)),
			KeepaliveTimeout: awscdk.Duration_*Seconds(jsii.Number(45)),
		}),
	},
})

Initializer ​

ts
new FunctionUrlOrigin(lambdaFunctionUrl: IFunctionUrl, props?: FunctionUrlOriginProps)
python
FunctionUrlOrigin(lambda_function_url: IFunctionUrl, props: typing.Optional[FunctionUrlOriginProps] = None)
java
new FunctionUrlOrigin(IFunctionUrl lambdaFunctionUrl, FunctionUrlOriginProps props)
csharp
new FunctionUrlOrigin(IFunctionUrl lambdaFunctionUrl, FunctionUrlOriginProps? props = null)
go
NewFunctionUrlOrigin(LambdaFunctionUrl IFunctionUrl, Props FunctionUrlOriginProps)

Methods ​

bind(scope: Construct, options: OriginBindOptions): OriginBindConfigdef bind(self, scope: Construct, options: OriginBindOptions) -> OriginBindConfigpublic OriginBindConfig bind(Construct scope, OriginBindOptions options)public OriginBindConfig Bind(Construct scope, OriginBindOptions options)func Bind(Scope Construct, Options OriginBindOptions) OriginBindConfig #
Binds the origin to the associated Distribution.

Can be used to grant permissions, create dependent resources, etc.

withOriginAccessControl(lambdaFunctionUrl: IFunctionUrl, props?: FunctionUrlOriginWithOACProps): IOrigin@staticmethod def with_origin_access_control(lambda_function_url: IFunctionUrl, props: typing.Optional[FunctionUrlOriginWithOACProps] = None) -> IOriginpublic static IOrigin withOriginAccessControl(IFunctionUrl lambdaFunctionUrl, FunctionUrlOriginWithOACProps props)public static IOrigin WithOriginAccessControl(IFunctionUrl lambdaFunctionUrl, FunctionUrlOriginWithOACProps? props = null)func WithOriginAccessControl(LambdaFunctionUrl IFunctionUrl, Props FunctionUrlOriginWithOACProps) IOrigin static #
Create a Lambda Function URL Origin with Origin Access Control (OAC) configured.