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

mongodbatlas_custom_db_role not waiting for resource creation #148

Closed
bauerben opened this issue Feb 21, 2020 · 1 comment · Fixed by #155
Closed

mongodbatlas_custom_db_role not waiting for resource creation #148

bauerben opened this issue Feb 21, 2020 · 1 comment · Fixed by #155

Comments

@bauerben
Copy link

When creating several custom db roles at the same time with mongodbatlas_custom_db_role, seems like the provider is not waiting long enough or retrying to get the return confirmation of resource creation.

Terraform source:

variable "db_list" {
  type = list(string)
  default = ["db1", "db2", "db3", "db4" ,"db5" ]
}

resource "mongodbatlas_custom_db_role" "db_role" {
  for_each = toset(var.db_list)
  project_id = var.atlas_project_id
  role_name  = "READ__${each.key}"
  actions {
    action = "FIND"
    resources {
      collection_name = ""
      database_name = each.key
    }
  }
}

Terraform apply results in code 404 :

mongodbatlas_custom_db_role.db_role["db1"]: Creating...
mongodbatlas_custom_db_role.db_role["db4"]: Creating...
mongodbatlas_custom_db_role.db_role["db2"]: Creating...
mongodbatlas_custom_db_role.db_role["db5"]: Creating...
mongodbatlas_custom_db_role.db_role["db3"]: Creating...
mongodbatlas_custom_db_role.db_role["db3"]: Creation complete after 1s [id=cmVjdF9pZA==:NWU0ZWMyOGJiYTRmNDEzMTk0ZGYxOTR9sZV9uYW1l:UkVBRF9fZGIz]
mongodbatlas_custom_db_role.db_role["db1"]: Creation complete after 1s [id=cHJvaF9pZA==:NWU0ZWMyOGJiYTRmNDEzMTk0ZGYxOTR9sZV9uYW1l:UkVBRF9fZGIx]
mongodbatlas_custom_db_role.db_role["db2"]: Creation complete after 1s [id=cHJvamVjZA==:NWU0ZWMyOGJiYTRmNDEzMTk0ZGYxOTR9sZV9uYW1l:UkVBRF9fZGIy]

Error: error creating custom db role: POST https://cloud.mongodb.com/api/atlas/v1.0/groups/XXXXXXXXXXXXX/customDBRoles/roles: 404 (request "Not Found") The specified custom db role READ__db4 does not exist.

  on custom_db_roles.tf line 20, in resource "mongodbatlas_custom_db_role" "db_role":
  20: resource "mongodbatlas_custom_db_role" "db_role"  {



Error: error creating custom db role: POST https://cloud.mongodb.com/api/atlas/v1.0/groups/XXXXXXXXXXXXX/customDBRoles/roles: 404 (request "Not Found") The specified custom db role READ__db5 does not exist.

  on custom_db_roles.tf line 20, in resource "mongodbatlas_custom_db_role" "db_role":
  20: resource "mongodbatlas_custom_db_role" "db_role"  {

Applying a second time works.

In case of creating a lot of resources at the same time, retry should be implemented in every resource types as it has been done with replicasets or whitelists creation ?

Mentioning depends_on seems to be a possible workaround in the meanwhile :

variable "db_list" {
  type = list(string)
  default = ["db1", "db2", "db3", "db4" ,"db5" ]
}

resource "mongodbatlas_custom_db_role" "db_role" {
  for_each = toset(var.db_list)
  project_id = var.atlas_project_id
  role_name  = "READ__${each.key}"
  depends_on = [var.db_list]
  actions {
    action = "FIND"
    resources {
      collection_name = ""
      database_name = each.key
    }
  }
}
@themantissa
Copy link
Collaborator

@bauerben thank you for the report. We'll look to improve the retry experience going forward by your workaround for now with depends_on seems solid. @marinsalinas and @PacoDw, thoughts on depends_on as a documented workaround until we have time to schedule in retry work?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants