Skip to content

Commit

Permalink
Merge pull request #8174 from thomasv314/bugfix/recreate-glue-catalog…
Browse files Browse the repository at this point in the history
…-table

Fixes #8173
  • Loading branch information
bflad committed Apr 5, 2019
2 parents 71bef45 + 9d93f15 commit b342269
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
1 change: 1 addition & 0 deletions aws/resource_aws_glue_catalog_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
35 changes: 35 additions & 0 deletions aws/resource_aws_glue_catalog_table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit b342269

Please sign in to comment.