Skip to content
v2.277.0

WebFunctionEndpointLocation Class ​

Where a WebFunction endpoint serves traffic.

A regional location carries its replica Regions, and a home-Region one has none, so a combination the service rejects cannot be expressed.

Example ​

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

declare const codeBucket: s3.IBucket;

new lambda.WebFunction(this, 'GlobalApi', {
  code: lambda.WebFunctionCode.fromBucket(codeBucket, 'app.zip', 'version-id'),
  runtime: lambda.WebFunctionRuntime.NODEJS_24_X,
  defaultEndpointAuth: lambda.WebFunctionAuthType.IAM_AUTH,
  defaultEndpoint: {
    endpointLocation: lambda.WebFunctionEndpointLocation.multiRegion(['us-east-1', 'eu-west-1', 'ap-northeast-1']),
  },
});
python
import aws_cdk.aws_s3 as s3

# code_bucket: s3.IBucket


lambda_.WebFunction(self, "GlobalApi",
    code=lambda_.WebFunctionCode.from_bucket(code_bucket, "app.zip", "version-id"),
    runtime=lambda_.WebFunctionRuntime.NODEJS_24_X,
    default_endpoint_auth=lambda_.WebFunctionAuthType.IAM_AUTH,
    default_endpoint=lambda.WebFunctionDefaultEndpointOptions(
        endpoint_location=lambda_.WebFunctionEndpointLocation.multi_region(["us-east-1", "eu-west-1", "ap-northeast-1"])
    )
)
java
import software.amazon.awscdk.services.s3.*;

IBucket codeBucket;


WebFunction.Builder.create(this, "GlobalApi")
        .code(WebFunctionCode.fromBucket(codeBucket, "app.zip", "version-id"))
        .runtime(WebFunctionRuntime.NODEJS_24_X)
        .defaultEndpointAuth(WebFunctionAuthType.IAM_AUTH)
        .defaultEndpoint(WebFunctionDefaultEndpointOptions.builder()
                .endpointLocation(WebFunctionEndpointLocation.multiRegion(List.of("us-east-1", "eu-west-1", "ap-northeast-1")))
                .build())
        .build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
using Amazon.CDK.AWS.S3;

IBucket codeBucket;


new WebFunction(this, "GlobalApi", new WebFunctionProps {
    Code = WebFunctionCode.FromBucket(codeBucket, "app.zip", "version-id"),
    Runtime = WebFunctionRuntime.NODEJS_24_X,
    DefaultEndpointAuth = WebFunctionAuthType.IAM_AUTH,
    DefaultEndpoint = new WebFunctionDefaultEndpointOptions {
        EndpointLocation = WebFunctionEndpointLocation.MultiRegion(new [] { "us-east-1", "eu-west-1", "ap-northeast-1" })
    }
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
import s3 "github.com/aws/aws-cdk-go/awscdk"

var codeBucket IBucket


lambda.NewWebFunction(this, jsii.String("GlobalApi"), &WebFunctionProps{
	Code: lambda.WebFunctionCode_FromBucket(codeBucket, jsii.String("app.zip"), jsii.String("version-id")),
	Runtime: lambda.WebFunctionRuntime_NODEJS_24_X(),
	DefaultEndpointAuth: lambda.WebFunctionAuthType_IAM_AUTH,
	DefaultEndpoint: &WebFunctionDefaultEndpointOptions{
		EndpointLocation: lambda.WebFunctionEndpointLocation_MultiRegion([]*string{
			jsii.String("us-east-1"),
			jsii.String("eu-west-1"),
			jsii.String("ap-northeast-1"),
		}),
	},
})

Properties ​

The endpoint type this location maps to.
replicaRegionsmay be undefinedstring[]replica_regionsmay be undefinedtyping.List[str]replicaRegionsmay be undefinedList<String>ReplicaRegionsmay be undefinedstring[]ReplicaRegionsmay be undefined*[]*string #
The replica Regions, for a regional location, as given.

Methods ​

homeRegion(): WebFunctionEndpointLocation // chainable@staticmethod def home_region() -> WebFunctionEndpointLocationpublic static WebFunctionEndpointLocation homeRegion()public static WebFunctionEndpointLocation HomeRegion()func HomeRegion() WebFunctionEndpointLocation static #
Serve from the stack's Region only, under one regional domain name.
multiRegion(replicaRegions: string[]): WebFunctionEndpointLocation // chainable@staticmethod def multi_region(replica_regions: typing.List[str]) -> WebFunctionEndpointLocationpublic static WebFunctionEndpointLocation multiRegion(List<String> replicaRegions)public static WebFunctionEndpointLocation MultiRegion(string[] replicaRegions)func MultiRegion(ReplicaRegions *[]*string) WebFunctionEndpointLocation static #
Serve from the stack's Region and the replica Regions under one global domain name, with requests routed to the nearest Region.
notes · 1 parameter

The stack's own Region always serves traffic, so listing it has no effect, and replicaRegions must hold at least one other Region. The list is treated as a set: order and duplicates do not matter. Adding or removing a Region replaces the endpoint; a deploy-time list (for example from a CfnParameter) cannot feed the default endpoint name, so changing its value at deployment also needs a new endpointName.

Parameters

  • replicaRegionsreplica_regionsreplicaRegionsreplicaRegionsReplicaRegions — the Regions to replicate to, for example ['us-east-1', 'eu-west-1'].
perRegion(replicaRegions: string[]): WebFunctionEndpointLocation // chainable@staticmethod def per_region(replica_regions: typing.List[str]) -> WebFunctionEndpointLocationpublic static WebFunctionEndpointLocation perRegion(List<String> replicaRegions)public static WebFunctionEndpointLocation PerRegion(string[] replicaRegions)func PerRegion(ReplicaRegions *[]*string) WebFunctionEndpointLocation static #
Serve from the stack's Region and the replica Regions, with a separate domain name in each Region and no managed routing between them.

The same rules for replicaRegions apply as for multiRegion().