Description
Description:
Using the new sam-beta-cdk it is possible to locally invoke Lambda function in your CDK project. This should also work when the Lamba function is using a Lambda Layer which is created in the CDK.
When testing I found out this only works when the Lambda Function and Layer are created in the same (sub)stack. When using different substacks sam-beta-cdk local invoke
will fail with the following error:
Error: referencetosamcdklayerdemolayerstackNestedStacklayerstackNestedStackResource8F1D43CDOutputssamcdklayerdemolayerstacklayertest7F01C4FERef is an Invalid Layer Arn.
Steps to reproduce:
- Clone https://github.com/dazzle1979/sam-cdk-layer-demo
- Create a local environment:
python3 -m venv .env
- Install dependencies
pip install -r requirements.txt
- Run:
sam-beta-cdk build
- Run:
sam-beta-cdk local invoke sam-cdk-layer-demo/test-function-same-stack
- Run:
sam-beta-cdk local invoke sam-cdk-layer-demo/lambda-stack/test-function
Observed result:
Invoking test-function
will fail:
Error: referencetosamcdklayerdemolayerstackNestedStacklayerstackNestedStackResource8F1D43CDOutputssamcdklayerdemolayerstacklayertest7F01C4FERef is an Invalid Layer Arn.
Expected result:
I would expect invoking both function would have the same result because they are the same only not created in the same stack.
Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
- OS: Mac OS Big Sur 11.2.3
sam --version
: SAM CLI, version 1.23.0sam-beta-cdk --version
: SAM CLI, version 1.22.0.dev202104291816