Indicate operation errors already in the plan phase
This idea originates from my original bug report: https://github.com/mongodb/terraform-provider-mongodbatlas/issues/284
Changing the name of an existing custom_db_role
is currently not possible without ending in an error in the apply
step. The plan for a name change currently indicates the replacement due to the name change:
# module.versioner.mongodbatlas_custom_db_role.this must be replaced
-/+ resource "mongodbatlas_custom_db_role" "this" {
~ id = "someid" -> (known after apply)
project_id = "5c860ed2a6f2396cd47f4785"
~ role_name = "old_name" -> "newName" # forces replacement
Applying this results in the following error:
Error: error deleting custom db role (mongoversioner): DELETE https://cloud.mongodb.com/api/atlas/v1.0/groups/projectid/customDBRoles/roles/old_name: 409 (request "Conflict") Deleting specified custom role would leave the following users without a role: someuser.
I understand that this is not possible directly without unassigning the user, but some indication for these kinds of issues already in the plan phase would make things much easier to handle.