Skip to content

Commit cfe992c

Browse files
authored
feat: added adminuser and certificate_base64 outputs and updated the logic to always output hostname and port details (#333)
1 parent ef7a3a2 commit cfe992c

File tree

11 files changed

+66
-21
lines changed

11 files changed

+66
-21
lines changed

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ You need the following permissions to run this module.
4949
| Name | Version |
5050
|------|---------|
5151
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3.0, <1.7.0 |
52-
| <a name="requirement_ibm"></a> [ibm](#requirement\_ibm) | >= 1.61.0, < 2.0.0 |
52+
| <a name="requirement_ibm"></a> [ibm](#requirement\_ibm) | >= 1.64.2, < 2.0.0 |
5353
| <a name="requirement_time"></a> [time](#requirement\_time) | >= 0.9.1, < 1.0.0 |
5454

5555
### Modules
@@ -102,12 +102,14 @@ You need the following permissions to run this module.
102102

103103
| Name | Description |
104104
|------|-------------|
105+
| <a name="output_adminuser"></a> [adminuser](#output\_adminuser) | Database admin user name |
105106
| <a name="output_cbr_rule_ids"></a> [cbr\_rule\_ids](#output\_cbr\_rule\_ids) | CBR rule ids created to restrict MongoDB |
107+
| <a name="output_certificate_base64"></a> [certificate\_base64](#output\_certificate\_base64) | Database connection certificate |
106108
| <a name="output_crn"></a> [crn](#output\_crn) | MongoDB instance crn |
107109
| <a name="output_guid"></a> [guid](#output\_guid) | MongoDB instance guid |
108-
| <a name="output_hostname"></a> [hostname](#output\_hostname) | Database hostname. Only contains value when var.service\_credential\_names or var.users are set. |
110+
| <a name="output_hostname"></a> [hostname](#output\_hostname) | Database connection hostname |
109111
| <a name="output_id"></a> [id](#output\_id) | MongoDB instance ID |
110-
| <a name="output_port"></a> [port](#output\_port) | Database port. Only contains value when var.service\_credential\_names or var.users are set. |
112+
| <a name="output_port"></a> [port](#output\_port) | Database connection port |
111113
| <a name="output_service_credentials_json"></a> [service\_credentials\_json](#output\_service\_credentials\_json) | Service credentials json map |
112114
| <a name="output_service_credentials_object"></a> [service\_credentials\_object](#output\_service\_credentials\_object) | Service credentials object |
113115
| <a name="output_version"></a> [version](#output\_version) | MongoDB instance version |

examples/basic/outputs.tf

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
##############################################################################
22
# Outputs
33
##############################################################################
4-
54
output "id" {
65
description = "Mongodb instance id"
76
value = module.mongodb.id
@@ -11,3 +10,24 @@ output "version" {
1110
description = "Mongodb instance version"
1211
value = module.mongodb.version
1312
}
13+
14+
output "adminuser" {
15+
description = "Database admin user name"
16+
value = module.mongodb.adminuser
17+
}
18+
19+
output "hostname" {
20+
description = "Database connection hostname"
21+
value = module.mongodb.hostname
22+
}
23+
24+
output "port" {
25+
description = "Database connection port"
26+
value = module.mongodb.port
27+
}
28+
29+
output "certificate_base64" {
30+
description = "Database connection certificate"
31+
value = module.mongodb.certificate_base64
32+
sensitive = true
33+
}

examples/basic/version.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ terraform {
44
# Pin to the lowest provider version of the range defined in the main module's version.tf to ensure lowest version still works
55
ibm = {
66
source = "IBM-Cloud/ibm"
7-
version = "1.61.0"
7+
version = "1.64.2"
88
}
99
}
1010
}

examples/complete/version.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ terraform {
44
# Use latest version of provider in non-basic examples to verify latest version works with module
55
ibm = {
66
source = "IBM-Cloud/ibm"
7-
version = ">=1.61.0, <2.0.0"
7+
version = ">=1.64.2, <2.0.0"
88
}
99
}
1010
}

examples/fscloud/version.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ terraform {
44
# Use latest version of provider in non-basic examples to verify latest version works with module
55
ibm = {
66
source = "IBM-Cloud/ibm"
7-
version = ">=1.61.0, <2.0.0"
7+
version = ">=1.64.2, <2.0.0"
88
}
99
}
1010
}

main.tf

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,9 +209,8 @@ locals {
209209
}
210210

211211
data "ibm_database_connection" "database_connection" {
212-
count = length(var.users) > 0 ? 1 : 0
213212
endpoint_type = var.endpoints
214213
deployment_id = ibm_database.mongodb.id
215-
user_id = var.users[0].name
216-
user_type = var.users[0].type
214+
user_id = ibm_database.mongodb.adminuser
215+
user_type = "database"
217216
}

modules/fscloud/README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ The IBM Cloud Framework for Financial Services mandates the application of an in
1414
| Name | Version |
1515
|------|---------|
1616
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3.0, <1.7.0 |
17-
| <a name="requirement_ibm"></a> [ibm](#requirement\_ibm) | >=1.61.0, <2.0.0 |
17+
| <a name="requirement_ibm"></a> [ibm](#requirement\_ibm) | >=1.64.2, <2.0.0 |
1818

1919
### Modules
2020

@@ -55,12 +55,14 @@ No resources.
5555

5656
| Name | Description |
5757
|------|-------------|
58+
| <a name="output_adminuser"></a> [adminuser](#output\_adminuser) | Database admin user name |
5859
| <a name="output_cbr_rule_ids"></a> [cbr\_rule\_ids](#output\_cbr\_rule\_ids) | CBR rule ids created to restrict MongoDB |
60+
| <a name="output_certificate_base64"></a> [certificate\_base64](#output\_certificate\_base64) | Database connection certificate |
5961
| <a name="output_crn"></a> [crn](#output\_crn) | MongoDB instance crn |
6062
| <a name="output_guid"></a> [guid](#output\_guid) | MongoDB instance guid |
61-
| <a name="output_hostname"></a> [hostname](#output\_hostname) | MongoDB instance hostname |
63+
| <a name="output_hostname"></a> [hostname](#output\_hostname) | Database connection hostname |
6264
| <a name="output_id"></a> [id](#output\_id) | MongoDB instance id |
63-
| <a name="output_port"></a> [port](#output\_port) | MongoDB instance port |
65+
| <a name="output_port"></a> [port](#output\_port) | Database connection port |
6466
| <a name="output_service_credentials_json"></a> [service\_credentials\_json](#output\_service\_credentials\_json) | Service credentials json map |
6567
| <a name="output_service_credentials_object"></a> [service\_credentials\_object](#output\_service\_credentials\_object) | Service credentials object |
6668
| <a name="output_version"></a> [version](#output\_version) | MongoDB instance version |

modules/fscloud/outputs.tf

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,23 @@ output "service_credentials_object" {
3939
sensitive = true
4040
}
4141

42+
output "adminuser" {
43+
description = "Database admin user name"
44+
value = module.mongodb.adminuser
45+
}
46+
4247
output "hostname" {
43-
description = "MongoDB instance hostname"
48+
description = "Database connection hostname"
4449
value = module.mongodb.hostname
4550
}
4651

4752
output "port" {
48-
description = "MongoDB instance port"
53+
description = "Database connection port"
4954
value = module.mongodb.port
5055
}
56+
57+
output "certificate_base64" {
58+
description = "Database connection certificate"
59+
value = module.mongodb.certificate_base64
60+
sensitive = true
61+
}

modules/fscloud/version.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ terraform {
88
ibm = {
99
source = "IBM-Cloud/ibm"
1010
# Use "greater than or equal to" range in modules
11-
version = ">=1.61.0, <2.0.0"
11+
version = ">=1.64.2, <2.0.0"
1212
}
1313
}
1414
}

outputs.tf

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,23 @@ output "service_credentials_object" {
3939
sensitive = true
4040
}
4141

42+
output "adminuser" {
43+
description = "Database admin user name"
44+
value = ibm_database.mongodb.adminuser
45+
}
46+
4247
output "hostname" {
43-
description = "Database hostname. Only contains value when var.service_credential_names or var.users are set."
44-
value = length(var.service_credential_names) > 0 ? nonsensitive(ibm_resource_key.service_credentials[keys(var.service_credential_names)[0]].credentials["connection.mongodb.hosts.0.hostname"]) : length(var.users) > 0 ? data.ibm_database_connection.database_connection[0].mongodb[0].hosts[0].hostname : null
48+
description = "Database connection hostname"
49+
value = data.ibm_database_connection.database_connection.mongodb[0].hosts[0].hostname
4550
}
4651

4752
output "port" {
48-
description = "Database port. Only contains value when var.service_credential_names or var.users are set."
49-
value = length(var.service_credential_names) > 0 ? nonsensitive(ibm_resource_key.service_credentials[keys(var.service_credential_names)[0]].credentials["connection.mongodb.hosts.0.port"]) : length(var.users) > 0 ? data.ibm_database_connection.database_connection[0].mongodb[0].hosts[0].port : null
53+
description = "Database connection port"
54+
value = data.ibm_database_connection.database_connection.mongodb[0].hosts[0].port
55+
}
56+
57+
output "certificate_base64" {
58+
description = "Database connection certificate"
59+
value = data.ibm_database_connection.database_connection.mongodb[0].certificate[0].certificate_base64
60+
sensitive = true
5061
}

0 commit comments

Comments
 (0)