Skip to content

Commit

Permalink
Workaround for mongodb_template DataSource problem
Browse files Browse the repository at this point in the history
  • Loading branch information
YannickEvers committed Jul 18, 2024
1 parent 74af620 commit 1f6d436
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion modules/ionos-mongodb-cluster/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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 = terraform_data.template_id_workaround.output
edition = var.resource_template == null ? "enterprise" : null

maintenance_window {
Expand All @@ -25,6 +25,15 @@ 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
Expand Down

0 comments on commit 1f6d436

Please sign in to comment.