From 717592944578f33737ae21824363f99ab45df3e7 Mon Sep 17 00:00:00 2001 From: The Magician Date: Mon, 17 Jun 2019 13:38:27 -0700 Subject: [PATCH] Ignore host when searching for postgres sql user in read from list (#849) Signed-off-by: Modular Magician --- google-beta/resource_sql_user.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/google-beta/resource_sql_user.go b/google-beta/resource_sql_user.go index e1b4df60ea..db8020a888 100644 --- a/google-beta/resource_sql_user.go +++ b/google-beta/resource_sql_user.go @@ -125,11 +125,13 @@ func resourceSqlUserRead(d *schema.ResourceData, meta interface{}) error { var user *sqladmin.User for _, currentUser := range users.Items { - // The second part of this conditional is irrelevant for postgres instances because - // host and currentUser.Host will always both be empty. - if currentUser.Name == name && currentUser.Host == host { - user = currentUser - break + if currentUser.Name == name { + // Host can only be empty for postgres instances, + // so don't compare the host if the API host is empty. + if currentUser.Host == "" || currentUser.Host == host { + user = currentUser + break + } } }