Skip to content

Commit

Permalink
Add support for glue version on aws_glue_job
Browse files Browse the repository at this point in the history
Fixes #9524
  • Loading branch information
NSjogren committed Sep 25, 2019
1 parent 6fe866b commit cb8453f
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 0 deletions.
13 changes: 13 additions & 0 deletions aws/resource_aws_glue_job.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ func resourceAwsGlueJob() *schema.Resource {
Type: schema.TypeString,
Optional: true,
},
"glue_version": {
Type: schema.TypeString,
Optional: true,
},
"execution_property": {
Type: schema.TypeList,
Optional: true,
Expand Down Expand Up @@ -155,6 +159,10 @@ func resourceAwsGlueJobCreate(d *schema.ResourceData, meta interface{}) error {
input.Description = aws.String(v.(string))
}

if v, ok := d.GetOk("glue_version"); ok {
input.GlueVersion = aws.String(v.(string))
}

if v, ok := d.GetOk("execution_property"); ok {
input.ExecutionProperty = expandGlueExecutionProperty(v.([]interface{}))
}
Expand Down Expand Up @@ -213,6 +221,7 @@ func resourceAwsGlueJobRead(d *schema.ResourceData, meta interface{}) error {
return fmt.Errorf("error setting default_arguments: %s", err)
}
d.Set("description", job.Description)
d.Set("glue_version", job.GlueVersion)
if err := d.Set("execution_property", flattenGlueExecutionProperty(job.ExecutionProperty)); err != nil {
return fmt.Errorf("error setting execution_property: %s", err)
}
Expand Down Expand Up @@ -267,6 +276,10 @@ func resourceAwsGlueJobUpdate(d *schema.ResourceData, meta interface{}) error {
jobUpdate.Description = aws.String(v.(string))
}

if v, ok := d.GetOk("glue_version"); ok {
jobUpdate.GlueVersion = aws.String(v.(string))
}

if v, ok := d.GetOk("execution_property"); ok {
jobUpdate.ExecutionProperty = expandGlueExecutionProperty(v.([]interface{}))
}
Expand Down
53 changes: 53 additions & 0 deletions aws/resource_aws_glue_job_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,40 @@ func TestAccAWSGlueJob_Description(t *testing.T) {
})
}

func TestAccAWSGlueJob_GlueVersion(t *testing.T) {
var job glue.Job

rName := fmt.Sprintf("tf-acc-test-%s", acctest.RandString(5))
resourceName := "aws_glue_job.test"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckAWSGlueJobDestroy,
Steps: []resource.TestStep{
{
Config: testAccAWSGlueJobConfig_GlueVersion(rName, "0.9"),
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSGlueJobExists(resourceName, &job),
resource.TestCheckResourceAttr(resourceName, "glue_version", "0.9"),
),
},
{
Config: testAccAWSGlueJobConfig_GlueVersion(rName, "1.0"),
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSGlueJobExists(resourceName, &job),
resource.TestCheckResourceAttr(resourceName, "glue_version", "1.0"),
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
},
})
}

func TestAccAWSGlueJob_ExecutionProperty(t *testing.T) {
var job glue.Job

Expand Down Expand Up @@ -645,6 +679,25 @@ resource "aws_glue_job" "test" {
`, testAccAWSGlueJobConfig_Base(rName), description, rName)
}

func testAccAWSGlueJobConfig_GlueVersion(rName, glueVersion string) string {
return fmt.Sprintf(`
%s
resource "aws_glue_job" "test" {
glue_version = "%s"
name = "%s"
role_arn = "${aws_iam_role.test.arn}"
allocated_capacity = 10
command {
script_location = "testscriptlocation"
}
depends_on = ["aws_iam_role_policy_attachment.test"]
}
`, testAccAWSGlueJobConfig_Base(rName), glueVersion, rName)
}

func testAccAWSGlueJobConfig_ExecutionProperty(rName string, maxConcurrentRuns int) string {
return fmt.Sprintf(`
%s
Expand Down

0 comments on commit cb8453f

Please sign in to comment.