ovh/terraform-provider-ovh

[BUG] list order not consistent in containerregistry_ip_restrictions

mxm-tr opened this issue · 3 comments

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)

  • cloud_project_containerregistry_ip_restrictions_registry
  • cloud_project_containerregistry_ip_restrictions_management

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",
    }
])

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

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

Yes that would be perfect