Skip to content

Commit

Permalink
add use_private_ip and add to test
Browse files Browse the repository at this point in the history
Signed-off-by: AvivGuiser <[email protected]>
  • Loading branch information
KyriosGN0 committed Jun 29, 2024
1 parent 6c21252 commit 3e45436
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
12 changes: 12 additions & 0 deletions vault/resource_database_secret_backend_connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,12 @@ func connectionStringResource(config *connectionStringConfig) *schema.Resource {
Description: "A JSON encoded credential for use with IAM authorization",
Sensitive: true,
}
res.Schema["use_private_ip"] = &schema.Schema{
Type: schema.TypeBool,
Default: false,
Optional: true,
Description: "Specify if need to connect with a PrivateIP for CloudSQL",
}
}

if !config.excludeUsernameTemplate {
Expand Down Expand Up @@ -1097,6 +1103,9 @@ func getPostgresConnectionDetailsFromResponse(d *schema.ResourceData, prefix str
result["service_account_json"] = v.(string)
}
}
if v, ok := d.GetOk(prefix + "use_private_ip"); ok {
result["use_private_ip"] = v.(bool)
}
}

return result
Expand Down Expand Up @@ -1464,6 +1473,9 @@ func setCloudDatabaseConnectionData(d *schema.ResourceData, prefix string, data
if v, ok := d.GetOk(prefix + "service_account_json"); ok {
data["service_account_json"] = v.(string)
}
if v, ok := d.GetOk(prefix + "use_private_ip"); ok {
data["use_private_ip"] = v.(bool)
}
}

func setMSSQLDatabaseConnectionData(d *schema.ResourceData, prefix string, data map[string]interface{}) {
Expand Down
4 changes: 3 additions & 1 deletion vault/resource_database_secret_backend_connection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -862,6 +862,7 @@ func TestAccDatabaseSecretBackendConnection_postgresql_cloud(t *testing.T) {
resource.TestCheckResourceAttr(testDefaultDatabaseSecretBackendResource, "postgresql.0.connection_url", connURL),
resource.TestCheckResourceAttr(testDefaultDatabaseSecretBackendResource, "postgresql.0.disable_escaping", "true"),
resource.TestCheckResourceAttr(testDefaultDatabaseSecretBackendResource, "postgresql.0.auth_type", "gcp_iam"),
resource.TestCheckResourceAttr(testDefaultDatabaseSecretBackendResource, "postgresql.0.use_private_ip", "true"),
),
},
{
Expand Down Expand Up @@ -1733,6 +1734,7 @@ resource "vault_database_secret_backend_connection" "test" {
connection_url = "%s"
auth_type = "%s"
service_account_json = "%s"
use_private_ip = "true"
}
}
`, path, name, connURL, authType, serviceAccountJSON)
Expand All @@ -1751,7 +1753,7 @@ resource "vault_database_secret_backend_connection" "test" {
allowed_roles = ["dev", "prod"]
root_rotation_statements = ["FOOBAR"]
snowflake {
snowflake {
connection_url = "%s"
username = "%s"
password = "%s"
Expand Down

0 comments on commit 3e45436

Please sign in to comment.