hashicorp / terraform

Terraform enables you to safely and predictably create, change, and improve infrastructure. It is a source-available tool that codifies APIs into declarative configuration files that can be shared amongst team members, treated as code, edited, reviewed, and versioned.
https://www.terraform.io/
Other
42.37k stars 9.49k forks source link

Show all warnings in `terraform plan`, that are indicated by `"x similar warnings"` in the output #32104

Open abudri opened 1 year ago

abudri commented 1 year ago

Terraform Version

Terraform v1.3.3

Also using AWS provider ~> "4.0", which currently resolves to v4.36.1

Use Cases

Currently when running a terraform plan, the output of the command shows a single warning, but doesn't print them all out:

terraform plan
aws_s3_bucket.my_bucket: Refreshing state... [id=my_bucket20221027164110839800000001]

No changes. Your infrastructure matches the configuration.

Terraform has compared your real infrastructure against your configuration and found no differences, so no changes are needed.
╷
│ Warning: Argument is deprecated
│ 
│   with aws_s3_bucket.my_bucket,
│   on main.tf line 1, in resource "aws_s3_bucket" "my_bucket":
│    1: resource "aws_s3_bucket" "my_bucket" {
│ 
│ Use the aws_s3_bucket_versioning resource instead
│ 
│ (and 3 more similar warnings elsewhere)

"3 more similar warnings elsewhere" is the extent of the detail. If a TF code base has many more warnings - which I have run into - that can be much more tedious to deal with, trying to knock out new printed warning after warning after each terraform apply.

Attempted Solutions

terraform validate does not check against remote state, and does not show all the warnings that I am aware of.

terraform plan does not show all the warnings that I am aware of.

Proposal

Since Terraform is catching the warnings and giving back the number of warnings, can all the actual warnings themselves be returned as part of the output of a terraform plan with some type of new flag or option, such as -all-warnings or -verbose-warnings in order to help speed up development?

References

No response

crw commented 1 year ago

Thanks for this feature request! If you are viewing this issue and would like to indicate your interest, please use the 👍 reaction on the issue description to upvote this issue. We also welcome additional use case descriptions. Thanks again!

gtirloni commented 1 year ago

Is this planned?

crw commented 1 year ago

@gtirloni It is not currently on the roadmap.

josephmidura commented 1 year ago

I inherited a project with Terraform code that hasn't been updated in two years. I have over a hundred warnings to address. It would be helpful to receive more information than "and x more similar warnings elsewhere" since after each code fix I make I have to run terraform plan again to see the next error. I agree the proposed enhancement would be a high quality addition to Terraform.

gtirloni commented 1 year ago

I inherited a project with Terraform code that hasn't been updated in two years

I'm on the same boat. I appreciate the ability to have it be less verbose but I think it should be optional.

In the last year alone, I've wasted too many hours re-running terraform plan over and over just to see the next warning when I could have fixed them all at once.

vghero commented 10 months ago

Ran into this again today :/. The workarounds mentioned here are also not working for me, like the issue owner already mentioned. C'mon guys is it that difficult to add an option for that? It was more work to actual implement that grouping...

kwolf-experian commented 9 months ago

Same issue here. If you don't want to add a flag for this, I'd honestly rather see the grouping removed completely.

kevinsun2012 commented 7 months ago

Please add this flag!

alecsiemerink commented 7 months ago

We would like to have this implemented. Would save some time and use of other tools.

blongman-snapdocs commented 5 months ago

Came here looking for something like this. We currently run our terraform through github actions and at the end of the day, we miss deprecation warnings unless we check the action itself or run at the command line. The practical result is that we don't fix deprecations in a timely manner, and they all stack up when we go to upgrade to a new version of terraform. Would be very nice to see something like a terraform show-deprecations that could be picked up and added to our actions so that these are highlighted.

mrclrchtr commented 3 weeks ago

unbelievable that this flag does not exist

wikhede commented 5 days ago

Came here looking for something similar. To add to earlier mentioned use cases it gets even more frustrating when I've addressed lots of warnings and come down to 4 remaining warnings. But I won't be able to address the warning that is now shown for a couple of months due to other people already working on prerequisites for that specific fix. Please address this!

miteax commented 3 days ago

This is a very frustration limitation. The suggested method of using terraform validate doesn't work as it doesn't list warnings inside modules. As we are using modules for pretty much everything, we can only see a single warning at a time, there is no way to get a full list of everything that needs to be addressed.