Skip to content

Commit

Permalink
grab service_account_json from terraform data since we don't get it i…
Browse files Browse the repository at this point in the history
…n the response
  • Loading branch information
kpcraig committed Oct 2, 2023
1 parent 5da6780 commit 425a138
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
12 changes: 11 additions & 1 deletion vault/resource_database_secret_backend_connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -1029,6 +1029,17 @@ func getConnectionDetailsFromResponse(d *schema.ResourceData, prefix string, res
result["username_template"] = v.(string)
}
}
if v, ok := data["auth_type"]; ok {
result["auth_type"] = v.(string)
}
if v, ok := d.GetOk(prefix + "service_account_json"); ok {
result["service_account_json"] = v.(string)
} else {
if v, ok := data["service_account_json"]; ok {
result["service_account_json"] = v.(string)
}
}

return result
}

Expand Down Expand Up @@ -1370,7 +1381,6 @@ func setDatabaseConnectionData(d *schema.ResourceData, prefix string, data map[s

func setCloudDatabaseConnectionData(d *schema.ResourceData, prefix string, data map[string]interface{}) {
if v, ok := d.GetOk(prefix + "auth_type"); ok {
fmt.Println("setting auth_type")
data["auth_type"] = v.(string)
}
if v, ok := d.GetOk(prefix + "service_account_json"); ok {
Expand Down
3 changes: 1 addition & 2 deletions vault/resource_database_secret_backend_connection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -467,8 +467,7 @@ func TestAccDatabaseSecretBackendConnection_mysql_cloud(t *testing.T) {
resource.TestCheckResourceAttr(testDefaultDatabaseSecretBackendResource, "root_rotation_statements.0", "FOOBAR"),
resource.TestCheckResourceAttr(testDefaultDatabaseSecretBackendResource, "verify_connection", "true"),
resource.TestCheckResourceAttr(testDefaultDatabaseSecretBackendResource, "mysql.0.connection_url", connURL),
// vault needs to be updated to return this value if it exists, i think?
//resource.TestCheckResourceAttr(testDefaultDatabaseSecretBackendResource, "mysql.0.auth_type", "gcp_iam"),
resource.TestCheckResourceAttr(testDefaultDatabaseSecretBackendResource, "mysql.0.auth_type", "gcp_iam"),
resource.TestCheckResourceAttr(testDefaultDatabaseSecretBackendResource, "mysql.0.max_open_connections", "2"),
resource.TestCheckResourceAttr(testDefaultDatabaseSecretBackendResource, "mysql.0.max_idle_connections", "0"),
resource.TestCheckResourceAttr(testDefaultDatabaseSecretBackendResource, "mysql.0.max_connection_lifetime", "0"),
Expand Down

0 comments on commit 425a138

Please sign in to comment.