Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Address_book as unordered list #169

Closed
lukestu opened this issue Apr 8, 2021 · 5 comments · Fixed by #319
Closed

Address_book as unordered list #169

lukestu opened this issue Apr 8, 2021 · 5 comments · Fixed by #319
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@lukestu
Copy link

lukestu commented Apr 8, 2021

It seems the global address_book is reconfigured on every terraform plan even if only the order has changed.
Is it possible to have the address_book rendered as an unordered list, e.g. using Typeset rather than Typelist?

example:

     ~ address_set {
          ~ address = [
              - "net.aa01:cc01:1100::/40",
              + "net.bb02:dd01:500::/40",
            ]
          ~ name    = "site.net1" -> "site.net2"
        }
	  ~ address_set {
          ~ address = [
              - "net.bb02:dd01:500::/40",
              + "net.cc03:ee01:900::/40",
            ]
          ~ name    = "site.net2" -> "site.net3"
        }

Thanks again for your great work on this!

@jeremmfr
Copy link
Owner

jeremmfr commented Apr 8, 2021

Yes, ordering lists in global_address_book is unnecessary for Junos but is supported in its config and diff when run terraform plan is much more convenient.
Example with this config :

network_address {
    name  = "red"
    value = "192.0.2.3/32"
  }
  network_address {
    name  = "green"
    value = "192.0.2.2/32"
  }
  network_address {
    name  = "blue"
    value = "192.0.2.1/32"
  }
  address_set {
    name    = "color2"
    address = ["green", "blue"]
  }
  address_set {
    name    = "color1"
    address = ["green", "red", "blue"]
  }

When add red in color2 with have :

  • plan with ordered list :
      ~ address_set {
         ~ address = [
               # (1 unchanged element hidden)
               "blue",
             + "red",
           ]
           name    = "color2"
       }

       # (4 unchanged blocks hidden)
  • plan without ordered list :
      + address_set {
         + address = [
             + "green",
             + "blue",
             + "red",
           ]
         + name    = "color2"
       }
     - address_set {
         - address = [
             - "green",
             - "blue",
           ] -> null
         - name    = "color2" -> null
       }
     - address_set {
         - address = [
             - "green",
             - "red",
             - "blue",
           ] -> null
         - name    = "color1" -> null
       }
     + address_set {
         + address = [
             + "green",
             + "red",
             + "blue",
           ]
         + name    = "color1"
       }

       # (3 unchanged blocks hidden)

So I prefer to stay with an ordered list

@jeremmfr jeremmfr self-assigned this Apr 8, 2021
@jeremmfr jeremmfr added the wontfix This will not be worked on label Apr 8, 2021
@lukestu
Copy link
Author

lukestu commented Apr 8, 2021

Fair enough.

The problem we face is that we have a large address book, 500+ records. If we add one more, then the terraform plan will show hundreds of changes simply for the one address addition. This makes it very hard to properly review the changes that will be made, before we apply them.

@jeremmfr
Copy link
Owner

jeremmfr commented Apr 8, 2021

Fair enough.

The problem we face is that we have a large address book, 500+ records. If we add one more, then the terraform plan will show hundreds of changes simply for the one address addition. This makes it very hard to properly review the changes that will be made, before we apply them.

You should add the new entry at the end of the resource definition to have a more readable plan

@tagur87
Copy link
Contributor

tagur87 commented Apr 12, 2021

I investigated this further myself...and there seems to be a pattern that is followed by the AWS provider that might be helpful.
https://github.com/hashicorp/terraform-provider-aws/blob/main/aws/resource_aws_security_group.go#L78

Seems we can use the Set: option to define a schema.SchemaSetFunc type, which would output a hash of name-value combination, to uniquely identify the individual entries.

I tested this a bit, but it does not seem to work as I would hope.

After doing a bit of digging, it seems that this issue still could exist with a TypeSet type. See the issue in the main terraform project for more information. Seems there is work being done to provide more rich type support to the SDK.

hashicorp/terraform#28281

@jeremmfr
Copy link
Owner

jeremmfr commented Dec 6, 2021

Following my investigation in issue #316, I found a workaround to avoid large update plan output.
So I reopen this issue to take care of making the change to an unordered block.

@jeremmfr jeremmfr reopened this Dec 6, 2021
@jeremmfr jeremmfr added enhancement New feature or request and removed wontfix This will not be worked on labels Dec 6, 2021
jeremmfr added a commit that referenced this issue Dec 6, 2021
The outputs of the update plan will be different, see the note in the documentation to prevent unchanged blocks not being correctly hidden.
Fixes #169
@jeremmfr jeremmfr added this to the v1.23.0 milestone Dec 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants