Skip to content

Commit

Permalink
Add credential_type and credential_config to static roles for DBs
Browse files Browse the repository at this point in the history
  • Loading branch information
catouc committed Dec 19, 2024
1 parent 78f2eda commit a2ac1e7
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ FEATURES:
* Update `vault_pki_secret_backend_role` to support the `cn_validations` role field ([#1820](https://github.com/hashicorp/terraform-provider-vault/pull/1820)).
* Add new resource `vault_pki_secret_backend_acme_eab` to manage PKI ACME external account binding tokens. Requires Vault 1.14+. ([#2367](https://github.com/hashicorp/terraform-provider-vault/pull/2367))
* Add new data source and resource `vault_pki_secret_backend_config_cmpv2`. Requires Vault 1.18+. *Available only for Vault Enterprise* ([#2330](https://github.com/hashicorp/terraform-provider-vault/pull/2330))
* Add `credential_type` and `credential_config` to `database_secret_backend_static_role` to support features like rsa keys for Snowflake DB engines with static roles

IMPROVEMENTS:

Expand Down
24 changes: 24 additions & 0 deletions vault/resource_database_secret_backend_static_role.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ var staticRoleFields = []string{
consts.FieldRotationPeriod,
consts.FieldRotationStatements,
consts.FieldDBName,
consts.FieldCredentialType,
consts.FieldCredentialConfig,
}

func databaseSecretBackendStaticRoleResource() *schema.Resource {
Expand Down Expand Up @@ -99,6 +101,20 @@ func databaseSecretBackendStaticRoleResource() *schema.Resource {
Description: "The password corresponding to the username in the database. " +
"Required when using the Rootless Password Rotation workflow for static roles.",
},
consts.FieldCredentialType: {
Type: schema.TypeString,
Optional: true,
Default: "password",
Description: "The credential type for the user, can be one of \"password\", \"rsa_private_key\" or \"client_certificate\"." +
"The configuration can be done in `credential_config`.",
},
consts.FieldCredentialConfig: {
Type: schema.TypeMap,
Elem: &schema.Schema{Type: schema.TypeString},
Optional: true,
Description: "The configuration for the credential type." +
"Full documentation for the allowed values can be found under \"https://developer.hashicorp.com/vault/api-docs/secret/databases#credential_config\".",
},
},
}
}
Expand Down Expand Up @@ -138,6 +154,14 @@ func databaseSecretBackendStaticRoleWrite(ctx context.Context, d *schema.Resourc
data[consts.FieldRotationPeriod] = v
}

if v, ok := d.GetOk(consts.FieldCredentialType); ok && v != "" {
data[consts.FieldCredentialType] = v
}

if v, ok := d.GetOk(consts.FieldCredentialConfig); ok && v != "" {
data[consts.FieldCredentialConfig] = v
}

if provider.IsAPISupported(meta, provider.VaultVersion118) && provider.IsEnterpriseSupported(meta) {
if v, ok := d.GetOk(consts.FieldSelfManagedPassword); ok && v != "" {
data[consts.FieldSelfManagedPassword] = v
Expand Down

0 comments on commit a2ac1e7

Please sign in to comment.