ERROR REFERENCE
Unable to upload artifact referenced by CodeUri
A CodeUri, ContentUri, or
DefinitionUri in the template points at a path that does
not exist where the deploy ran. The classic cause: deploying before
sam build, or deploying the source template instead of
the built one.
WHAT IT MEANS
What this error means
Unable to upload artifact ... referenced by CodeUri parameter of ... resourceParameter CodeUri of resource ... refers to a file or folder that does not exist
The template is fine and AWS was never the problem - the referenced path simply is not there. In CI this usually means the build step did not run, ran in a different working directory, or its output was not carried into the job that deploys.
FIX
How to fix it
-
Build, then deploy the built template:
Passingsam build sam deploy # uses .aws-sam/build/template.yaml automatically-t template.yamlto deploy after building reintroduces the source paths and this error with it. -
In CI, keep build and deploy in one job and one
directory — or explicitly hand the
.aws-sam/build/output between jobs as an artifact. -
Verify the path exists where the deploy runs:
ls .aws-sam/build/ && ls .aws-sam/build/template.yaml
AUTOMATE THE TRIAGE
Diagnose this automatically
SAM Doctor recognizes both phrasings (high confidence) and separates this local-path failure from the S3 access failures it superficially resembles. Runs locally; no AWS access, no log upload.
python -m pip install sam-doctor
sam-doctor diagnose deployment.log --format markdown
RELATED
Related errors
- S3 error: Access Denied (deployment bucket) — when the artifact exists but the bucket says no.
- Cannot connect to the Docker daemon — a build step that silently never produced artifacts.