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.52k stars 1.17k forks source link

Sam package too large when using custom lambda runtime #2964

Closed mufumade closed 3 years ago

mufumade commented 3 years ago

Description:

So I am trying to deploy an application that contains some lambdas with custom swift runtime using a makefile as build method. Example project. I ran sam build, sam package and deployed that. During deployment lambda is complaining that the package is too large.

Steps to reproduce:

It should be easy to reproduce on that Example project. Just sam build, sam package and finally deploy that package.

Observed result:

During deployment CloudFormation returns an error that the lambda deployment package exceeds the ≈250MB.

After some research I know that sam packages the entire project when the codeUri is not set or set to . Now, after looking at the Building custom runtimes sam tutorial from aws the CodeUri is also set to the root folder.

Expected result:

Better handling of custom lambda runtimes when using sam package.

As stated above I know that sam packages the directory set in the CodeUri but how should I set it up that it only packages the files needed. What am I doing wrong?

Any help is much appreciated!

aahung commented 3 years ago

Hi @mufumade

I cannot reproduce it, the files sam-cli uploaded are about 20M in size:

sam package --resolve-s3                                                           ✘ 2

        Managed S3 bucket: aws-sam-cli-managed-default-samclisourcebucket-qtl95tb0hf9t
        A different default S3 bucket can be set in samconfig.toml
        Or by specifying --s3-bucket explicitly.
Uploading to 03f3f3aa3874550abf1ea7c9d669a6d4  22385842 / 22385842  (100.00%)
Uploading to 42785cc8a469d39d7ea367eb125eaa14  21885356 / 21885356  (100.00%)

After some research I know that sam packages the entire project when the codeUri is not set or set to .

This is true but usually not an issue unless you have big files in your project directory. And .aws-sam is not included in this case, which is 400MB+

One possible it package the entire project directory including .aws-sam is that you ran sam package without --template-file template.yaml or -t template.yaml, by default it packages the template in .aws-sam/build/template.yaml whose CodeUri is no longer ..

Please open a new issue if you encounters it again, one way to investigate what goes wrong is to download the packaged file from your S3 bucket, unzip and see what are inside.

github-actions[bot] commented 3 years ago

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.