Terraform response api

Hi team,

What is the right way to query execution response.
We are maintaining ~1K modules with CI/CD - and sometimes logs are ~300K lines.
I’m thinking to capture stdout and stderr with python to parse exact errors.

So maybe there is some right way to do that or you can suggest some right regex to parse errors.


Hi @chell0veck,

If your goal is to build software that takes actions based on Terraform’s behavior then I would suggest achieving that by making your wrapping program run terraform plan and/or terraform apply using the extra -json option, which will then make the output appear as a stream of JSON objects that you can parse and analyze without using regular expressions.

Terraform’s human-oriented output is not guaranteed to remain consistent in future versions of Terraform CLI, so if you build a solution that involves parsing the human-oriented output then you may need to change it each time you upgrade Terraform CLI.