opentofu icon indicating copy to clipboard operation
opentofu copied to clipboard

list resource addresses on `plan`(`tofu plan -summary`)

Open flavono123 opened this issue 2 years ago • 2 comments

OpenTofu Version

Terraform v1.5.7
on darwin_arm64

Use Cases

from plan, easily get what would be added/changed/deleted

the current plan output:

  • is too long to get which resources would be added/changed/deleted.
  • has summary just each number of them, not the addresses(name), at the end. https://www.reddit.com/r/Terraform/comments/10m7jdd/show_only_the_resources_that_will_be_changed_in/

people already have same requirements i think

Attempted Solutions

demo

https://github.com/flavono123/terraform-plan-summary

Proposal

👆 can i contribute the above feature, -summary (or with another proper name) flag to plan? i'm also open for any feedbacks :)

References

also commented in https://github.com/opentofu/opentofu/issues/306#issuecomment-1732218136

flavono123 avatar Sep 24 '23 04:09 flavono123

@flavono123 Hey! Thank you for your proposal!

Could you please share a few use cases to illustrate the value of the feature? Thanks!

For example, I can only think of resources governance (re-tagging) when knowing which resources are updated is somewhat more important than to know what kind of changes are expected. However in general, it's crucial to review plan details IMO.

Also, it's likely that the plan will be stored to a temp file, so one can use it to summarise the changes. It may be handy for GitOps approach indeed.

For example, one can run the following commands to see the summary of the changes (assuming that grep is installed to the environment):

tofu plan -out=plan.tofuplan 1> /dev/null
tofu show plan.tofuplan | grep "will be"

WDYT?

kislerdm avatar Nov 09 '23 08:11 kislerdm

hi @kislerdm ,

i think this is just one of way of visualization for a plan report and improving observability about the infra resources:

  • overview of cost changes in resource level, approximately(there are more exact plugins though).

For example, I can only think of resources governance (re-tagging) when knowing which resources are updated is somewhat more important than to know what kind of changes are expected.

yes. it shows as just simple "kinds", only 3 of added/changed/deleted, for resources, if i'm on target. (sorry, i don't know resources governance exactly but not suitable for this, i guess).

However in general, it's crucial to review plan details IMO.

definitely. i can totally agree with that. but the current plan output is unhelpful, i mean hard to review, especially when it is too long.

so, the result i suggested, just appending a resource addr list, which is more verbose version of plan stat, just saying the count of what they "will be". then, this option makes more "detailed" plan output, isn't it?

For example, one can run the following commands to see the summary of the changes (assuming that grep is installed to the environment):

i did. and got tired. even we can save as JSON and do more elaborate processings. but more workflows more tired. so suggest this :)

flavono123 avatar Nov 09 '23 09:11 flavono123

Hey @flavono123, thank you for this issue and appologies for the late reply. This sounds very similar to #306, which the core team has recently marked it as accepted and open for community contributions. I'm closing this issue since it seems like a duplicate, but feel free to reopen it if the linked issue doesn't cover your needs.

janosdebugs avatar Jan 25 '24 19:01 janosdebugs