Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

r/glue_crawler - allow removing schedule #14792

Merged
merged 2 commits into from
Aug 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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