aws-amplify / aws-amplify/amplify-cli

Specify public layer arn once and use in all Lambda functions

Open
#6,641 1 comment 0 reactions 0 assignees View on GitHub
feature-request lambda-layers p4
Dominant language
TypeScript
Stars
2.9k
Forks
825
Avg merge
11d 23h
Merged PRs (30d)
2

Description

**Which Category is your question related to?**
Function

**Amplify CLI Version**
4.43.0

**Challenge**
I want to use a publicly available layer, like a layer to instrument my code for extra visibility (eg Lumigo, Thundra).
These have a specific layer ARN, for example: `arn:aws:lambda:eu-west-1:xxxxxxxx:layer:layer-name:224`.

I want to use this layer in all my lambda functions.
**How can I specify this layer once, and use it in all my lambda functions?**

*Current intermediate solutions:*
- Either use `parameters.json` to provide the layerArn to your function's CF template.
`parameters.json`:
```
{
"layerArn": "arn:aws:lambda:eu-west-1:xxxxxxx:layer:layer-name:version"
}
```
You have to do this for every function.
- Or specify the layerARN directly in every function's CF template:
`lambda-CF.json`
```
"Layers": [
"arn:aws:lambda:eu-west-1:xxxxxxxxxx:layer:layer-name:version
],
```
You have to do this for every function.
- Or use ssm to fetch the layerARN from
`lambda-CF.json`:
```
"Layers": [
{
"Fn::Sub": "{{resolve:ssm:/your-app/${env}/layer-arn:1}}"
}
],
```
This takes care of only having to specify the version of the layer once (in ssm).
Yet it makes you dependent on ssm parameters which you have to provision for every new environment you checkout.

Is there another way to provide this layerArn as a parameter to all stacks and not time and time again define it in every stack?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.