Skip to content

Commit

Permalink
OPS-6704-mongodb-template-workaround (#32)
Browse files Browse the repository at this point in the history
Workaround for a problem with the ionoscloud_mongo_template DataSource.
  • Loading branch information
YannickEvers authored Jul 25, 2024
1 parent 74af620 commit 2e28fe9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
2 changes: 2 additions & 0 deletions modules/ionos-mongodb-cluster/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
| Name | Version |
|------|---------|
| <a name="provider_ionoscloud"></a> [ionoscloud](#provider\_ionoscloud) | 6.4.18 |
| <a name="provider_null"></a> [null](#provider\_null) | n/a |
## Modules

| Name | Source | Version |
Expand Down Expand Up @@ -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 |
<!-- END_TF_DOCS -->
11 changes: 11 additions & 0 deletions modules/ionos-mongodb-cluster/data.tf
Original file line number Diff line number Diff line change
@@ -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 ]
}
2 changes: 1 addition & 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 = data.null_data_source.template_workaround.outputs["mongo_template_id"]
edition = var.resource_template == null ? "enterprise" : null

maintenance_window {
Expand Down

0 comments on commit 2e28fe9

Please sign in to comment.