-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug: SAM does not write Layer build results to build.toml
unless its table already exists
#5585
Comments
build.toml
build.toml
unless its table already exists
Thanks for reporting. I was able to reproduce this and we welcome contributions if you'd like to help fix this issue! |
@davidjb , the steps you mentioned as a workaround does not work on my side. My findings is SAM CLI does not write to aws-sam-cli/samcli/lib/build/app_builder.py Line 264 in 46c374f
aws-sam-cli/samcli/lib/build/build_graph.py Lines 320 to 321 in d841801
aws-sam-cli/samcli/lib/build/build_graph.py Lines 442 to 479 in d841801
I will check with the team if this was done on purpose. |
I checked this issue with the team, and we confirmed that SAM CLI does not create the The work around for this issue now is to first run |
@moelasmar So the issue is trying to reach a point where a It may be possible to change configurations and hack things up until [layer_build_definitions.00000000-0000-0000-0000-000000000000]
layer_name = "MyLayer"
codeuri = "/path/to/layers/mylayer"
build_method = "makefile"
compatible_runtimes = ["provided.al2"]
architecture = "arm64"
source_hash = "fake"
manifest_hash = ""
layer = "MyLayer" Once this exists, then running Could a similar strategy be added into |
Description:
Starting with an empty environment (e.g. no
.aws-sam
directory or no.aws-sam/build.toml
file), attempting to build a layer by itself:does not result in the layer's build results being written to
.aws-sam/build.toml
. In fact, this file does not even get created.This means that subsequent calls to the same build command will not use the cache, despite cached files being created in
.aws-sam/cache
and that a problem such as #5507 cannot be worked around.Edit: currently, a Layer build will only update its entry within
.aws-sam/build.toml
(e.g. SAM won't create this file just for building a Layer), essentially meaning that in order for a Layer to be cached, it must first at least have been attempted to be cached. A workaround for this situation is to force the creation of.aws-sam/build.toml
, building in whatever way is necessary to generate the Layer's entry in this file (or otherwise manually creating the TOML would work too). In my case, it was quickest to just do:Steps to reproduce:
.aws-sam
directory or.aws-sam/build.toml
filetemplate.yaml
:MyFunction:
Type: AWS::Serverless::Function
Metadata:
BuildMethod: go1.x
Properties:
CodeUri: functions/myfunction
Handler: bootstrap
Runtime: provided.al2
Layers:
- !Ref MyLayer
sam build --cached --use-container MyLayer
.aws-sam/build.toml
file is created.sam build
command and layer will not have been cached.Observed result:
Expected result:
Layer to be cached and recorded, available for subsequent runs of
sam build
.Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
The text was updated successfully, but these errors were encountered: