Safeguard
Developer Tools•

Should you bundle the AWS SDK in your Lambda package?

AWS recommends packaging the SDK with your function. The reasons are control, compatibility and an honest dependency list. Trade offs and exceptions.

Safeguard Security Team
4 min read

Yes, in most cases. AWS recommends including the SDK modules your code uses, along with their dependencies, in your deployment package or a layer. That gives you version control, avoids surprises when the runtime updates, and puts the SDK on your dependency list where scanners can see it.

What the runtime gives you

The Node.js, Python and Ruby runtimes include a version of the AWS SDK. Lambda periodically updates that version. AWS says to use the runtime included SDK only when you cannot include additional packages, for example when you write code in the console editor or inline in a CloudFormation template.

Four reasons to bundle

  1. Compatibility. AWS describes a case where a function uses package A from the runtime but package B from the deployment package. A future runtime update to A may need a newer B, and your older B takes precedence. Packaging both avoids that mismatch.
  2. Precedence is on your side. For Python, the AWS documentation says your deployment package takes precedence over runtime included libraries, and dependencies in layers also take precedence over the runtime copies.
  3. Visible inventory. A package in your manifest and lockfile shows up in SBOMs and scans. A library that lives inside the runtime image does not appear in your lockfile at all.
  4. A known version for testing. The version you test is the version that runs.

The cost

Bundling means you own updates. When the SDK or one of its dependencies gets a security fix, you rebuild and redeploy. The runtime included copy would have updated itself. That is the trade: stability and visibility in exchange for responsibility.

A Python warning from AWS is worth repeating. If you ship your own copy of an SDK dependency such as urllib3 without shipping the SDK itself, a runtime update can leave the two out of step. Ship the whole set together.

A simple decision guide

SituationSuggestion
Normal deployable functionBundle the SDK modules you use
Console inline code or tiny CloudFormation snippetRuntime copy is acceptable; keep the function trivial
Many functions sharing one SDK versionPut it in a layer and track the layer version
Go or Rust functionDependencies are compiled into the executable; AWS recommends against layers for these
Need identical versions across regionsUse container images, as AWS suggests

Keep bundles small and honest

Import only the clients you need rather than the whole SDK. The AWS performance guidance shows requiring a single service client instead of the entire SDK, which also trims initialization time and the number of packages you must track.

Try it yourself

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

Look for how direct and transitive packages are listed. Bundled SDK modules appear here, runtime copies do not.

Quick check

Is the bundled SDK slower to start?

It adds package size, which AWS lists as a factor in initialization time. Importing individual clients keeps that small.

Who patches the runtime included SDK?

Lambda updates it periodically as part of runtime updates, but AWS still recommends bundling for control and compatibility.

Safeguard's SBOM and dependency scanning can list the SDK packages in your function bundle and flag vulnerable versions. Try a free scan at gold.safeguard.sh/scan.

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.