Add better error message for sql 409 (#3414)

Signed-off-by: Modular Magician <magic-modules@google.com>
This commit is contained in:
The Magician 2019-04-11 11:13:12 -07:00 committed by emily
parent 55ef37fe38
commit 53cc7fe1ee
2 changed files with 3 additions and 1 deletions

View File

@ -492,6 +492,9 @@ func resourceSqlDatabaseInstanceCreate(d *schema.ResourceData, meta interface{})
op, err := config.clientSqlAdmin.Instances.Insert(project, instance).Do()
if err != nil {
if gerr, ok := err.(*googleapi.Error); ok && gerr.Code == 409 {
return fmt.Errorf("Error, failed to create instance %s with error code 409: %s. This may be due to a name collision - SQL instance names cannot be reused within a week.", instance.Name, err)
}
return fmt.Errorf("Error, failed to create instance %s: %s", instance.Name, err)
}

View File

@ -9,7 +9,6 @@ import (
"github.com/hashicorp/terraform/helper/acctest"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform"
sqladmin "google.golang.org/api/sqladmin/v1beta4"
)