Is there an existing issue for this?
Provider Version
v2.10.0
Terraform Version
v1.14.8
Terraform Edition
Terraform Open Source (OSS)
Current Behavior
After upgrading an Atlas cluster out-of-band from MongoDB 7.0 to 8.0 and unpinning FCV, Atlas API returns:
featureCompatibilityVersion = "8.0"
mongoDBMajorVersion = "8.0"
mongoDBVersion = "8.0.21"
However, mongodbatlas_advanced_cluster appears to keep the previous mongo_db_major_version value from Terraform state ("7.0"), which causes a persistent diff when the configuration is updated to "8.0".
In my case:
- setting
mongo_db_major_version = "8.0" produces a plan with mongo_db_major_version = "7.0" -> "8.0"
- setting
mongo_db_major_version = "7.0" with pinned_fcv = null results in No changes
This makes it look like the provider state is retaining the old major version even though Atlas API reports 8.0.
I believe the issue may be related to this logic in internal/service/advancedcluster/resource_compatiblity.go:
beforeVersion := conversion.NilForUnknown(modelIn.MongoDBMajorVersion, modelIn.MongoDBMajorVersion.ValueStringPointer())
if beforeVersion != nil && !modelIn.MongoDBMajorVersion.Equal(modelOut.MongoDBMajorVersion) {
modelOut.MongoDBMajorVersion = types.StringPointerValue(beforeVersion)
}
That seems to overwrite the API value with the previous state value whenever they differ. This may have been intended to smooth over formatting differences such as 8 vs 8.0, but it also masks a real 7.0 -> 8.0 transition.
Terraform configuration to reproduce the issue
resource "mongodbatlas_advanced_cluster" "test" {
project_id = var.project_id
name = var.cluster_name
cluster_type = "REPLICASET"
mongo_db_major_version = "8.0"
pinned_fcv = null
replication_specs = [{
region_configs = [{
provider_name = "AWS"
region_name = "AP_NORTHEAST_1"
priority = 7
electable_specs = {
instance_size = "M10"
node_count = 3
disk_size_gb = 15
}
auto_scaling = {
compute_enabled = true
compute_scale_down_enabled = true
compute_min_instance_size = "M10"
compute_max_instance_size = "M40"
disk_gb_enabled = true
}
}]
}]
backup_enabled = true
pit_enabled = true
termination_protection_enabled = true
version_release_system = "LTS"
}
variable "project_id" {
type = string
}
variable "cluster_name" {
type = string
}
Steps To Reproduce
- Create and apply the cluster with
mongo_db_major_version = "7.0".
- Upgrade the cluster out-of-band in Atlas UI (or Atlas API) from MongoDB 7.0 to 8.0.
- Unpin FCV so that the cluster is fully on 8.0.
- Verify Atlas API returns:
featureCompatibilityVersion = "8.0"
mongoDBMajorVersion = "8.0"
mongoDBVersion = "8.0.21"
- Update Terraform config to:
mongo_db_major_version = "8.0"
pinned_fcv = null
- Run
terraform plan.
- Observe that Terraform still proposes:
mongo_db_major_version = "7.0" -> "8.0"
even though Atlas API already reports 8.0.
- Optionally, change
mongo_db_major_version back to "7.0" while keeping pinned_fcv = null and run terraform plan again.
- Observe that the plan becomes
No changes, which suggests the provider is preserving the old state value rather than the API value.
Logs
Atlas CLI / Atlas Admin API result:
"featureCompatibilityVersion":"8.0"
"mongoDBMajorVersion":"8.0"
"mongoDBVersion":"8.0.21"
terraform plan excerpt when config uses mongo_db_major_version = "8.0":
~ mongo_db_major_version = "7.0" -> "8.0"
~ mongo_db_version = "8.0.21" -> (known after apply)
terraform plan result when config uses mongo_db_major_version = "7.0" and pinned_fcv = null:
No changes. Your infrastructure matches the configuration.
Code of Conduct
Is there an existing issue for this?
Provider Version
v2.10.0
Terraform Version
v1.14.8
Terraform Edition
Terraform Open Source (OSS)
Current Behavior
After upgrading an Atlas cluster out-of-band from MongoDB 7.0 to 8.0 and unpinning FCV, Atlas API returns:
featureCompatibilityVersion = "8.0"mongoDBMajorVersion = "8.0"mongoDBVersion = "8.0.21"However,
mongodbatlas_advanced_clusterappears to keep the previousmongo_db_major_versionvalue from Terraform state ("7.0"), which causes a persistent diff when the configuration is updated to"8.0".In my case:
mongo_db_major_version = "8.0"produces a plan withmongo_db_major_version = "7.0" -> "8.0"mongo_db_major_version = "7.0"withpinned_fcv = nullresults inNo changesThis makes it look like the provider state is retaining the old major version even though Atlas API reports
8.0.I believe the issue may be related to this logic in
internal/service/advancedcluster/resource_compatiblity.go:That seems to overwrite the API value with the previous state value whenever they differ. This may have been intended to smooth over formatting differences such as
8vs8.0, but it also masks a real7.0->8.0transition.Terraform configuration to reproduce the issue
Steps To Reproduce
mongo_db_major_version = "7.0".featureCompatibilityVersion = "8.0"mongoDBMajorVersion = "8.0"mongoDBVersion = "8.0.21"mongo_db_major_version = "8.0"pinned_fcv = nullterraform plan.mongo_db_major_version = "7.0" -> "8.0"even though Atlas API already reports
8.0.mongo_db_major_versionback to"7.0"while keepingpinned_fcv = nulland runterraform planagain.No changes, which suggests the provider is preserving the old state value rather than the API value.Logs
Code of Conduct