terraform
terraform copied to clipboard
Optional flag to treat warnings as errors
Terraform Version
Terraform v1.3.5
on darwin_amd64
Use Cases
As an engineer using terraform, I want the option to get forceful feedback from terraform, particularly with CI, when deprecated usages are introduced (e.g. through provider upgrades, old copypasta, etc.). Warning text at the end of a successful plan is easily missed -- again, particularly when using CI.
Attempted Solutions
None, although some form of output parsing post-plan
would be a CI workaround.
Proposal
Add a CLI option to terraform plan
that supports treating warnings as errors. At a minimum, it would set a non-zero exit code if any warnings are present during an otherwise successful plan
. It might also update the yellow Warning:
text to red Error:
text, though for my purposes that is less important.
-warnings-as-errors All warnings produces by Terraform are upgraded to errors
in plan output and will set the Errored exit status.
References
- A request to optionally make a particular warning an error: https://github.com/hashicorp/terraform/issues/31280. Opener did suggest a similar overall option in a followup comment.
- Old identical request possibly ignored since it didn't use a template (fair enough!): https://github.com/hashicorp/terraform/issues/23411