Closed ilya-scale closed 1 year ago
@ilya-scale We will have to explore options to restructure the datatype to a list Internal ticket INTMDB-464
Sounds great! Maybe there are better options though that will allow to use autoscaling without an ignore, i.e. not specifying the instance_size directly (at least to have it as an option), but always using the compute_min_instance_size config from autoscaling e.g. as a starting point
@martinstibbe thanks for taking it into a backlog. I'm waiting for such a possibility as well. Seems like it will require changing of attributes structure to list or map instead of a set - https://github.com/hashicorp/terraform/issues/26359#issuecomment-1064652196.
Error example,
╷
│ Error: Cannot index a set value
│
│ on mongodb_atlas_cluster.tf line 70, in resource "mongodbatlas_advanced_cluster" "product_api":
│ 70: replication_specs.region_configs.electable_specs.instance_size
│
│ Block type "replication_specs" is represented by a set of objects, and set elements do not have addressable keys. To find elements matching specific criteria, use a
│ "for" expression with an "if" clause.
Just wanted to add a +1
. We are very interested in this as well.
@ilya-scale @leo-ferlin-sutton @ivan-sukhomlyn brief update, we have allocated this fix to our next v1.8.0 release which should be out next week. will keep you posted when it has been published to the Terraform Registry.
Similar issue but ours is slightly more complex in that our replication_specs
and region_configs
are dynamic. Just wanted to flag the use case so it gets tested with your 1.0 fix.
replication_specs {
dynamic "region_configs" {
for_each = var.regions
content {
region_name = replace(upper(region_configs.value["region_name"]), "-", "_")
provider_name = "AWS"
priority = region_configs.value["electable_nodes"] > 0 ? region_configs.value["priority"] : 0
electable_specs {
node_count = region_configs.value["electable_nodes"]
instance_size = var.provider_default_instance_size
}
read_only_specs {
node_count = region_configs.value["read_only_nodes"]
instance_size = var.provider_default_instance_size
}
auto_scaling {
disk_gb_enabled = true
compute_enabled = true
compute_scale_down_enabled = true
compute_min_instance_size = var.provider_auto_scaling_compute_min_instance_size
compute_max_instance_size = var.provider_auto_scaling_compute_max_instance_size
}
}
}
Worth also noting that your docs about auto_scaling recommend a solution that does not work: https://registry.terraform.io/providers/mongodb/mongodbatlas/latest/docs/resources/advanced_cluster#auto_scaling
@ilya-scale @leo-ferlin-sutton @ivan-sukhomlyn @icco we just released v1.8.0, feel free to give it try! issue should have been resolved.
I can confirm that the issue has been fixed with the v1.8.0 version.
Config example,
lifecycle {
# as storage and compute autoscaling is enabled
ignore_changes = [
disk_size_gb,
replication_specs[0].region_configs[0].electable_specs[0].instance_size
]
}
$ terraform version
+ provider registry.terraform.io/mongodb/mongodbatlas v1.8.0
Thanks @Zuhairahmed @evertsd 👍
Wonderful to hear! Thanks for the confirmation @ivan-sukhomlyn
It seems to work fine for me as well, thanks for the fix!
I agree. Thanks a lot!
Terraform CLI and Terraform MongoDB Atlas Provider Version
Terraform Configuration File
Steps to Reproduce
Expected Behavior
I expect that there is a possibility to ignore instance_size
Actual Behavior
It is not possible to do since terraform does not support referencing elements of a set. This is what I get if I try to reference region_configs:
Debug Output
Crash Output
Additional Context
References
An issue in terraform core that says pretty much that it is not possible to reference sets and providers should use e.g. a list: https://github.com/hashicorp/terraform/issues/26359