datadrivers / terraform-provider-nexus

Terraform provider for Sonatype Nexus
https://registry.terraform.io/providers/datadrivers/nexus
Mozilla Public License 2.0
119 stars 53 forks source link

Add source parameter to user resource #475

Open Edu-DevOps opened 1 month ago

Edu-DevOps commented 1 month ago

Issue detailed here: https://github.com/datadrivers/terraform-provider-nexus/issues/371#issuecomment-2420299200

In a nutshell, without the source parameter two users (one local and one LDAP) can collide using the same userid.

I've updated documentation and run tests successfully.

This is a test done in a local environment:

Terraform will perform the following actions:

  # nexus_security_user.test will be created
  + resource "nexus_security_user" "test" {
      + email     = "nexus@example.com"
      + firstname = "Test"
      + id        = (known after apply)
      + lastname  = "User"
      + password  = (sensitive value)
      + roles     = [
          + "nx-admin",
        ]
      **+ source    = "default"**
      + status    = "active"
      + userid    = "test-user"
    }

Plan: 1 to add, 0 to change, 0 to destroy.
2024-10-18T14:39:44.953+0200 [DEBUG] command: asking for input: "\nDo you want to perform these actions?"

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

Apply complete! Resources: 1 added, 0 changed, 0 destroyed.

And this is a state show of the object

terraform state show nexus_security_user.test
# nexus_security_user.test:
resource "nexus_security_user" "test" {
    email     = "nexus@example.com"
    firstname = "Test"
    id        = "test-user"
    lastname  = "User"
    password  = (sensitive value)
    roles     = [
        "nx-admin",
    ]
    source    = "default"
    status    = "active"
    userid    = "test-user"
}

Taken advantage of the PR I've fixed the examples/local-development/main.tf file which was using a resource that doesn't exist