0

I'm trying to import IBM Cloud users, previously created with terraform, into a new state file after the old one was accidentally deleted!

In our tf file we have the resource:

resource "ibm_iam_user_invite" "account_users" {
  users = var.account_users
}

In our variables.tf file we have the variable:

variable "account_users" {
  type        = list(string)
  description = "List of all the current users with access to the IBM Cloud account"
}

And in our terraform.tfvars we have:

account_users = [
"user1@domain.com",
"user2@domain.com",
"user3@domain.com",
...
...
]

I can import a single user successfully using this command:

terraform import 'ibm_iam_user_invite.account_users' user1@domain.com

But when I try and import more users I get an error saying

Error: Resource already managed by Terraform

Terraform is already managing a remote object for ibm_iam_user_invite.account_users. To import to this address you must first remove the existing object from the state.

How do I correctly import the users?

John D
  • 45
  • 1
  • 3
  • 1
    According to the documentation "The import functionality is not supported for this resource." so that would be both an answer and non-answer for your question. – Matthew Schuchard Apr 13 '23 at 17:35

1 Answers1

0

The single invitation works because you assigned the name "account_users" to user1@domain.com. The, you tried to invite another user to the same TF resource name. Try 'ibm_iam_user_invite.account_users2' and it should work.

The resource allows to manage multiple users in a list. It seems that feature is not supported for import.

data_henrik
  • 16,724
  • 2
  • 28
  • 49