-
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
doc: Update effective field documentation #3891
Conversation
|
APIx bot: a message has been sent to Docs Slack channel |
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.
Pull Request Overview
This PR updates documentation to introduce the use_effective_fields attribute for the mongodbatlas_advanced_cluster resource. This new opt-in feature simplifies auto-scaling workflows by eliminating the need for lifecycle.ignore_changes blocks and providing visibility into Atlas-managed changes through effective field attributes.
Key Changes:
- Introduction of
use_effective_fieldsattribute documentation explaining its purpose and benefits for auto-scaling scenarios - Updates to examples demonstrating the recommended approach for managing auto-scaled clusters
- Addition of new module examples showing how to build reusable Terraform modules that support both auto-scaling and non-auto-scaling configurations
Reviewed Changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| examples/mongodbatlas_network_peering/gcp/cluster.tf | Demonstrates use_effective_fields in a VPC peering scenario, removes lifecycle blocks |
| examples/mongodbatlas_advanced_cluster/effective-fields-module/*/versions.tf | Defines Terraform and provider version requirements for new module examples |
| examples/mongodbatlas_advanced_cluster/effective-fields-module/*/variables.tf | Defines input variables for module examples |
| examples/mongodbatlas_advanced_cluster/effective-fields-module/*/main.tf | Implements module examples with and without auto-scaling using use_effective_fields |
| examples/mongodbatlas_advanced_cluster/effective-fields-module/module/*.tf | Provides reusable module implementation demonstrating effective fields usage |
| examples/mongodbatlas_advanced_cluster/effective-fields-module/README.md | Comprehensive documentation for the effective fields module examples |
| examples/mongodbatlas_advanced_cluster/auto-scaling-per-shard/. | Updates auto-scaling per shard example to use recommended use_effective_fields approach |
| docs/resources/advanced_cluster.md | Extensive documentation updates explaining use_effective_fields, effective specs, and migration path |
| docs/guides/*.md | Updates migration and sharding guides to reference new effective fields functionality |
| docs/data-sources/advanced_cluster*.md | Documents use_effective_fields and effective spec attributes in data sources |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
examples/mongodbatlas_advanced_cluster/effective-fields-module/README.md
Show resolved
Hide resolved
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
|
||
| * `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, returns the original client-specified values and provides separate effective fields showing current operational values. When false (default), hardware specification fields show current operational values directly. Primarily used for autoscaling compatibility. **Note:** Effective specs (`effective_electable_specs`, `effective_analytics_specs`, `effective_read_only_specs`) are always returned independently of the flag value. See the resource documentation for [Auto-Scaling with Effective Fields](../resources/advanced_cluster.md#auto-scaling-with-effective-fields) for more details. |
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.
| * `use_effective_fields` - (Optional) Controls how hardware specification fields are returned in the response. When set to true, returns the original client-specified values and provides separate effective fields showing current operational values. When false (default), hardware specification fields show current operational values directly. Primarily used for autoscaling compatibility. **Note:** Effective specs (`effective_electable_specs`, `effective_analytics_specs`, `effective_read_only_specs`) are always returned independently of the flag value. See the resource documentation for [Auto-Scaling with Effective Fields](../resources/advanced_cluster.md#auto-scaling-with-effective-fields) for more details. | |
| * `use_effective_fields` - (Optional) Controls how hardware specification fields (e.g. `instance_size`) are returned in the response. When set to true, returns the original client-specified values and provides separate effective fields showing current operational values. When false (default), hardware specification fields show current operational values directly. Primarily used for autoscaling compatibility. **Note:** Effective specs (`effective_electable_specs`, `effective_analytics_specs`, `effective_read_only_specs`) are always returned independently of the flag value. See the resource documentation for [Auto-Scaling with Effective Fields](../resources/advanced_cluster.md#auto-scaling-with-effective-fields) for more details. |
I think Primarily used for autoscaling compatibility. is confusing, what are you referring to?
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.
the first part is directly got from API doc: "Controls how hardware specification fields are returned in the response. When set to true, returns the original client-specified values and provides separate effective fields showing current operational values. When false (default), hardware specification fields show current operational values directly. Primarily used for autoscaling compatibility."
Agreed it's a bit confusing, I interpreted it's to help with autoscaling
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.
looking with @jwilliams-mongo to change it
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.
|
|
||
| * `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, returns the original client-specified values and provides separate effective fields showing current operational values. When false (default), hardware specification fields show current operational values directly. Primarily used for autoscaling compatibility. **Note:** Effective specs (`effective_electable_specs`, `effective_analytics_specs`, `effective_read_only_specs`) are always returned independently of the flag value. See the resource documentation for [Auto-Scaling with Effective Fields](../resources/advanced_cluster.md#auto-scaling-with-effective-fields) for more details. |
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.
could we perhaps link this section to the previous "ignore_changes" recommendation we have in our docs, meaning that setting it to true resolves the need of using ignore_changes
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.
data source doc doesn't mention ignore_changes, it's only in the resource doc, that's why I think it's fine as it is, with the last link to the resource effective-field specific section with all the info including ignore_changes: ../resources/advanced_cluster.md#auto-scaling-with-effective-fields
or maybe i didn't understand you
|
|
||
| ```terraform | ||
| resource "mongodbatlas_advanced_cluster" "example" { | ||
| resource "mongodbatlas_advanced_cluster" "this" { |
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 😄
AgustinBettati
left a comment
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.
LGTM
| name = "AutoScalingCluster" | ||
| cluster_type = "SHARDED" | ||
| use_effective_fields = true | ||
|
|
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.
nit: Maybe we can add a comment on the electable_specs.instance_size attribute to clarify the value will be preserved but will not reflect actual scaling.
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.
good idea, added this comment when applicable:
instance_size = "M10" # Initial size value that won't change in Terraform state, actual size in Atlas may differ due to auto-scaling
| @@ -0,0 +1,297 @@ | |||
| # MongoDB Atlas Advanced Cluster Module with Effective Fields | |||
|
|
|||
| This example demonstrates a reusable Terraform module for MongoDB Atlas clusters that supports both auto-scaling and non-auto-scaling configurations without requiring `lifecycle.ignore_changes` blocks. | |||
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
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.
+1 very nicely written
examples/mongodbatlas_advanced_cluster/effective-fields-module/README.md
Show resolved
Hide resolved
| ```terraform | ||
| resource "mongodbatlas_advanced_cluster" "this" { | ||
| project_id = "<YOUR-PROJECT-ID>" | ||
| name = "auto-scale-cluster-1" |
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.
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.
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.
I think we don't but agreed we could
marcabreracast
left a comment
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.
LGTM
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.
a few minor comments (mainly suggested revision of use_effective_fields definition). Looks great
|
|
||
| * `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, returns the original client-specified values and provides separate effective fields showing current operational values. When false (default), hardware specification fields show current operational values directly. Primarily used for autoscaling compatibility. **Note:** Effective specs (`effective_electable_specs`, `effective_analytics_specs`, `effective_read_only_specs`) are always returned independently of the flag value. See the resource documentation for [Auto-Scaling with Effective Fields](../resources/advanced_cluster.md#auto-scaling-with-effective-fields) for more details. |
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.
| * `use_effective_fields` - (Optional) Controls how hardware specification fields are returned in the response. When set to true, returns the original client-specified values and provides separate effective fields showing current operational values. When false (default), hardware specification fields show current operational values directly. Primarily used for autoscaling compatibility. **Note:** Effective specs (`effective_electable_specs`, `effective_analytics_specs`, `effective_read_only_specs`) are always returned independently of the flag value. See the resource documentation for [Auto-Scaling with Effective Fields](../resources/advanced_cluster.md#auto-scaling-with-effective-fields) for more details. | |
| * `use_effective_fields` - (Optional) Controls how hardware specification fields are returned in the response. When set to true, the `analytics_specs`, electable_specs`, and `read_only_specs` fields return the hardware specifications that the client provided. When set to false (default), the `analytics_specs`, electable_specs`, and `read_only_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_analytics_specs`, `effective_read_only_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. |
left a few suggestions for clarity. One question: if a user manually scales a cluster and this field is set to true would the original hardware configuration or the new one be returned for the non-effective fields? The answer might cause me to slightly alter suggestion
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.
the first part is exactly like that in API doc: "Controls how hardware specification fields are returned in the response. When set to true, returns the original client-specified values and provides separate effective fields showing current operational values. When false (default), hardware specification fields show current operational values directly. Primarily used for autoscaling compatibility."
@jwilliams-mongo I'm ok to change it here, then do you mind to create a ticket to MMS to align with your suggestion? Or we can keep Atlas doc text if that's preferred.
return the hardware specifications that the client provided when the resource was created
not totally accurate, the user can update the cluster specs in TF config and these new values will be returned, so we can delete "when the resource was created" from that sentence.
if a user manually scales a cluster and this field is set to true would the original hardware configuration or the new one be returned for the non-effective fields
for non-effective specs: the original one (configured in Terraform) when true so there is no state drift
for effective specs: always the new values, are unaffected by flag value.
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.
I can file a ticket because we should adjust this upstream as well. I had to read it a few times to understand as-written.
revised suggestion to remove "when resource was created".
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.
thanks @jwilliams-mongo for taking care of the MMS ticket.
I've updated the doc with your suggestion, only difference i've reduced writing the 3 specs to only once, WDYT? commit with changes: 8a1a4e6
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.
was not correct, fixed here: fa08b39
| ## 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, returns the original client-specified values and provides separate effective fields showing current operational values. When false (default), hardware specification fields show current operational values directly. Primarily used for autoscaling compatibility. **Note:** Effective specs (`effective_electable_specs`, `effective_analytics_specs`, `effective_read_only_specs`) are always returned independently of the flag value. See the resource documentation for [Auto-Scaling with Effective Fields](../resources/advanced_cluster.md#auto-scaling-with-effective-fields) for more details. |
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.
see comment above
examples/mongodbatlas_advanced_cluster/auto-scaling-per-shard/README.md
Outdated
Show resolved
Hide resolved
| @@ -0,0 +1,297 @@ | |||
| # MongoDB Atlas Advanced Cluster Module with Effective Fields | |||
|
|
|||
| This example demonstrates a reusable Terraform module for MongoDB Atlas clusters that supports both auto-scaling and non-auto-scaling configurations without requiring `lifecycle.ignore_changes` blocks. | |||
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.
+1 very nicely written
Co-authored-by: John Williams <55147273+jwilliams-mongo@users.noreply.github.com>
…README.md Co-authored-by: John Williams <55147273+jwilliams-mongo@users.noreply.github.com>
* CLOUDP-313272-dev-effective-fields: test: Fixes `TestAccEventTriggerDSPlural_realmClientWorks` failing test (#3899) chore: Bump actions/checkout from 5.0.0 to 5.0.1 (#3896) chore: Bump github.com/hashicorp/terraform-plugin-log (#3897) chore: Avoids accidental context.Background usage to support all analytics (#3888) doc: Fix assume_role.role_arn doc (#3894) build(deps): bump go.mongodb.org/atlas-sdk (#3890) Add older version of autogen cluster_api (#3892) chore: Generate and consume flattened multi-version API Spec in autogeneration (#3884)
|
I propose we make effective fields the only recommendation and remove the life cycle improvement reference and note
|
|
as discussed offline I'm going to go ahead and merge |
3938b53
into
CLOUDP-313272-dev-effective-fields
Description
Update effective field documentation
Doc changes:
Link to any related issue(s): CLOUDP-360060
Type of change:
Required Checklist:
Further comments