AWS SAM CLI Errors Fixed: "Build Succeeded" With No Code, "Requires a Container Runtime", Binary Validation Failed, Missing --stack-name and sam deploy Credentials

Logeshwaran
—

Most AWS SAM CLI errors come from three commands and a handful of causes. sam build fails when the runtime in your template is not installed on your machine (Binary validation failed for python) or a dependency cannot be installed (PythonPipBuilder:ResolveDependencies); sam local fails when no container runtime is running (Running AWS SAM projects locally requires a container runtime. Do you have Docker or Finch installed and running?); and sam deploy fails on credentials, a missing --stack-name, S3 options or capabilities. The surprise that costs the most time is a failure SAM does not report: if the CodeUri in your template points to a folder that does not exist, sam build prints "Skipping copy operation since source ... does not exist" and then "Build Succeeded". You deploy a function with no code, and the first invoke fails with "Unable to import module". The fixes are short: install the runtime or build with --use-container, start Docker or Finch, run sam deploy --guided once to save your settings in samconfig.toml, and read the build output, not just its last line. Every error message below is quoted as SAM CLI 1.169 prints it, with the exact fix.

Ethan was moving the shop's reminder texts from a cron job on the back-office PC to a Lambda function, built with SAM. The first sam build said Build Succeeded, the deploy went through, and every reminder failed overnight with No module named 'app'. "It said succeeded," Jake pointed out. "It said succeeded at building nothing," Ethan said, scrolling up to a line he had skipped: Skipping copy operation since source ... does not exist. He had typed reminder/ in the template and named the folder reminders/. This page is every SAM error Ethan met that week, and the one it never showed.

⚡ Quick Answer

• "Build Succeeded" but no code: the CodeUri folder does not exist; look for "Skipping copy operation". The silent failure.

• Binary validation failed: install that runtime version, or run sam build --use-container. Runtime fix.

• "Requires a container runtime": start Docker or Finch before sam local. Docker fix.

• Missing --stack-name: run sam deploy --guided once; it saves samconfig.toml. Deploy errors.

• Unable to locate credentials: configure a profile or SSO login, or pass --profile. Credentials.

All errors at a glance · Dependencies · sam local · samconfig.toml · Installing and upgrading · CI.

New to SAM? The AWS Serverless Application Model is a shorter way to write CloudFormation templates for serverless apps, plus a command-line tool. sam build packages your Lambda code and dependencies into .aws-sam/build, sam local runs functions and APIs on your machine in containers that imitate Lambda, and sam deploy uploads the build and creates or updates a CloudFormation stack.

🧭 NEW HERE? READ THESE FIRST

New to Lambda, CloudFormation or AWS credentials? These five pages cover the basics this fix builds on:

💡 Run sam --version first; several errors only exist in old versions of the CLI.

Every common SAM CLI error at a glance

MessageCommandCauseFix
Skipping copy operation since source ... does not exist, then Build Succeededsam buildCodeUri points to a missing folderFix the path
requirements.txt file not found. Continuing the build without dependencies.sam buildNo requirements file in the code folder (or a wrong folder)Add it next to the handler
PythonPipBuilder:Validation - Binary validation failed for pythonsam buildThe template's runtime version is not on your PATHInstall it, or --use-container
PythonPipBuilder:ResolveDependencies - Could not satisfy the requirementsam buildA package or version that pip cannot find for that runtimeFix the requirement
Running AWS SAM projects locally requires a container runtime. Do you have Docker or Finch installed and running?sam localNo Docker or Finch, or it is not runningStart one
Template file not found at .../template.ymlanyWrong folder, or a differently named templatecd to the project or pass -t
Missing option '--stack-name'sam deployNo stack name on the command line or in samconfig.tomlsam deploy --guided once
Unable to locate credentials / Failed to create managed resourcessam deployNo AWS credentials for this shell or profileConfigure, log in, or --profile
Cannot use both --resolve-s3 and --s3-bucket parameters in non-guided deploymentssam deployBoth options given (often one is in samconfig.toml)Keep one
Security Constraints Not Satisfiedsam deploy --guidedYou answered N to "may not have authorization defined"Add auth, or answer Y
No such command 'remote'sam remote invokeSAM CLI older than 1.88.0Upgrade

The silent one: "Build Succeeded" with no code in it

This is what sam build prints when the template says CodeUri: helo/ but the folder is called hello/:

Building codeuri: /home/ethan/sam-app/helo runtime: python3.13 architecture: x86_64 functions: HelloFunction
requirements.txt file not found. Continuing the build without dependencies.
 Running PythonPipBuilder:CopySource
Skipping copy operation since source /home/ethan/sam-app/helo does not exist
Build Succeeded

Nothing is wrong as far as the command is concerned, so it exits successfully, and sam deploy happily uploads a function package with no handler file. You find out at the first invocation, when Lambda reports Runtime.ImportModuleError: Unable to import module 'app': No module named 'app' (our import module guide covers the other causes of that error).

It is easy to see how this happens in real projects: a folder renamed during a tidy-up, a template copied from another project, or a path written with a capital letter on a case-sensitive file system. Three habits make this impossible to miss:

  • Read the build output for "Skipping" and "not found", not just the last line. In CI, fail the job if those words appear: sam build 2>&1 | tee build.log; ! grep -E "Skipping copy operation|file not found" build.log.
  • Look inside the artifact: ls .aws-sam/build/HelloFunction should list your handler file and dependencies. If the folder is missing or empty, the build did nothing.
  • Test locally before deploying: sam local invoke HelloFunction fails immediately with the import error, long before customers notice.

The same silence applies to a misnamed requirements.txt (or one in the wrong folder): SAM notes it and continues without dependencies, and the function fails at runtime with "No module named" for the package instead.

"Binary validation failed for python": the runtime is not on your machine

Build Failed
Error: PythonPipBuilder:Validation - Binary validation failed for python, searched for python in following
locations  : ['/usr/bin/python', '/bin/python', '/usr/bin/python3', '/bin/python3'] which did not satisfy
constraints for runtime: python3.12. Do you have python for runtime: python3.12 on your PATH?

A plain sam build builds with the language tools installed on your machine, and it insists on the exact version in the template. On a machine with only Python 3.13 and 3.14 installed, a template saying Runtime: python3.12 fails like this. Node.js (NodejsNpmBuilder), Java and .NET builders fail the same way when their version is missing. You have three ways out:

  1. Install that version and make sure it is on your PATH as python3.12 (pyenv, the python.org installer, or your package manager), then build again.
  2. Build in a container with sam build --use-container, which uses a build image matching the Lambda runtime, so your machine's versions no longer matter. It needs Docker or Finch running, and the first build downloads the image.
  3. Change the template to a runtime you have, if your code supports it, for example python3.13.

--use-container is also the right choice when your dependencies include compiled code (database drivers, image libraries, cryptography): it compiles them for Amazon Linux, the environment Lambda runs, instead of for your laptop. A package built on a Mac or Windows machine and deployed as is often fails with "invalid ELF header" or an import error on Lambda.

Dependency errors: ResolveDependencies and friends

Running PythonPipBuilder:ResolveDependencies
Build Failed
Error: PythonPipBuilder:ResolveDependencies - Could not satisfy the requirement: requestz-not-a-package==9.9.9

pip could not find that package and version for the target runtime and architecture. Check, in order:

  • Spelling and version in requirements.txt: the example above is a typo for requests.
  • Python version support: a pinned version too old for the runtime (no wheels for Python 3.13) fails the same way. Try the version that supports your runtime.
  • Architecture: with Architectures: [arm64], a package without ARM wheels may fail to resolve; --use-container builds it in the right environment.
  • Private package indexes: pip inside the build needs the same index settings you use; pass them with --container-env-var for container builds, or a pip.conf.
  • Network: behind a proxy, set HTTPS_PROXY for the build.

For Node.js and TypeScript, SAM can bundle with esbuild when the function has Metadata: BuildMethod: esbuild; esbuild must then be installed (globally or in the project), or the build fails before it starts. For anything unusual, a Makefile with BuildMethod: makefile lets you run your own build steps.

Which builder SAM uses for your runtime

The word before the colon in a build error (PythonPipBuilder, NodejsNpmBuilder...) names the builder that failed, which tells you which tool on your machine to check. SAM picks the builder from the function's runtime, or from Metadata: BuildMethod when you set one:

Runtime or BuildMethodBuilder in the errorNeeds on your machine (without --use-container)
python3.xPythonPipBuilderThat exact Python version and pip; requirements.txt in CodeUri
BuildMethod: python-uvPythonUvBuilderuv, for projects managed with uv
nodejsNN.xNodejsNpmBuilderNode.js and npm; package.json
BuildMethod: esbuildNodejsNpmEsbuildBuilderNode.js, npm and esbuild (for TypeScript and bundling)
javaNNJavaGradleWorkflow or JavaMavenWorkflowA JDK plus Gradle or Maven, picked by build.gradle or pom.xml
dotnetN / BuildMethod: dotnetDotnetCliPackageBuilderThe .NET SDK and Amazon.Lambda.Tools
rubyN.NRubyBundlerBuilderRuby and Bundler; Gemfile
provided.al2023 with GoGoModulesBuilderGo; go.mod
BuildMethod: rust-cargolambdaRustCargoLambdaBuilderRust and cargo-lambda
BuildMethod: makefileCustomMakeBuildermake, and a build-FunctionLogicalId target in your Makefile

Layers are built the same way, with one extra rule: a layer that SAM should build needs a Metadata: BuildMethod (for example python3.13), or the build stops with Build method missing in layer .... Layers you build yourself can skip sam build by pointing ContentUri at a ready-made folder or zip.

Node.js and TypeScript build errors

The Node.js builders have their own error messages when the tools are missing. Without npm on the PATH, a function with Runtime: nodejs22.x stops at once:

Build Failed
Error: NodejsNpmBuilder:Resolver - Path resolution for runtime: nodejs22.x of binary: npm was not successful

And a function with Metadata: BuildMethod: esbuild reports the same root cause differently:

Build Failed
Error: Esbuild Failed: The esbuild workflow couldn't find npm installed on your system.

Install Node.js (which brings npm) in the major version your runtime names, then, for esbuild functions, add esbuild to the project (npm install --save-dev esbuild) or install it globally. If you cannot or do not want to install Node.js locally, sam build --use-container builds inside the Lambda build image, which has them. For TypeScript, make sure BuildProperties: EntryPoints lists the .ts file you export the handler from, and that the handler in the template matches the bundled output name (for an entry point app.ts, the handler is app.handler).

"Unzipped size must be smaller than..." after a successful build

Big dependencies pass sam build and then fail at deploy. Lambda limits a zip-packaged function, including its layers, to 250 MB unzipped, and the CloudFormation update fails with a message saying the unzipped size must be smaller than 262,144,000 bytes. Data science packages (numpy, pandas, scipy, scikit-learn), headless browsers and machine learning libraries reach that quickly. You have four options:

  • Trim the package: remove test files, docs and unused extras; keep development tools (pytest, linters, boto3 itself, which the runtime already provides) out of requirements.txt.
  • Move shared libraries to a layer, which helps when several functions share them, though the 250 MB limit counts function and layers together.
  • Use a container image (PackageType: Image), which allows up to 10 GB.
  • Split the function so the heavy part runs only where it is needed.

Starting fresh with sam init

When a project is in an unknown state, generating a known-good one next to it is often faster than debugging: sam init --runtime python3.13 --dependency-manager pip --app-template hello-world --name sam-check --no-interactive creates a working project in the official layout, cloned from AWS's app templates repository. Leave out any of those options with --no-interactive and SAM stops with a list of what it needs:

Error: Missing required parameters, with --no-interactive set.
Must provide one of the following required parameter combinations:
	--name, --location
	--name, --package-type, --base-image
	--name, --runtime, --dependency-manager, --app-template

(Run sam init without --no-interactive to be asked for each value instead.) Build and invoke it once. If it works, the problem is in your project (template paths, handler names, requirements); if it fails the same way, the problem is your machine (runtime versions, Docker, credentials). Then copy your function code into the fresh project, which also gives you an up-to-date template structure.

Windows-specific SAM problems

  • Quoting in PowerShell: values with spaces or special characters in --parameter-overrides need care; wrap the whole list in single quotes, for example sam deploy --parameter-overrides 'Stage=prod AlertEmail=ops@example.com', or put them in samconfig.toml and avoid quoting entirely.
  • Long paths: deep node_modules or Python packages can pass Windows' path limit and produce FileNotFoundError; enable long paths or move the project closer to the drive root.
  • Line endings: shell scripts copied into a function or used in a makefile build fail on Linux if they have Windows line endings; set your editor or Git to keep them as LF.
  • Docker Desktop with WSL 2: sam local works from both PowerShell and WSL, but mixing the two (a project on the Windows drive, run from WSL) is slow; keep the project in the environment you run SAM from.

"Requires a container runtime": sam local without Docker

$ sam local invoke HelloFunction
Error: Running AWS SAM projects locally requires a container runtime. Do you have Docker or Finch installed and running?

Older SAM CLI versions word it as Running AWS SAM projects locally requires Docker. Have you got it installed?; the cause is the same. Everything under sam local (invoke, start-api, start-lambda) runs your function inside a container that imitates Lambda, so it needs a container runtime that is installed and running:

  • Windows and macOS: install Docker Desktop (or Finch, which SAM supports too) and start it; the error appears whenever the app is closed.
  • Linux: install Docker Engine and make sure the daemon runs (sudo systemctl start docker). If you see Cannot connect to the Docker daemon, add your user to the docker group and log in again (on an EC2 instance, a reboot may be needed).
  • Remote or rootless runtimes: if your Docker-compatible engine listens somewhere unusual, set DOCKER_HOST to its socket so SAM can find it.
  • WSL 2: enable Docker Desktop's WSL integration for your distribution, or run Docker inside it.

Check with docker info (or finch info): if that fails, SAM will too. On a company laptop where Docker Desktop is not allowed, Finch (an open-source container tool from AWS) is a common way to get sam local working without it. sam build without --use-container and sam deploy do not need Docker at all, so you can still deploy from a machine without it.

Other sam local problems

Once the container runtime works, a few behaviors confuse people:

  • Changes do not show up: if you ran sam build, sam local runs the built copy in .aws-sam/build. Run sam build again after code changes; restart sam local start-api only after template changes.
  • The first invoke is slow: SAM pulls the runtime image ("Local image is out of date and will be updated"). Later runs are faster; --skip-pull-image skips the check, and --warm-containers eager keeps containers running between requests.
  • The API returns "Missing Authentication Token": the path or method in your request does not match the template. sam local start-api lists the mounted routes, such as http://127.0.0.1:3000/hello [GET]; call exactly that. Our Missing Authentication Token guide covers the deployed version of this error.
  • Environment variables are missing: pass them with --env-vars locals.json, a JSON file keyed by function logical ID.
  • You need a realistic event: sam local generate-event s3 put (or sqs, apigateway and many more) prints a sample you can save and pass with --event.

sam local talking to local databases and services

A function running under sam local lives in its own container, so localhost inside the function is the container, not your laptop. If your function calls a DynamoDB Local, a Postgres or any service you run in Docker on your machine, two options let it reach them:

  • Share a Docker network: run the database container on a named network (docker network create sam-dev, then start it with --network sam-dev --name dynamodb-local), and start SAM with sam local invoke --docker-network sam-dev (or start-api). The function then reaches the database by its container name, for example http://dynamodb-local:8000.
  • Map a hostname: --add-host passes a hostname-to-IP mapping into the function's container, useful for reaching a service on your host machine by a fixed name.

Pass the endpoint to your code through an environment variable in --env-vars, so the same code uses the local database under SAM and the real one in AWS. Our DynamoDB Local guide covers running the database side, including the "could not connect" error you get when containers are on different networks.

sam deploy errors: stack name, S3 bucket and prompts

"Missing option '--stack-name'". A plain sam deploy needs a stack name and an S3 location for artifacts, from the command line or from samconfig.toml. The message itself suggests the easiest fix:

Error: Missing option '--stack-name', 'sam deploy --guided' can be used to provide and save needed parameters for future deploys.

Run sam deploy --guided once: it asks for the stack name, Region, parameters and confirmations, and offers to save the answers in samconfig.toml. From then on, plain sam deploy works.

"Cannot use both --resolve-s3 and --s3-bucket". --resolve-s3 tells SAM to create and use a managed bucket; --s3-bucket names your own. Use one. The conflict often comes from resolve_s3 = true already saved in samconfig.toml while a script also passes --s3-bucket.

"Security Constraints Not Satisfied". During a guided deploy, SAM asks Function may not have authorization defined, Is this okay? [y/N] for any API without authorization. The default answer N stops the deploy. Add authorization to the API (a Cognito, Lambda or IAM authorizer) or, if a public endpoint is what you want, deploy again and answer Y.

Capabilities, no changes, rollbacks. Three CloudFormation errors appear through sam deploy and have their own guides: Requires capabilities: [CAPABILITY_IAM] (capabilities guide), No changes to deploy. Stack is up to date (no updates guide; note that sam deploy returns a non-zero exit code for an empty change set unless you pass --no-fail-on-empty-changeset), and a first deploy ending in ROLLBACK_COMPLETE (rollback guide).

"Unable to locate credentials" and other credential errors

Error: Unable to locate credentials

SAM uses the same credential chain as the AWS CLI and boto3. The error means none was found for this shell: no environment variables, no default profile, no SSO session. Fix it the way you would for the AWS CLI:

  1. Check what SAM would use: aws sts get-caller-identity (with --profile NAME if you use one). If this fails, SAM fails.
  2. For IAM Identity Center, sign in: aws sso login --profile NAME (our SSO profile guide covers setup).
  3. Pass the same profile to SAM: sam deploy --profile NAME, or save profile = "NAME" in samconfig.toml under the deploy parameters.
  4. In CI, give the job a role through OIDC rather than stored keys (our GitHub Actions OIDC guide).

The guided deploy's first message, Failed to create managed resources: Unable to locate credentials, is the same problem appearing at the step where SAM creates its managed artifact bucket. No current session found, using default AWS::AccountId during sam local is only a warning: local runs do not need credentials unless your code calls AWS.

A minimal SAM project that builds and deploys cleanly

When nothing works and you are not sure which piece is wrong, start from a project you know is right and add your code to it. This layout and template build and deploy as they are:

shop-reminders/
├── template.yaml
├── samconfig.toml          (written by sam deploy --guided)
└── reminders/
    ├── app.py              (def handler(event, context): ...)
    └── requirements.txt

# template.yaml
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Resources:
  ReminderFunction:
    Type: AWS::Serverless::Function
    Properties:
      CodeUri: reminders/
      Handler: app.handler
      Runtime: python3.13
      Architectures: [arm64]
      Timeout: 30
      Events:
        Nightly:
          Type: ScheduleV2
          Properties:
            ScheduleExpression: cron(0 18 * * ? *)

Then, in order:

  1. sam validate --lint: the template is valid.
  2. sam build (or sam build --use-container): read the output; there must be no "Skipping copy operation" line.
  3. ls .aws-sam/build/ReminderFunction: app.py and your dependencies are there.
  4. sam local invoke ReminderFunction: the function runs locally (needs Docker or Finch).
  5. sam deploy --guided the first time, plain sam deploy afterwards.
  6. sam logs -n ReminderFunction --stack-name shop-reminders --tail while you trigger it once in the cloud.

The two lines people get wrong most in templates are CodeUri, which must name the folder holding the handler file, and Handler, which is the file name without extension, a dot, then the function name. With reminders/app.py defining handler, that is CodeUri: reminders/ and Handler: app.handler.

samconfig.toml: what it saves and how environments work

The configuration file lives next to your template and saves command options so you do not retype them. A typical one, written by sam deploy --guided and edited by hand:

version = 0.1

[default.global.parameters]
stack_name = "shop-reminders"

[default.build.parameters]
cached = true
parallel = true

[default.deploy.parameters]
capabilities = "CAPABILITY_IAM"
confirm_changeset = true
resolve_s3 = true
region = "us-east-1"

[prod.deploy.parameters]
stack_name = "shop-reminders-prod"
confirm_changeset = false
resolve_s3 = true
region = "us-east-1"

The rules: the top level is an environment (default unless you pass --config-env prod), then the command (build, deploy, local_start_api, or global for all), then parameters. Option names drop the leading dashes and use underscores instead of hyphens (--resolve-s3 becomes resolve_s3). Command-line options override the file. Many "it works on my machine" SAM problems are a value saved in samconfig.toml that a teammate does not have, or the other way round, so commit the file with the project.

Installing, upgrading and version errors

  • Use the native installers: the MSI on Windows, the .pkg on macOS (x86_64 or arm64 for Apple silicon), the zip installer on Linux. Check with sam --version.
  • Upgrade the way you installed: on Linux, the same installer with --update (sudo ./sam-installation/install --update); on Windows and macOS, the new installer. Mixing methods leaves two copies on your PATH.
  • pip installs can break: installing aws-sam-cli with pip next to other tools can produce ERROR: pip's dependency resolver ... conflicts with aws-sam-translator. Use the native installer, or install with pip into its own virtual environment.
  • Homebrew: AWS stopped maintaining the Homebrew installer in September 2023; a community-managed formula exists, but the supported route is the .pkg.
  • Windows FileNotFoundError during builds can come from paths longer than Windows' limit; enable long paths in Windows, or move the project to a shorter path such as C:\src\app.
  • Missing commands: No such command 'remote' means a version older than 1.88.0, which introduced sam remote invoke. Newer commands need newer CLIs, so upgrade before you search for anything else.

Running SAM in CI without surprises

A build-and-deploy job that avoids most of the errors above:

sam --version
sam validate --lint
sam build --use-container 2>&1 | tee build.log
! grep -E "Skipping copy operation|file not found" build.log
sam deploy --config-env prod --no-confirm-changeset --no-fail-on-empty-changeset

If you deploy several stacks from one repository, run this block once per stack with its own --config-env, and keep the environments in one committed samconfig.toml so every runner and every teammate deploys with the same settings. Each line has a job: the version line makes logs comparable, validate --lint catches template mistakes before building, the container build makes the result independent of the runner's installed languages, the grep fails the job on the silent "nothing was built" case, and the deploy flags stop it from waiting for a prompt or failing when nothing changed. The runner needs Docker for --use-container; on GitHub-hosted Linux runners it is available.

Container image functions: the extra deploy settings

Functions packaged as container images (PackageType: Image) build with your Dockerfile, so sam build always needs Docker or Finch for them, and the function's Metadata must name the Dockerfile, DockerContext and DockerTag. At deploy time SAM must also know where to push the image. Either let SAM create and manage repositories with --resolve-image-repos, or map each function to an existing Amazon ECR repository with --image-repositories HelloFunction=111122223333.dkr.ecr.us-east-1.amazonaws.com/hello. A guided deploy asks and saves the answer in samconfig.toml. If the push itself is refused, the ECR side is covered in our ECR permission guides; the usual cause is that the identity running sam deploy lacks ecr:InitiateLayerUpload and related actions on that repository.

Catch template mistakes before building: sam validate and --lint

sam validate checks that the template is valid SAM, and says so in a single line, adding a hint you should take: ... is a valid SAM Template. This is according to basic SAM Validation, for additional validation, please run with "--lint" option. Basic validation catches structure errors, not wrong values. sam validate --lint runs cfn-lint over the template and also flags things such as a runtime that Lambda no longer supports, a property that does not exist on a resource type, or a reference to a resource that is not defined. It does not check that a CodeUri folder exists, which is why the build log check above still matters. Run both before every deploy; they take seconds and catch problems that otherwise appear halfway through a CloudFormation update.

Getting more detail: --debug, sam logs and sam delete

  • --debug on any SAM command prints every step, the exact commands builders run (pip, npm, docker) and the AWS calls SAM makes. When an error message is vague, the line just before the failure in the debug output usually names the real problem.
  • sam logs reads a deployed function's CloudWatch logs from your terminal: sam logs -n HelloFunction --stack-name shop-reminders --tail follows them live, and -s '10min ago' starts from a point in time. It is the fastest way to see the "No module named" error after a deploy.
  • sam delete removes the stack and the artifacts SAM uploaded for it: sam delete --stack-name shop-reminders (add --no-prompts in scripts). It is the clean way to remove a test stack, instead of deleting the CloudFormation stack by hand and leaving artifacts behind.

One more behavior worth knowing for sam local: when your function calls AWS services during a local run, it uses the credentials of your shell or the --profile you pass, not the function's execution role. A local run can therefore succeed (you are an administrator) where the deployed function fails with access denied (its role lacks the permission), so test permissions in the cloud too.

When Lambda retires your runtime

Lambda deprecates old language versions on a published schedule, and SAM projects tend to outlive them. The symptoms appear in SAM in three places: sam validate --lint warns that the runtime is deprecated, sam build may fail because the old version is no longer installed on your machine (the binary validation error above), and sam deploy can be refused by Lambda once creating or updating functions on that runtime is blocked. The fix is the same each time (our runtime no longer supported guide lists the dates): change Runtime in the template to a supported version (for example python3.13 or nodejs22.x), update dependencies that pinned old versions, run your tests, then build and deploy. Check every function and layer in the template, including CompatibleRuntimes on layers, and the Globals section, where a runtime set for all functions hides in plain sight.

Let SAM write the CI pipeline: sam pipeline

If you are setting up CI from scratch, SAM can generate it. sam pipeline bootstrap creates the AWS resources a pipeline needs for each stage (an artifacts bucket, roles for the pipeline to assume and, for image functions, an ECR repository), and sam pipeline init writes a pipeline definition for the CI system you choose, such as GitHub Actions, GitLab CI, Jenkins, Bitbucket or AWS CodePipeline, with build, test and deploy steps already wired. Review what it generates (role permissions in particular) before you commit it, then adjust the build step to include the log check from the section above.

SAM vs CDK vs the Serverless Framework

If SAM keeps fighting you, it is fair to ask whether it is the right tool. SAM is a thin layer over CloudFormation in YAML, best for small and medium serverless apps where you want templates close to what AWS deploys and good local testing. The AWS CDK writes the same CloudFormation from TypeScript, Python, Java or other languages, which suits larger apps and teams who prefer code to YAML (our CDK tutorial compares them); you can still use sam local against a CDK app's synthesized template. The Serverless Framework is a third-party tool with its own configuration format and plugins. Errors in all three end up as CloudFormation errors in the end, so the deploy-side fixes on this page carry over.

sam sync and sam remote invoke: faster loops, new errors

Two newer commands change the day-to-day loop. sam sync --stack-name NAME --watch pushes code changes straight to the deployed function without a full CloudFormation update, which is quick for development stacks; it prints a warning because it can make the deployed stack differ from the template, so never point it at production. sam remote invoke calls a deployed function from your terminal; with a single function, give it --stack-name, and if you pass a function ARN while samconfig.toml also has a stack name, SAM treats the ARN as a logical ID and reports that it cannot find the resource, so pass the logical ID instead.

SAM CLI troubleshooting, by symptom

Build Succeeded, but the function fails with "No module named"

The CodeUri folder or requirements.txt was not found and SAM skipped it. Look for "Skipping copy operation" or "file not found" in the build output and fix the path.

Binary validation failed for python (or nodejs)

The exact runtime version in the template is not installed on your PATH. Install it, or build with sam build --use-container.

sam local says it requires a container runtime

Docker or Finch is not installed or not running. Start it and check with docker info.

Cannot connect to the Docker daemon (Linux)

The daemon is stopped or your user cannot use it. Start Docker and add your user to the docker group, then log in again.

Missing option '--stack-name'

No stack name was given or saved. Run sam deploy --guided once and save the answers to samconfig.toml.

Unable to locate credentials

No credentials for this shell or profile. Check aws sts get-caller-identity, sign in with SSO, and pass --profile to SAM.

Cannot use both --resolve-s3 and --s3-bucket

One option is on the command line and the other in samconfig.toml. Keep only one of them.

NodejsNpmBuilder: path resolution of binary npm was not successful

npm is not installed or not on your PATH. Install Node.js in the runtime's major version, or build with --use-container.

Build method missing in layer

A layer that SAM builds needs Metadata with a BuildMethod, such as python3.13. Add it, or point ContentUri at a ready-built layer.

"Missing required parameters, with --no-interactive set" from sam init

Non-interactive init needs a full set of options, such as --name, --runtime, --dependency-manager and --app-template. Add the missing ones or drop --no-interactive.

Deploy fails because the unzipped size is too large

Function plus layers exceed 250 MB unzipped. Trim dependencies, move shared ones to a layer, or package the function as a container image.

My code changes do not appear in sam local

sam local runs the built copy. Run sam build again, or skip sam build while iterating locally.

Compiled dependencies fail on Lambda but work locally

They were built for your laptop, not Amazon Linux. Rebuild with sam build --use-container.

AWS SAM CLI errors: frequently asked questions

Why does sam build say Build Succeeded when my code is missing?

If CodeUri points to a folder that does not exist, SAM skips the copy and still reports success. Check the build output for "Skipping copy operation" and look inside .aws-sam/build.

How do I fix "Binary validation failed for python" in sam build?

Install the Python version named in the template's Runtime and make it available on your PATH, or build with sam build --use-container.

Does sam local need Docker?

Yes, or Finch. sam local invoke, start-api and start-lambda run functions in containers, so a container runtime must be installed and running.

What does "Running AWS SAM projects locally requires a container runtime" mean?

SAM could not find a running Docker or Finch. Install one, start it, and check with docker info before running sam local again.

What does sam build --use-container do?

It builds your function inside a container image that matches the Lambda runtime, so your machine's language versions do not matter and compiled dependencies work on Lambda.

How do I fix "Missing option --stack-name" in sam deploy?

Pass --stack-name, or run sam deploy --guided once and save the settings to samconfig.toml so plain sam deploy works afterwards.

What is samconfig.toml?

SAM's configuration file next to your template. It saves options per environment and command, such as the stack name, Region, capabilities and S3 settings.

How do I use different settings for dev and prod in SAM?

Add environments to samconfig.toml, such as [prod.deploy.parameters], and pick one with --config-env prod.

What does --resolve-s3 do in sam deploy?

It creates and uses a SAM-managed S3 bucket for deployment artifacts. Do not combine it with --s3-bucket in non-guided deployments.

How do I fix "Unable to locate credentials" in SAM?

Configure credentials as for the AWS CLI: aws configure, aws sso login, or environment variables, and pass --profile if you use a named profile.

What does "Security Constraints Not Satisfied" mean?

You answered no when SAM warned that an API has no authorization. Add an authorizer, or deploy again and answer yes if a public API is intended.

Why does sam deploy fail when there are no changes?

By default it returns a non-zero exit code for an empty change set. Add --no-fail-on-empty-changeset in scripts and CI.

How do I upgrade the AWS SAM CLI?

Use the same method you installed with: the new MSI or pkg installer, or the Linux installer with --update.

Why is the sam local first run so slow?

SAM downloads the Lambda runtime image the first time. Later runs reuse it; --skip-pull-image skips the update check.

How do I pass environment variables to sam local invoke?

Put them in a JSON file keyed by the function's logical ID and pass it with --env-vars.

What does "No such command remote" mean in SAM?

Your SAM CLI is older than 1.88.0, which added sam remote invoke. Upgrade the CLI.

For readers preparing for an AWS certification

We have been covering AWS certifications alongside our fixes, so here is a short extra for readers studying for one. If you only came for the fix, you already have it; feel free to skip this part.

Exams that test this topic: Developer – Associate (DVA-C03 from December 1, 2026) • DevOps Engineer – Professional (DOP-C02) • CloudOps Engineer – Associate (SOA-C03).

Here are the exam-style questions this topic tends to raise, with the reasoning you need to answer them:

1. A developer must test a Lambda function and API locally before deploying with AWS SAM. What is required on the workstation?

The AWS SAM CLI and a container runtime such as Docker or Finch, because sam local runs functions in Lambda-like containers.

2. sam build fails because the Python version in the template is not installed locally, and compiled dependencies must match Lambda. Which option solves both?

sam build --use-container, which builds inside an image matching the Lambda runtime.

3. A team wants plain sam deploy to work without retyping the stack name, Region and options. What should they use?

Run sam deploy --guided once and save the settings in samconfig.toml, optionally with separate environments selected by --config-env.

4. A CI pipeline fails when sam deploy finds no changes. Which flag prevents this?

--no-fail-on-empty-changeset.

5. Which command reads a deployed function's CloudWatch logs from the terminal in a SAM project?

sam logs -n FunctionLogicalId --stack-name STACK --tail.

6. sam build reports success but the deployed function fails with Unable to import module. What should be checked first?

That CodeUri points to the folder containing the handler; SAM skips a missing source folder without failing the build.

Exam codes and dates change often. Our AWS certification changes page keeps track of what is current.

The reminders went out the next evening, after Ethan renamed the folder, rebuilt, checked .aws-sam/build with his own eyes, and ran one sam local invoke with a sample event. He also added the grep line to the shop's deploy script. Jake asked whether SAM would ever say "succeeded" about nothing again. "It will," Ethan said. "But now the script reads the small print for me."

📌 If you keep one line from this page

Read sam build's output for "Skipping copy operation" (a wrong CodeUri still says Build Succeeded), build with --use-container when runtimes or compiled packages differ, start Docker or Finch before sam local, and run sam deploy --guided once so samconfig.toml remembers the rest.

Messages as printed by SAM CLI 1.169 · sam remote invoke needs 1.88+ · --no-fail-on-empty-changeset for CI.

Revision note. Written October 22, 2026, with AWS SAM CLI 1.169 behavior and messages of that date. "All that glitters is not gold," the proverb says; with sam build, not every "Succeeded" is a build.

Related