class FunctionUrl (construct)
| Language | Type name |
|---|---|
.NET | Amazon.CDK.AWS.Lambda.FunctionUrl |
Go | github.com/aws/aws-cdk-go/awscdk/v2/awslambda#FunctionUrl |
Java | software.amazon.awscdk.services.lambda.FunctionUrl |
Python | aws_cdk.aws_lambda.FunctionUrl |
TypeScript (source) | aws-cdk-lib » aws_lambda » FunctionUrl |
Implements
IConstruct, IDependable, IResource, IEnvironment, IFunction
Defines a Lambda function url.
Example
import * as lambda from 'aws-cdk-lib/aws-lambda';
declare const fn: lambda.Function;
const fnUrl = fn.addFunctionUrl({
authType: lambda.FunctionUrlAuthType.AWS_IAM,
});
new cloudfront.Distribution(this, 'MyDistribution', {
defaultBehavior: {
origin: origins.FunctionUrlOrigin.withOriginAccessControl(fnUrl),
},
});
Initializer
new FunctionUrl(scope: Construct, id: string, props: FunctionUrlProps)
Parameters
- scope
Construct - id
string - props
FunctionUrl Props
Construct Props
| Name | Type | Description |
|---|---|---|
| function | IFunction | The function to which this url refers. |
| auth | Function | The type of authentication that your function URL uses. |
| cors? | Function | The cross-origin resource sharing (CORS) settings for your function URL. |
| invoke | Invoke | The type of invocation mode that your Lambda function uses. |
function
Type:
IFunction
The function to which this url refers.
It can also be an Alias but not a Version.
authType?
Type:
Function
(optional, default: FunctionUrlAuthType.AWS_IAM)
The type of authentication that your function URL uses.
cors?
Type:
Function
(optional, default: No CORS configuration.)
The cross-origin resource sharing (CORS) settings for your function URL.
invokeMode?
Type:
Invoke
(optional, default: InvokeMode.BUFFERED)
The type of invocation mode that your Lambda function uses.
Properties
| Name | Type | Description |
|---|---|---|
| auth | Function | The authentication type used for this Function URL. |
| env | Resource | The environment this resource belongs to. |
| function | string | The ARN of the function this URL refers to. |
| node | Node | The tree node. |
| stack | Stack | The stack in which this resource is defined. |
| url | string | The url of the Lambda function. |
| static PROPERTY_INJECTION_ID | string | Uniquely identifies this class. |
authType
Type:
Function
The authentication type used for this Function URL.
env
Type:
Resource
The environment this resource belongs to.
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.
functionArn
Type:
string
The ARN of the function this URL refers to.
node
Type:
Node
The tree node.
stack
Type:
Stack
The stack in which this resource is defined.
url
Type:
string
The url of the Lambda function.
static PROPERTY_INJECTION_ID
Type:
string
Uniquely identifies this class.
Methods
| Name | Description |
|---|---|
| apply | Apply the given removal policy to this resource. |
| grant | Grant the given identity permissions to invoke this Lambda Function URL. |
| to | Returns a string representation of this construct. |
applyRemovalPolicy(policy)
public applyRemovalPolicy(policy: RemovalPolicy): void
Parameters
- policy
RemovalPolicy
Apply the given removal policy to this resource.
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).
grantInvokeUrl(grantee)
public grantInvokeUrl(grantee: IGrantable): Grant
Parameters
- grantee
IGrantable
Returns
Grant the given identity permissions to invoke this Lambda Function URL.
toString()
public toString(): string
Returns
string
Returns a string representation of this construct.

.NET
Go
Java
Python
TypeScript (