John D
John D

Reputation: 55

Using Terraform import to import IAM users on IBM Cloud

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 = [
"[email protected]",
"[email protected]",
"[email protected]",
...
...
]

I can import a single user successfully using this command:

terraform import 'ibm_iam_user_invite.account_users' [email protected]

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?

Upvotes: 0

Views: 189

Answers (1)

data_henrik
data_henrik

Reputation: 17176

The single invitation works because you assigned the name "account_users" to [email protected]. 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.

Upvotes: 0

Related Questions