WebFunctionEndpointLocation Class Added in v2.276.0
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']),
},
});
Properties
endpointTypeWebFunctionEndpointTypeendpoint_typeWebFunctionEndpointTypeendpointTypeWebFunctionEndpointTypeEndpointTypeWebFunctionEndpointTypeEndpointTypeWebFunctionEndpointType#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() WebFunctionEndpointLocationstatic#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) WebFunctionEndpointLocationstatic#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) WebFunctionEndpointLocationstatic#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().