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

Importing users documentation vs actual behaviour #224

Closed
lneves75 opened this issue Mar 15, 2021 · 4 comments
Closed

Importing users documentation vs actual behaviour #224

lneves75 opened this issue Mar 15, 2021 · 4 comments
Labels
documentation Improvements or additions to documentation

Comments

@lneves75
Copy link

lneves75 commented Mar 15, 2021

Terraform version

Terraform v0.14.5

  • provider registry.terraform.io/rollbar/rollbar v1.0.6

Affected resource(s)

  • rollbar_user

Terraform configuration files

resource "rollbar_user" "luis" {
  email = "[email protected]"
  team_ids = [
    local.team_everyone_id,
    rollbar_team.myteam.id,
  ]
}

Steps to reproduce

  1. According to documentation we need the user ID to import it
  2. Obtain the user ID via API
  3. run terraform import rollbar_user.luis 238583
  4. run `terraform plan -out tfplan -target rollbar_user.luis

Expected outcome

rollbar_user.luis: Refreshing state... [id=238583]

No changes. Infrastructure is up-to-date.

This means that Terraform did not detect any differences between your
configuration and real physical resources that exist. As a result, no
actions need to be performed.

User imported without diffs

Actual output

Terraform will perform the following actions:

  # rollbar_user.luis must be replaced
-/+ resource "rollbar_user" "luis" {
      ~ email    = "238583" -> "[email protected]" # forces replacement
      ~ id       = "238583" -> (known after apply)
      ~ status   = "invited" -> (known after apply)
      ~ team_ids = [
          + 199890,
          + 479930,
        ]
      + user_id  = (known after apply)
      + username = (known after apply)
    }

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

More context

Looking at the source code I see that it's also possible to import the user via email.
Doing so still produces a diff trying to add the user to the everyone team (id=199890)

  # rollbar_user.luis will be updated in-place
  ~ resource "rollbar_user" "luis" {
        id       = "[email protected]"
      ~ team_ids = [
          + 199890,
            # (1 unchanged element hidden)
        ]
        # (3 unchanged attributes hidden)
    }

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

Warning: Resource targeting is in effect

Having looked at this, I wonder if the documentation should also state that a user can be imported via email.
Or, should the plugin just allow to import registered users, therefore importing using ID only ?

Also team rollbar_team.myteam.id is correctly imported but team everyone with id=199890 is not.

@Jonnymcc
Copy link

Jonnymcc commented Apr 13, 2021

I have noticed this as well. Importing using an id will force a replacement because the email attribute will change. Using the import command but specifying the email instead of the user id works as expected. I was going to make a PR to update the docs to state using email instead of id when importing, wondering what others think. Looking at the importer code the methods and variables imply that email should be used instead of id.
Also, note in the above plan that the team ids are being added. I think based on the debug output, that I collected, that if id is used the importer will create the resource mistakenly (should throw err) because the debug logs show that the user could not be found. Probably again because the code is searching by email address.

@haggishunk haggishunk added the documentation Improvements or additions to documentation label Feb 14, 2022
@magnetikonline
Copy link

Using the import command but specifying the email instead of the user id works as expected.

Seeing the same behaviour - the documentation is very much wrong.

This is also the fix for #235.

@magnetikonline
Copy link

Also, note in the above plan that the team ids are being added. I think based on the debug output,

This also doesn't work - basically team_ids is an unworkable property.

It seems this can work with resource.rollbar_team_user - which makes me question, why do both methods of team assignment exist?

resource "rollbar_user" "joeblogs" {
  email    = "[email protected]"
  team_ids = [] # have to give some form of team list
}

resource "rollbar_team_user" "joeblogs" {
  team_id = data.rollbar_team.owners.id
  email   = "[email protected]"
}

@magnetikonline
Copy link

Having looked at this, I wonder if the documentation should also state that a user can be imported via email.

This has been updated via #396 via #395.

@alif alif closed this as completed Jun 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

5 participants