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.
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 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
- Run the command manually in the same directory/env
- Set
interpreterandworking_dir; addset -euo pipefail - Use cloud-init/user_data or Ansible instead of provisioners
Detailed fix by platform
Terraform
provisioner "local-exec" { command = "./deploy.sh" interpreter = ["/bin/bash", "-c"] working_dir = path.module }
How to diagnose
- Output — Script error?
- Env — Same tools?
- 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:
Similar errors
- AlreadyExists Error from server (AlreadyExists): ... already exists
- Error creating resource: already exists (needs import) Terraform: Error: creating S3 Bucket (my-bucket): BucketAlreadyOwnedByYou / EntityAlreadyExists: Role with name x already exists
- field is immutable The Deployment is invalid: spec.selector: Invalid value: field is immutable
Most viewed in Terraform
- Error acquiring the state lock Terraform: Error: Error acquiring the state lock — ConditionalCheckFailedException / state blob is already locked
- Inconsistent dependency lock file Terraform: Error: Inconsistent dependency lock file — provider x: required by this configuration but no version is selected
- Reference to undeclared resource Terraform: Error: Reference to undeclared resource / Reference to undeclared input variable
Other ways to find it
Where this error sits
Origin: Platform & cloud. Errors that are often confused with or caused by this one (click to open):
🧠 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.
Report a correction or suggest an improvement
Last updated 5 Nov 2026