-
Notifications
You must be signed in to change notification settings - Fork 209
doc: Update effective field documentation #3891
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 all commits
73e080b
fd4f4a3
06e3a28
e871e39
9406537
29d7b8a
329469f
9202ae1
259c05e
421c159
db28bfd
27b9abd
f3aea33
5434a88
ab2aa05
a7d76b4
0a02431
a0c34ed
755aef0
7aa65a5
dd6f73d
07368e2
70ec127
8a1a4e6
fa08b39
eee9464
bd644d6
4dc42fa
368b363
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 |
|---|---|---|
|
|
@@ -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" | ||
|
|
@@ -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" | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
|
@@ -68,7 +150,7 @@ resource "mongodbatlas_advanced_cluster" "example" { | |
| region_name = "EU_WEST_1" | ||
| } | ||
| ] | ||
| }, | ||
| }, | ||
| { | ||
| region_configs = [ | ||
| { | ||
|
|
@@ -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 | ||
|
|
||
|
|
@@ -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). | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! Ensuring consistency 😄
There was a problem hiding this comment.
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 😄