opendevstack / ods-pipeline-terraform

ODS Pipeline tasks for Terraform deployment - Experimental
Apache License 2.0
0 stars 0 forks source link

Summary of plan for human reviewers #8

Open henrjk opened 8 months ago

henrjk commented 8 months ago

Terraform plan output is typically quite large. In https://github.com/hashicorp/terraform/issues/10507#issuecomment-1157697160 there was a decision to not provide direct support for concise formatting but instead give the ability to format the plan as json (and document the format).

Now in the mentioned issue there are regexes mentioned as workaround, for example in comment https://github.com/hashicorp/terraform/issues/10507#issuecomment-596218415: terraform plan -no-color | grep -E '(^.*[#~+-] .*|^[[:punct:]]|Plan)'

The benefit of this regex is that it typically shows the important pieces of the output.

I would suspect that there are many good tools for summarizing and or evaluating terraform plans, but have not found too many. One example is tf-summarize which provide a summary of changes.

As a reviewer you would like to see which resources are being planned for import/deletion/creation and presumably for these the name would be sufficient as the resources themselves or the terraform configuration can be inspected to see all details. However for updates it would be nice to see the drift. In the (few) examples I tried the above grep statement appears to work well here.

One possibility would be to support a regex for plan output filtering which might to default the above information.