Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(layers): update docs #12331

Open
wants to merge 1 commit into
base: v3
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
33 changes: 25 additions & 8 deletions docs/providers/aws/guide/layers.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ layout: Doc

# AWS Lambda Layers

If you are using AWS as a provider, all _layers_ inside the service are [AWS Lambda
layers](https://aws.amazon.com/blogs/aws/new-for-aws-lambda-use-any-programming-language-and-share-common-components/).
If you are using AWS as a provider, all _layers_ inside the service are [AWS Lambda layers](https://aws.amazon.com/blogs/aws/new-for-aws-lambda-use-any-programming-language-and-share-common-components/).

## Configuration

Expand Down Expand Up @@ -152,7 +151,7 @@ layers:

## Using your layers

Using the `layers` configuration key in a function makes it possible for your layer with a function
Using the `layers` configuration key in a function makes it possible to use your function with layers.

```yml
functions:
Expand All @@ -162,10 +161,7 @@ functions:
- arn:aws:lambda:region:XXXXXX:layer:LayerName:Y
```

To use a layer with a function in the same service, use a CloudFormation Ref. The name of your layer
in the CloudFormation template will be your layer name
[TitleCased](https://en.wikipedia.org/wiki/Letter_case#Title_Case) (without spaces) and have
`LambdaLayer` appended to the end. EG:
To use a layer with a function in the same service, use a CloudFormation Ref. The name of your layer in the CloudFormation template will be your layer name [TitleCased](https://en.wikipedia.org/wiki/Letter_case#Title_Case) (without spaces) and have `LambdaLayer` appended to the end.

```yml
layers:
Expand All @@ -178,7 +174,7 @@ functions:
- !Ref TestLambdaLayer
```

You can also configure layers at the service level. EG:
You can also configure layers at the service level which applies to all functions in the service.

```yml
# serverless.yml
Expand All @@ -197,3 +193,24 @@ functions:
hello2:
handler: handler.hello2
```

When using both service and function `layers` property, function level will take precedence over service level.

```yml
# serverless.yml
service: myService

provider:
name: aws
runtime: python3.11
layers:
- arn:aws:lambda:us-east-1:xxxxxxxxxxxxx:layer:xxxxx:mylayer1

functions:
hello1:
handler: handler.hello1
layers:
- arn:aws:lambda:us-east-1:xxxxxxxxxxxxx:layer:xxxxx:mylayer2 # Only this layer will be included
hello2:
handler: handler.hello2
```