-
Notifications
You must be signed in to change notification settings - Fork 207
doc: Adds examples for advanced_cluster upgrade to v2.0 & improves documentation #3767
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
Changes from 12 commits
44f53c8
7de8b29
da12de7
ddb255f
f2b83c5
5a52443
4a3f929
f4cce6d
ae2c6ab
3020d5e
97805a6
98bc7ad
733c619
97b8c99
6e1a978
8c41d7d
2ba836a
25ff428
03d0d66
b5c1168
bf47f5c
49b5467
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -8,6 +8,28 @@ page_title: "Migration Guide: Advanced Cluster New Sharding Configurations" | |||
|
||||
Note: Once applied, the `mongodbatlas_advanced_cluster` resource making use of the new sharding configuration will not be able to transition back to the old sharding configuration. | ||||
|
||||
## Who should read this guide? | ||||
maastha marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||
|
||||
This guide is intended for **customers using or migrating to the `mongodbatlas_advanced_cluster` resource** who want to understand the **new sharding model that allows you to scale shards independently**. | ||||
|
||||
Use this guide if any of the following applies to you: | ||||
|
||||
- **You currently use the legacy schema** (your configuration defines `num_shards` and a single `replication_specs` block): | ||||
→ Follow this guide to understand how multiple `replication_specs` blocks now represent shards individually, allowing you to scale or modify each shard independently. | ||||
→ As mentioned in the [Prerequisites](#prerequisites), once you understand the new model, proceed to the [Migrate to Advanced Cluster 2.0](migrate-to-advanced-cluster-2.0) guide to update your configuration to the latest schema first in order to upgrade to provider version 2.0.0 or later. | ||||
|
||||
- **You currently use v1.x.x of the provider with the preview schema** (using the `MONGODB_ATLAS_PREVIEW_PROVIDER_V2_ADVANCED_CLUSTER=true` environment variable and list-style attributes): | ||||
|
### Attribute vs Block Syntax |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Upgrade `mongodbatlas_advanced_cluster` v1.x → v2.0.0 (Asymmetric Sharded Cluster) | ||
|
||
This directory uses the deprecated v1.x schema version of the asymmetric sharded cluster example for migration reference. | ||
Refer the `main.tf` in the parent directory (`../`) that shows what the corresponding configuration should look like after upgrading to provider v2.0.0+. | ||
|
||
**For details & to learn how to migrate, review the complete [Migration Guide: Advanced Cluster (v1.x → v2.0.0)](https://registry.terraform.io/providers/mongodb/mongodbatlas/latest/docs/guides/migrate-to-advanced-cluster-2.0#how-to-migrate)** | ||
|
||
## Key changes in v2.0.0 | ||
- `replication_specs` becomes a list of objects (was blocks in v1.x). | ||
- `region_configs` becomes a list of objects (was blocks in v1.x). | ||
- `electable_specs` becomes an attribute (was a nested block in v1.x). | ||
- `advanced_configuration` becomes an attribute (was a block in v1.x). | ||
- `tags` becomes a map attribute (was blocks in v1.x). | ||
- Per-shard configuration remains explicit and can vary (e.g., different `instance_size` per shard). | ||
- **If previously using** `disk_size_gb` at resource root level, it has been removed in v2.0.0 and now can be specified into the inner specs (for example, `electable_specs.disk_size_gb`). | ||
- Some references drop `[0]` or `.0` indexing because objects are no longer lists but singular attributes (e.g., `replication_specs[0].region_configs[0].electable_specs.disk_size_gb`). |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
provider "mongodbatlas" { | ||
public_key = var.public_key | ||
maastha marked this conversation as resolved.
Show resolved
Hide resolved
|
||
private_key = var.private_key | ||
maastha marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
# Below is the old v1.x schema of mongodbatlas_advanced_cluster. | ||
# To migrate to v2.0.0+, see the main.tf in the parent directory. Refer README.md for more details. | ||
resource "mongodbatlas_advanced_cluster" "cluster" { | ||
project_id = mongodbatlas_project.project.id | ||
name = var.cluster_name | ||
cluster_type = "SHARDED" | ||
backup_enabled = true | ||
disk_size_gb = 10 # removed in v2.0.0+, this can now be set per shard for inner specs | ||
|
||
# replication_specs are updated to a list of objects instead of blocks in v2.0.0+ | ||
replication_specs { # shard 1 - M30 instance size | ||
region_configs { # region_configs are updated to a list of objects instead of blocks in v2.0.0+ | ||
electable_specs { # electable_specs are updated to an attribute instead of a block in v2.0.0+ | ||
instance_size = "M30" | ||
disk_iops = 3000 | ||
node_count = 3 | ||
} | ||
provider_name = "AWS" | ||
priority = 7 | ||
region_name = "EU_WEST_1" | ||
} | ||
} | ||
|
||
replication_specs { # shard 2 - 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" | ||
} | ||
} | ||
|
||
replication_specs { # shard 3 - M40 instance size | ||
region_configs { | ||
electable_specs { | ||
instance_size = "M40" | ||
disk_iops = 3000 | ||
node_count = 3 | ||
} | ||
provider_name = "AWS" | ||
priority = 7 | ||
region_name = "EU_WEST_1" | ||
} | ||
} | ||
|
||
replication_specs { # shard 4 - M40 instance size | ||
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 are updated to an attribute instead of a block in v2.0.0+ | ||
javascript_enabled = true | ||
oplog_size_mb = 999 | ||
sample_refresh_interval_bi_connector = 300 | ||
} | ||
|
||
tags { # tags and labels are updated to maps instead of blocks in v2.0.0+ | ||
key = "environment" | ||
value = "dev" | ||
} | ||
} | ||
|
||
resource "mongodbatlas_project" "project" { | ||
name = "Asymmetric Sharded Cluster" | ||
org_id = var.atlas_org_id | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
variable "atlas_org_id" { | ||
description = "Atlas organization id" | ||
type = string | ||
} | ||
variable "public_key" { | ||
maastha marked this conversation as resolved.
Show resolved
Hide resolved
|
||
description = "Public API key to authenticate to Atlas" | ||
type = string | ||
} | ||
variable "private_key" { | ||
description = "Private API key to authenticate to Atlas" | ||
type = string | ||
} | ||
variable "cluster_name" { | ||
description = "Atlas cluster name" | ||
type = string | ||
default = "AsymmetricShardedCluster" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
terraform { | ||
required_providers { | ||
mongodbatlas = { | ||
source = "mongodb/mongodbatlas" | ||
version = "<=1.41.0" | ||
} | ||
} | ||
required_version = ">= 1.0" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Upgrade `mongodbatlas_advanced_cluster` v1.x → v2.0.0 (Auto-scaling per Shard) | ||
|
||
This directory contains the deprecated v1.x schema version of the auto-scaling per shard example for migration reference. | ||
Refer the `main.tf` in the parent directory (`../`) that shows what the corresponding configuration should look like after upgrading to provider v2.0.0+. | ||
|
||
**For details & to learn how to migrate, review the complete [Migration Guide: Advanced Cluster (v1.x → v2.0.0)](https://registry.terraform.io/providers/mongodb/mongodbatlas/latest/docs/guides/migrate-to-advanced-cluster-2.0#how-to-migrate)** | ||
|
||
## Key changes in v2.0.0 | ||
- `replication_specs` becomes a list of objects (was a block in v1.x). | ||
- `region_configs` becomes a list of objects (was a block in v1.x). | ||
- `auto_scaling` and `analytics_auto_scaling` become attributes (were nested blocks in v1.x). | ||
- `electable_specs` becomes an attribute (was a nested block in v1.x). | ||
- **If previously using** `disk_size_gb` at resource root level, it has been removed in v2.0.0 and now can be specified into the inner specs (for example, `electable_specs.disk_size_gb`). | ||
- Some references drop `[0]` or `.0` indexing because nested objects are no longer lists. |
Uh oh!
There was an error while loading. Please reload this page.