generated from Azure/terraform-azurerm-avm-template
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmain.mongo.tf
50 lines (41 loc) · 1.63 KB
/
main.mongo.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
resource "azurerm_cosmosdb_mongo_database" "this" {
for_each = var.mongo_databases
account_name = azurerm_cosmosdb_account.this.name
name = each.value.name
resource_group_name = azurerm_cosmosdb_account.this.resource_group_name
throughput = each.value.throughput
dynamic "autoscale_settings" {
for_each = try(each.value.autoscale_settings.max_throughput, null) != null ? [1] : []
content {
max_throughput = each.value.autoscale_settings.max_throughput
}
}
}
resource "azurerm_cosmosdb_mongo_collection" "this" {
for_each = local.mongodb_collections
account_name = azurerm_cosmosdb_account.this.name
database_name = azurerm_cosmosdb_mongo_database.this[each.value.db_name].name
name = each.value.collection_name
resource_group_name = azurerm_cosmosdb_account.this.resource_group_name
default_ttl_seconds = each.value.collection_params.default_ttl_seconds
shard_key = each.value.collection_params.shard_key
throughput = each.value.collection_params.throughput
dynamic "autoscale_settings" {
for_each = try(each.value.collection_params.autoscale_settings.max_throughput, null) != null ? [1] : []
content {
max_throughput = each.value.collection_params.autoscale_settings.max_throughput
}
}
dynamic "index" {
for_each = each.value.collection_params.index != null ? [each.value.collection_params.index] : []
content {
keys = index.value.keys
unique = index.value.unique
}
}
index {
# We need to create a default unique one for the _id field
keys = ["_id"]
unique = true
}
}