Skip to content
Latchkey

AWS SAM "Build Failed" from sam build in CI

sam build compiles each function with its runtime workflow (pip, npm, go, maven). One function failed, so sam aborts with "Build Failed" and a per-function reason just above the summary.

What this error means

sam build ends with "Build Failed" and an error like "RuntimeError", a dependency install failure, or "Manifest file not found". The job stops before deploy.

sam
Build Failed
Error: PythonPipBuilder:ResolveDependencies - {numpy==99.9.9(wheel)}
... Could not find a version that satisfies the requirement numpy==99.9.9

Common causes

A function dependency failed to install

The runtime workflow (pip/npm/etc.) could not resolve or compile a dependency, so that function build failed.

Missing manifest or wrong CodeUri

The function points at a directory without its manifest (requirements.txt, package.json), so sam has nothing to build.

How to fix it

Read the per-function build error

  1. Find the function name in the "Build Failed" output.
  2. Fix the named cause: a bad dependency pin, a missing manifest, or a compiler need.
  3. For native deps, build in the Lambda-like image with --use-container.
Terminal
sam build --use-container

Point CodeUri at the manifest directory

Ensure each function's CodeUri contains its dependency manifest.

template.yaml
MyFunction:
  Type: AWS::Serverless::Function
  Properties:
    CodeUri: src/my_function/   # contains requirements.txt
    Handler: app.handler

How to prevent it

  • Build native dependencies with --use-container for Lambda parity.
  • Keep each function's manifest beside its CodeUri.
  • Pin dependency versions that actually publish for the runtime.

Frequently asked questions

What causes "sam build "Build Failed""?
The runtime workflow (pip/npm/etc.) could not resolve or compile a dependency, so that function build failed.
How do I fix sam build "Build Failed"?
Read the per-function build error

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card