Skip to content

Commit

Permalink
Merge pull request #14792 from DrFaust92/r/glue_crawler_schedule
Browse files Browse the repository at this point in the history
r/glue_crawler - allow removing schedule
  • Loading branch information
anGie44 authored Aug 24, 2020
2 parents 116a671 + 3f20019 commit d15179e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 31 deletions.
27 changes: 12 additions & 15 deletions aws/resource_aws_glue_crawler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
},
},
},
Expand Down Expand Up @@ -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{}))
}
Expand Down
25 changes: 9 additions & 16 deletions aws/resource_aws_glue_crawler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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,
},
},
})
Expand Down Expand Up @@ -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", ""),
),
},
},
})
}
Expand Down

0 comments on commit d15179e

Please sign in to comment.