From c4202d3011339d69b6c9b99514c43e86b3a618ee Mon Sep 17 00:00:00 2001 From: ykethan Date: Wed, 11 Dec 2024 23:03:15 -0500 Subject: [PATCH 1/2] update layer doc to add short version --- .../functions/add-lambda-layers/index.mdx | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/pages/[platform]/build-a-backend/functions/add-lambda-layers/index.mdx b/src/pages/[platform]/build-a-backend/functions/add-lambda-layers/index.mdx index 132d20ec1ff..cff814db844 100644 --- a/src/pages/[platform]/build-a-backend/functions/add-lambda-layers/index.mdx +++ b/src/pages/[platform]/build-a-backend/functions/add-lambda-layers/index.mdx @@ -50,9 +50,23 @@ To add a Lambda layer to your function, follow these steps: }, }); ``` - - The Lambda layer is represented by an object of key/value pairs where the key is the module name that is exported from your layer and the value is the ARN of the layer. The key (module name) is used to externalize the module dependency so it doesn't get bundled with your lambda function. A maximum of 5 layers can be attached to a function, and they must be in the same region as the function. + The Lambda layer is represented by an object of key/value pairs where the key is the module name that is exported from your layer and the value is the ARN of the layer. The key (module name) is used to externalize the module dependency so it doesn't get bundled with your lambda function. A maximum of 5 layers can be attached to a function, and they must be in the same region as the function. +

Alternatively, you can specify the layer as `myLayer:1` where `myLayer` is the name of the layer and `1` is the version of the layer. For example: + + ```ts title="amplify/functions/my-function/resource.ts" + import { defineFunction } from "@aws-amplify/backend"; + + export const myFunction = defineFunction({ + name: "my-function", + layers: { + "module": "myLayer:1" + }, + }); + ``` + + Amplify will automatically convert this to the full layer ARN format `arn:aws:lambda:::layer:myLayer:1` using your existing account id and region. + When using layers, be mindful of versioning. The ARN includes a version number (e.g., `:12` in the example). Ensure you're using the appropriate version and have a strategy for updating layers when new versions are released. From 6f77bda8b0a59f403c3c31799d5b6ba437d88476 Mon Sep 17 00:00:00 2001 From: ykethan Date: Thu, 12 Dec 2024 20:50:46 -0500 Subject: [PATCH 2/2] nits --- .../functions/add-lambda-layers/index.mdx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/pages/[platform]/build-a-backend/functions/add-lambda-layers/index.mdx b/src/pages/[platform]/build-a-backend/functions/add-lambda-layers/index.mdx index cff814db844..12d2dcceb1a 100644 --- a/src/pages/[platform]/build-a-backend/functions/add-lambda-layers/index.mdx +++ b/src/pages/[platform]/build-a-backend/functions/add-lambda-layers/index.mdx @@ -51,8 +51,9 @@ To add a Lambda layer to your function, follow these steps: }); ``` - The Lambda layer is represented by an object of key/value pairs where the key is the module name that is exported from your layer and the value is the ARN of the layer. The key (module name) is used to externalize the module dependency so it doesn't get bundled with your lambda function. A maximum of 5 layers can be attached to a function, and they must be in the same region as the function. -

Alternatively, you can specify the layer as `myLayer:1` where `myLayer` is the name of the layer and `1` is the version of the layer. For example: + The Lambda layer is represented by an object of key/value pairs where the key is the module name that is exported from your layer and the value is the ARN of the layer. The key (module name) is used to externalize the module dependency so it doesn't get bundled with your Lambda function. A maximum of 5 layers can be attached to a function, and they must be in the same region as the function. + +
Alternatively, you can specify the layer as `myLayer:1` where `myLayer` is the name of the layer and `1` is the version of the layer. For example: ```ts title="amplify/functions/my-function/resource.ts" import { defineFunction } from "@aws-amplify/backend"; @@ -60,12 +61,12 @@ To add a Lambda layer to your function, follow these steps: export const myFunction = defineFunction({ name: "my-function", layers: { - "module": "myLayer:1" + "some-module": "myLayer:1" }, }); ``` - Amplify will automatically convert this to the full layer ARN format `arn:aws:lambda:::layer:myLayer:1` using your existing account id and region. + Amplify will automatically convert this to the full layer ARN format `arn:aws:lambda:::layer:myLayer:1` using your existing account ID and region.