Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Adding a user to multi namespaces seems to re-create the user each time and not just give them read access #119

Closed
tony-powell-sp opened this issue Aug 30, 2024 · 11 comments
Assignees
Labels
bug Something isn't working

Comments

@tony-powell-sp
Copy link

tony-powell-sp commented Aug 30, 2024

What are you really trying to do?

Create a user and assign to a namespace with a defined role so this is managed through code but each time it appears to re-create the user and they only have access to last namespace created.

Describe the bug

Minimal Reproduction

Environment/Versions

  • OS and processor: [e.g. M1 Mac, x86 Windows, Linux] Mac running Terraform
  • Temporal Version: [e.g. 1.14.0?] and/or SDK version terraform provider 0.0.11
  • Are you using Docker or Kubernetes or building Temporal from source? --- NO

Additional context

@tony-powell-sp tony-powell-sp added the bug Something isn't working label Aug 30, 2024
@swgillespie swgillespie self-assigned this Sep 20, 2024
swgillespie added a commit that referenced this issue Sep 24, 2024
This PR addresses #119, #116, and #115 by decoupling the definition of user accesses from the user itself, via a new resource: `temporalcloud_user_namespace_access`. This resource is intended to provide a many-to-many mapping between namespaces and users. Under the hood, this resource is manipulating a single User object via the API (as the underlying data model stashes all namespaces accesses on the user object), while also preserving the invariant that adding or removing a single user from a single namespace won't obliterate the list of permissions that a user has.

I do intend to write some more tests but I wanted to get this out quickly for review for some fast feedback before I write a bunch of tests that exercise things that might change in review.
@rohitgup14
Copy link

@swgillespie Can I close this issue ?

@jlacefie
Copy link
Collaborator

jlacefie commented Nov 6, 2024

This should be resolved with the solution for #109

@jlacefie jlacefie assigned briankassouf and unassigned swgillespie Nov 6, 2024
@jlacefie
Copy link
Collaborator

@tony-powell-sp we're struggling to recreate this scenario. Do you have more details or ways we can reproduce.

@jlacefie
Copy link
Collaborator

jlacefie commented Nov 19, 2024

I was able to reproduce.

Here are the steps

  • Create a terraform1.TF file with a Namespace Resource for NS1 and a User Resource User1 with Namespace Access to NS1
  • Create a second terraform.2TF file with a Namespace Resource for NS2 and the same User Resource with Namespace Access to NS2
  • Run terraform1.TF
    -- NS1 Created temporalcloud_namespace.namespace: Creation complete after 1m46s [id=multinsusertest1.ksfop]
    -- User1 Created with access to NS1 temporalcloud_user.developer: Creation complete after 1s [id=7772d588ae404f8dbe41fa4a74dc7084]
  • Run terraform2.TF
    -- NS2 Created temporalcloud_namespace.namespace: Creation complete after 1m42s [id=multinsusertest2.ksfop]
    -- User1's Namespace Access is wiped and the user has access to NS2 only temporalcloud_user.developer: Creation complete after 1s [id=7772d588ae404f8dbe41fa4a74dc7084]

terraform1.TF

esource "temporalcloud_namespace" "namespace" {
        name               = "multinsusertest1"
        regions            = ["aws-us-east-1"]
        accepted_client_ca = base64encode(file("../ca.pem"))
        retention_days     = 30
}

resource "temporalcloud_user" "developer" {
  email          = "mut1@gmail.io"
  account_access = "Developer"
  namespace_accesses = [
      {
      namespace_id = temporalcloud_namespace.namespace.id
      permission = "Read"
    }
 ]
}

terraform2.TF

resource "temporalcloud_namespace" "namespace" {
        name               = "multinsusertest2"
        regions            = ["aws-us-east-1"]
        accepted_client_ca = base64encode(file("../ca.pem"))
        retention_days     = 30
}

resource "temporalcloud_user" "developer" {
  email          = "mut1@gmail.io"
  account_access = "Developer"
  namespace_accesses = [
      {
      namespace_id = temporalcloud_namespace.namespace.id
      permission = "Read"
    }
 ]
}

@jlacefie jlacefie assigned anekkanti and unassigned briankassouf and anekkanti Nov 21, 2024
@jlacefie
Copy link
Collaborator

RCA - current logic for creating a user in Temporal allows for "re-inviting" users while their invitation is open, "not accepted".

The impact from the API is that the API will not fail a create request for an existing user.

@jlacefie
Copy link
Collaborator

document as side-effect and behavior of the current underlying API. Also, recommend this is not best practice for TF.

@jlacefie jlacefie self-assigned this Nov 21, 2024
@jlacefie
Copy link
Collaborator

docs addressed by #192

@jlacefie
Copy link
Collaborator

also addressed by the Temporal docs PR temporalio/documentation#3219

@tony-powell-sp
Copy link
Author

thanks @jlacefie I agree that terraform is not the best place but we have had issues trying to use the sdk to do the user management so we are just wanting to find a reliable method so that this is not a hand driven process and uniformity is across the environment!!

@tony-powell-sp
Copy link
Author

glad you where able to re-create the condition :)

@jlacefie
Copy link
Collaborator

jlacefie commented Dec 3, 2024

The first pass of this issue is resolved with documentation guidance.

@jlacefie jlacefie closed this as completed Dec 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants