Fix concurrent error in cosmosdb example (#191)
* fix concurrent error in cosmosdb example * change to random_string to reduce the collision rate * fix 101-cosmos-db-free-tier account name too long issue --------- Co-authored-by: zjhe <hezijie@microsoft.com>
This commit is contained in:
@ -3,8 +3,21 @@ resource "azurerm_resource_group" "example" {
|
||||
location = var.location
|
||||
}
|
||||
|
||||
resource "random_string" "db_account_name" {
|
||||
count = var.cosmosdb_account_name == null ? 1 : 0
|
||||
|
||||
length = 20
|
||||
upper = false
|
||||
special = false
|
||||
numeric = false
|
||||
}
|
||||
|
||||
locals {
|
||||
cosmosdb_account_name = try(random_string.db_account_name[0].result, var.cosmosdb_account_name)
|
||||
}
|
||||
|
||||
resource "azurerm_cosmosdb_account" "example" {
|
||||
name = var.cosmosdb_account_name
|
||||
name = local.cosmosdb_account_name
|
||||
location = var.cosmosdb_account_location
|
||||
resource_group_name = azurerm_resource_group.example.name
|
||||
offer_type = "Standard"
|
||||
|
Reference in New Issue
Block a user