I had previously successfully captured terraform plan
outputs to a file by using the unix output redirections like this:
tf plan -no-color > plan.txt
When my plan
(or apply
) has errors, the output text file is empty although I see the error messages in the terminal output.
How can I capture output even in the cases there are errors?
CodePudding user response:
If you want to redirect everything you can do the following:
tf plan -no-color > plan.txt 2>&1
CodePudding user response:
Terraform has a built in variable TF_LOG_PATH
to redirect all output including errors to a specific file. You don't need to redirect the output.
example:
export TF_LOG_PATH=/mydirectory/mylogfile.log
terraform plan
Source: https://www.terraform.io/docs/internals/debugging.html