Safeguard
Supply Chain•

What do you do when you hit the five Lambda layer limit?

Lambda allows five layers per function. Options: merge layers, bundle into the package, or move to a container image, with patching tradeoffs for each.

Safeguard Security Team
3 min read

Lambda allows up to five layers per function, and the layers count toward the 250 MB unzipped package limit. When you hit that, you can merge layers, bundle dependencies into the function package, or switch to a container image. Each choice changes how you patch, so pick on patching, not convenience.

What the limits are

AWS documents that you can include up to five layers per function, that layers work only with functions deployed as .zip archives, and that a layer's contents are extracted to /opt. The unzipped deployment size limit of 250 MB includes layers.

Option 1: merge layers

Combine two or three layers into one. This frees slots and keeps the shared patching model.

  • Good when the merged layers change together.
  • Risky when they have different owners, because one team now blocks another.
  • Keep a manifest of the layer's contents so the merge does not hide what is inside.

Option 2: bundle into the package

Put dependencies in the function zip.

  • Good when only one or two functions use a library.
  • Patching is per function, so a shared vulnerability means rebuilding each one.
  • Scanning is simpler, since the artifact is self-contained.

Option 3: move to a container image

AWS says container image functions package their own runtime and dependencies, and layers are not used there. The code package limit is 10 GB uncompressed.

A decision table

SituationLeaning
Shared libraries, one owner, change togetherMerge layers
Library used by one or two functionsBundle into the package
Large or native dependencies, over 250 MBContainer image
Go or Rust functionCompile into the binary, see AWS guidance on layers for Go and Rust

Whatever you choose, keep an inventory

A layer is easy to forget because the function code never shows it. List each function with its layer ARNs and versions. AWS's list-functions output includes each function's layers and runtime, which makes a script straightforward, as covered in inventorying every Lambda function and layer.

Try it yourself

Open the demo and trace one package to every place it is used. That cross-reference is what you need before you merge or split layers.

Click through it at your own pace, or open it full screen.

Where Safeguard fits

Safeguard's SBOM and dependency scanning can cover the build of a layer as well as of a function, so merged or split layers still have an inventory. Free scan: gold.safeguard.sh/scan.

Quick check

Do layers count toward the package size limit?

Yes. AWS says the 250 MB unzipped limit includes layers and custom runtimes.

Can container image functions use layers?

No. AWS says layers apply only to .zip functions, and container images package their own dependencies.

Sources

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.