hashicorp / terraform-provider-azurerm

Terraform provider for Azure Resource Manager
https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
Mozilla Public License 2.0
4.52k stars 4.6k forks source link

Support for Cosmosdb mongo RBAC #19695

Open brahmiam opened 1 year ago

brahmiam commented 1 year ago

Is there an existing issue for this?

Community Note

Description

In the same manner as azurerm_cosmosdb_sql_role_definition for sql provisionned account, it would be great to do the same for mongo-provisionned accounts.

New or Affected Resource(s)/Data Source(s)

azurerm_cosmosdb_account

Potential Terraform Configuration

azurerm_cosmosdb_mongo_role_definition and azurerm_cosmosdb_mongo_role_assignment

similar to the sql equivalent

References

No response

restfulhead commented 6 months ago

@brahmiam I believe this has been added by now. The following works for me:

resource "azurerm_cosmosdb_mongo_role_definition" "app" {
  cosmos_mongo_database_id = "..."
  role_name                = "my-custom-role"

  privilege {
    actions = ["find", "insert", "remove", "update"]
    resource = {
      db_name = "..."
      collection_name = "..."
    }
  }
}

resource "azurerm_cosmosdb_mongo_user_definition" "app" {
  depends_on               = [azurerm_cosmosdb_mongo_role_definition.app]
  cosmos_mongo_database_id = "..."
  username                 = "..."
  password                 = "..."
  inherited_role_names     = ["my-custom-role"]
}