dineshba / tf-summarize

A command-line utility to print the summary of the terraform plan
MIT License
534 stars 38 forks source link

For the resources which should be replaced in place you see no changes in output #26

Open kevit opened 1 year ago

kevit commented 1 year ago

Imagine a situation when you want to add one more record in route table as below

# aws_default_route_table.main will be updated in-place
  ~ resource "aws_default_route_table" "main" {
        id                     = "rtb-048986295f3176afa"
      ~ route                  = [
          + {
              + cidr_block                 = "192.168.0.0/24"
              + core_network_arn           = ""
              + destination_prefix_list_id = ""
              + egress_only_gateway_id     = ""
              + gateway_id                 = ""
              + instance_id                = ""
              + ipv6_cidr_block            = ""
              + nat_gateway_id             = ""
              + network_interface_id       = "eni-0eb25aad6ca3e44bf"
              + transit_gateway_id         = ""
              + vpc_endpoint_id            = ""
              + vpc_peering_connection_id  = ""
            },/0"
              + core_network_arn           = ""
              + destination_prefix_list_id = ""
              + egress_only_gateway_id     = ""
              + gateway_id                 = ""
              + instance_id                = ""
              + ipv6_cidr_block            = ""
              + nat_gateway_id             = "igw-0eb25ccd5ca0e25bf"
              + network_interface_id       = ""
              + transit_gateway_id         = ""
              + vpc_endpoint_id            = ""
              + vpc_peering_connection_id  = ""
            },
          + {
              + cidr_block                 = "0.0.0.0/0"
              + core_network_arn           = ""
              + destination_prefix_list_id = ""
              + egress_only_gateway_id     = ""
              + gateway_id                 = ""
              + instance_id                = ""
              + ipv6_cidr_block            = ""
              + nat_gateway_id             = "igw-0eb25ccd5ca0e25bc"
              + network_interface_id       = ""
              + transit_gateway_id         = ""
              + vpc_endpoint_id            = ""
              + vpc_peering_connection_id  = ""
            },
          - {
              - cidr_block                 = "0.0.0.0/0"
              - core_network_arn           = ""
              - destination_prefix_list_id = ""
              - egress_only_gateway_id     = ""
              - gateway_id                 = "igw-0eb25ccd5ca0e25bc"
              - instance_id                = ""
              - ipv6_cidr_block            = ""
              - nat_gateway_id             = ""
              - network_interface_id       = ""
              - transit_gateway_id         = ""
              - vpc_endpoint_id            = ""
              - vpc_peering_connection_id  = ""
            },
        ]

tf-summarize marked only that resource is updated, but not mentioned that new records(or changed records) took place

Expected behaviour: list of changed records

dineshba commented 1 year ago

Could you please provide the current tf-summarize output for the above terraform plan?

buckleyGI commented 1 month ago

I used tf-summarize in the past without any problem but I think I hit this problem just now. Can I send you the plan directly @dineshba ? I will sent a redacted version.

buckleyGI commented 1 month ago

The -json flag doesn't show version changes (for example) to helm charts

Given this is input 9769 tf-summarize -json picks up the changes but displays {} image

I don't think this is the expected behaviour?

dineshba commented 1 month ago

Hi @buckleyGI , I have created a new release to surface this error and print in stderr. Could you please update to https://github.com/dineshba/tf-summarize/releases/tag/v0.3.13 and try it and let me know if the error is similar to

error: unmarshalling diff: invalid character '}' looking for beginning of value
dineshba commented 1 month ago

I was able to reproduce this issue.

Working tfplan.json tfplan.json Notworking tfplan.json tfplan-notworking.json

tf-summarize -json tfplan.json

In this tfplan-notworking.json, I have removed the metadata field in the after resource_change which is creating this issue.

Fix needs little more extra time to investigation. So, I made a quick fix to print the raw format if there is issue with formatting jsondiff

I will try to fix it. If someone is able to contribute, please help here

buckleyGI commented 1 month ago

Thanks for reproducing the issue. This is indeed my case as well, the metadata field in the after change has a character that the triggered the problem. Thanks dineshba!