diff --git a/aws/resource_aws_glue_job.go b/aws/resource_aws_glue_job.go index 796765888193..5c9b111aef4f 100644 --- a/aws/resource_aws_glue_job.go +++ b/aws/resource_aws_glue_job.go @@ -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, @@ -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{})) } @@ -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) } @@ -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{})) } diff --git a/aws/resource_aws_glue_job_test.go b/aws/resource_aws_glue_job_test.go index b9aedb3b160f..b5d4d6a56c8c 100644 --- a/aws/resource_aws_glue_job_test.go +++ b/aws/resource_aws_glue_job_test.go @@ -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 @@ -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 diff --git a/website/docs/r/glue_job.html.markdown b/website/docs/r/glue_job.html.markdown index af6b630e81c4..a1935d3890d6 100644 --- a/website/docs/r/glue_job.html.markdown +++ b/website/docs/r/glue_job.html.markdown @@ -61,7 +61,8 @@ be removed in future releases, please use `max_capacity` instead. * `role_arn` – (Required) The ARN of the IAM role associated with this job. * `timeout` – (Optional) The job timeout in minutes. The default is 2880 minutes (48 hours). * `security_configuration` - (Optional) The name of the Security Configuration to be associated with the job. - +* `glue_version` - (Optional) The version of glue to use, for example "1.0". For information about available versionse see [AWS Glue Release Notes](https://docs.aws.amazon.com/glue/latest/dg/release-notes.html). + ### command Argument Reference * `name` - (Optional) The name of the job command. Defaults to `glueetl`