Skip to content
v2.276.0

WebFunctionEndpoint L2 construct Added in v2.276.0 ​

An endpoint of a Lambda WebFunction: a domain that serves HTTP traffic for one of the function's revisions.

A WebFunction creates one, fn.endpoint. Create more with fn.addEndpoint(), for example to serve the same function with a different auth type or endpoint type.

Example ​

ts
declare const fn: lambda.WebFunction;

const internal = fn.addEndpoint('Internal', {
  authType: lambda.WebFunctionAuthType.IAM_AUTH,
});
python
# fn: lambda.WebFunction


internal = fn.add_endpoint("Internal",
    auth_type=lambda_.WebFunctionAuthType.IAM_AUTH
)
java
WebFunction fn;


WebFunctionEndpoint internal = fn.addEndpoint("Internal", WebFunctionEndpointOptions.builder()
        .authType(WebFunctionAuthType.IAM_AUTH)
        .build());
csharp
// Install: dotnet add package Amazon.CDK.Lib
WebFunction fn;


var internal = fn.AddEndpoint("Internal", new WebFunctionEndpointOptions {
    AuthType = WebFunctionAuthType.IAM_AUTH
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
var fn WebFunction


internal := fn.AddEndpoint(jsii.String("Internal"), &WebFunctionEndpointOptions{
	AuthType: lambda.WebFunctionAuthType_IAM_AUTH,
})

Initializer ​

ts
new WebFunctionEndpoint(scope: Construct, id: string, props: WebFunctionEndpointProps)
python
WebFunctionEndpoint(scope: Construct, id: str, props: WebFunctionEndpointProps)
java
new WebFunctionEndpoint(Construct scope, String id, WebFunctionEndpointProps props)
csharp
new WebFunctionEndpoint(Construct scope, string id, WebFunctionEndpointProps props)
go
NewWebFunctionEndpoint(Scope Construct, Id *string, Props WebFunctionEndpointProps)

Construct Props ​

The authentication type for the WebFunction endpoint.
notes

There is no default: you must choose explicitly so an endpoint is never accidentally public or accidentally locked down. Specify WebFunctionAuthType.IAM_AUTH (Lambda authorizes requests with SigV4/IAM) or WebFunctionAuthType.APPLICATION_MANAGED (the endpoint is public and your function handles authorization).

With IAM_AUTH, requests must be signed with SigV4 and carry the X-Amz-Content-SHA256 header, also for a request without a body; without it the endpoint returns 403 even for a valid signature. A MULTI_REGION endpoint is signed with SigV4a, for the Region set *.

endpointDescriptionoptionalstringendpoint_descriptionoptionalstrendpointDescriptionoptionalStringEndpointDescriptionoptionalstringEndpointDescriptionoptional*string#
A description of the endpoint.

Default: No description.

Up to 256 characters.

endpointLocationoptionalWebFunctionEndpointLocationendpoint_locationoptionalWebFunctionEndpointLocationendpointLocationoptionalWebFunctionEndpointLocationEndpointLocationoptionalWebFunctionEndpointLocationEndpointLocationoptionalWebFunctionEndpointLocation#
Where the endpoint serves traffic: the home Region only, or a set of replica Regions.

Default: WebFunctionEndpointLocation.homeRegion()

Changing it replaces the endpoint, which yields a new domainName. If you set endpointName, change it at the same time.

endpointNameoptionalstringendpoint_nameoptionalstrendpointNameoptionalStringEndpointNameoptionalstringEndpointNameoptional*string#
The name of the WebFunction endpoint.

Default: for the endpoint a WebFunction creates, prod in the home Region and, for a regional endpoint, prod- followed by a hash of its location; for any other endpoint, a name derived from its construct path and location

notes

Must be 2 to 64 characters of letters, numbers, hyphens or underscores, starting and ending with a letter or number.

Changing this property replaces the endpoint, which yields a new domainName.

endpointLocation also replaces the endpoint when it changes, and CloudFormation cannot replace a resource that keeps its name. Without this property the name is derived from the location, so that works. With it, change the name together with the location, or the deployment fails.

maxEnvironmentsoptionalnumbermax_environmentsoptionalint | floatmaxEnvironmentsoptionalNumberMaxEnvironmentsoptionaldoubleMaxEnvironmentsoptional*float64#
The maximum number of concurrent execution environments for the endpoint.

Default: Scaling is limited only by your account's vCPU quota.

This is an optional cap on top of your account's vCPU quota, not a reservation: it further constrains how far the endpoint scales. Must be 2 or greater.

rateLimitoptionalnumberrate_limitoptionalint | floatrateLimitoptionalNumberRateLimitoptionaldoubleRateLimitoptional*float64#
The maximum request rate per second for the endpoint, up to 10000.

Default: The request rate is limited only by your account's rate limit quota.

notes

This is an optional cap on top of your account's rate limit quota. Specify 0 to reject all new requests.

The service accepts only certain values: 0, 100 through 1000 in increments of 100, and 2000 through 10000 in increments of 1000. Which of those are available varies by Region, and an unsupported value is rejected at deploy time with the values that Region does accept. Only the lower bound is checked at synth, since the schema declares nothing more.

The revisions that receive the endpoint's traffic.

For a WebFunction defined in this app, WebFunction.addEndpoint() sets this to the function's revision.

webFunctionIWebFunctionRefweb_functionIWebFunctionRefwebFunctionIWebFunctionRefWebFunctionIWebFunctionRefWebFunctionIWebFunctionRefrequired#
The WebFunction the endpoint serves.

Properties ​

How the endpoint authenticates requests.
domainNamestringdomain_namestrdomainNameStringDomainNamestringDomainName*string#
The domain name of the endpoint: the host clients send requests to.
endpointArnstringendpoint_arnstrendpointArnStringEndpointArnstringEndpointArn*string#
The ARN of the endpoint.
The endpoint type.
The environment this resource belongs to.
notes

For resources that are created and managed in a Stack (those created by creating new class instances like new Role(), new Bucket(), etc.), this is always the same as the environment of the stack they belong to.

For referenced resources (those obtained from referencing methods like Role.fromRoleArn(), Bucket.fromBucketName(), etc.), they might be different than the stack they were imported into.

nodeNodenodeNodenodeNodeNodeNodeNodeNode#
The tree node.
PROPERTY_INJECTION_IDstringproperty_injection_idstrPROPERTY_INJECTION_IDStringPROPERTY_INJECTION_IDstringPROPERTY_INJECTION_ID*stringstatic#
Uniquely identifies this class.
The underlying L1 CfnWebFunctionEndpoint resource.

Use for escape hatches.

stackStackstackStackstackStackStackStackStackStack#
The stack in which this resource is defined.
webFunctionArnstringweb_function_arnstrwebFunctionArnStringWebFunctionArnstringWebFunctionArn*string#
The ARN of the WebFunction the endpoint serves.
webFunctionEndpointRefWebFunctionEndpointReferenceweb_function_endpoint_refWebFunctionEndpointReferencewebFunctionEndpointRefWebFunctionEndpointReferenceWebFunctionEndpointRefWebFunctionEndpointReferenceWebFunctionEndpointRefWebFunctionEndpointReference#
A reference to a WebFunctionEndpoint resource.

Methods ​

addToResourcePolicy(statement: PolicyStatement): AddToResourcePolicyResultdef add_to_resource_policy(self, statement: PolicyStatement) -> AddToResourcePolicyResultpublic AddToResourcePolicyResult addToResourcePolicy(PolicyStatement statement)public AddToResourcePolicyResult AddToResourcePolicy(PolicyStatement statement)func AddToResourcePolicy(Statement PolicyStatement) AddToResourcePolicyResult#
Adds a statement to the resource-based policy of the WebFunction the endpoint serves.

For an endpoint in another stack than its function, the statement names the endpoint by the function's ARN and the endpoint name, so the name must be a literal.

applyCrossStackReferenceStrength(strength: ReferenceStrength): voiddef apply_cross_stack_reference_strength(self, strength: ReferenceStrength) -> Nonepublic void applyCrossStackReferenceStrength(ReferenceStrength strength)public void ApplyCrossStackReferenceStrength(ReferenceStrength strength)func ApplyCrossStackReferenceStrength(Strength ReferenceStrength)#
Override the cross-stack reference strength for this resource.
notes · 1 parameter

When set, any cross-stack reference to this resource will use the specified mechanism instead of the global default determined by the @aws-cdk/core:defaultCrossStackReferences context key. This is useful for selectively weakening specific references to avoid the "deadly embrace" problem without changing the app-wide default.

Parameters

  • strengthstrengthstrengthstrengthStrength — - The reference strength to use for this resource.
applyRemovalPolicy(policy: RemovalPolicy): voiddef apply_removal_policy(self, policy: RemovalPolicy) -> Nonepublic void applyRemovalPolicy(RemovalPolicy policy)public void ApplyRemovalPolicy(RemovalPolicy policy)func ApplyRemovalPolicy(Policy RemovalPolicy)#
Apply the given removal policy to this resource.
notes

The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you've removed it from the CDK application or because you've made a change that requires the resource to be replaced.

The resource can be deleted (RemovalPolicy.DESTROY), or left in your AWS account for data recovery and cleanup later (RemovalPolicy.RETAIN).

fromWebFunctionEndpointAttributes(scope: Construct, id: string, attrs: WebFunctionEndpointAttributes): IWebFunctionEndpoint@staticmethod def from_web_function_endpoint_attributes(scope: Construct, id: str, attrs: WebFunctionEndpointAttributes) -> IWebFunctionEndpointpublic static IWebFunctionEndpoint fromWebFunctionEndpointAttributes(Construct scope, String id, WebFunctionEndpointAttributes attrs)public static IWebFunctionEndpoint FromWebFunctionEndpointAttributes(Construct scope, string id, WebFunctionEndpointAttributes attrs)func FromWebFunctionEndpointAttributes(Scope Construct, Id *string, Attrs WebFunctionEndpointAttributes) IWebFunctionEndpointstatic#
Import an existing WebFunction endpoint by its attributes.
isConstruct(x: any): boolean@staticmethod def is_construct(x: Any) -> boolpublic static Boolean isConstruct(Object x)public static bool IsConstruct(object x)func IsConstruct(X interface{}) *boolstatic#
Checks if `x` is a construct.
notes · 1 parameter · returns

Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.

Parameters

  • xxxxX — Any object.

Returns: true if x is an object created from a class which extends Construct.

isOwnedResource(construct: IConstruct): boolean@staticmethod def is_owned_resource(construct: IConstruct) -> boolpublic static Boolean isOwnedResource(IConstruct construct)public static bool IsOwnedResource(IConstruct construct)func IsOwnedResource(Construct IConstruct) *boolstatic#
Returns true if the construct was created by CDK, and false otherwise.
isResource(construct: IConstruct): boolean@staticmethod def is_resource(construct: IConstruct) -> boolpublic static Boolean isResource(IConstruct construct)public static bool IsResource(IConstruct construct)func IsResource(Construct IConstruct) *boolstatic#
Check whether the given construct is a Resource.
isWebFunctionEndpoint(x: any): boolean@staticmethod def is_web_function_endpoint(x: Any) -> boolpublic static Boolean isWebFunctionEndpoint(Object x)public static bool IsWebFunctionEndpoint(object x)func IsWebFunctionEndpoint(X interface{}) *boolstatic#
Return whether the given object is a WebFunctionEndpoint.
toString(): stringdef to_string(self, ) -> strpublic String toString()public string ToString()func ToString() *string#
Returns a string representation of this construct.
with(...mixins: IMixin[]): IConstructdef with(self, mixins: IMixin) -> IConstructpublic IConstruct with(IMixin mixins)public IConstruct With(IMixin mixins)func With(Mixins IMixin) IConstruct#
Applies one or more mixins to this construct.

Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited. Use multiple with() calls if subsequent mixins should apply to added constructs.