Skip to content

Commit

Permalink
db: add fields for skip auto rotation of static roles
Browse files Browse the repository at this point in the history
  • Loading branch information
fairclothjm committed Jan 3, 2025
1 parent 78f2eda commit bb8a648
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions vault/resource_database_secret_backend_connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -1863,6 +1863,10 @@ func writeDatabaseSecretConfig(d *schema.ResourceData, client *api.Client,
}
}

if v, ok := d.Get(prefix + consts.FieldSkipStaticRoleImportRotation).(bool); ok {
data[consts.FieldSkipStaticRoleImportRotation] = v
}

log.Printf("[DEBUG] Writing connection config to %q", path)
_, err = client.Logical().Write(path, data)
if err != nil {
Expand Down
3 changes: 3 additions & 0 deletions vault/resource_database_secret_backend_connection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -820,6 +820,7 @@ func TestAccDatabaseSecretBackendConnection_postgresql(t *testing.T) {
resource.TestCheckResourceAttr(testDefaultDatabaseSecretBackendResource, "postgresql.0.password", password),
resource.TestCheckResourceAttr(testDefaultDatabaseSecretBackendResource, "postgresql.0.disable_escaping", "true"),
resource.TestCheckResourceAttr(testDefaultDatabaseSecretBackendResource, "postgresql.0.username_template", userTempl),
resource.TestCheckResourceAttr(testDefaultDatabaseSecretBackendResource, "postgresql.0.skip_static_role_import_rotation", "true"),
),
},
{
Expand Down Expand Up @@ -1753,6 +1754,8 @@ resource "vault_database_secret_backend_connection" "test" {
password = "%s"
username_template = "%s"
disable_escaping = true
skip_static_role_import_rotation = true
}
}
`, path, name, parsedURL.String(), openConn, idleConn, maxConnLifetime, username, password, userTempl)
Expand Down
5 changes: 5 additions & 0 deletions vault/resource_database_secrets_mount.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,11 @@ func getCommonDatabaseSchema() schemaMap {
Description: "Specifies if the connection is verified during initial configuration.",
Default: true,
},
consts.FieldSkipStaticRoleImportRotation: {
Type: schema.TypeBool,
Optional: true,
Description: "Skip rotation of static role secrets on import.",
},
"allowed_roles": {
Type: schema.TypeList,
Optional: true,
Expand Down

0 comments on commit bb8a648

Please sign in to comment.