Skip to content

Commit f4537ba

Browse files
authored
feat: Add support to the DAs to store credentials in secrets manager (#705)
1 parent 3d45322 commit f4537ba

File tree

14 files changed

+569
-58
lines changed

14 files changed

+569
-58
lines changed

.secrets.baseline

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"files": "go.sum|^.secrets.baseline$",
44
"lines": null
55
},
6-
"generated_at": "2025-05-12T14:07:27Z",
6+
"generated_at": "2025-08-18T20:05:03Z",
77
"plugins_used": [
88
{
99
"name": "AWSKeyDetector"
@@ -92,15 +92,15 @@
9292
"hashed_secret": "44cdfc3615970ada14420caaaa5c5745fca06002",
9393
"is_secret": false,
9494
"is_verified": false,
95-
"line_number": 58,
95+
"line_number": 124,
9696
"type": "Secret Keyword",
9797
"verified_result": null
9898
},
9999
{
100100
"hashed_secret": "bd0d0d73a240c29656fb8ae0dfa5f863077788dc",
101101
"is_secret": false,
102102
"is_verified": false,
103-
"line_number": 63,
103+
"line_number": 129,
104104
"type": "Secret Keyword",
105105
"verified_result": null
106106
}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ To attach access management tags to resources in this module, you need the follo
121121
| <a name="input_timeouts_update"></a> [timeouts\_update](#input\_timeouts\_update) | A database update may require a longer timeout for the update to complete. The default is 120 minutes. Set this variable to change the `update` value in the `timeouts` block. [Learn more](https://developer.hashicorp.com/terraform/language/resources/syntax#operation-timeouts). | `string` | `"120m"` | no |
122122
| <a name="input_use_default_backup_encryption_key"></a> [use\_default\_backup\_encryption\_key](#input\_use\_default\_backup\_encryption\_key) | When `use_ibm_owned_encryption_key` is set to false, backups will be encrypted with either the key specified in `kms_key_crn`, or in `backup_encryption_key_crn` if a value is passed. If you do not want to use your own key for backups encryption, you can set this to `true` to use the IBM Cloud Databases default encryption for backups. Alternatively set `use_ibm_owned_encryption_key` to true to use the default encryption for both backups and deployment data. | `bool` | `false` | no |
123123
| <a name="input_use_ibm_owned_encryption_key"></a> [use\_ibm\_owned\_encryption\_key](#input\_use\_ibm\_owned\_encryption\_key) | IBM Cloud Databases will secure your deployment's data at rest automatically with an encryption key that IBM hold. Alternatively, you may select your own Key Management System instance and encryption key (Key Protect or Hyper Protect Crypto Services) by setting this to false. If setting to false, a value must be passed for the `kms_key_crn` input. | `bool` | `true` | no |
124-
| <a name="input_use_same_kms_key_for_backups"></a> [use\_same\_kms\_key\_for\_backups](#input\_use\_same\_kms\_key\_for\_backups) | Set this to false if you wan't to use a different key that you own to encrypt backups. When set to false, a value is required for the `backup_encryption_key_crn` input. Alternatiely set `use_default_backup_encryption_key` to true to use the IBM Cloud Databases default encryption. Applies only if `use_ibm_owned_encryption_key` is false. Bare in mind that backups encryption is only available in certain regions. See [Bring your own key for backups](https://cloud.ibm.com/docs/cloud-databases?topic=cloud-databases-key-protect&interface=ui#key-byok) and [Using the HPCS Key for Backup encryption](https://cloud.ibm.com/docs/cloud-databases?topic=cloud-databases-hpcs#use-hpcs-backups). | `bool` | `true` | no |
124+
| <a name="input_use_same_kms_key_for_backups"></a> [use\_same\_kms\_key\_for\_backups](#input\_use\_same\_kms\_key\_for\_backups) | Set this to false if you wan't to use a different key that you own to encrypt backups. When set to false, a value is required for the `backup_encryption_key_crn` input. Alternatively set `use_default_backup_encryption_key` to true to use the IBM Cloud Databases default encryption. Applies only if `use_ibm_owned_encryption_key` is false. Bare in mind that backups encryption is only available in certain regions. See [Bring your own key for backups](https://cloud.ibm.com/docs/cloud-databases?topic=cloud-databases-key-protect&interface=ui#key-byok) and [Using the HPCS Key for Backup encryption](https://cloud.ibm.com/docs/cloud-databases?topic=cloud-databases-hpcs#use-hpcs-backups). | `bool` | `true` | no |
125125
| <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 = optional(string)<br/> role = optional(string)<br/> }))</pre> | `[]` | no |
126126
| <a name="input_version_upgrade_skip_backup"></a> [version\_upgrade\_skip\_backup](#input\_version\_upgrade\_skip\_backup) | Whether to skip taking a backup before upgrading the database version. Attention: Skipping a backup is not recommended. Skipping a backup before a version upgrade is dangerous and may result in data loss if the upgrade fails at any stage — there will be no immediate backup to restore from. | `bool` | `false` | no |
127127

examples/complete/main.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,10 @@ module "icd_postgresql" {
119119
backup_encryption_key_crn = module.key_protect_all_inclusive.keys["icd.${local.backups_key_name}"].crn
120120
tags = var.resource_tags
121121
service_credential_names = {
122-
"postgressql_admin" : "Administrator",
123-
"postgressql_operator" : "Operator",
124-
"postgressql_viewer" : "Viewer",
125-
"postgressql_editor" : "Editor",
122+
"postgresql_admin" : "Administrator",
123+
"postgresql_operator" : "Operator",
124+
"postgresql_viewer" : "Viewer",
125+
"postgresql_editor" : "Editor",
126126
}
127127
access_tags = var.access_tags
128128
member_host_flavor = "multitenant"

examples/fscloud/main.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,10 @@ module "postgresql_db" {
6767
backup_crn = var.backup_crn
6868
tags = var.resource_tags
6969
service_credential_names = {
70-
"postgressql_admin" : "Administrator",
71-
"postgressql_operator" : "Operator",
72-
"postgressql_viewer" : "Viewer",
73-
"postgressql_editor" : "Editor",
70+
"postgresql_admin" : "Administrator",
71+
"postgresql_operator" : "Operator",
72+
"postgresql_viewer" : "Viewer",
73+
"postgresql_editor" : "Editor",
7474
}
7575
access_tags = var.access_tags
7676
deletion_protection = false

ibm_catalog.json

Lines changed: 64 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,9 +302,47 @@
302302
{
303303
"key": "service_credential_names"
304304
},
305+
{
306+
"key": "service_credential_secrets",
307+
"type": "array",
308+
"custom_config": {
309+
"type": "textarea",
310+
"grouping": "deployment",
311+
"original_grouping": "deployment"
312+
}
313+
},
305314
{
306315
"key": "admin_pass"
307316
},
317+
{
318+
"key": "existing_secrets_manager_instance_crn"
319+
},
320+
{
321+
"key": "existing_secrets_manager_endpoint_type",
322+
"hidden": true,
323+
"options": [
324+
{
325+
"displayname": "public",
326+
"value": "public"
327+
},
328+
{
329+
"displayname": "private",
330+
"value": "private"
331+
}
332+
]
333+
},
334+
{
335+
"key": "skip_postgresql_secrets_manager_auth_policy"
336+
},
337+
{
338+
"key": "admin_pass_secrets_manager_secret_group"
339+
},
340+
{
341+
"key": "admin_pass_secrets_manager_secret_name"
342+
},
343+
{
344+
"key": "use_existing_admin_pass_secrets_manager_secret_group"
345+
},
308346
{
309347
"key": "users",
310348
"type": "array",
@@ -583,11 +621,32 @@
583621
{
584622
"key": "service_credential_names"
585623
},
624+
{
625+
"key": "service_credential_secrets",
626+
"type": "array",
627+
"custom_config": {
628+
"type": "textarea",
629+
"grouping": "deployment",
630+
"original_grouping": "deployment"
631+
}
632+
},
586633
{
587634
"key": "admin_pass"
588635
},
589636
{
590-
"key": "skip_postgresql_kms_auth_policy"
637+
"key": "existing_secrets_manager_instance_crn"
638+
},
639+
{
640+
"key": "skip_postgresql_secrets_manager_auth_policy"
641+
},
642+
{
643+
"key": "admin_pass_secrets_manager_secret_group"
644+
},
645+
{
646+
"key": "admin_pass_secrets_manager_secret_name"
647+
},
648+
{
649+
"key": "use_existing_admin_pass_secrets_manager_secret_group"
591650
},
592651
{
593652
"key": "users",
@@ -621,10 +680,13 @@
621680
"key": "existing_backup_kms_key_crn"
622681
},
623682
{
624-
"key": "remote_leader_crn"
683+
"key": "skip_postgresql_kms_auth_policy"
625684
},
626685
{
627686
"key": "existing_postgresql_instance_crn"
687+
},
688+
{
689+
"key": "remote_leader_crn"
628690
}
629691
],
630692
"terraform_version": "1.10.5"

modules/fscloud/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ No resources.
5353
| <a name="input_timeouts_update"></a> [timeouts\_update](#input\_timeouts\_update) | A database update may require a longer timeout for the update to complete. The default is 120 minutes. Set this variable to change the `update` value in the `timeouts` block. [Learn more](https://developer.hashicorp.com/terraform/language/resources/syntax#operation-timeouts). | `string` | `"120m"` | no |
5454
| <a name="input_use_default_backup_encryption_key"></a> [use\_default\_backup\_encryption\_key](#input\_use\_default\_backup\_encryption\_key) | When `use_ibm_owned_encryption_key` is set to false, backups will be encrypted with either the key specified in `kms_key_crn`, or in `backup_encryption_key_crn` if a value is passed. If you do not want to use your own key for backups encryption, you can set this to `true` to use the IBM Cloud Databases default encryption for backups. Alternatively set `use_ibm_owned_encryption_key` to true to use the default encryption for both backups and deployment data. | `bool` | `false` | no |
5555
| <a name="input_use_ibm_owned_encryption_key"></a> [use\_ibm\_owned\_encryption\_key](#input\_use\_ibm\_owned\_encryption\_key) | Set to true to use the default IBM Cloud® Databases randomly generated keys for disk and backups encryption. To control the encryption keys, use the `kms_key_crn` and `backup_encryption_key_crn` inputs. | `string` | `false` | no |
56-
| <a name="input_use_same_kms_key_for_backups"></a> [use\_same\_kms\_key\_for\_backups](#input\_use\_same\_kms\_key\_for\_backups) | Set this to false if you wan't to use a different key that you own to encrypt backups. When set to false, a value is required for the `backup_encryption_key_crn` input. Alternatiely set `use_default_backup_encryption_key` to true to use the IBM Cloud Databases default encryption. Applies only if `use_ibm_owned_encryption_key` is false. Bare in mind that backups encryption is only available in certain regions. See [Bring your own key for backups](https://cloud.ibm.com/docs/cloud-databases?topic=cloud-databases-key-protect&interface=ui#key-byok) and [Using the HPCS Key for Backup encryption](https://cloud.ibm.com/docs/cloud-databases?topic=cloud-databases-hpcs#use-hpcs-backups). | `bool` | `true` | no |
56+
| <a name="input_use_same_kms_key_for_backups"></a> [use\_same\_kms\_key\_for\_backups](#input\_use\_same\_kms\_key\_for\_backups) | Set this to false if you wan't to use a different key that you own to encrypt backups. When set to false, a value is required for the `backup_encryption_key_crn` input. Alternatively set `use_default_backup_encryption_key` to true to use the IBM Cloud Databases default encryption. Applies only if `use_ibm_owned_encryption_key` is false. Bare in mind that backups encryption is only available in certain regions. See [Bring your own key for backups](https://cloud.ibm.com/docs/cloud-databases?topic=cloud-databases-key-protect&interface=ui#key-byok) and [Using the HPCS Key for Backup encryption](https://cloud.ibm.com/docs/cloud-databases?topic=cloud-databases-hpcs#use-hpcs-backups). | `bool` | `true` | no |
5757
| <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 = optional(string)<br/> role = optional(string)<br/> }))</pre> | `[]` | no |
5858
| <a name="input_version_upgrade_skip_backup"></a> [version\_upgrade\_skip\_backup](#input\_version\_upgrade\_skip\_backup) | Whether to skip taking a backup before upgrading the database version. Attention: Skipping a backup is not recommended. Skipping a backup before a version upgrade is dangerous and may result in data loss if the upgrade fails at any stage — there will be no immediate backup to restore from. | `bool` | `false` | no |
5959

modules/fscloud/variables.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ variable "kms_key_crn" {
196196

197197
variable "use_same_kms_key_for_backups" {
198198
type = bool
199-
description = "Set this to false if you wan't to use a different key that you own to encrypt backups. When set to false, a value is required for the `backup_encryption_key_crn` input. Alternatiely set `use_default_backup_encryption_key` to true to use the IBM Cloud Databases default encryption. Applies only if `use_ibm_owned_encryption_key` is false. Bare in mind that backups encryption is only available in certain regions. See [Bring your own key for backups](https://cloud.ibm.com/docs/cloud-databases?topic=cloud-databases-key-protect&interface=ui#key-byok) and [Using the HPCS Key for Backup encryption](https://cloud.ibm.com/docs/cloud-databases?topic=cloud-databases-hpcs#use-hpcs-backups)."
199+
description = "Set this to false if you wan't to use a different key that you own to encrypt backups. When set to false, a value is required for the `backup_encryption_key_crn` input. Alternatively set `use_default_backup_encryption_key` to true to use the IBM Cloud Databases default encryption. Applies only if `use_ibm_owned_encryption_key` is false. Bare in mind that backups encryption is only available in certain regions. See [Bring your own key for backups](https://cloud.ibm.com/docs/cloud-databases?topic=cloud-databases-key-protect&interface=ui#key-byok) and [Using the HPCS Key for Backup encryption](https://cloud.ibm.com/docs/cloud-databases?topic=cloud-databases-hpcs#use-hpcs-backups)."
200200
default = true
201201
}
202202

solutions/fully-configurable/DA-types.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,72 @@ You can specify a set of IAM credentials to connect to the database with the `se
3131
}
3232
```
3333

34+
## Service credential secrets <a name="service-credential-secrets"></a>
35+
36+
When you add an IBM Database for PostgreSQL deployable architecture from the IBM Cloud catalog to IBM Cloud Project, you can configure service credentials. In edit mode for the projects configuration, from the configure panel click the optional tab.
37+
38+
To enter a custom value, use the edit action to open the "Edit Array" panel. Add the service credential secrets configurations to the array here.
39+
40+
In the configuration, specify the secret group name, whether it already exists or will be created and include all the necessary service credential secrets that need to be created within that secret group.
41+
42+
[Learn more](https://cloud.ibm.com/docs/databases-for-postgresql?topic=databases-for-postgresql-user-management&interface=ui#user-management-service-cred) about service credential secrets.
43+
44+
- Variable name: `service_credential_secrets`.
45+
- Type: A list of objects that represent a service credential secret groups and secrets
46+
- Default value: An empty list (`[]`)
47+
48+
### Options for service_credential_secrets
49+
50+
- `secret_group_name` (required): A unique human-readable name that identifies this service credential secret group.
51+
- `secret_group_description` (optional, default = `null`): A human-readable description for this secret group.
52+
- `existing_secret_group`: (optional, default = `false`): Set to true, if secret group name provided in the variable `secret_group_name` already exists.
53+
- `service_credentials`: (optional, default = `[]`): A list of object that represents a service credential secret.
54+
55+
#### Options for service_credentials
56+
57+
- `secret_name`: (required): A unique human-readable name of the secret to create.
58+
- `service_credentials_source_service_role_crn`: (required): The CRN of the role to give the service credential in the IBM Cloud Database service. Service credentials role CRNs can be found at https://cloud.ibm.com/iam/roles, select the IBM Cloud Database and select the role.
59+
- `secret_labels`: (optional, default = `[]`): Labels of the secret to create. Up to 30 labels can be created. Labels can be 2 - 30 characters, including spaces. Special characters that are not permitted include the angled brackets (<>), comma (,), colon (:), ampersand (&), and vertical pipe character (|).
60+
- `secret_auto_rotation`: (optional, default = `true`): Whether to configure automatic rotation of service credential.
61+
- `secret_auto_rotation_unit`: (optional, default = `day`): Specifies the unit of time for rotation of a secret. Acceptable values are `day` or `month`.
62+
- `secret_auto_rotation_interval`: (optional, default = `89`): Specifies the rotation interval for the rotation unit.
63+
- `service_credentials_ttl`: (optional, default = `7776000`): The time-to-live (TTL) to assign to generated service credentials (in seconds).
64+
- `service_credential_secret_description`: (optional, default = `null`): Description of the secret to create.
65+
66+
The following example includes all the configuration options for four service credentials and two secret groups.
67+
```hcl
68+
[
69+
{
70+
"secret_group_name": "sg-1"
71+
"existing_secret_group": true
72+
"service_credentials": [ # pragma: allowlist secret
73+
{
74+
"secret_name": "cred-1"
75+
"service_credentials_source_service_role_crn": "crn:v1:bluemix:public:iam::::role:Editor"
76+
"secret_labels": ["test-editor-1", "test-editor-2"]
77+
"secret_auto_rotation": true
78+
"secret_auto_rotation_unit": "day"
79+
"secret_auto_rotation_interval": 89
80+
"service_credentials_ttl": 7776000
81+
"service_credential_secret_description": "sample description"
82+
},
83+
{
84+
"secret_name": "cred-2"
85+
"service_credentials_source_service_role_crn": "crn:v1:bluemix:public:iam::::role:Viewer"
86+
}
87+
]
88+
},
89+
{
90+
"secret_group_name": "sg-2"
91+
"service_credentials": [ # pragma: allowlist secret
92+
{
93+
"secret_name": "cred-3"
94+
"service_credentials_source_service_role_crn": "crn:v1:bluemix:public:iam::::role:Viewer"
95+
}
96+
]
97+
}
98+
]
99+
```
34100

35101
## Users <a name="users"></a>
36102

0 commit comments

Comments
 (0)