Skip to content
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

Add Exception handling when Terraform not on Path #127

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

richkamulda
Copy link

I spent a couple hours helping a colleague debug why his python_terraform code was unexpectedly throwing FileNotFoundErrors. It finally boiled down to the terraform binary not being on Path. Windows didn't offer any helpful hints to which file in the error messages. I also tested it on Ubuntu which would at least provide that "terraform" was the file. This is a result of subprocess.Popen not knowing what to do with "terraform" and trying to open something by that name. When terraform is not on Path and the binary path not provided, it will always die on the call to p = subprocess.Popen(...). I added exception handling to better inform users, especially on Windows, what the issue likely is when not providing a path to the binary. I tried to work my way best around still getting the TerraformCommandError to logs while giving context.

Windows Before
Windows After

Ubuntu Before
Ubuntu After

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant