Reputation: 13237
I've seen a similar question on a Hashicorp forum and their solution was to consolidate similar warnings, so I see something like this in a codebase I've started working on:
Warning: Interpolation-only expressions are deprecated
...
(and 50 more similar warnings elsewhere)
Definitely better than seeing 50 (or whatever) repeated warnings! Thank you Hashicorp. But, even with this reduction, I still find that at end of terraform plan
I have to scroll up to find what I'm really interested in, such as No changes. Infrastructure is up-to-date.
If anyone is aware of a method to make these warnings go away for a while, native or not, preferably simple, would be grateful to hear it.
Upvotes: 7
Views: 9925
Reputation: 1698
That's an interesting question, as far I know there is no perfect solution for that yet. These are the workaround that I use:
Native way:
There is no way to exclude all warnings, but you can use the -compact-warnings
flag in the terraform commands to show a compact view of them. By compact view they basically mean that not all warning explanations will be displayed (so you are avoiding like two paragraphs of annoying warning explanations).
Running the commands using that flag:
terraform plan -compact-warnings
Or defining them as environment variables:
export TF_CLI_ARGS_plan="-compact-warnings"
export TF_CLI_ARGS_apply="-compact-warnings"
Non native way:
If don't want to display any warnings at all and just display the plan I use:
terraform plan -compact-warnings | awk '/Warnings/ {exit} {print}'
Upvotes: 19