Skip to content

Commit

Permalink
upstream 9723 (GoogleCloudPlatform#5112)
Browse files Browse the repository at this point in the history
* Fix:9723 google_sql_user - "Root resource was present, but now absent"

* Moved the declaration closer to the usage

* Fetching the instance data

Co-authored-by: Josh Angolano <[email protected]>
  • Loading branch information
2 people authored and khajduczenia committed Oct 12, 2021
1 parent 6b6734e commit fb8d6c7
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions mmv1/third_party/terraform/resources/resource_sql_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,15 @@ func resourceSqlUserRead(d *schema.ResourceData, meta interface{}) error {
}

var user *sqladmin.User
for _, currentUser := range users.Items {
databaseInstance, err := config.NewSqlAdminClient(userAgent).Instances.Get(project, instance).Do()
if err != nil {
return err
}

name = strings.Split(name, "@")[0]
for _, currentUser := range users.Items {
if !strings.Contains(databaseInstance.DatabaseVersion, "POSTGRES") {
name = strings.Split(name, "@")[0]
}

if currentUser.Name == name {
// Host can only be empty for postgres instances,
Expand Down

0 comments on commit fb8d6c7

Please sign in to comment.