mongodb / terraform-provider-mongodbatlas

Terraform MongoDB Atlas Provider: Deploy, update, and manage MongoDB Atlas infrastructure as code through HashiCorp Terraform
https://registry.terraform.io/providers/mongodb/mongodbatlas
Mozilla Public License 2.0
241 stars 167 forks source link

Changes are not detected when changing Team's role_names attribute on mongodbatlas_project #209

Closed michelzanini closed 4 years ago

michelzanini commented 4 years ago

Hi,

I have a project resource such as this:

resource "mongodbatlas_project" "project" {
  org_id  = local.organization_id
  name    = local.project_name

  teams {
    team_id    = "5e5cf01b8d40110c9995491d"
    role_names = ["GROUP_OWNER"]
  }
}

This creates correctly, but when I want to change the teams permission, lets say from ["GROUP_OWNER"] to ["GROUP_DATA_ACCESS_READ_WRITE"], that change is not detected.

I run terraform plan after editing the field and it says every thing is up-to-date. Basically I can't edit the role of a team. I had to remove the team, apply it, then add it back again with a different value. But this requires code changes etc...

Expected behaviour is to detect the change correctly and update the resource. Of course, if the role name is still the same then no change should be detected.

Can this be fixed please? Thanks.

themantissa commented 4 years ago

@michelzanini can you include which provider version you have just so we can be sure to have the team investigate this w/ the same version? (I notice you are submitting a few issues- can you please include details on Terraform version/provider version on each)

michelzanini commented 4 years ago

Version 0.5.1 of the provider, Terraform version 0.12.16

themantissa commented 4 years ago

Confirmed bug, when a team has been added to a project changing or adding to the role_name array in the configuration was not detected as different on refresh. Will ask the developers to look into.

PacoDw commented 4 years ago

Hello @michelzanini, thank you so much for your review, I fixed it you can check if the changes are ok on the fix-#209 branch.

Let me know if you have another comment or concern

michelzanini commented 4 years ago

Thanks for the fix @PacoDw . I tested the branch and it worked. I can see terraform plan now displays the difference and terraform apply is applying it correctly afterwards.

Plan outout:

+ teams {
          + role_names = [
              + "GROUP_DATA_ACCESS_READ_WRITE",
            ]
          + team_id    = "5e3d6b2d014b7673c90b76aa"
        }
      - teams {
          - role_names = [
              - "GROUP_OWNER",
            ] -> null
          - team_id    = "5e3d6b2d014b7673c90b76aa" -> null
        }

Looks good! Thanks.

PacoDw commented 4 years ago

you're welcome :)