diff --git a/modules/ionos-mongodb-cluster/README.md b/modules/ionos-mongodb-cluster/README.md index 1568db0..741712c 100644 --- a/modules/ionos-mongodb-cluster/README.md +++ b/modules/ionos-mongodb-cluster/README.md @@ -5,6 +5,7 @@ | Name | Version | |------|---------| | [ionoscloud](#provider\_ionoscloud) | 6.4.18 | +| [null](#provider\_null) | n/a | ## Modules | Name | Source | Version | @@ -52,4 +53,5 @@ | [ionoscloud_mongo_cluster.mongo_cluster](https://registry.terraform.io/providers/ionos-cloud/ionoscloud/6.4.18/docs/resources/mongo_cluster) | resource | | [ionoscloud_mongo_user.initial_mongo_user](https://registry.terraform.io/providers/ionos-cloud/ionoscloud/6.4.18/docs/resources/mongo_user) | resource | | [ionoscloud_mongo_template.mongo_template](https://registry.terraform.io/providers/ionos-cloud/ionoscloud/6.4.18/docs/data-sources/mongo_template) | data source | +| [null_data_source.template_workaround](https://registry.terraform.io/providers/hashicorp/null/latest/docs/data-sources/data_source) | data source | \ No newline at end of file diff --git a/modules/ionos-mongodb-cluster/data.tf b/modules/ionos-mongodb-cluster/data.tf index 0644a1c..e7d4cd1 100644 --- a/modules/ionos-mongodb-cluster/data.tf +++ b/modules/ionos-mongodb-cluster/data.tf @@ -1,4 +1,15 @@ data "ionoscloud_mongo_template" "mongo_template" { count = var.resource_template == null ? 0 : 1 name = var.resource_template +} + +# Workaround +# There's probably a bug in the IONOS Provider: The DataSource ionoscloud_mongo_template doesn't define id +# as computed, leading to an inconsistent final plan (id is null instead of unknown in the initial plan) +# This null_data_source is in between and the output is unknown in the initial plan, solving the problem. +data "null_data_source" "template_workaround" { + inputs = { + mongo_template_id = var.resource_template == null ? null : data.ionoscloud_mongo_template.mongo_template[0].id + } + depends_on = [ data.ionoscloud_mongo_template.mongo_template ] } \ No newline at end of file diff --git a/modules/ionos-mongodb-cluster/main.tf b/modules/ionos-mongodb-cluster/main.tf index 7c6e674..2182229 100644 --- a/modules/ionos-mongodb-cluster/main.tf +++ b/modules/ionos-mongodb-cluster/main.tf @@ -16,7 +16,7 @@ resource ionoscloud_mongo_cluster "mongo_cluster" { cidr_list = local.cidrs } - template_id = var.resource_template == null ? null : data.ionoscloud_mongo_template.mongo_template[0].id + template_id = data.null_data_source.template_workaround.outputs["mongo_template_id"] edition = var.resource_template == null ? "enterprise" : null maintenance_window {