Node, can't use layer from arn for lambda
See original GitHub issueHaving an existing layer in my account referencing it with cdk 1.31.0, to use in a new lambda does not work.
the Cloudformation error is not understandable, saying that the arn is not conforme, but the layer arn match the regex
Reproduction Steps
const myLayer = LayerVersion.fromLayerVersionArn(this, 'myLayer',
arn:aws:lambda:eu-central-1:${this.account}:layer:mylayer:1`)
new lambda.Function(this, ‘Lambda’, { layers: [myLayer] […] });`
Error Log
1 validation error detected: Value ‘[arn:aws:lambda:eu-central-1:XXXXMYACCOUNT:layer:mylayer:1"]’ at ‘layers’ failed to satisfy constraint: Member must satisfy constraint: [Member must have length less than or equal to 140, Member must have length greater than or equal to 1, Member must satisfy regular expression pattern: (arn:[a-zA-Z0-9-]+:lambda:[a-zA-Z0-9-]+:\d{12}:layer:[a-zA-Z0-9-]+:[0-9]+)|(arn:[a-zA-Z0-9-]+:lambda:::awslayer:[a-zA-Z0-9-]+)] (Service: AWSLambdaInternal; Status Code: 400; Error Code: ValidationException; Request ID: bb1b3629-bbb6-43a7-94e8-4b84388c2d38)
Environment
- **CLI Version :aws-cli/1.15.4 Python/2.7.13 Linux/4.9.0-12-amd64 botocore/1.10.4
- **Framework Version:1.31.0
- **Language :typescript
This is 🐛 Bug Report
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top GitHub Comments
This is the typescript CDK app I have that does what you’ve suggested and I was able to successfully deploy this -
(using version
1.31.0
)The error message suggests that the ARN is malformed, but I can’t see that to be the case. Make sure you’re deploying to the same region as the layer, perhaps that is tripping this error message?
If you’re still seeing this, could you provide a code snippet similar to the one I’ve provided above that’s failing, that we can use to reproduce.
I got this error when accidentally passing the ARN of a layer rather than a layer version. Took me an embarrassing amount of time to notice that detail 😃