- 1 year ago
Terraform external provider - jq in bash script is giving jq: command not found
If you're encountering the "jq: command not found" error when using the jq
command in a Terraform external provider script, it indicates that the jq
command-line tool is not installed or not accessible in the environment where the script is being executed.
To resolve this issue, you can take the following steps:
Install
jq
: Ensure thatjq
is installed on the machine where the Terraform script is being executed. The process for installingjq
can vary depending on your operating system. Here are a few examples:On Ubuntu/Debian:
sqlsudo apt-get update
sudo apt-get install jq
On CentOS/RHEL:
arduinosudo yum install epel-release
sudo yum install jq
On macOS (using Homebrew):
brew install jq
Check
jq
executable path: After installingjq
, ensure that thejq
executable is accessible from the location where the Terraform script is being executed. You can check the location of thejq
executable by running the command:bashwhich jq
It should return the path to the
jq
executable. If it doesn't return anything or returns an incorrect path, you may need to adjust the environment variables or update the system'sPATH
variable accordingly.Specify full path to
jq
: If thejq
executable is installed but not accessible via thePATH
variable, you can specify the full path to thejq
executable in your Terraform script. For example:hcldata "external" "example" {
program = ["/usr/bin/jq", "-n", "{ result: \"example output\" }"]
}
By following these steps, you should be able to resolve the "jq: command not found" error and successfully use the jq
command in your Terraform external provider script.