Skip to content
This repository was archived by the owner on Jun 30, 2025. It is now read-only.

Commit 3a99c35

Browse files
authored
fix: remove null optional elements before jsonencode is called (resolves this [bug](terraform-ibm-modules/terraform-ibm-icd-postgresql#273) (#37)
1 parent 14fe657 commit 3a99c35

File tree

5 files changed

+14
-7
lines changed

5 files changed

+14
-7
lines changed

examples/complete/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ An end-to-end example that provisions the following infrastructure:
55
- A resource group, if one is not passed in.
66
- A Key Protect instance with a root key.
77
- An instance of Databases for etcd with BYOK encryption and autoscaling.
8+
- Set 250 max connection for Databases for etcd instance.
89
- Service credentials for the database instance.

examples/complete/main.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,7 @@ module "etcd_db" {
4242
tags = var.resource_tags
4343
access_tags = var.access_tags
4444
service_credential_names = var.service_credential_names
45+
configuration = {
46+
max_connections = 250
47+
}
4548
}

main.tf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ resource "ibm_database" "etcd_db" {
5151
tags = var.tags
5252
adminpassword = var.admin_pass
5353
service_endpoints = var.service_endpoints
54-
configuration = var.configuration != null ? jsonencode(var.configuration) : null
54+
# remove elements with null values: see https://github.com/terraform-ibm-modules/terraform-ibm-icd-postgresql/issues/273
55+
configuration = var.configuration != null ? jsonencode({ for k, v in var.configuration : k => v if v != null }) : null
5556

5657
key_protect_key = var.kms_key_crn
5758
backup_encryption_key_crn = local.backup_encryption_key_crn

module-metadata.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@
456456
},
457457
"pos": {
458458
"filename": "main.tf",
459-
"line": 174
459+
"line": 175
460460
}
461461
},
462462
"ibm_resource_tag.etcd_tag": {
@@ -472,7 +472,7 @@
472472
},
473473
"pos": {
474474
"filename": "main.tf",
475-
"line": 123
475+
"line": 124
476476
}
477477
}
478478
},
@@ -492,7 +492,7 @@
492492
},
493493
"pos": {
494494
"filename": "main.tf",
495-
"line": 202
495+
"line": 203
496496
}
497497
}
498498
},
@@ -571,7 +571,7 @@
571571
},
572572
"pos": {
573573
"filename": "main.tf",
574-
"line": 134
574+
"line": 135
575575
}
576576
}
577577
}

tests/pr_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ func TestRunCompleteUpgradeExample(t *testing.T) {
100100
})
101101

102102
output, err := options.RunTestUpgrade()
103-
assert.Nil(t, err, "This should not have errored")
104-
assert.NotNil(t, output, "Expected some output")
103+
if !options.UpgradeTestSkipped {
104+
assert.Nil(t, err, "This should not have errored")
105+
assert.NotNil(t, output, "Expected some output")
106+
}
105107
}

0 commit comments

Comments
 (0)