diff --git a/aws/resource_aws_glue_catalog_table.go b/aws/resource_aws_glue_catalog_table.go index 3f9c19b13691..4c0084369ef2 100644 --- a/aws/resource_aws_glue_catalog_table.go +++ b/aws/resource_aws_glue_catalog_table.go @@ -265,6 +265,7 @@ func resourceAwsGlueCatalogTableRead(d *schema.ResourceData, meta interface{}) e if isAWSErr(err, glue.ErrCodeEntityNotFoundException, "") { log.Printf("[WARN] Glue Catalog Table (%s) not found, removing from state", d.Id()) d.SetId("") + return nil } return fmt.Errorf("Error reading Glue Catalog Table: %s", err) diff --git a/aws/resource_aws_glue_catalog_table_test.go b/aws/resource_aws_glue_catalog_table_test.go index 360560522d7c..fbf1ff6794dd 100644 --- a/aws/resource_aws_glue_catalog_table_test.go +++ b/aws/resource_aws_glue_catalog_table_test.go @@ -12,6 +12,41 @@ import ( "github.com/hashicorp/terraform/terraform" ) +func TestAccAWSGlueCatalogTable_recreates(t *testing.T) { + resourceName := "aws_glue_catalog_table.test" + rInt := acctest.RandInt() + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckGlueTableDestroy, + Steps: []resource.TestStep{ + { + Config: testAccGlueCatalogTable_basic(rInt), + Check: resource.ComposeTestCheckFunc( + testAccCheckGlueCatalogTableExists(resourceName), + ), + }, + { + PreConfig: func() { + conn := testAccProvider.Meta().(*AWSClient).glueconn + input := &glue.DeleteTableInput{ + Name: aws.String(fmt.Sprintf("my_test_catalog_table_%d", rInt)), + DatabaseName: aws.String(fmt.Sprintf("my_test_catalog_database_%d", rInt)), + } + _, err := conn.DeleteTable(input) + if err != nil { + t.Fatalf("error deleting Glue Catalog Table: %s", err) + } + }, + Config: testAccGlueCatalogTable_basic(rInt), + ExpectNonEmptyPlan: true, + PlanOnly: true, + }, + }, + }) +} + func TestAccAWSGlueCatalogTable_importBasic(t *testing.T) { resourceName := "aws_glue_catalog_table.test" rInt := acctest.RandInt()