Open maksymdukov opened 2 years ago
Thanks for reporting this in! We will first try to reproduce this issue using information you provided
@maksymdukov Sorry for a postponed response here, as I look at the issue carefully I wonder if we are missing some logic to create function layer reference syncs when the layer attribute is defined in functions. Can I confirm with you that this only happens when you define the layer reference in globals? Meanwhile we will reproduce the issue and investigate if the get dependent functions method didn't return all functions for your case
Below is how we are finding the layer's related functions:
def _get_dependent_functions(self) -> List[Function]:
function_provider = SamFunctionProvider(cast(List[Stack], self._stacks), locate_layer_nested=True)
dependent_functions = []
for function in function_provider.get_all():
if self._layer_identifier in [layer.full_path for layer in function.layers]:
LOG.debug(
"%sAdding function %s for updating its Layers with this new version",
self.log_prefix,
function.name,
)
dependent_functions.append(function)
return dependent_functions
Also just assigning myself here to keep track of the issue
We are also impacted by this issue. The issue happens only when the layer is defined in the Globals section.
Just ran into this issue as well. Would love any thoughts about timing to resolve. we're thinking about giving up using Globals for this because of how much worse it makes sam sync
Similarly, I am using nested templates where the layers are defined in one template and the functions that use the layers are in a different template. The deployments work correctly, but when I use sam sync --watch
and update the layer code, the layers are updated but the functions are not updated to point to the latest layer. Are there any known workarounds to get sam sync
working properly with nested templates?
Here is how I'm currently exporting the layer reference:
Outputs:
LayerArn:
Value: !Ref Layer
Export:
Name: LayerArn
Here is how I'm using the layer reference:
Function:
...
Layers:
- !ImportValue LayerArn
This still seems to be an issue.
Still an issue for me as well!
Description:
sam sync
--watch
and--code
does not syncFunction Layer Reference
under certain conditions when Layer itself gets synced.Steps to reproduce:
Create serverless template yaml and put it in \<rootDir>/cf/template.yaml
\<rootDir>/src/common/Makefile
\<rootDir>/src/common/log.js
\<rootDir>/src/handlers/handle.js
From the rooDir run sam sync:
Try to change code in the layer \<rootDir>/src/common/log.js
Observed result:
Updated layer gets synced but Lambda's Layer Reference does not get updated, meaning Lambda still points to the old layer version
Expected result:
Lambda's Layer Reference gets updated
Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
Workaround (1) to make it all work - specify
- !Ref LambdaLayer
in a lambda declaration section instead of the Globals sectionWorkaround (2) - move template.yaml into the root directory.
sam --version
: SAM CLI, version 1.53.0Add --debug flag to command you are running