dineshba / tf-summarize

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

Add support for terraform outputs? #31

Closed kenfusion closed 1 year ago

kenfusion commented 1 year ago

Hi!

Love this tool! I've been piping json plans to jq to pick apart plans, but I'll just start using this as it pretty much fits my needs.

I was wondering if there are plans to add terraform outputs to the summary? If not, that's okay.

resource "aws_iam_user" "test" {
  name = "test"
}

resource "aws_iam_user" "test2" {
  name = "test2"
}

output "user1-name" {
  value = aws_iam_user.test.name
}
output "user2-name" {
  value = aws_iam_user.test2.name
}
Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # aws_iam_user.test will be created
  + resource "aws_iam_user" "test" {
      + arn           = (known after apply)
      + force_destroy = false
      + id            = (known after apply)
      + name          = "test"
      + path          = "/"
      + tags_all      = (known after apply)
      + unique_id     = (known after apply)
    }

  # aws_iam_user.test2 will be created
  + resource "aws_iam_user" "test2" {
      + arn           = (known after apply)
      + force_destroy = false
      + id            = (known after apply)
      + name          = "test2"
      + path          = "/"
      + tags_all      = (known after apply)
      + unique_id     = (known after apply)
    }

Plan: 2 to add, 0 to change, 0 to destroy.

Changes to Outputs:
  + user1-name = "test"
  + user2-name = "test2"
terraform show -json out.tfplan | tf-summarize                
+--------+--------------------+
| CHANGE |        NAME        |
+--------+--------------------+
| add    | aws_iam_user.test  |
+        +--------------------+
|        | aws_iam_user.test2 |
+--------+--------------------+
dineshba commented 1 year ago

Hi @kenfusion Thanks for the trying out the tool.

It is better to add outputs in summary. Thansk for the great feedback. I have added this as todo here https://github.com/users/dineshba/projects/1/views/1

Please feel free to raise PR if you got some time. Or else, I can pick this up when I get some time.