ovh / terraform-provider-ovh

Terraform OVH provider
https://registry.terraform.io/providers/ovh/ovh/latest/docs
Mozilla Public License 2.0
182 stars 136 forks source link

[BUG] list order not consistent in containerregistry_ip_restrictions #636

Closed mxm-tr closed 3 months ago

mxm-tr commented 4 months ago

Describe the bug

When applying the same container registry configuration multiple times, the ip_restrictions list is not consistent. This causes the Managed Registries to be recreated at each apply operation.

Terraform Version

OpenTofu, but other clients should have the same issue.

OVH Terraform Provider Version

Latest version

Affected Resource(s)

Terraform Configuration Files

Any managed registry object with multiple ip_restrictions:

  ip_restrictions = [
    { 
      ip_block = "xxx.xxx.xxx.xxx/xx"
      description = "xxxxxxx"
    },
    { 
      ip_block = "xxx.xxx.xxx.xxx/xx"
      description = "xxxxxxx"
    }
]

Expected Behavior

When applying a the same hcl configuration file multiple times, no change should be triggered.

Actual Behavior

When applying a the same hcl configuration file multiple times, changes were triggered.

Steps to Reproduce

  1. Create a registry with multiple entries in ip_restrictions
  2. Run terraform apply multiple times without any change in the hcl definition.

Additional context

A workaround is to order the items in the hcl file directly:

ip_restrictions= toset([
    {
      "description" : "XXXXXX"
      ip_block = "nnn.nnn.nnn.nnn/nn",
    },
    {
      "description" : "XXXXXX"
      ip_block = "nnn.nnn.nnn.nnn/nn",
    }
])
amstuta commented 4 months ago

Hi @mxm-tr, this is indeed a bug and I think ip_restrictions should be a TypeSet instead of a TypeList, wdyt ?

mxm-tr commented 4 months ago

Hi, yes this could work thanks! I can create a PR next week if you want

amstuta commented 4 months ago

Yes that would be perfect