-
Notifications
You must be signed in to change notification settings - Fork 10.2k
Description
Terraform Version
Terraform v1.14.3
on darwin_arm64
+ provider registry.terraform.io/hashicorp/archive v2.7.1
+ provider registry.terraform.io/hashicorp/aws v6.28.0
+ provider registry.terraform.io/hashicorp/null v3.2.4
+ provider registry.terraform.io/hashicorp/random v3.Use Cases
Currently the plan output does note that a resources has moved.
# resource_type.name_new will be updated in-place
# (moved from resource_type.name_old)
I'd like that to be in the Terraform plan summary like:
Plan: 0 to add, 1 to change, 0 to destroy, 1 to move.
The summary is incredibly helpful when reviewing PRs - more accurately, when to really review. Though a move doesn't really change anything - I still want to know.
I want this because I use GitHub Actions to put the Terraform plan summary in a comment on the PR. The contents of the plan are collapsed - so users can chose to see it, but a summary is displayed:
I think adding moved to the plan summary would be helpful on CLI and in tooling like pictured above.
Attempted Solutions
I wrote some stuff that would parse the plan output and tell me things moved - but it was wonky and complicated. It would be so much cleaner if terraform itself provided the info in the summary.
Proposal
Add a move count to the ChangeSummary struct and include it in the plan summary output.
A resource is considered "moved" when its current address differs from its previous address (i.e., it was relocated via a move{} block). This count is independent of other actions - a resource can be moved and updated/created/destroyed, and would appear in both counts.
Example output:
Plan: 0 to add, 1 to change, 0 to destroy, 1 to move.
The move count would only be displayed when greater than zero to keep the common case clean.
This applies to both human-readable output and JSON output (adding a "move" field to the change summary JSON).
References
No response