aws-sam-cli icon indicating copy to clipboard operation
aws-sam-cli copied to clipboard

Feature request: validate Functions meet deployment package size quota (250MB / 262144000 bytes)

Open davidjb opened this issue 1 year ago • 1 comments

Describe your idea/feature/enhancement

Currently, if a Function and its Layers exceed the deployment package size quota of "250MB" (in reality 262144000 bytes), a user won't discover this until running sam deploy and CloudFormation emits an error along the lines of Unzipped size must be smaller than 262144000 bytes (or lower, depending on what caused the quota to be exceeded and when).

Ideally, SAM would detect a pending problem during development of a Function/LayerVersion that will exceed the quota, either checking the unzipped size at build time, and separately during invocation of a Function, since the quota applies to the Function and all its Layers. By checking this ahead of time, development time improved with early detection of size issues. Equally, checking sizes just before deploying would avoid failed deploys and rollbacks, and the time required to reach this point for zipping/uploads/etc.

Proposal

  • Build time: after building a Function or Layer, check the size. Error if over quota.
    • To save time with space calculations, consider caching size into build.toml.
  • Local invocation time: ahead of sam local invoke, sum size of Function and all Layers (if cached, use values from build.toml. Error if over quota.
  • Deploy time: ahead of creating zips for sam deploy, check size and perform sums for Functions and their Layers. Error if any over quota.

Additional Details

davidjb avatar Dec 01 '23 00:12 davidjb

Thanks for opening this feature request! Let me bring this to the team for prioritization.

lucashuy avatar Dec 01 '23 23:12 lucashuy