Skip to content

Commit 552f37b

Browse files
committed
failing region_configs test
1 parent 5eceea1 commit 552f37b

File tree

2 files changed

+104
-0
lines changed

2 files changed

+104
-0
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
resource "mongodbatlas_advanced_cluster" "dynamic_regions_config" {
2+
project_id = var.project_id
3+
name = "cluster"
4+
cluster_type = "SHARDED"
5+
replication_specs {
6+
num_shards = var.replication_specs.num_shards
7+
zone_name = var.zone_name
8+
dynamic "region_configs" {
9+
for_each = var.replication_specs.region_configs
10+
content {
11+
priority = region_configs.value.prio
12+
provider_name = "AWS"
13+
region_name = region_configs.value.region_name
14+
electable_specs {
15+
instance_size = region_configs.value.instance_size
16+
node_count = region_configs.value.node_count
17+
}
18+
}
19+
}
20+
}
21+
}
22+
23+
# example of variable for demostration purposes, not used in the conversion
24+
variable "replication_specs" {
25+
type = object({
26+
num_shards = number
27+
region_configs = list(object({
28+
prio = number
29+
region_name = string
30+
instance_size = string
31+
node_count = number
32+
}))
33+
})
34+
default = {
35+
num_shards = 3
36+
region_configs = [
37+
{
38+
prio = 7
39+
region_name = "US_EAST_1"
40+
instance_size = "M10"
41+
node_count = 2
42+
},
43+
{
44+
prio = 6
45+
region_name = "US_WEST_2"
46+
instance_size = "M10"
47+
node_count = 1
48+
}
49+
]
50+
}
51+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
resource "mongodbatlas_advanced_cluster" "dynamic_regions_config" {
2+
project_id = var.project_id
3+
name = "cluster"
4+
cluster_type = "SHARDED"
5+
replication_specs = [
6+
for i in range(var.replication_specs.num_shards) : {
7+
zone_name = var.zone_name
8+
region_configs = [
9+
for region in var.replication_specs.region_configs : {
10+
priority = region.prio
11+
provider_name = "AWS"
12+
region_name = region.region_name
13+
electable_specs = {
14+
instance_size = region.instance_size
15+
node_count = region.node_count
16+
}
17+
}
18+
]
19+
}
20+
]
21+
22+
# Updated by atlas-cli-plugin-terraform, please review the changes.
23+
}
24+
25+
# example of variable for demostration purposes, not used in the conversion
26+
variable "replication_specs" {
27+
type = object({
28+
num_shards = number
29+
region_configs = list(object({
30+
prio = number
31+
region_name = string
32+
instance_size = string
33+
node_count = number
34+
}))
35+
})
36+
default = {
37+
num_shards = 3
38+
region_configs = [
39+
{
40+
prio = 7
41+
region_name = "US_EAST_1"
42+
instance_size = "M10"
43+
node_count = 2
44+
},
45+
{
46+
prio = 6
47+
region_name = "US_WEST_2"
48+
instance_size = "M10"
49+
node_count = 1
50+
}
51+
]
52+
}
53+
}

0 commit comments

Comments
 (0)