aws / aws-sam-cli

CLI tool to build, test, debug, and deploy Serverless applications using AWS SAM
https://aws.amazon.com/serverless/sam/
Apache License 2.0
6.53k stars 1.17k forks source link

Bug: Using Rust SDK - CodeUri in SAM Template creates wrong S3 zip archive for upload #7713

Open deanchalk opened 1 week ago

deanchalk commented 1 week ago

Description:

Im writing Lambdas in Rust and using SAM to build and deploy. I am expecting to use the same 'template.yaml' file for both. However, when running 'sam build' the CodeUri settings needs to be to the folder where the Cargo.toml file is located. However, when I run 'sam deploy' (with the same template file) it zips up EVERYTHING in that same directory which includes all debug/release output artifacts and any thing else in there. The resultant zip that goes up to S3 for deployment is often over 250mb so fails to deploy. In reality, I only want to deploy the 'bootstrap' target file which is about 1.5mb and lives under ./src//target/lambda// directory.

The only work around is to change the CodeUri setting for each lambda to something different betweem 'sam build' and 'sam deploy'

This seems like a bug. Ive been through loads of docs but cant find anything related to this issue for Rust with SAM

dkphm commented 5 days ago

Hi @deanchalk , thanks for reporting the issue. From what I checked, the script only upload an artifact with bootstrap as a content to S3. Could you please let us know more detail on the lambda you are working on, or on which environment (Windows or Linux) to help further investigations?