labd / terraform-provider-commercetools

Terraform provider for commercetools
https://registry.terraform.io/providers/labd/commercetools/latest/docs
Mozilla Public License 2.0
64 stars 68 forks source link

Resource commercetools_associate_role: order of permissions #505

Open md283aa opened 3 weeks ago

md283aa commented 3 weeks ago

Version information

Describe the bug

When creating a commercetools_associate_role resource the array of permissions is not handled correctly. The permissions are obviously stored in a random order (or at least in a different order as the input array). When comparing the resource in commercetools with the tf spec it is always considered as different.

When applying the tf resource initially it returns:

commercetools_associate_role.my_role: Creating...
╷
│ Error: Provider produced inconsistent result after apply
│ 
│ When applying changes to commercetools_associate_role.my_role, provider "provider[\"registry.terraform.io/labd/commercetools\"]" produced an unexpected new value:
│ .permissions[0]: was cty.StringVal("CreateMyCarts"), but now cty.StringVal("ViewOthersCarts").
│ 
│ This is a bug in the provider, which should be reported in the provider's own issue tracker.

To Reproduce

Expected behavior

Order of permissions is not taken into account when comparing permissions

Screenshots

If applicable, add screenshots to help explain your problem.

Additional context

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:

  # commercetools_associate_role.my_role will be created
  + resource "commercetools_associate_role" "my_role" {
      + buyer_assignable = false
      + id               = (known after apply)
      + key              = "my_role"
      + name             = "My Role"
      + permissions      = [
          + "CreateMyCarts",
          + "DeleteMyCarts",
          + "UpdateMyCarts",
          + "ViewMyCarts",
          + "CreateMyOrdersFromMyCarts",
          + "CreateMyOrdersFromMyQuotes",
          + "UpdateMyOrders",
          + "ViewMyOrders",
          + "AcceptMyQuotes",
          + "ReassignMyQuotes",
          + "RenegotiateMyQuotes",
          + "ViewMyQuotes",
          + "CreateMyQuoteRequestsFromMyCarts",
          + "UpdateMyQuoteRequests",
          + "ViewMyQuoteRequests",
          + "ViewOthersQuotes",
          + "ViewOthersCarts",
          + "CreateOrdersFromOthersCarts",
          + "CreateOrdersFromOthersQuotes",
          + "UpdateOthersOrders",
          + "ViewOthersOrders",
          + "AcceptOthersQuotes",
          + "ReassignOthersQuotes",
          + "RenegotiateOthersQuotes",
          + "ViewOthersQuotes",
          + "CreateQuoteRequestsFromOthersCarts",
          + "UpdateOthersQuoteRequests",
          + "ViewOthersQuoteRequests",
        ]
      + version          = (known after apply)
    }

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

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

commercetools_associate_role.my_role: Creating...
╷
│ Error: Provider produced inconsistent result after apply
│ 
│ When applying changes to commercetools_associate_role.my_role, provider "provider[\"registry.terraform.io/labd/commercetools\"]" produced an unexpected new value:
│ .permissions[0]: was cty.StringVal("CreateMyCarts"), but now cty.StringVal("ViewOthersCarts").
│ 
│ This is a bug in the provider, which should be reported in the provider's own issue tracker.
╵
╷
│ Error: Provider produced inconsistent result after apply
│ 
│ When applying changes to commercetools_associate_role.my_role, provider "provider[\"registry.terraform.io/labd/commercetools\"]" produced an unexpected new value:
│ .permissions[1]: was cty.StringVal("DeleteMyCarts"), but now cty.StringVal("CreateQuoteRequestsFromOthersCarts").
│ 
│ This is a bug in the provider, which should be reported in the provider's own issue tracker.
╵
╷
│ Error: Provider produced inconsistent result after apply
│ 
│ When applying changes to commercetools_associate_role.my_role, provider "provider[\"registry.terraform.io/labd/commercetools\"]" produced an unexpected new value:
│ .permissions[3]: was cty.StringVal("ViewMyCarts"), but now cty.StringVal("CreateMyOrdersFromMyCarts").
│ 
│ This is a bug in the provider, which should be reported in the provider's own issue tracker.
╵