Skip to content

Commit c64b251

Browse files
authored
doc: Examples for advanced_cluster preview v2 (#3054)
* root readme * fix example as used region doesn't exist in GCP * change examples * undo comment * doc for backing_provider_name
1 parent c1f9a08 commit c64b251

File tree

12 files changed

+106
-117
lines changed

12 files changed

+106
-117
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Examples for mongodbatlas_advanced_cluster (Preview for MongoDB Atlas Provider v2)
2+
3+
This directory contains examples of using the `mongodbatlas_advanced_cluster` resource for the **Preview for MongoDB Atlas Provider v2**.
4+
5+
In order to enable the Preview, you must set the enviroment variable `MONGODB_ATLAS_ADVANCED_CLUSTER_V2_SCHEMA=true`, otherwise the current version will be used.
6+
7+
You can find more info in the [resource doc page](https://registry.terraform.io/providers/mongodb/mongodbatlas/latest/docs/resources/advanced_cluster%2520%2528preview%2520v2%2529).

examples/mongodbatlas_advanced_cluster (preview v2)/asymmetric-sharded-cluster/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ This example creates a project and a Sharded Cluster with 4 independent shards w
44

55
## Dependencies
66

7-
* Terraform MongoDB Atlas Provider v1.18.0
7+
* Terraform MongoDB Atlas Provider v1.27.0
88
* A MongoDB Atlas account
99

1010
```
1111
Terraform >= 0.13
12-
+ provider registry.terraform.io/terraform-providers/mongodbatlas v1.18.0
12+
+ provider registry.terraform.io/terraform-providers/mongodbatlas v1.27.0
1313
```
1414

1515

examples/mongodbatlas_advanced_cluster (preview v2)/asymmetric-sharded-cluster/main.tf

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,67 +9,63 @@ resource "mongodbatlas_advanced_cluster" "cluster" {
99
cluster_type = "SHARDED"
1010
backup_enabled = true
1111

12-
replication_specs { # shard 1 - M30 instance size
13-
region_configs {
14-
electable_specs {
12+
replication_specs = [{ # shard 1 - M30 instance size
13+
region_configs = [{
14+
electable_specs = {
1515
instance_size = "M30"
1616
disk_iops = 3000
1717
node_count = 3
1818
}
1919
provider_name = "AWS"
2020
priority = 7
2121
region_name = "EU_WEST_1"
22-
}
23-
}
22+
}]
23+
}, { # shard 2 - M30 instance size
2424

25-
replication_specs { # shard 2 - M30 instance size
26-
region_configs {
27-
electable_specs {
25+
region_configs = [{
26+
electable_specs = {
2827
instance_size = "M30"
2928
disk_iops = 3000
3029
node_count = 3
3130
}
3231
provider_name = "AWS"
3332
priority = 7
3433
region_name = "EU_WEST_1"
35-
}
36-
}
34+
}]
35+
}, { # shard 3 - M40 instance size
3736

38-
replication_specs { # shard 3 - M40 instance size
39-
region_configs {
40-
electable_specs {
37+
region_configs = [{
38+
electable_specs = {
4139
instance_size = "M40"
4240
disk_iops = 3000
4341
node_count = 3
4442
}
4543
provider_name = "AWS"
4644
priority = 7
4745
region_name = "EU_WEST_1"
48-
}
49-
}
46+
}]
47+
}, { # shard 4 - M40 instance size
5048

51-
replication_specs { # shard 4 - M40 instance size
52-
region_configs {
53-
electable_specs {
49+
region_configs = [{
50+
electable_specs = {
5451
instance_size = "M40"
5552
disk_iops = 3000
5653
node_count = 3
5754
}
5855
provider_name = "AWS"
5956
priority = 7
6057
region_name = "EU_WEST_1"
61-
}
62-
}
58+
}]
59+
}]
6360

64-
advanced_configuration {
61+
advanced_configuration = {
6562
javascript_enabled = true
6663
oplog_size_mb = 999
6764
sample_refresh_interval_bi_connector = 300
6865
}
6966

70-
tags {
71-
key = "environment"
72-
value = "dev"
67+
tags = {
68+
environment = "dev"
7369
}
7470
}
7571

examples/mongodbatlas_advanced_cluster (preview v2)/auto-scaling-per-shard/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ This example creates a Sharded Cluster with 2 shards defining electable and anal
55

66
## Dependencies
77

8-
* Terraform MongoDB Atlas Provider v1.23.0
8+
* Terraform MongoDB Atlas Provider v1.27.0
99
* A MongoDB Atlas account
1010

1111
```
1212
Terraform >= 0.13
13-
+ provider registry.terraform.io/terraform-providers/mongodbatlas v1.23.0
13+
+ provider registry.terraform.io/terraform-providers/mongodbatlas v1.27.0
1414
```
1515

1616

examples/mongodbatlas_advanced_cluster (preview v2)/auto-scaling-per-shard/main.tf

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,60 +7,60 @@ resource "mongodbatlas_advanced_cluster" "test" {
77
project_id = mongodbatlas_project.project.id
88
name = "AutoScalingCluster"
99
cluster_type = "SHARDED"
10-
replication_specs { # first shard
11-
region_configs {
12-
auto_scaling {
10+
replication_specs = [{ # first shard
11+
region_configs = [{
12+
auto_scaling = {
1313
compute_enabled = true
1414
compute_max_instance_size = "M60"
1515
}
16-
analytics_auto_scaling {
16+
analytics_auto_scaling = {
1717
compute_enabled = true
1818
compute_max_instance_size = "M60"
1919
}
20-
electable_specs {
20+
electable_specs = {
2121
instance_size = "M40"
2222
node_count = 3
2323
}
24-
analytics_specs {
24+
analytics_specs = {
2525
instance_size = "M40"
2626
node_count = 1
2727
}
2828
provider_name = "AWS"
2929
priority = 7
3030
region_name = "EU_WEST_1"
31-
}
31+
}]
3232
zone_name = "Zone 1"
33-
}
34-
replication_specs { # second shard
35-
region_configs {
36-
auto_scaling {
33+
}, { # second shard
34+
region_configs = [{
35+
auto_scaling = {
3736
compute_enabled = true
3837
compute_max_instance_size = "M60"
3938
}
40-
analytics_auto_scaling {
39+
analytics_auto_scaling = {
4140
compute_enabled = true
4241
compute_max_instance_size = "M60"
4342
}
44-
electable_specs {
43+
electable_specs = {
4544
instance_size = "M40"
4645
node_count = 3
4746
}
48-
analytics_specs {
47+
analytics_specs = {
4948
instance_size = "M40"
5049
node_count = 1
5150
}
5251
provider_name = "AWS"
5352
priority = 7
5453
region_name = "EU_WEST_1"
55-
}
54+
}]
5655
zone_name = "Zone 1"
57-
}
56+
}]
57+
5858
lifecycle { # avoids non-empty plans as instance size start to scale from initial values
5959
ignore_changes = [
60-
replication_specs[0].region_configs[0].electable_specs[0].instance_size,
61-
replication_specs[0].region_configs[0].analytics_specs[0].instance_size,
62-
replication_specs[1].region_configs[0].electable_specs[0].instance_size,
63-
replication_specs[1].region_configs[0].analytics_specs[0].instance_size
60+
replication_specs[0].region_configs[0].electable_specs.instance_size,
61+
replication_specs[0].region_configs[0].analytics_specs.instance_size,
62+
replication_specs[1].region_configs[0].electable_specs.instance_size,
63+
replication_specs[1].region_configs[0].analytics_specs.instance_size
6464
]
6565
}
6666
}

examples/mongodbatlas_advanced_cluster (preview v2)/global-cluster/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ This example creates a project and a Global Cluster with 2 zones where each zone
44

55
## Dependencies
66

7-
* Terraform MongoDB Atlas Provider v1.10.0
7+
* Terraform MongoDB Atlas Provider v1.27.0
88
* A MongoDB Atlas account
99

1010
```
1111
Terraform >= 0.13
12-
+ provider registry.terraform.io/terraform-providers/mongodbatlas v1.10.0
12+
+ provider registry.terraform.io/terraform-providers/mongodbatlas v1.27.0
1313
```
1414

1515

examples/mongodbatlas_advanced_cluster (preview v2)/global-cluster/main.tf

Lines changed: 28 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -13,111 +13,99 @@ resource "mongodbatlas_advanced_cluster" "cluster" {
1313

1414
backup_enabled = true
1515

16-
replication_specs { # shard 1 - zone n1
16+
replication_specs = [{ # shard 1 - zone n1
1717
zone_name = "zone n1"
1818

19-
region_configs {
20-
electable_specs {
19+
region_configs = [{
20+
electable_specs = {
2121
instance_size = "M30"
2222
node_count = 3
2323
}
2424
provider_name = "AWS"
2525
priority = 7
2626
region_name = "US_EAST_1"
27-
}
28-
29-
region_configs {
30-
electable_specs {
27+
}, {
28+
electable_specs = {
3129
instance_size = "M30"
3230
node_count = 2
3331
}
3432
provider_name = "AZURE"
3533
priority = 6
3634
region_name = "US_EAST_2"
37-
}
38-
}
35+
}]
36+
}, { # shard 2 - zone n1
3937

40-
replication_specs { # shard 2 - zone n1
4138
zone_name = "zone n1"
4239

43-
region_configs {
44-
electable_specs {
40+
region_configs = [{
41+
electable_specs = {
4542
instance_size = "M30"
4643
node_count = 3
4744
}
4845
provider_name = "AWS"
4946
priority = 7
5047
region_name = "US_EAST_1"
51-
}
52-
53-
region_configs {
54-
electable_specs {
48+
}, {
49+
electable_specs = {
5550
instance_size = "M30"
5651
node_count = 2
5752
}
5853
provider_name = "AZURE"
5954
priority = 6
6055
region_name = "US_EAST_2"
61-
}
62-
}
56+
}]
57+
}, { # shard 1 - zone n2
6358

64-
replication_specs { # shard 1 - zone n2
6559
zone_name = "zone n2"
6660

67-
region_configs {
68-
electable_specs {
61+
region_configs = [{
62+
electable_specs = {
6963
instance_size = "M30"
7064
node_count = 3
7165
}
7266
provider_name = "AWS"
7367
priority = 7
7468
region_name = "EU_WEST_1"
75-
}
76-
77-
region_configs {
78-
electable_specs {
69+
}, {
70+
electable_specs = {
7971
instance_size = "M30"
8072
node_count = 2
8173
}
8274
provider_name = "AZURE"
8375
priority = 6
8476
region_name = "EUROPE_NORTH"
85-
}
86-
}
77+
}]
78+
}, { # shard 2 - zone n2
8779

88-
replication_specs { # shard 2 - zone n2
8980
zone_name = "zone n2"
9081

91-
region_configs {
92-
electable_specs {
82+
region_configs = [{
83+
electable_specs = {
9384
instance_size = "M30"
9485
node_count = 3
9586
}
9687
provider_name = "AWS"
9788
priority = 7
9889
region_name = "EU_WEST_1"
99-
}
100-
101-
region_configs {
102-
electable_specs {
90+
}, {
91+
electable_specs = {
10392
instance_size = "M30"
10493
node_count = 2
10594
}
10695
provider_name = "AZURE"
10796
priority = 6
10897
region_name = "EUROPE_NORTH"
109-
}
110-
}
98+
}]
99+
}]
111100

112-
advanced_configuration {
101+
advanced_configuration = {
113102
javascript_enabled = true
114103
oplog_size_mb = 999
115104
sample_refresh_interval_bi_connector = 300
116105
}
117106

118-
tags {
119-
key = "environment"
120-
value = "dev"
107+
tags = {
108+
environment = "dev"
121109
}
122110
}
123111

examples/mongodbatlas_advanced_cluster (preview v2)/tenant-upgrade/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Utilize the following to execute a working example, replacing the org id, public
1515

1616
Apply with the following `terraform.tfvars` to first create a shared tier cluster:
1717
```
18-
atlas_org_id = "627a9687f7f7f7f774de306f14"
18+
atlas_org_id = <REDACTED>
1919
public_key = <REDACTED>
2020
private_key = <REDACTED>
2121
provider_name = "TENANT"
@@ -25,8 +25,8 @@ provider_instance_size_name = "M2"
2525

2626
Apply with the following `terraform.tfvars` to upgrade the shared tier cluster you just created to dedicated tier:
2727
```
28-
atlas_org_id = "627a9687f7f7f7f774de306f14"
28+
atlas_org_id = <REDACTED>
2929
public_key = <REDACTED>
3030
private_key = <REDACTED>
31-
provider_name = "GCP"
32-
provider_instance_size_name = "M10"
31+
provider_name = "AWS"
32+
provider_instance_size_name = "M10"

0 commit comments

Comments
 (0)