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.
Build Failed
Error: PythonPipBuilder:ResolveDependencies - {numpy==99.9.9(wheel)}
... Could not find a version that satisfies the requirement numpy==99.9.9Common 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
- Find the function name in the "Build Failed" output.
- Fix the named cause: a bad dependency pin, a missing manifest, or a compiler need.
- For native deps, build in the Lambda-like image with
--use-container.
sam build --use-containerPoint CodeUri at the manifest directory
Ensure each function's CodeUri contains its dependency manifest.
MyFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: src/my_function/ # contains requirements.txt
Handler: app.handlerHow to prevent it
- Build native dependencies with
--use-containerfor Lambda parity. - Keep each function's manifest beside its CodeUri.
- Pin dependency versions that actually publish for the runtime.