-
Notifications
You must be signed in to change notification settings - Fork 150
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ERROR: /hashicorp/terraform does not look like terraform #102
Comments
Hello @anthonycolon25, You have just found something that I haven't thought about. The document needs to be updated about this. First of all, your function is not correct :) You are trying to mount a volume to a path in the docker image that doesn't exist ( function terraform-compliance { docker run --rm -v $(pwd):/target -i -t eerkunt/terraform-compliance "$@"; } Normally this should work for you, assuming your terraform executable is living in In the document, it is currently written that you need to pass absolute path of terraform executable when you use POTENTIAL SOLUTIONS :
function terraform-compliance { docker run --rm -v $(pwd):/target -v /path/to/terraform/executable/directory:/terraform -i -t eerkunt/terraform-compliance "$@"; } and then run terraform compliance with ;
since
since I will find a better solution to this, meanwhile you can try one of these workarounds, or just install via |
Hi, Sorry for the confusion. I had the function in exactly that format originally (copied from github page) and got the same error. What I pasted was one of the iterations trying to get it to work. Here is my current folder structure (I'll clean it up later once I get things working) hashicorp I believe -v $(pwd):/target will map my current directory to /target on the container. So once that is done the paths I pass to the -p and -f arguments should include /target in the path. colon191818al:hashicorp abs123$ function terraform-compliance { docker run -v colon191818al:hashicorp abs123$ terraform-compliance -p /target/tc-test2/tf-template/plan.out -f /target/tc-test2/features -t /target/terraform . Converting terraform plan file. Also, if I put a bogus path to the terraform file I get a "No such file or directory" error. colon191818al:hashicorp abs123$ terraform-compliance -p /target/tc-test2/tf-template/plan.out -f /target/tc-test2/features -t /target/notthere/terraform . Converting terraform plan file. This leads me to believe that it is indeed finding the terraform file in /target/terraform but somehow is not able to use it. |
Ah of course. Possibly the operating systems compared with the Docker container and the host machine is different and the terraform that you use within your host machine is not compiled for the OS running in Docker container. I will embed different terraform versions within the Docker and also add into the $PATH within the Docker for avoiding this problem. Thanks a lot debugging this! As a workaround, you can convert your plan to
and give |
I see. That makes perfect sense. I am running on a Mac, so the terraform executable may not be compatible with Docker image OS. I have converted the output to the json format. It got further but now I get FATAL ERROR: Unsupported terraform version (0.12.2). $ terraform-compliance -p /target/tc-test2/tf-template/plan.out.json -f /target/tc-test2/features
. Running tests. FATAL ERROR: Unsupported terraform version (0.12.2). 2 features (0 passed) I get the same error on terraform 0.12.3. |
ah yes, I already tested that with those versions. #104 has this fix. |
Can you try with |
With 1.0.7 I am now able to run tests based on the json output. |
Thanks to @wp-davisona, |
Assuming this is fixed, please re-open the issue if this is not working for you. |
I am trying to use the 1.0.5 Docker image but I get the following error:
colon191818al:hashicorp abs123$ terraform-compliance -p /hashicorp/tc-test2/tf-template/plan.out -f /hashicorp/tc-test2/features -t /hashicorp/terraform
terraform-compliance v1.0.5 initiated
. Converting terraform plan file.
Using /hashicorp/terraform as terraform executable.
ERROR: /hashicorp/terraform does not look like terraform. Please give correct executable for "terraform".
[Errno 8] Exec format error: '/hashicorp/terraform'
colon191818al:hashicorp abs123$
I mapped the docker call to a function as follows:
colon191818al:hashicorp abs123$ function terraform-compliance { docker run -v$(pwd):/hashicorp -i -t eerkunt/terraform-compliance "$ @"; }
Terraform was added to my .profile so I can execute from anywhere:
colon191818al:hashicorp abs123$ terraform -version
Terraform v0.12.2
colon191818al:hashicorp abs123$ ls -al
total 106056
drwxr-xr-x 9 abs123 COMPANY\Domain Users 288 Jun 24 17:28 .
drwxr-xr-x+ 39 abs123 COMPANY\Domain Users 1248 Jun 24 18:48 ..
drwxr-xr-x 5 abs123 COMPANY\Domain Users 160 Jun 24 17:58 tc-test2
-rwxrwxr-x@ 1 abs123 COMPANY\Domain Users 54228088 Jun 12 20:12 terraform
Is Terraform v0.12.2 supported?
Thanks in advance for your help.
The text was updated successfully, but these errors were encountered: