Hi there,
While the plans produced by Terraform are comprehensive, they can be a bit tough to read especially in the case of things like LC policy changes and other json changes. Landscape seems to do a nice job of formatting the Terraform plan, https://github.com/coinbase/terraform-landscape .
Would is be possible to incorporate this type of formatting natively?
Thanks
Hi @danbf,
We are planning to rework the formatting of plans once we've completed some in-progress work to change how Terraform represents values internally, so that the diff renderer will know the true types of all of the values (lists, maps, etc) and can thus render things in a more reasonable way.
We're waiting until after the type system work because this will end up being a total rewrite of the plan renderer with the new data model.
The following shows a mockup of what the new result might look like once the diff renderer has access to full type information:

Details may change when we get there, and indeed there should also be special handling of multi-line strings not shown here, but this gives a sense of what sort of thing should be able to achieve under the new model. (The "Requires Service Interruption" annotation is part of a mock of a different idea and will not be included in this initial set of work.)
that would be awesome since there is a huge difference in plan readability. since landscape can do it working off the the produced plan, perhaps some changes could be made prior to the bigger changes by just adding a plan post processor?
normal terraform:
~ update in-place
Terraform will perform the following actions:
~ module.rig.module.default_ecs_class_host_group.aws_cloudformation_stack.rig_cluster
template_body: "{\"AWSTemplateFormatVersion\":\"2010-09-09\",\"Outputs\":{\"AsgName\":{\"Value\":{\"Ref\":\"RigClusterAsg\"}}},\"Resources\":{\"RigClusterAsg\":{\"CreationPolicy\":{\"ResourceSignal\":{\"Count\":\"3\",\"Timeout\":\"PT20M\"}},\"Properties\":{\"HealthCheckGracePeriod\":\"60\",\"HealthCheckType\":\"EC2\",\"LaunchConfigurationName\":\"rig-XXXXX-ecs-asg_XXXXXX\",\"MaxSize\":\"18\",\"MetricsCollection\":[{\"Granularity\":\"1Minute\",\"Metrics\":[\"GroupMinSize\",\"GroupMaxSize\",\"GroupDesiredCapacity\",\"GroupInServiceInstances\",\"GroupPendingInstances\",\"GroupStandbyInstances\",\"GroupTerminatingInstances\",\"GroupTotalInstances\"]}],\"MinSize\":\"3\",\"Tags\":[{\"Key\":\"Name\",\"PropagateAtLaunch\":false,\"Value\":\"rig-XXXXX-ecs\"},{\"Key\":\"rig:cluster\",\"PropagateAtLaunch\":true,\"Value\":\"XXXXX\"},{\"Key\":\"rig:role\",\"PropagateAtLaunch\":true,\"Value\":\"ecs\"}],\"TerminationPolicies\":[\"OldestLaunchConfiguration\",\"OldestInstance\",\"default\"],\"VPCZoneIdentifier\":[\"subnet-XXXXXX\",\"subnet-XXXXX\",\"subnet-XXXXXXXX\"]},\"Type\":\"AWS::AutoScaling::AutoScalingGroup\",\"UpdatePolicy\":{\"AutoScalingRollingUpdate\":{\"MaxBatchSize\":\"18\",\"MinInstancesInService\":\"3\",\"PauseTime\":\"PT5M\",\"WaitOnResourceSignals\":true}}}}}" => "{\"AWSTemplateFormatVersion\":\"2010-09-09\",\"Outputs\":{\"AsgName\":{\"Value\":{\"Ref\":\"RigClusterAsg\"}}},\"Resources\":{\"RigClusterAsg\":{\"CreationPolicy\":{\"ResourceSignal\":{\"Count\":\"3\",\"Timeout\":\"PT20M\"}},\"Properties\":{\"HealthCheckGracePeriod\":\"60\",\"HealthCheckType\":\"EC2\",\"LaunchConfigurationName\":\"rig-XXXXX-ecs-asg_XXXXXX\",\"MaxSize\":\"18\",\"MetricsCollection\":[{\"Granularity\":\"1Minute\",\"Metrics\":[\"GroupMinSize\",\"GroupMaxSize\",\"GroupDesiredCapacity\",\"GroupInServiceInstances\",\"GroupPendingInstances\",\"GroupStandbyInstances\",\"GroupTerminatingInstances\",\"GroupTotalInstances\"]}],\"MinSize\":\"3\",\"Tags\":[{\"Key\":\"Name\",\"PropagateAtLaunch\":false,\"Value\":\"rig-XXXXXX-ecs\"},{\"Key\":\"rig:cluster\",\"PropagateAtLaunch\":true,\"Value\":\"XXXXXX\"},{\"Key\":\"rig:role\",\"PropagateAtLaunch\":true,\"Value\":\"ecs\"}],\"TerminationPolicies\":[\"OldestLaunchConfiguration\",\"OldestInstance\",\"default\"],\"VPCZoneIdentifier\":[\"subnet-XXXXX\",\"subnet-XXXX\",\"subnet-XXXXXXXX\"]},\"Type\":\"AWS::AutoScaling::AutoScalingGroup\",\"UpdatePolicy\":{\"AutoScalingRollingUpdate\":{\"MaxBatchSize\":\"4\",\"MinInstancesInService\":\"3\",\"PauseTime\":\"PT5M\",\"WaitOnResourceSignals\":true}}}}}"
Plan: 0 to add, 1 to change, 0 to destroy.
with landscape:
~ module.rig.module.default_ecs_class_host_group.aws_cloudformation_stack.rig_cluster
template_body: ]
},
"Type": "AWS::AutoScaling::AutoScalingGroup",
"UpdatePolicy": {
"AutoScalingRollingUpdate": {
- "MaxBatchSize": "18",
+ "MaxBatchSize": "4",
"MinInstancesInService": "3",
"PauseTime": "PT5M",
"WaitOnResourceSignals": true
}
}
Plan: 0 to add, 1 to change, 0 to destroy.
Hi @danbf,
The Terraform team is currently focused on the longer-term work that should make the above possible and thus not able to spend time on a short-term fix, but if you or someone else is motivated to work on this (knowing that it'll get removed again once we rewrite the plan formatter) then we'd be happy to review a PR.
Implementing it as a post-processor of the text output shouldn't be necessary _within_ Terraform because all of the necessary information is already available in the plan data structure. Indeed, we would not be able to merge the post-processor approach since it'd create a maintenance burden for future work. However, achieving the same result with the native plan object should be possible, though indeed not necessarily _easy_.
Hi again @danbf,
We've been doing some more prototyping in this area as part of planning the integration work for the type system changes I previously mentioned. I shared some results of this prototyping over in #15180, and I'm going to close this issue now just so we can consolidate future diff-improvement-related discussion over there.
I'm going to lock this issue because it has been closed for _30 days_ โณ. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.
Most helpful comment
Hi @danbf,
We are planning to rework the formatting of plans once we've completed some in-progress work to change how Terraform represents values internally, so that the diff renderer will know the true types of all of the values (lists, maps, etc) and can thus render things in a more reasonable way.
We're waiting until after the type system work because this will end up being a total rewrite of the plan renderer with the new data model.
The following shows a mockup of what the new result might look like once the diff renderer has access to full type information:
Details may change when we get there, and indeed there should also be special handling of multi-line strings not shown here, but this gives a sense of what sort of thing should be able to achieve under the new model. (The "Requires Service Interruption" annotation is part of a mock of a different idea and will not be included in this initial set of work.)