I can able to create user in terraform for first time. After I delete that in console and create it again it throws error
Error: Failed to read user 94775dca-150f-44df-b959-fb1c0e11cb2d: API Error: 404 - Entity [user] is not found by _id [94775dca-150f-44df-b959-fb1c0e11cb2d] (4c4b3677-2273-4021-aac1-f1844efa58c8)
│
│ with genesyscloud_user.robert_smith,
│ on users.tf line 2, in resource "genesyscloud_user" "robert_smith":
│ 2: resource "genesyscloud_user" "robert_smith" {
│
│ with genesyscloud_user.robert_smith,
│ on users.tf line 2, in resource "genesyscloud_user" "robert_smith":
│ 2: resource "genesyscloud_user" "robert_smith" {
│
I haven't been able to recreate the error using your config. A few questions: Is this the only resource in your config, or are there other components? Also, I assume the only console commands you're running to encounter this error are terraform apply and terraform destroy ?
I 'm using the files from cx as code Developer blog. In that I was not using setenv.sh and queues.tf file. Intead of using setenv.sh I was storing the credentials in main.tf.
And I was getting this error for both terraform apply and terraform plan.
Terraform, the technology CX as Code is based on, maintains the state of any object created by it. Since you create the object via CX as Code and then delete the thing via the console, when Terraform runs it will attempt to validate that the object is still there, see that it isn't, and then fail. A couple of things:
Do not manipulate objects created via CX as Code via the console. CX as Code/Terraform expects that objects created by it are built and maintained via a CI/CD pipeline.
Unless you are setting up demonstration accounts, Genesys recommends against using CX as Code to provision users. We have betters tools like our SCIM tools for this.
If you are new to Genesys, understand that when you delete a user, you never truly delete it. All of our deletes with users are soft deletes. So if you now try to recreate that user with the same email account via CX as Code or the API you will get an error. We have added some intelligence to our CX as Code provider so that if you create a user via CX as Code, delete the user via CX as Code, and then recreate the user with CX as Code, we check to see if that user already exists as a deleted user and then just reactivate them.
Since you have deleted the above user via the console, you need to remove the existing user from the terraform state file via a terraform state rm <<user guiid>>, reactivate the user in the console, and then pull the user account back into the state file using a terraform import command.
Thanks,
John Carnell
Manager, Developer Engagement
Thanks for the detailed explanation and clarification. I have removed the resource from state and imported it again as you have suggested. Now I can able to run terraform plan without any error.
I have created user from Cx as code only for testing. We only need to create the architect flow using the Cx as code.