question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"sam build" causes "sam deploy" to create a deployment package even if nothing changed, for functions with dependencies

See original GitHub issue

#1387 # Description

If I have a SAM template with multiple python functions, each in its own folder, and one of the functions has dependencies listed in requirements.txt, after issuing “sam build”, even if nothing changed in the template, function code, or dependencies, “sam deploy” will upload a new package, which takes time.

Steps to reproduce

  1. create a project with two functions, each in its own folder.
  2. for one of the functions add a dependency in requirements.txt (e.g., x-ray)
  3. run “sam build”
  4. run “sam deploy”
  5. run “sam build” again, without making any changes.
  6. run “sam deploy again”

Observed result

The function that contains dependencies, and the template, are packaged and uploaded, like this:

Initiating deployment

File with same data is already exists at serverless-scheduler/985973fbd971e45a959e6d520b75dfe1. Skipping upload File with same data is already exists at serverless-scheduler/6d9fba98bc2a080b3ec43a4921f5d0a9. Skipping upload Uploading to serverless-scheduler/8a441f7496a766afaf6cf4cf86407263 7460512 / 7460512.0 (100.00%) Uploading to serverless-scheduler/7a235e33ae6c1ab803faf9b9d3230e56.template 3220 / 3220.0 (100.00%)

Expected result

I would expect the “run deploy” to not do anything, like the following which happens if I ran “sam deploy” immediately after “sam deploy”: Initiating deployment

File with same data is already exists at serverless-scheduler/985973fbd971e45a959e6d520b75dfe1. Skipping upload File with same data is already exists at serverless-scheduler/6d9fba98bc2a080b3ec43a4921f5d0a9. Skipping upload File with same data is already exists at serverless-scheduler/bd363502c619e8fd70fb4b59c0e90e91. Skipping upload File with same data is already exists at serverless-scheduler/5a9cfd304a71aea5caa2a6298a2ceddb.template. Skipping upload

Additional environment details (Ex: Windows, Mac, Amazon Linux etc)

  1. OS: MacOS
  2. sam --version: SAM CLI, version 0.40.0

Add --debug flag to command you are running

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
vkiranmaniyacommented, Jul 9, 2022

I’m still having the issue in version 1.53.0. I have nearly 50 lambda functions and SAM cli tries to upload the build 50 times. Screen Shot 2022-07-10 at 3 04 16 AM

0reactions
mousedownmikecommented, Aug 1, 2022

@deltafactory I think it’ll have to do the build in order to get the checksum that verifies the contents to upload are the same as the destination. The only part of this process that is skipped (I assume) is the actual transmission of the full built package, it will still have to communicate with the destination to get the ETag or whatever it uses to compare checksums and it will need a locally built version to generate the checksum to compare with.

Read more comments on GitHub >

github_iconTop Results From Across the Web

"sam build" causes "sam deploy" to create a ... - GitHub
"sam build" causes "sam deploy" to create a deployment package even if nothing changed, for functions with dependencies #1779.
Read more >
sam build - AWS Serverless Application Model
The sam build command processes your AWS SAM template file, application code, and any applicable language-specific files and dependencies.
Read more >
Chapter 4. Operating AWS Lambda Functions - O'Reilly
sam deploy starts by uploading our deployment package to S3, but only if the contents of that package have changed. Earlier in the...
Read more >
DEEP DIVE INTO AWS SAM BUILDING AND PACKAGING ...
How to share dependencies between different functions ? ... can choose a different deployment strategy for your safe deployments in AWS SAM.
Read more >
Serverless TypeScript: A complete setup for AWS SAM Lambdas
Keeping the local development experience mostly unchanged: no moving package. · No running sam build on every change in function handler code.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found