beelit94 / python-terraform

MIT License
475 stars 171 forks source link

fixes 0.12 path.module resolution #71

Open jalavoy opened 5 years ago

jalavoy commented 5 years ago

0.12.x changed how ${path.module} is rendered, and since python-terraform isn't explicitly passing a path to the terraform binary, terraform is using the implied value of . instead of the full path cwd.

This patch explicitly passes the path to the terraform binary when Popen() is called, which restores the old behavior in <0.11.x. Basically, it stops chdir() into the terraform root directory and passes the directory to terraform instead.

This was a drop in replacement in my testing that fixed the problem outright. The only other things I had to change in my code were paths being passed to backend_config since terraform is being called from a different directory now (the root of the project rather than the terraform root).

It's very possible this breaks other peoples configurations, and this problem was unique to my workflow. If that's the case feel free to reject the patch. Just passing up what worked for me in case it can help others.

Thank you for your time and attention