Skip to content

Commit b338b11

Browse files
authored
update layer doc to add short version (#8161)
* update layer doc to add short version * nits
1 parent 768dccf commit b338b11

File tree

1 file changed

+17
-2
lines changed
  • src/pages/[platform]/build-a-backend/functions/add-lambda-layers

1 file changed

+17
-2
lines changed

src/pages/[platform]/build-a-backend/functions/add-lambda-layers/index.mdx

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,24 @@ To add a Lambda layer to your function, follow these steps:
5050
},
5151
});
5252
```
53-
54-
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.
5553

54+
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.
55+
56+
<br/>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:
57+
58+
```ts title="amplify/functions/my-function/resource.ts"
59+
import { defineFunction } from "@aws-amplify/backend";
60+
61+
export const myFunction = defineFunction({
62+
name: "my-function",
63+
layers: {
64+
"some-module": "myLayer:1"
65+
},
66+
});
67+
```
68+
69+
Amplify will automatically convert this to the full layer ARN format `arn:aws:lambda:<region>:<account-id>:layer:myLayer:1` using your existing account ID and region.
70+
5671
<Callout type="warning">
5772

5873
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.

0 commit comments

Comments
 (0)