Error running command: exit status 1 (local-exec/remote-exec) Terraform Origin: Platform & cloud Last updated 5 Nov 2026

Terraform: Error: local-exec provisioner error — Error running command './deploy.sh': exit status 1. Output: ...

A local-exec/remote-exec provisioner command failed, so the resource is marked tainted.

Exact message you may see Error: local-exec provisioner errorError running command './deploy.sh': exit status 1Error: remote-exec provisioner errorError: error executing "/tmp/terraform_123.sh": Process exited with status 1Error running command: exit status 127 local-exec
Seen on: Terraform

Meaning

Run the command manually with the same environment to see the failure; the "Output:" lines show stdout/stderr. Check interpreter (interpreter = ["/bin/bash","-c"]), working dir, missing tools on the runner, exit codes, quoting, and secrets in env. Prefer null_resource/terraform_data with triggers or configuration tools (cloud-init, Ansible) over provisioners.

Common causes

  • Script exits non-zero (missing tool/permission)
  • Wrong working directory/relative path
  • Command quoting/interpreter differences (sh vs bash)
  • SSH connection for remote-exec not ready
  • Network/API failure inside the script

⚡ Quick fix

  1. Run the command manually in the same directory/env
  2. Set interpreter and working_dir; add set -euo pipefail
  3. Use cloud-init/user_data or Ansible instead of provisioners

Detailed fix by platform

Terraform

  1. provisioner "local-exec" { command = "./deploy.sh" interpreter = ["/bin/bash", "-c"] working_dir = path.module }

How to diagnose

  1. Output — Script error?
  2. Env — Same tools?
  3. Alternative — cloud-init?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: Platform & cloud. Errors that are often confused with or caused by this one (click to open):

AlreadyExists — Error from server (AlreadyExists): ... already exists (Kubernetes)AlreadyExistsError creating resource: already exists (needs import) — Terraform: Error: creating S3 Bucket (my-bucket): BucketAlreadyOwnedByYou / EntityAlreadyExists: Role with name x already exists (Terraform)Error creating resour…field is immutable — The Deployment is invalid: spec.selector: Invalid value: field is immutable (Kubernetes)field is immutableInvalid AWS Region — Terraform: Error: Invalid AWS Region: us-east-3 / Error: configuring Terraform AWS Provider: validating provider credentials: operation error STS: GetCallerIdentity (Terraform)Invalid AWS RegionNo valid credential sources found (AWS provider) — Terraform: Error: No valid credential sources found — failed to refresh cached credentials, no EC2 IMDS role found / Error: configuring Terraform AWS Provider: no valid credential sources (Terraform)No valid credential s…Provider produced inconsistent result after apply — Terraform: Error: Provider produced inconsistent result after apply — When applying changes to aws_x.y, provider produced an unexpected new value: Root resource was present, but now absent (Terraform)Provider produced inc…Resource is tainted and must be replaced — Terraform: # aws_instance.web is tainted, so must be replaced — -/+ destroy and then create replacement (Terraform)Resource is tainted a…timeout while waiting for state to become 'available' — Terraform: Error: waiting for RDS DB Instance create: timeout while waiting for state to become 'available' (last state: 'creating', timeout: 40m0s) (Terraform)timeout while waiting…Error run…

Explore the map of this error Full error map →

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.