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 ac238d4..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 = terraform_data.template_id_workaround.output + template_id = data.null_data_source.template_workaround.outputs["mongo_template_id"] edition = var.resource_template == null ? "enterprise" : null maintenance_window { @@ -25,15 +25,6 @@ resource ionoscloud_mongo_cluster "mongo_cluster" { } } -# 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 resource is in between and the output is unknown in the initial plan, solving the problem. -resource "terraform_data" "template_id_workaround" { - input = var.resource_template == null ? null : data.ionoscloud_mongo_template.mongo_template[0].id - depends_on = [ data.ionoscloud_mongo_template.mongo_template ] -} - resource "ionoscloud_mongo_user" "initial_mongo_user" { for_each = var.users cluster_id = ionoscloud_mongo_cluster.mongo_cluster.id