Skip to content

Commit 2b6eeba

Browse files
feat: add support to optionally create database users in the FSCloud profile submodule (using new users variable), and admin password (using new admin_pass variable) + add new outputs hostname and port to the FSCloud profile submodule, which will only output if users or service credentials are created. (#206)
1 parent 45b7abf commit 2b6eeba

File tree

4 files changed

+35
-0
lines changed

4 files changed

+35
-0
lines changed

profiles/fscloud/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ No resources.
3131
| Name | Description | Type | Default | Required |
3232
|------|-------------|------|---------|:--------:|
3333
| <a name="input_access_tags"></a> [access\_tags](#input\_access\_tags) | A list of access tags to apply to the PostgreSQL instance created by the module, see https://cloud.ibm.com/docs/account?topic=account-access-tags-tutorial for more details | `list(string)` | `[]` | no |
34+
| <a name="input_admin_pass"></a> [admin\_pass](#input\_admin\_pass) | The password for the database administrator. If the admin password is null then the admin user ID cannot be accessed. More users can be specified in a user block. The admin password must be in the range of 10-32 characters. | `string` | `null` | no |
3435
| <a name="input_auto_scaling"></a> [auto\_scaling](#input\_auto\_scaling) | Optional rules to allow the database to increase resources in response to usage. Only a single autoscaling block is allowed. Make sure you understand the effects of autoscaling, especially for production environments. See https://ibm.biz/autoscaling-considerations in the IBM Cloud Docs. | <pre>object({<br> disk = object({<br> capacity_enabled = optional(bool, false)<br> free_space_less_than_percent = optional(number, 10)<br> io_above_percent = optional(number, 90)<br> io_enabled = optional(bool, false)<br> io_over_period = optional(string, "15m")<br> rate_increase_percent = optional(number, 10)<br> rate_limit_mb_per_member = optional(number, 3670016)<br> rate_period_seconds = optional(number, 900)<br> rate_units = optional(string, "mb")<br> })<br> memory = object({<br> io_above_percent = optional(number, 90)<br> io_enabled = optional(bool, false)<br> io_over_period = optional(string, "15m")<br> rate_increase_percent = optional(number, 10)<br> rate_limit_mb_per_member = optional(number, 114688)<br> rate_period_seconds = optional(number, 900)<br> rate_units = optional(string, "mb")<br> })<br> })</pre> | `null` | no |
3536
| <a name="input_cbr_rules"></a> [cbr\_rules](#input\_cbr\_rules) | (Optional, list) List of CBR rules to create | <pre>list(object({<br> description = string<br> account_id = string<br> rule_contexts = list(object({<br> attributes = optional(list(object({<br> name = string<br> value = string<br> }))) }))<br> enforcement_mode = string<br> }))</pre> | `[]` | no |
3637
| <a name="input_configuration"></a> [configuration](#input\_configuration) | Database configuration. | <pre>object({<br> max_connections = optional(number)<br> max_prepared_transactions = optional(number)<br> deadlock_timeout = optional(number)<br> effective_io_concurrency = optional(number)<br> max_replication_slots = optional(number)<br> max_wal_senders = optional(number)<br> shared_buffers = optional(number)<br> synchronous_commit = optional(string)<br> wal_level = optional(string)<br> archive_timeout = optional(number)<br> log_min_duration_statement = optional(number)<br> })</pre> | `null` | no |
@@ -47,13 +48,16 @@ No resources.
4748
| <a name="input_resource_tags"></a> [resource\_tags](#input\_resource\_tags) | Optional list of tags to be added to the PostgreSQL instance. | `list(string)` | `[]` | no |
4849
| <a name="input_service_credential_names"></a> [service\_credential\_names](#input\_service\_credential\_names) | Map of name, role for service credentials that you want to create for the database | `map(string)` | `{}` | no |
4950
| <a name="input_skip_iam_authorization_policy"></a> [skip\_iam\_authorization\_policy](#input\_skip\_iam\_authorization\_policy) | Set to true to skip the creation of an IAM authorization policy that permits all PostgreSQL database instances in the resource group to read the encryption key from the Hyper Protect Crypto Services instance. The HPCS instance is passed in through the var.existing\_kms\_instance\_guid variable. | `bool` | `false` | no |
51+
| <a name="input_users"></a> [users](#input\_users) | A list of users that you want to create on the database. Multiple blocks are allowed. The user password must be in the range of 10-32 characters. Be warned that in most case using IAM service credentials (via the var.service\_credential\_names) is sufficient to control access to the Postgres instance. This blocks creates native postgres database users, more info on that can be found here https://cloud.ibm.com/docs/databases-for-postgresql?topic=databases-for-postgresql-user-management&interface=ui | <pre>list(object({<br> name = string<br> password = string # pragma: allowlist secret<br> type = string # "type" is required to generate the connection string for the outputs.<br> role = optional(string)<br> }))</pre> | `[]` | no |
5052

5153
## Outputs
5254

5355
| Name | Description |
5456
|------|-------------|
5557
| <a name="output_crn"></a> [crn](#output\_crn) | Postgresql instance crn |
5658
| <a name="output_guid"></a> [guid](#output\_guid) | Postgresql instance guid |
59+
| <a name="output_hostname"></a> [hostname](#output\_hostname) | Postgresql instance hostname |
5760
| <a name="output_id"></a> [id](#output\_id) | Postgresql instance id |
61+
| <a name="output_port"></a> [port](#output\_port) | Postgresql instance port |
5862
| <a name="output_version"></a> [version](#output\_version) | Postgresql instance version |
5963
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->

profiles/fscloud/main.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ module "postgresql_db" {
1818
member_disk_mb = var.member_disk_mb
1919
member_cpu_count = var.member_cpu_count
2020
members = var.members
21+
admin_pass = var.admin_pass
22+
users = var.users
2123
service_credential_names = var.service_credential_names
2224
auto_scaling = var.auto_scaling
2325
}

profiles/fscloud/outputs.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,13 @@ output "crn" {
2121
description = "Postgresql instance crn"
2222
value = module.postgresql_db.crn
2323
}
24+
25+
output "hostname" {
26+
description = "Postgresql instance hostname"
27+
value = module.postgresql_db.hostname
28+
}
29+
30+
output "port" {
31+
description = "Postgresql instance port"
32+
value = module.postgresql_db.port
33+
}

profiles/fscloud/variables.tf

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,25 @@ variable "member_cpu_count" {
4747
default = 3
4848
}
4949

50+
variable "admin_pass" {
51+
type = string
52+
description = "The password for the database administrator. If the admin password is null then the admin user ID cannot be accessed. More users can be specified in a user block. The admin password must be in the range of 10-32 characters."
53+
default = null
54+
sensitive = true
55+
}
56+
57+
variable "users" {
58+
type = list(object({
59+
name = string
60+
password = string # pragma: allowlist secret
61+
type = string # "type" is required to generate the connection string for the outputs.
62+
role = optional(string)
63+
}))
64+
default = []
65+
sensitive = true
66+
description = "A list of users that you want to create on the database. Multiple blocks are allowed. The user password must be in the range of 10-32 characters. Be warned that in most case using IAM service credentials (via the var.service_credential_names) is sufficient to control access to the Postgres instance. This blocks creates native postgres database users, more info on that can be found here https://cloud.ibm.com/docs/databases-for-postgresql?topic=databases-for-postgresql-user-management&interface=ui"
67+
}
68+
5069
variable "service_credential_names" {
5170
description = "Map of name, role for service credentials that you want to create for the database"
5271
type = map(string)

0 commit comments

Comments
 (0)