Skip to content

Terraform lifecycle.ignore_changes Limitation for Autoscaling Scenarios #3427

@uni-manojkumar-n

Description

@uni-manojkumar-n

Hi team.

We are using the MongoDB Atlas Terraform Provider to manage multiple mongodbatlas_cluster resources. Many of these clusters have autoscaling enabled. In those cases, MongoDB Atlas may automatically change values like:

provider_instance_size_name

disk_size_gb

provider_disk_iops

To avoid Terraform constantly trying to revert these autoscaled changes, we want to use the lifecycle { ignore_changes = [...] } block. However, we only want to ignore these fields when autoscaling is enabled.

We tried making ignore_changes conditional, like:

lifecycle {
ignore_changes = var.ignore_cluster_drift ? [
"provider_instance_size_name",
"disk_size_gb",
"provider_disk_iops"
] : []
}
But this fails with the error:

Error: Invalid expression
A static list expression is required.
This is a known Terraform limitation: ignore_changes cannot accept dynamic expressions or variables.

Is there any recommended pattern or guidance from MongoDB for managing autoscaling clusters in Terraform without risking Terraform drift, but still enforcing values when autoscaling is disabled?

Do you recommend always ignoring changes to these fields for all clusters, or is there a safer workaround that works with a shared module?

Are there future improvements planned to better support this Terraform use case?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions