Url
The Url resource lets you manage AWS Lambda Urls for your Lambda functions, allowing you to expose them directly over HTTP(S).
Minimal Example
Section titled “Minimal Example”Create a basic Lambda Url for a function with essential properties:
import AWS from "alchemy/aws/control";
const lambdaUrl = await AWS.Lambda.Url("myLambdaUrl", { TargetFunctionArn: "arn:aws:lambda:us-west-2:123456789012:function:myLambdaFunction", AuthType: "AWS_IAM", // Authentication type InvokeMode: "BUFFERED" // Invocation mode});
Advanced Configuration
Section titled “Advanced Configuration”Configure a Lambda Url with additional CORS settings and a specific qualifier:
const advancedLambdaUrl = await AWS.Lambda.Url("advancedLambdaUrl", { TargetFunctionArn: "arn:aws:lambda:us-west-2:123456789012:function:myLambdaFunction", AuthType: "AWS_IAM", InvokeMode: "BUFFERED", Cors: { AllowOrigins: ["https://example.com"], AllowMethods: ["GET", "POST"], AllowHeaders: ["Content-Type"] }, Qualifier: "$LATEST" // Specify the version of the function});
Using an Existing Resource
Section titled “Using an Existing Resource”If you want to adopt an existing Lambda Url instead of failing when it already exists:
const existingLambdaUrl = await AWS.Lambda.Url("existingLambdaUrl", { TargetFunctionArn: "arn:aws:lambda:us-west-2:123456789012:function:myExistingLambdaFunction", AuthType: "NONE", // Public access adopt: true // Adopt existing resource});
Custom Invocation Mode
Section titled “Custom Invocation Mode”Create a Lambda Url with a different invocation mode for specific use cases:
const customInvocationModeUrl = await AWS.Lambda.Url("customInvocationUrl", { TargetFunctionArn: "arn:aws:lambda:us-west-2:123456789012:function:myCustomLambdaFunction", AuthType: "AWS_IAM", InvokeMode: "DIRECT" // Direct invocation mode});