Skip to content

doc: Examples for advanced_cluster preview v2 #3054

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Examples for mongodbatlas_advanced_cluster (Preview for MongoDB Atlas Provider v2)

This directory contains examples of using the `mongodbatlas_advanced_cluster` resource for the **Preview for MongoDB Atlas Provider v2**.

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.

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).
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ This example creates a project and a Sharded Cluster with 4 independent shards w

## Dependencies

* Terraform MongoDB Atlas Provider v1.18.0
* Terraform MongoDB Atlas Provider v1.27.0
Copy link
Collaborator

@EspenAlbert EspenAlbert Feb 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we locking in on 1.27? Makes sense to me, if there for some reason is another release before, we can always change it

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that was my thought, it won't be available in previous version, if not in 1.27 we can change again

* A MongoDB Atlas account

```
Terraform >= 0.13
+ provider registry.terraform.io/terraform-providers/mongodbatlas v1.18.0
+ provider registry.terraform.io/terraform-providers/mongodbatlas v1.27.0
```


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,67 +9,63 @@ resource "mongodbatlas_advanced_cluster" "cluster" {
cluster_type = "SHARDED"
backup_enabled = true

replication_specs { # shard 1 - M30 instance size
region_configs {
electable_specs {
replication_specs = [{ # shard 1 - M30 instance size
region_configs = [{
electable_specs = {
instance_size = "M30"
disk_iops = 3000
node_count = 3
}
provider_name = "AWS"
priority = 7
region_name = "EU_WEST_1"
}
}
}]
}, { # shard 2 - M30 instance size

replication_specs { # shard 2 - M30 instance size
region_configs {
electable_specs {
region_configs = [{
electable_specs = {
instance_size = "M30"
disk_iops = 3000
node_count = 3
}
provider_name = "AWS"
priority = 7
region_name = "EU_WEST_1"
}
}
}]
}, { # shard 3 - M40 instance size

replication_specs { # shard 3 - M40 instance size
region_configs {
electable_specs {
region_configs = [{
electable_specs = {
instance_size = "M40"
disk_iops = 3000
node_count = 3
}
provider_name = "AWS"
priority = 7
region_name = "EU_WEST_1"
}
}
}]
}, { # shard 4 - M40 instance size

replication_specs { # shard 4 - M40 instance size
region_configs {
electable_specs {
region_configs = [{
electable_specs = {
instance_size = "M40"
disk_iops = 3000
node_count = 3
}
provider_name = "AWS"
priority = 7
region_name = "EU_WEST_1"
}
}
}]
}]

advanced_configuration {
advanced_configuration = {
javascript_enabled = true
oplog_size_mb = 999
sample_refresh_interval_bi_connector = 300
}

tags {
key = "environment"
value = "dev"
tags = {
environment = "dev"
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ This example creates a Sharded Cluster with 2 shards defining electable and anal

## Dependencies

* Terraform MongoDB Atlas Provider v1.23.0
* Terraform MongoDB Atlas Provider v1.27.0
* A MongoDB Atlas account

```
Terraform >= 0.13
+ provider registry.terraform.io/terraform-providers/mongodbatlas v1.23.0
+ provider registry.terraform.io/terraform-providers/mongodbatlas v1.27.0
```


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,60 +7,60 @@ resource "mongodbatlas_advanced_cluster" "test" {
project_id = mongodbatlas_project.project.id
name = "AutoScalingCluster"
cluster_type = "SHARDED"
replication_specs { # first shard
region_configs {
auto_scaling {
replication_specs = [{ # first shard
region_configs = [{
auto_scaling = {
compute_enabled = true
compute_max_instance_size = "M60"
}
analytics_auto_scaling {
analytics_auto_scaling = {
compute_enabled = true
compute_max_instance_size = "M60"
}
electable_specs {
electable_specs = {
instance_size = "M40"
node_count = 3
}
analytics_specs {
analytics_specs = {
instance_size = "M40"
node_count = 1
}
provider_name = "AWS"
priority = 7
region_name = "EU_WEST_1"
}
}]
zone_name = "Zone 1"
}
replication_specs { # second shard
region_configs {
auto_scaling {
}, { # second shard
region_configs = [{
auto_scaling = {
compute_enabled = true
compute_max_instance_size = "M60"
}
analytics_auto_scaling {
analytics_auto_scaling = {
compute_enabled = true
compute_max_instance_size = "M60"
}
electable_specs {
electable_specs = {
instance_size = "M40"
node_count = 3
}
analytics_specs {
analytics_specs = {
instance_size = "M40"
node_count = 1
}
provider_name = "AWS"
priority = 7
region_name = "EU_WEST_1"
}
}]
zone_name = "Zone 1"
}
}]

lifecycle { # avoids non-empty plans as instance size start to scale from initial values
ignore_changes = [
replication_specs[0].region_configs[0].electable_specs[0].instance_size,
replication_specs[0].region_configs[0].analytics_specs[0].instance_size,
replication_specs[1].region_configs[0].electable_specs[0].instance_size,
replication_specs[1].region_configs[0].analytics_specs[0].instance_size
replication_specs[0].region_configs[0].electable_specs.instance_size,
replication_specs[0].region_configs[0].analytics_specs.instance_size,
replication_specs[1].region_configs[0].electable_specs.instance_size,
replication_specs[1].region_configs[0].analytics_specs.instance_size
]
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ This example creates a project and a Global Cluster with 2 zones where each zone

## Dependencies

* Terraform MongoDB Atlas Provider v1.10.0
* Terraform MongoDB Atlas Provider v1.27.0
* A MongoDB Atlas account

```
Terraform >= 0.13
+ provider registry.terraform.io/terraform-providers/mongodbatlas v1.10.0
+ provider registry.terraform.io/terraform-providers/mongodbatlas v1.27.0
```


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,111 +13,99 @@ resource "mongodbatlas_advanced_cluster" "cluster" {

backup_enabled = true

replication_specs { # shard 1 - zone n1
replication_specs = [{ # shard 1 - zone n1
zone_name = "zone n1"

region_configs {
electable_specs {
region_configs = [{
electable_specs = {
instance_size = "M30"
node_count = 3
}
provider_name = "AWS"
priority = 7
region_name = "US_EAST_1"
}

region_configs {
electable_specs {
}, {
electable_specs = {
instance_size = "M30"
node_count = 2
}
provider_name = "AZURE"
priority = 6
region_name = "US_EAST_2"
}
}
}]
}, { # shard 2 - zone n1

replication_specs { # shard 2 - zone n1
zone_name = "zone n1"

region_configs {
electable_specs {
region_configs = [{
electable_specs = {
instance_size = "M30"
node_count = 3
}
provider_name = "AWS"
priority = 7
region_name = "US_EAST_1"
}

region_configs {
electable_specs {
}, {
electable_specs = {
instance_size = "M30"
node_count = 2
}
provider_name = "AZURE"
priority = 6
region_name = "US_EAST_2"
}
}
}]
}, { # shard 1 - zone n2

replication_specs { # shard 1 - zone n2
zone_name = "zone n2"

region_configs {
electable_specs {
region_configs = [{
electable_specs = {
instance_size = "M30"
node_count = 3
}
provider_name = "AWS"
priority = 7
region_name = "EU_WEST_1"
}

region_configs {
electable_specs {
}, {
electable_specs = {
instance_size = "M30"
node_count = 2
}
provider_name = "AZURE"
priority = 6
region_name = "EUROPE_NORTH"
}
}
}]
}, { # shard 2 - zone n2

replication_specs { # shard 2 - zone n2
zone_name = "zone n2"

region_configs {
electable_specs {
region_configs = [{
electable_specs = {
instance_size = "M30"
node_count = 3
}
provider_name = "AWS"
priority = 7
region_name = "EU_WEST_1"
}

region_configs {
electable_specs {
}, {
electable_specs = {
instance_size = "M30"
node_count = 2
}
provider_name = "AZURE"
priority = 6
region_name = "EUROPE_NORTH"
}
}
}]
}]

advanced_configuration {
advanced_configuration = {
javascript_enabled = true
oplog_size_mb = 999
sample_refresh_interval_bi_connector = 300
}

tags {
key = "environment"
value = "dev"
tags = {
environment = "dev"
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Utilize the following to execute a working example, replacing the org id, public

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

Apply with the following `terraform.tfvars` to upgrade the shared tier cluster you just created to dedicated tier:
```
atlas_org_id = "627a9687f7f7f7f774de306f14"
atlas_org_id = <REDACTED>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't know why we are using REDACTED here. Instead of {ORG_ID} or {PLACEHOLDER} or something else

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's in the spirit of they can use their own org_id, I think it's confusing to have a hardcoded value, in this way they don't they have to enter their own org_id. not strong opinion about change it to {ORG_ID} although it looks like it's a variable, in current way I think it's more clear that they need to enter the number of the org_id

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

at the end I've changed it here: #3059

public_key = <REDACTED>
private_key = <REDACTED>
provider_name = "GCP"
provider_instance_size_name = "M10"
provider_name = "AWS"
provider_instance_size_name = "M10"
Loading
Loading