Reputation: 83
Cannot initialize the Terraform module or even check version.
$ ls
main.tf output.tf variables.tf
$ terraform --v
env: 22:58:10: No such file or directory
$ rm -rf .terraform && terraform init
env: 23:43:38: No such file or directory
However, terraform is correctly installed
$ which terraform
/usr/local/bin/terraform
content of the terraform shell script
$ cat /usr/local/bin/terraform
#!/bin/bash
#set -x
DEFAULT_VERSION="0.12.24"
if [[ -z "$VERSION" ]]; then
TF_VERSION="$DEFAULT_VERSION"
else
TF_VERSION="$VERSION"
fi
VADDR=$(grep 'provider "vault"' *.tf --exclude-dir=modules -A2 | grep -P --color -o '(?<=address = ")(.*)(?=")')
if [ -n "$VADDR" ]; then
#echo "got vault addr $VADDR"
VAULT_CONFIG="VAULT_TOKEN=$(unset VAULT_TOKEN && VAULT_ADDR=$VADDR viq tokengen)"
#echo "got vault token $VAULT_CONFIG"
else
VAULT_CONFIG="dummyfoo=dummybar"
fi
env $VAULT_CONFIG /opt/terraform/v${TF_VERSION}/terraform $@ 2>&1 | \
sed -r -e 's/([ ]+)result:([ ]+)"[[:alnum:][:punct:]]+" => \
<computed>/\1result:\2<redacted> => <computed>/' \
-e 's/([ ]+)MasterUserPassword:([ ]+)"[^"]+"/\1MasterUserPassword:\2<redacted>/' \
| sed -r -e 's/"10MySqlPassword".*/"10MySqlPassword" = "****" -> <redacted>/g' \
| sed -r -e 's/API_KEY".*/API_KEY" = "****" -> <redacted>/g'
What's the problem here?
Upvotes: 0
Views: 12197
Reputation: 136
Thanks for answers, they helped me in my set up. However on my side, there was a bit different situation.
while installing tfenv, I used needed to use manual installation, and redirect PATH export to ~/.zshrc
instead ~/.bash_profile
.
terraform
command was working fine for me.
But did mistake on IDE config. Terraform executable path
setting. I needed to point exact binary file (.tfenv/bin/terraform
) instead directory only (.tfenv/bin
). Stupid mistake, mayby it will help some others :D
Upvotes: 0
Reputation: 1411
Please check if /usr/local/bin
is in your $PATH
. The $PATH
env
variable tells your system where to look for installed files.
$ echo $PATH
If it is not in your $PATH
, then add the directory to your $PATH
.
$ export PATH=$PATH:/usr/local/bin
Add the above line to your ~/.bashrc
(or equivalent) file to persist the change.
If it is in your path, then see if terraform
is working by trying to check the version while specifying the full path of the executable.
$ /usr/local/bin/terraform --v
Upvotes: 1