Comments (8)
I think I found root cause for the above error...
The below code in terraform_files.py returns None for terraform_executable
def convert_terraform_plan_to_json(terraform_plan_file, terraform_executable=None):
print('. Converting terraform plan file.')
if terraform_executable is None:
terraform_executable = which('terraform')
hence its failing when the code tries to convert the plan file to json
so, next instead of testing the terraform plan file, I created the terraform state file and then ran the terraform-compliance tests, it worked properly..
Question : has anybody tested terraform-compliance 1.0.1 in windows with out any issues?
it looks like to me that in windows, the python which function not working hence returning None when executed the code: terraform_executable = which('terraform')
Please let me know. Thanks!
from cli.
Thanks for the issue!
I haven't tested the code on Windows, unfortunately. This might be an OS specific bug, too.
Found the problem, fixing.
from cli.
Before I release the fix, to have a workaround, after you create your plan.out
, convert it with terraform like terraform show -json plan.out > plan.out.json
. Then you can pass plan.out.json
(or whatever file you created) to terraform-compliance
I will also fix the convertion part where it won't require to do this.
from cli.
Can you try the same behaviour with 1.0.2
please ?
from cli.
Hi @eerkunt ,
Thanks for the quick response!
-
First I have tried your workaround, i.e. convert plan.out with terraform like terraform show -json plan.out > plan.out.json. Then pass plan.out.json (or whatever file you created) to terraform-compliance
and it worked :) -
I installed v 1.0.3 then tried with plan.out, but still it failed with below error
`C:\Users\vrb.cntrl>terraform-compliance -f C:\Training\cloud\terraform-compliance\1.0.3\terraform-compliance-master\terraform-compliance-master\example\example_01\aws -p C:\Training\AWS\Terraform-Examples\intro-to-terraform-master\single-web-server\plan.out
terraform-compliance v1.0.3 initiated
. Converting terraform plan file.
ERROR: Could not find "terraform" executable in PATH. Please either use "-t" parameter or add terraform executable to your PATH.`
then I added the -t parameter and the terraform.exe path as shown below but it also failed
**C:\Users\vrb.cntrl>terraform-compliance -f C:\Training\cloud\terraform-compliance\1.0.3\terraform-compliance-master\terraform-compliance-master\example\example_01\aws -p C:\Training\AWS\Terraform-Examples\intro-to-terraform-master\single-web-server\plan.out -t C:\Training\cloud\terraform\terraform_0.12.1_windows_amd64
terraform-compliance v1.0.3 initiated
. Converting terraform plan file.
ERROR: Could not find "terraform" executable in PATH. Please either use "-t" parameter or add terraform executable to your PATH.**
I think you still need to fix the convert_terraform_plan_to_json() function add a thrird parameter to it i.e. -t parameter value from CLI and assign that value to terraform_executable variable in the else condition?
else:
print('Using {} as terraform executable.'.format(terraform_file))
terraform_executable = terraform_file
Please let me know.Thanks!
from cli.
It looks like -t
parameter could not be initialised. Fixed the problem.
1.0.4
is being released right now, please let me know if it is still failing for you.
Just a hint, better to add C:\Training\cloud\terraform\
to your %PATH%
not to pass -t
all the time :)
from cli.
thanks for the fix.
I have the terraform.exe file path i.e. C:\Training\cloud\terraform\terraform_0.12.1_windows_amd64 in my %PATH% from the beginning, not sure why it is not able to read that path.
So, I have tested 1.0.4 with out -t parameter and with terraform executable path in %PATH%, but it still failed
Tested 1.0.4 with -t parameter with its value as C:\Training\cloud\terraform\terraform_0.12.1_windows_amd64 but it still failed with below error
`C:\WINDOWS\system32>terraform-compliance -f C:\Training\cloud\terraform-compliance\1.0.4\terraform-compliance-master\example\example_01\aws -p C:\Training\AWS\Terraform-Examples\intro-to-terraform-master\single-web-server\plan.out -t C:\Training\cloud\terraform\terraform_0.12.1_windows_amd64
terraform-compliance v1.0.4 initiated
. Converting terraform plan file.
Using C:\Training\cloud\terraform\terraform_0.12.1_windows_amd64 as terraform executable.
ERROR: C:\Training\cloud\terraform\terraform_0.12.1_windows_amd64 is not executable. Please give correct executable for "terraform".
[WinError 5] Access is denied`
so, I added the terrform.exe to the end of the path in -t parameter and it worked
`C:\WINDOWS\system32>terraform-compliance -f C:\Training\cloud\terraform-compliance\1.0.4\terraform-compliance-master\example\example_01\aws -p C:\Training\AWS\Terraform-Examples\intro-to-terraform-master\single-web-server\plan.out -t C:\Training\cloud\terraform\terraform_0.12.1_windows_amd64\terraform.exe
terraform-compliance v1.0.4 initiated
. Converting terraform plan file.
Using C:\Training\cloud\terraform\terraform_0.12.1_windows_amd64\terraform.exe as terraform executable.
- Features : C:\Training\cloud\terraform-compliance\1.0.4\terraform-compliance-master\example\example_01\aws
- Plan File : C:\Training\AWS\Terraform-Examples\intro-to-terraform-master\single-web-server\plan.out.json
. Running tests.
Feature: Credentials should not be within the code # C:\Training\cloud\terraform-compliance\1.0.4\terraform-compliance-master\example\example_01\aws\credentials.feature
In order to prevent any credentials leakage
As engineers
We'll enforce credentials will not be hardcoded
.....................................................`
so, I think I'm good now. Thanks!
from cli.
Thanks for the re-test, yes, you need to give terraform
executable with -t
parameter instead of just the path. I will change the wording on -h
describing the parameter.
from cli.
Related Issues (20)
- cleanup tmp HOT 3
- --coverage flag with docker HOT 1
- FATAL ERROR: Unsupported terraform version (1.4.0). HOT 4
- Support for Terraform 1.4.* HOT 2
- Add support for testing the terraform block HOT 1
- tagging feature - false positive for aws_lambda_function's "environment" argument HOT 2
- Terregarrunt support
- Applying test cases to only resources from specific provider HOT 1
- Support for Terraform 1.5.* HOT 8
- Can not find aws_msk_cluster defined in target terraform plan
- Question: Using Terraform Compliance in CircleCI with Terraform and Python Orbs HOT 4
- Add support for Terraform Version 1.6.0 HOT 4
- Is `or` logic supported at all? HOT 1
- STDERR isn't being used, log level cannot be changed.
- THEN's condition matches for child properties in absence of a property at expected level. Is this expected? HOT 1
- 'AttributeError: 'str' object has no attribute 'append'' HOT 2
- "AttributeError: 'dict' object has no attribute 'startswith'" when using resources defining their own "references" blocks
- FATAL ERROR: Unsupported terraform version (1.7.0)
- Get rid of "/root/.cache" directory
- When condition on resource which has its own type property fails HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cli.