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

**Code:** `Error running command: exit status 1 (local-exec/remote-exec)` · **Category:** Terraform · **Seen on:** Terraform

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

## 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?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/terraform/local-exec-provisioner-failed)
