From 0f638c649e42394acf9a7e109f2877a1a12db954 Mon Sep 17 00:00:00 2001 From: Greg Furman Date: Wed, 31 Jul 2024 14:08:58 +0200 Subject: [PATCH] Lambda: Include support for custom URL aliases (#1409) --- content/en/user-guide/aws/lambda/index.md | 39 +++++++++++++++++------ 1 file changed, 29 insertions(+), 10 deletions(-) diff --git a/content/en/user-guide/aws/lambda/index.md b/content/en/user-guide/aws/lambda/index.md index 30596afac7..462942b46a 100644 --- a/content/en/user-guide/aws/lambda/index.md +++ b/content/en/user-guide/aws/lambda/index.md @@ -66,18 +66,10 @@ $ awslocal lambda create-function \ --handler index.handler \ --role arn:aws:iam::000000000000:role/lambda-role \ --tags '{"_custom_id_":"my-custom-subdomain"}' -$ awslocal lambda create-function-url-config \ - --function-name localstack-lambda-url-example \ - --auth-type NONE -{ - "FunctionUrl": "http://my-custom-subdomain.lambda-url....", - .... -} {{< / command >}} -You must specify the `_custom_id_` tag **before** using the `create-function-url-config` command. +You must specify the `_custom_id_` tag **before** creating a Function URL. After the URL configuration is set up, any modifications to the tag will not affect it. -At present, custom IDs can be assigned only to the `$LATEST` version of the function. -LocalStack does not yet support custom IDs for function version aliases. +LocalStack supports assigning custom IDs to both the `$LATEST` version of the function or to an existing version alias. {{< /callout >}} {{< callout >}} @@ -124,6 +116,33 @@ $ awslocal lambda create-function-url-config \ This will generate a HTTP URL that can be used to invoke the Lambda function. The URL will be in the format `http://.lambda-url.us-east-1.localhost.localstack.cloud:4566`. +{{< callout "note">}} +As previously mentioned, when a Lambda Function has a `_custom_id_` tag, LocalStack sets this tag's value as the subdomain in the Function's URL. + +{{< command >}} +$ awslocal lambda create-function-url-config \ + --function-name localstack-lambda-url-example \ + --auth-type NONE +{ + "FunctionUrl": "http://my-custom-subdomain.lambda-url....", + .... +} +{{< / command >}} + +In addition, if you pass an an existing version alias as a `Qualifier` to the request, the created URL will combine the custom ID and the alias in the form `-`. + +{{< command >}} +$ awslocal lambda create-function-url-config \ + --function-name localstack-lambda-url-example \ + --auth-type NONE + --qualifier test-alias +{ + "FunctionUrl": "http://my-custom-subdomain-test-alias.lambda-url....", + .... +} +{{< / command >}} +{{< /callout >}} + ### Trigger the Lambda function URL You can now trigger the Lambda function by sending a HTTP POST request to the URL using `cURL` or your REST HTTP client: