diff --git a/aws/resource_aws_glue_crawler.go b/aws/resource_aws_glue_crawler.go index f49e51777f7..fc416850d1e 100644 --- a/aws/resource_aws_glue_crawler.go +++ b/aws/resource_aws_glue_crawler.go @@ -81,23 +81,16 @@ func resourceAwsGlueCrawler() *schema.Resource { Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "delete_behavior": { - Type: schema.TypeString, - Optional: true, - Default: glue.DeleteBehaviorDeprecateInDatabase, - ValidateFunc: validation.StringInSlice([]string{ - glue.DeleteBehaviorDeleteFromDatabase, - glue.DeleteBehaviorDeprecateInDatabase, - glue.DeleteBehaviorLog, - }, false), + Type: schema.TypeString, + Optional: true, + Default: glue.DeleteBehaviorDeprecateInDatabase, + ValidateFunc: validation.StringInSlice(glue.DeleteBehavior_Values(), false), }, "update_behavior": { - Type: schema.TypeString, - Optional: true, - Default: glue.UpdateBehaviorUpdateInDatabase, - ValidateFunc: validation.StringInSlice([]string{ - glue.UpdateBehaviorLog, - glue.UpdateBehaviorUpdateInDatabase, - }, false), + Type: schema.TypeString, + Optional: true, + Default: glue.UpdateBehaviorUpdateInDatabase, + ValidateFunc: validation.StringInSlice(glue.UpdateBehavior_Values(), false), }, }, }, @@ -291,9 +284,13 @@ func updateCrawlerInput(crawlerName string, d *schema.ResourceData) (*glue.Updat if description, ok := d.GetOk("description"); ok { crawlerInput.Description = aws.String(description.(string)) } + if schedule, ok := d.GetOk("schedule"); ok { crawlerInput.Schedule = aws.String(schedule.(string)) + } else { + crawlerInput.Schedule = aws.String("") } + if classifiers, ok := d.GetOk("classifiers"); ok { crawlerInput.Classifiers = expandStringList(classifiers.([]interface{})) } diff --git a/aws/resource_aws_glue_crawler_test.go b/aws/resource_aws_glue_crawler_test.go index ff835979e86..5370a3fc582 100644 --- a/aws/resource_aws_glue_crawler_test.go +++ b/aws/resource_aws_glue_crawler_test.go @@ -578,7 +578,7 @@ func TestAccAWSGlueCrawler_CatalogTarget_Multiple(t *testing.T) { }) } -func TestAccAWSGlueCrawler_recreates(t *testing.T) { +func TestAccAWSGlueCrawler_disappears(t *testing.T) { var crawler glue.Crawler rName := acctest.RandomWithPrefix("tf-acc-test") resourceName := "aws_glue_crawler.test" @@ -592,23 +592,9 @@ func TestAccAWSGlueCrawler_recreates(t *testing.T) { Config: testAccGlueCrawlerConfig_S3Target(rName, "s3://bucket1"), Check: resource.ComposeTestCheckFunc( testAccCheckAWSGlueCrawlerExists(resourceName, &crawler), + testAccCheckResourceDisappears(testAccProvider, resourceAwsGlueCrawler(), resourceName), ), - }, - { - // Simulate deleting the crawler outside Terraform - PreConfig: func() { - conn := testAccProvider.Meta().(*AWSClient).glueconn - input := &glue.DeleteCrawlerInput{ - Name: aws.String(rName), - } - _, err := conn.DeleteCrawler(input) - if err != nil { - t.Fatalf("error deleting Glue Crawler: %s", err) - } - }, - Config: testAccGlueCrawlerConfig_S3Target(rName, "s3://bucket1"), ExpectNonEmptyPlan: true, - PlanOnly: true, }, }, }) @@ -834,6 +820,13 @@ func TestAccAWSGlueCrawler_Schedule(t *testing.T) { ImportState: true, ImportStateVerify: true, }, + { + Config: testAccGlueCrawlerConfig_S3Target(rName, "s3://bucket-name"), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSGlueCrawlerExists(resourceName, &crawler), + resource.TestCheckResourceAttr(resourceName, "schedule", ""), + ), + }, }, }) }