Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
73e080b
initial doc
lantoli Nov 18, 2025
fd4f4a3
module example
lantoli Nov 18, 2025
06e3a28
network peering with effective fields
lantoli Nov 18, 2025
e871e39
minor changes
lantoli Nov 18, 2025
9406537
improve resource doc
lantoli Nov 18, 2025
29d7b8a
update flag description
lantoli Nov 19, 2025
329469f
versions.tf file
lantoli Nov 19, 2025
9202ae1
this
lantoli Nov 19, 2025
259c05e
reorder examples
lantoli Nov 19, 2025
421c159
classify examples
lantoli Nov 19, 2025
db28bfd
add effective specs in region_configs in resource
lantoli Nov 19, 2025
27b9abd
improve auto_scaling notes
lantoli Nov 19, 2025
f3aea33
improve effective fields section
lantoli Nov 19, 2025
5434a88
fix cluster formatting in new sharding guide
lantoli Nov 19, 2025
ab2aa05
improve example
lantoli Nov 19, 2025
a7d76b4
reorder section
lantoli Nov 19, 2025
0a02431
improve example
lantoli Nov 19, 2025
a0c34ed
simplify Terraform Modules section
lantoli Nov 19, 2025
755aef0
Update examples/mongodbatlas_network_peering/gcp/cluster.tf
lantoli Nov 19, 2025
7aa65a5
auto_scale notes at the end of the section
lantoli Nov 19, 2025
dd6f73d
Update docs/guides/advanced-cluster-new-sharding-schema.md
lantoli Nov 19, 2025
07368e2
Update examples/mongodbatlas_advanced_cluster/auto-scaling-per-shard/…
lantoli Nov 19, 2025
70ec127
flag in data source examples
lantoli Nov 19, 2025
8a1a4e6
feedback use_effective_fields attribute doc
lantoli Nov 19, 2025
fa08b39
fix use_effective_fields doc
lantoli Nov 19, 2025
eee9464
Merge branch 'CLOUDP-313272-dev-effective-fields' into CLOUDP-360060_doc
lantoli Nov 20, 2025
bd644d6
document instance_size behavior
lantoli Nov 20, 2025
4dc42fa
document instance_size behavior in analytics_specs
lantoli Nov 20, 2025
368b363
revert comment when flag is not used
lantoli Nov 20, 2025
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
83 changes: 68 additions & 15 deletions docs/data-sources/advanced_cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ subcategory: "Clusters"
## Example Usage

```terraform
resource "mongodbatlas_advanced_cluster" "example" {
resource "mongodbatlas_advanced_cluster" "this" {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nice! Ensuring consistency 😄

Copy link
Member Author

Choose a reason for hiding this comment

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

yes, I remembered @EspenAlbert suggestion 😄

project_id = "<YOUR-PROJECT-ID>"
name = "cluster-test"
cluster_type = "REPLICASET"
Expand All @@ -42,16 +42,65 @@ resource "mongodbatlas_advanced_cluster" "example" {
]
}

data "mongodbatlas_advanced_cluster" "example" {
project_id = mongodbatlas_advanced_cluster.example.project_id
name = mongodbatlas_advanced_cluster.example.name
data "mongodbatlas_advanced_cluster" "this" {
project_id = mongodbatlas_advanced_cluster.this.project_id
name = mongodbatlas_advanced_cluster.this.name
}
```

## Example using effective fields with auto-scaling

```terraform
resource "mongodbatlas_advanced_cluster" "this" {
project_id = "<YOUR-PROJECT-ID>"
name = "auto-scale-cluster"
cluster_type = "REPLICASET"
use_effective_fields = true

replication_specs = [
{
region_configs = [
{
electable_specs = {
instance_size = "M10" # Initial size value that won't change in Terraform state, actual size in Atlas may differ due to auto-scaling
node_count = 3
}
auto_scaling = {
compute_enabled = true
compute_scale_down_enabled = true
compute_min_instance_size = "M10"
compute_max_instance_size = "M30"
}
provider_name = "AWS"
priority = 7
region_name = "US_EAST_1"
}
]
}
]
}

# Read effective values after Atlas auto-scales the cluster
data "mongodbatlas_advanced_cluster" "this" {
project_id = mongodbatlas_advanced_cluster.this.project_id
name = mongodbatlas_advanced_cluster.this.name
use_effective_fields = true
depends_on = [mongodbatlas_advanced_cluster.this]
}

output "configured_instance_size" {
value = data.mongodbatlas_advanced_cluster.this.replication_specs[0].region_configs[0].electable_specs.instance_size
}

output "actual_instance_size" {
value = data.mongodbatlas_advanced_cluster.this.replication_specs[0].region_configs[0].effective_electable_specs.instance_size
}
```

## Example using latest sharding configurations with independent shard scaling in the cluster

```terraform
resource "mongodbatlas_advanced_cluster" "example" {
resource "mongodbatlas_advanced_cluster" "this" {
project_id = "<YOUR-PROJECT-ID>"
name = "cluster-test"
backup_enabled = false
Expand All @@ -71,7 +120,7 @@ resource "mongodbatlas_advanced_cluster" "example" {
region_name = "EU_WEST_1"
}
]
},
},
{
region_configs = [
{
Expand All @@ -89,20 +138,20 @@ resource "mongodbatlas_advanced_cluster" "example" {
]
}

data "mongodbatlas_advanced_cluster" "example" {
project_id = mongodbatlas_advanced_cluster.example.project_id
name = mongodbatlas_advanced_cluster.example.name
data "mongodbatlas_advanced_cluster" "this" {
project_id = mongodbatlas_advanced_cluster.this.project_id
name = mongodbatlas_advanced_cluster.this.name
}
```

## Example using Flex cluster

```terraform
resource "mongodbatlas_advanced_cluster" "example-flex" {
resource "mongodbatlas_advanced_cluster" "this" {
project_id = "<YOUR-PROJECT-ID>"
name = "flex-cluster"
cluster_type = "REPLICASET"

replication_specs = [
{
region_configs = [
Expand All @@ -117,16 +166,17 @@ resource "mongodbatlas_advanced_cluster" "example-flex" {
]
}

data "mongodbatlas_advanced_cluster" "example" {
project_id = mongodbatlas_advanced_cluster.example-flex.project_id
name = mongodbatlas_advanced_cluster.example-flex.name
data "mongodbatlas_advanced_cluster" "this" {
project_id = mongodbatlas_advanced_cluster.this.project_id
name = mongodbatlas_advanced_cluster.this.name
}
```

## Argument Reference

* `project_id` - (Required) The unique ID for the project to create the cluster.
* `name` - (Required) Name of the cluster as it appears in Atlas. Once the cluster is created, its name cannot be changed.
* `use_effective_fields` - (Optional) Controls how hardware specification fields are returned in the response. When set to true, the non-effective specs (`electable_specs`, `read_only_specs`, `analytics_specs`) fields return the hardware specifications that the client provided. When set to false (default), the non-effective specs fields show the **current** hardware specifications. Cluster auto-scaling is the primary cause for differences between initial and current hardware specifications. **Note:** Effective specs (`effective_electable_specs`, `effective_read_only_specs`, `effective_analytics_specs`) are always returned regardless of the flag value and always report the **current** hardware specifications. See the resource documentation for [Auto-Scaling with Effective Fields](../resources/advanced_cluster.md#auto-scaling-with-effective-fields) for more details.

## Attributes Reference

Expand Down Expand Up @@ -193,7 +243,10 @@ Key-value pairs that categorize the cluster. Each key and value has a maximum le
* `analytics_auto_scaling` - Configuration for the Collection of settings that configures analytics-auto-scaling information for the cluster. See [below](#analytics_auto_scaling).
* `backing_provider_name` - Cloud service provider on which you provision the host for a multi-tenant cluster.
* `electable_specs` - Hardware specifications for electable nodes in the region.
* `priority` - Election priority of the region.
* `effective_electable_specs` - Effective hardware specifications for electable nodes in the region, reflecting actual Atlas-managed values including auto-scaling changes. See [below](#specs).
* `effective_analytics_specs` - Effective hardware specifications for analytics nodes in the region, reflecting actual Atlas-managed values including auto-scaling changes. See [below](#specs).
* `effective_read_only_specs` - Effective hardware specifications for read-only nodes in the region, reflecting actual Atlas-managed values including auto-scaling changes. See [below](#specs).
* `priority` - Election priority of the region.
* `provider_name` - Cloud service provider on which the servers are provisioned.
* `read_only_specs` - Hardware specifications for read-only nodes in the region. See [below](#specs).
* `region_name` - Physical location of your MongoDB cluster.
Expand Down
130 changes: 110 additions & 20 deletions docs/data-sources/advanced_clusters.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ subcategory: "Clusters"
## Example Usage

```terraform
resource "mongodbatlas_advanced_cluster" "example" {
resource "mongodbatlas_advanced_cluster" "this" {
project_id = "<YOUR-PROJECT-ID>"
name = "cluster-test"
cluster_type = "REPLICASET"
Expand All @@ -40,15 +40,97 @@ resource "mongodbatlas_advanced_cluster" "example" {
]
}

data "mongodbatlas_advanced_clusters" "example" {
project_id = mongodbatlas_advanced_cluster.example.project_id
data "mongodbatlas_advanced_clusters" "this" {
project_id = mongodbatlas_advanced_cluster.this.project_id
}
```

## Example using effective fields with auto-scaling

```terraform
resource "mongodbatlas_advanced_cluster" "this" {
project_id = "<YOUR-PROJECT-ID>"
name = "auto-scale-cluster-1"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: Do we have specific criteria for naming clusters? I've noticed it usually follows a CamelCase format (i.e SymmetricShardedCluster), but in others like this one, the spinal-case is used.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think we don't but agreed we could

cluster_type = "REPLICASET"
use_effective_fields = true

replication_specs = [
{
region_configs = [
{
electable_specs = {
instance_size = "M10" # Initial size value that won't change in Terraform state, actual size in Atlas may differ due to auto-scaling
node_count = 3
}
auto_scaling = {
compute_enabled = true
compute_scale_down_enabled = true
compute_min_instance_size = "M10"
compute_max_instance_size = "M30"
}
provider_name = "AWS"
priority = 7
region_name = "US_EAST_1"
}
]
}
]
}

resource "mongodbatlas_advanced_cluster" "this_2" {
project_id = "<YOUR-PROJECT-ID>"
name = "auto-scale-cluster-2"
cluster_type = "REPLICASET"
use_effective_fields = true

replication_specs = [
{
region_configs = [
{
electable_specs = {
instance_size = "M20" # Initial size value that won't change in Terraform state, actual size in Atlas may differ due to auto-scaling
node_count = 3
}
auto_scaling = {
compute_enabled = true
compute_scale_down_enabled = true
compute_min_instance_size = "M20"
compute_max_instance_size = "M40"
}
provider_name = "AWS"
priority = 7
region_name = "US_WEST_2"
}
]
}
]
}

# Read effective values for all clusters in the project
data "mongodbatlas_advanced_clusters" "this" {
project_id = "<YOUR-PROJECT-ID>"
use_effective_fields = true
depends_on = [
mongodbatlas_advanced_cluster.this,
mongodbatlas_advanced_cluster.this_2
]
}

output "all_cluster_names_and_sizes" {
value = [
for cluster in data.mongodbatlas_advanced_clusters.this.results : {
name = cluster.name
configured_size = cluster.replication_specs[0].region_configs[0].electable_specs.instance_size
actual_size = cluster.replication_specs[0].region_configs[0].effective_electable_specs.instance_size
}
]
}
```

## Example using latest sharding configurations with independent shard scaling in the cluster

```terraform
resource "mongodbatlas_advanced_cluster" "example" {
resource "mongodbatlas_advanced_cluster" "this" {
project_id = "<YOUR-PROJECT-ID>"
name = "cluster-test"
backup_enabled = false
Expand All @@ -68,7 +150,7 @@ resource "mongodbatlas_advanced_cluster" "example" {
region_name = "EU_WEST_1"
}
]
},
},
{
region_configs = [
{
Expand All @@ -86,38 +168,43 @@ resource "mongodbatlas_advanced_cluster" "example" {
]
}

data "mongodbatlas_advanced_cluster" "example-asym" {
project_id = mongodbatlas_advanced_cluster.example.project_id
name = mongodbatlas_advanced_cluster.example.name
data "mongodbatlas_advanced_cluster" "this" {
project_id = mongodbatlas_advanced_cluster.this.project_id
name = mongodbatlas_advanced_cluster.this.name
}
```

## Example using Flex cluster

```terraform
resource "mongodbatlas_advanced_cluster" "example-flex" {
resource "mongodbatlas_advanced_cluster" "this" {
project_id = "<YOUR-PROJECT-ID>"
name = "flex-cluster"
cluster_type = "REPLICASET"

replication_specs = [{
region_configs = [{
provider_name = "FLEX"
backing_provider_name = "AWS"
region_name = "US_EAST_1"
priority = 7
}]
}]

replication_specs = [
{
region_configs = [
{
provider_name = "FLEX"
backing_provider_name = "AWS"
region_name = "US_EAST_1"
priority = 7
}
]
}
]
}

data "mongodbatlas_advanced_clusters" "example" {
project_id = mongodbatlas_advanced_cluster.example-flex.project_id
data "mongodbatlas_advanced_clusters" "this" {
project_id = mongodbatlas_advanced_cluster.this.project_id
}
```

## Argument Reference

* `project_id` - (Required) The unique ID for the project to get the clusters.
* `use_effective_fields` - (Optional) Controls how hardware specification fields are returned in the response. When set to true, the non-effective specs (`electable_specs`, `read_only_specs`, `analytics_specs`) fields return the hardware specifications that the client provided. When set to false (default), the non-effective specs fields show the **current** hardware specifications. Cluster auto-scaling is the primary cause for differences between initial and current hardware specifications. **Note:** Effective specs (`effective_electable_specs`, `effective_read_only_specs`, `effective_analytics_specs`) are always returned regardless of the flag value and always report the **current** hardware specifications. See the resource documentation for [Auto-Scaling with Effective Fields](../resources/advanced_cluster.md#auto-scaling-with-effective-fields) for more details.

## Attributes Reference

Expand Down Expand Up @@ -188,6 +275,9 @@ Key-value pairs that categorize the cluster. Each key and value has a maximum le
* `analytics_auto_scaling` - Configuration for the Collection of settings that configures analytis-auto-scaling information for the cluster. See [below](#analytics_auto_scaling).
* `backing_provider_name` - Cloud service provider on which you provision the host for a multi-tenant cluster.
* `electable_specs` - Hardware specifications for electable nodes in the region.
* `effective_electable_specs` - Effective hardware specifications for electable nodes in the region, reflecting actual Atlas-managed values including auto-scaling changes. See [below](#specs).
* `effective_analytics_specs` - Effective hardware specifications for analytics nodes in the region, reflecting actual Atlas-managed values including auto-scaling changes. See [below](#specs).
* `effective_read_only_specs` - Effective hardware specifications for read-only nodes in the region, reflecting actual Atlas-managed values including auto-scaling changes. See [below](#specs).
* `priority` - Election priority of the region.
* `provider_name` - Cloud service provider on which the servers are provisioned.
* `read_only_specs` - Hardware specifications for read-only nodes in the region. See [below](#specs).
Expand Down
Loading
Loading