From 2605a170fee1c6b72b34a42fc26b588c7652a3bb Mon Sep 17 00:00:00 2001 From: Mike Fowler Date: Tue, 20 Jun 2017 23:54:40 +0100 Subject: [PATCH] Ensure split id length and report error otherwise --- google/resource_sql_database.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/google/resource_sql_database.go b/google/resource_sql_database.go index 96e3efb3342..84e2c35eaba 100644 --- a/google/resource_sql_database.go +++ b/google/resource_sql_database.go @@ -92,6 +92,12 @@ func resourceSqlDatabaseRead(d *schema.ResourceData, meta interface{}) error { } s := strings.Split(d.Id(), ":") + + if len(s) != 2 { + return fmt.Errorf("Error, failure importing database %s. "+ + "ID format is instance:name", d.Id()) + } + instance_name := s[0] database_name := s[1]