-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
Description:
When a Layer is built using --use-container option and any --container-env-var are passed, the cache is always missed.
This was already fixed by @mndeveci here: #2943, but only for Lambda Functions, while the same problem exists for layers.
Steps to reproduce:
Run below command twice to build any Layer (it will work fine in case of Functions) and see that the cache is not valid.
sam build --cached --use-container --container-env-var FOO=BAR
Observed result:
Cache is missed.
Expected result:
Cache should be hit.
Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
- OS: Linux
sam --version: SAM CLI, version 1.27.2- AWS region: N/A
Why does this happen?
Just like in case of #2943, a dictionary of env variables is being passed to the build function by DefaultBuildStrategy.build_single_layer_definition. Additional LAMBDA_BUILDERS_LOG_LEVEL variable is added to the dictionary, causing cache miss. We need to make a deepcopy of this dictionary, just like in DefaultBuildStrategy.build_single_function_definition.
I'm happy to work on a fix as soon as someone confirms my observations.