coinbase / terraform-landscape

Improve Terraform's plan output to be easier to read and understand
Apache License 2.0
1.59k stars 116 forks source link

Improve AWS Security Group rule changes #60

Closed rifelpet closed 4 years ago

rifelpet commented 6 years ago

I came across this gist and thought that implementing something similar in terraform-landscape would be a great improvement to how rule changes are currently formatted.

https://gist.github.com/greglook/747ae5671074e2905225a5a3e1e710e8

I realize terraform-landscape doesn't currently have any resource-type-specific formatting logic but I think it would help immensely when dealing with security group rule changes. The SG rules use an integer-only hashcode of the attributes of each rule as the ID of the rule set entry which is why the 10 digit number prefixing the rule attributes always changes when the rule changes. Its possible we could generalize the logic beyond security groups, since it looks like theres a handful of other resources that utilize hashcodes in their attribute sets.

sds commented 6 years ago

Hey @rifelpet,

We would love to have some way for you to specify custom formatters for resource changes. Security groups in particular are particularly difficult to reason about and are a great place for this.

We need to be cognizant of the fact that not everyone will want the same formatters applied to their plans. Introducing formatters also increases the likelihood that a bug is introduced where you accidentally omit crucial information about the plan.

With that said, I'm still in favor of this idea. We would love a pull request that added support for defining custom formatters that users could opt-in to—bonus if they can define them as plugins so that they don't need to submit a PR to this project in order to use them.

This can be as simple as adding a flag to Landscape that allows you to require a file. When rendering a plan for a resource, a dynamic lookup can be made to see if a certain class is defined—if it is, that class is responsible for rendering the resource changes.

Open to anyone tackling this!

sds commented 4 years ago

Tracking in #108.