From f6b6f5593bb59eed84cc89a1eee7fe1c625c14ff Mon Sep 17 00:00:00 2001 From: Achal-Aggarwal Date: Wed, 14 Aug 2019 10:44:14 +0530 Subject: [PATCH 1/2] Add glue.trigger.workflow_name --- aws/resource_aws_glue_trigger.go | 10 +++++ aws/resource_aws_glue_trigger_test.go | 53 +++++++++++++++++++++++++++ 2 files changed, 63 insertions(+) diff --git a/aws/resource_aws_glue_trigger.go b/aws/resource_aws_glue_trigger.go index 903f9551a03..1d17ab47724 100644 --- a/aws/resource_aws_glue_trigger.go +++ b/aws/resource_aws_glue_trigger.go @@ -126,6 +126,11 @@ func resourceAwsGlueTrigger() *schema.Resource { glue.TriggerTypeScheduled, }, false), }, + "workflow_name": { + Type: schema.TypeString, + ForceNew: true, + Optional: true, + }, }, } } @@ -153,6 +158,10 @@ func resourceAwsGlueTriggerCreate(d *schema.ResourceData, meta interface{}) erro input.Schedule = aws.String(v.(string)) } + if v, ok := d.GetOk("workflow_name"); ok { + input.WorkflowName = aws.String(v.(string)) + } + if d.Get("enabled").(bool) && triggerType != glue.TriggerTypeOnDemand { input.StartOnCreation = aws.Bool(true) } @@ -234,6 +243,7 @@ func resourceAwsGlueTriggerRead(d *schema.ResourceData, meta interface{}) error d.Set("name", trigger.Name) d.Set("schedule", trigger.Schedule) d.Set("type", trigger.Type) + d.Set("workflow_name", trigger.WorkflowName) return nil } diff --git a/aws/resource_aws_glue_trigger_test.go b/aws/resource_aws_glue_trigger_test.go index 5f21119b15a..6ec8ab92e4b 100644 --- a/aws/resource_aws_glue_trigger_test.go +++ b/aws/resource_aws_glue_trigger_test.go @@ -77,6 +77,7 @@ func TestAccAWSGlueTrigger_Basic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "predicate.#", "0"), resource.TestCheckResourceAttr(resourceName, "schedule", ""), resource.TestCheckResourceAttr(resourceName, "type", "ON_DEMAND"), + resource.TestCheckResourceAttr(resourceName, "workflow_name", ""), ), }, { @@ -239,6 +240,42 @@ func TestAccAWSGlueTrigger_Schedule(t *testing.T) { }) } + + +func TestAccAWSGlueTrigger_WorkflowName(t *testing.T) { + var trigger glue.Trigger + + rName := fmt.Sprintf("tf-acc-test-%s", acctest.RandString(5)) + resourceName := "aws_glue_trigger.test" + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSGlueTriggerDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSGlueTriggerConfig_WorkflowName(rName, "workflow_name1"), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSGlueTriggerExists(resourceName, &trigger), + resource.TestCheckResourceAttr(resourceName, "workflow_name", "workflow_name1"), + ), + }, + { + Config: testAccAWSGlueTriggerConfig_WorkflowName(rName, ""), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSGlueTriggerExists(resourceName, &trigger), + resource.TestCheckResourceAttr(resourceName, "workflow_name", ""), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + func testAccCheckAWSGlueTriggerExists(resourceName string, trigger *glue.Trigger) resource.TestCheckFunc { return func(s *terraform.State) error { rs, ok := s.RootModule().Resources[resourceName] @@ -398,3 +435,19 @@ resource "aws_glue_trigger" "test" { } `, testAccAWSGlueJobConfig_Required(rName), rName, schedule) } + +func testAccAWSGlueTriggerConfig_WorkflowName(rName, workflowName string) string { + return fmt.Sprintf(` +%s + +resource "aws_glue_trigger" "test" { + workflow_name = "%s" + name = "%s" + type = "ON_DEMAND" + + actions { + job_name = "${aws_glue_job.test.name}" + } +} +`, testAccAWSGlueJobConfig_Required(rName), workflowName, rName) +} From 5365c6893471aa86cddb81e9772fbd73f0e23e51 Mon Sep 17 00:00:00 2001 From: Achal-Aggarwal Date: Wed, 14 Aug 2019 10:58:07 +0530 Subject: [PATCH 2/2] Fix formatting --- aws/resource_aws_glue_trigger_test.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/aws/resource_aws_glue_trigger_test.go b/aws/resource_aws_glue_trigger_test.go index 6ec8ab92e4b..8527ef291e4 100644 --- a/aws/resource_aws_glue_trigger_test.go +++ b/aws/resource_aws_glue_trigger_test.go @@ -240,8 +240,6 @@ func TestAccAWSGlueTrigger_Schedule(t *testing.T) { }) } - - func TestAccAWSGlueTrigger_WorkflowName(t *testing.T) { var trigger glue.Trigger