From 040b7cf133e1538402338431ca269cdf8fbef9fa Mon Sep 17 00:00:00 2001 From: nikhil Date: Wed, 29 May 2024 21:37:40 +0100 Subject: [PATCH 1/9] aws_glue_job --- internal/service/glue/job.go | 14 +++++++++ internal/service/glue/job_test.go | 47 +++++++++++++++++++++++++++++-- 2 files changed, 59 insertions(+), 2 deletions(-) diff --git a/internal/service/glue/job.go b/internal/service/glue/job.go index b197c026e37..b36e6406c2c 100644 --- a/internal/service/glue/job.go +++ b/internal/service/glue/job.go @@ -119,6 +119,11 @@ func ResourceJob() *schema.Resource { Computed: true, ConflictsWith: []string{"number_of_workers", "worker_type"}, }, + "maintenance_window": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: verify.ValidOnceAWeekWindowFormat, + }, "max_retries": { Type: schema.TypeInt, Optional: true, @@ -227,6 +232,10 @@ func resourceJobCreate(ctx context.Context, d *schema.ResourceData, meta interfa input.MaxCapacity = aws.Float64(v.(float64)) } + if v, ok := d.GetOk("maintenance_window"); ok { + input.MaintenanceWindow = aws.String(v.(string)) + } + if v, ok := d.GetOk("max_retries"); ok { input.MaxRetries = aws.Int64(int64(v.(int))) } @@ -303,6 +312,7 @@ func resourceJobRead(ctx context.Context, d *schema.ResourceData, meta interface return sdkdiag.AppendErrorf(diags, "setting execution_property: %s", err) } d.Set("glue_version", job.GlueVersion) + d.Set("maintenance_window", job.MaintenanceWindow) d.Set(names.AttrMaxCapacity, job.MaxCapacity) d.Set("max_retries", job.MaxRetries) d.Set(names.AttrName, job.Name) @@ -355,6 +365,10 @@ func resourceJobUpdate(ctx context.Context, d *schema.ResourceData, meta interfa jobUpdate.GlueVersion = aws.String(v.(string)) } + if v, ok := d.GetOk("maintenance_window"); ok { + jobUpdate.MaintenanceWindow = aws.String(v.(string)) + } + if v, ok := d.GetOk("max_retries"); ok { jobUpdate.MaxRetries = aws.Int64(int64(v.(int))) } diff --git a/internal/service/glue/job_test.go b/internal/service/glue/job_test.go index 8f4fca1eb6f..6e1f4cdf330 100644 --- a/internal/service/glue/job_test.go +++ b/internal/service/glue/job_test.go @@ -388,6 +388,35 @@ func TestAccGlueJob_executionProperty(t *testing.T) { }) } +func TestAccGlueJob_maintenanceWindow(t *testing.T) { + ctx := acctest.Context(t) + var job glue.Job + rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) + resourceName := "aws_glue_job.test" + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { acctest.PreCheck(ctx, t) }, + ErrorCheck: acctest.ErrorCheck(t, names.GlueServiceID), + ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, + CheckDestroy: testAccCheckJobDestroy(ctx), + Steps: []resource.TestStep{ + { + Config: testAccJobConfig_maintenanceWindow(rName, "sun:23:00-sun:23:30"), + Check: resource.ComposeTestCheckFunc( + testAccCheckJobExists(ctx, resourceName, &job), + acctest.CheckResourceAttrRegionalARN(resourceName, names.AttrARN, "glue", fmt.Sprintf("job/%s", rName)), + resource.TestCheckResourceAttr(resourceName, "maintenance_window", "sun:23:00-sun:23:30"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + func TestAccGlueJob_maxRetries(t *testing.T) { ctx := acctest.Context(t) var job glue.Job @@ -1042,6 +1071,22 @@ resource "aws_glue_job" "test" { `, rName, maxConcurrentRuns)) } +func testAccJobConfig_maintenanceWindow(rName, maintenanceWindow string) string { + return acctest.ConfigCompose(testAccJobConfig_base(rName), fmt.Sprintf(` +resource "aws_glue_job" "test" { + name = %[2]q + role_arn = aws_iam_role.test.arn + maintenance_window = %[2]q + + command { + script_location = "testscriptlocation" + } + + depends_on = [aws_iam_role_policy_attachment.test] +} +`, rName, maintenanceWindow)) +} + func testAccJobConfig_maxRetries(rName string, maxRetries int) string { return acctest.ConfigCompose(testAccJobConfig_base(rName), fmt.Sprintf(` resource "aws_glue_job" "test" { @@ -1116,9 +1161,7 @@ func testAccJobConfig_tags1(rName, tagKey1, tagValue1 string) string { return acctest.ConfigCompose(testAccJobConfig_base(rName), fmt.Sprintf(` resource "aws_glue_job" "test" { name = %[1]q - number_of_workers = 1 role_arn = aws_iam_role.test.arn - worker_type = "Standard" command { script_location = "testscriptlocation" From 72c307fce142d656055d09b24aca710a99ba7be0 Mon Sep 17 00:00:00 2001 From: nikhil Date: Wed, 29 May 2024 21:39:16 +0100 Subject: [PATCH 2/9] maintenance_window --- .changelog/37760.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .changelog/37760.txt diff --git a/.changelog/37760.txt b/.changelog/37760.txt new file mode 100644 index 00000000000..39ac8c7ee24 --- /dev/null +++ b/.changelog/37760.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +resource/aws_glue_job: Add `maintenance_window` argument +``` \ No newline at end of file From c1e1b85169a933496c0a68e94f720f9a87f5f765 Mon Sep 17 00:00:00 2001 From: nikhil Date: Wed, 29 May 2024 21:42:44 +0100 Subject: [PATCH 3/9] maintenance_window --- internal/service/glue/job.go | 1 - 1 file changed, 1 deletion(-) diff --git a/internal/service/glue/job.go b/internal/service/glue/job.go index b36e6406c2c..2281f79a670 100644 --- a/internal/service/glue/job.go +++ b/internal/service/glue/job.go @@ -122,7 +122,6 @@ func ResourceJob() *schema.Resource { "maintenance_window": { Type: schema.TypeString, Optional: true, - ValidateFunc: verify.ValidOnceAWeekWindowFormat, }, "max_retries": { Type: schema.TypeInt, From 1d759d2b596d6fedac94527d6ecbbac2b5296835 Mon Sep 17 00:00:00 2001 From: nikhil Date: Wed, 29 May 2024 21:45:59 +0100 Subject: [PATCH 4/9] aws_docdb_cluster --- website/docs/r/glue_job.html.markdown | 1 + 1 file changed, 1 insertion(+) diff --git a/website/docs/r/glue_job.html.markdown b/website/docs/r/glue_job.html.markdown index 1fd6f3d3f35..7420edd3223 100644 --- a/website/docs/r/glue_job.html.markdown +++ b/website/docs/r/glue_job.html.markdown @@ -109,6 +109,7 @@ This resource supports the following arguments: * `execution_property` – (Optional) Execution property of the job. Defined below. * `glue_version` - (Optional) The version of glue to use, for example "1.0". Ray jobs should set this to 4.0 or greater. For information about available versions, see the [AWS Glue Release Notes](https://docs.aws.amazon.com/glue/latest/dg/release-notes.html). * `execution_class` - (Optional) Indicates whether the job is run with a standard or flexible execution class. The standard execution class is ideal for time-sensitive workloads that require fast job startup and dedicated resources. Valid value: `FLEX`, `STANDARD`. +* `maintenance_window` – (Optional) Specifies the day of the week and hour for the maintenance window for streaming jobs. * `max_capacity` – (Optional) The maximum number of AWS Glue data processing units (DPUs) that can be allocated when this job runs. `Required` when `pythonshell` is set, accept either `0.0625` or `1.0`. Use `number_of_workers` and `worker_type` arguments instead with `glue_version` `2.0` and above. * `max_retries` – (Optional) The maximum number of times to retry this job if it fails. * `name` – (Required) The name you assign to this job. It must be unique in your account. From 7c6ef36e35554c998bfe3e45ba63efe441a502e0 Mon Sep 17 00:00:00 2001 From: nikhil Date: Wed, 29 May 2024 21:47:13 +0100 Subject: [PATCH 5/9] maintenance window --- internal/service/glue/job_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/service/glue/job_test.go b/internal/service/glue/job_test.go index 6e1f4cdf330..7c98b1bd222 100644 --- a/internal/service/glue/job_test.go +++ b/internal/service/glue/job_test.go @@ -401,11 +401,11 @@ func TestAccGlueJob_maintenanceWindow(t *testing.T) { CheckDestroy: testAccCheckJobDestroy(ctx), Steps: []resource.TestStep{ { - Config: testAccJobConfig_maintenanceWindow(rName, "sun:23:00-sun:23:30"), + Config: testAccJobConfig_maintenanceWindow(rName, "sun:23:00"), Check: resource.ComposeTestCheckFunc( testAccCheckJobExists(ctx, resourceName, &job), acctest.CheckResourceAttrRegionalARN(resourceName, names.AttrARN, "glue", fmt.Sprintf("job/%s", rName)), - resource.TestCheckResourceAttr(resourceName, "maintenance_window", "sun:23:00-sun:23:30"), + resource.TestCheckResourceAttr(resourceName, "maintenance_window", "sun:23:00"), ), }, { From 0ef5d4a7e63c9141b78afc0cbb7bed1ca2fe6f93 Mon Sep 17 00:00:00 2001 From: nikhil Date: Wed, 29 May 2024 21:48:16 +0100 Subject: [PATCH 6/9] glue job --- internal/service/glue/job_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/service/glue/job_test.go b/internal/service/glue/job_test.go index 7c98b1bd222..d1249d5e423 100644 --- a/internal/service/glue/job_test.go +++ b/internal/service/glue/job_test.go @@ -401,11 +401,11 @@ func TestAccGlueJob_maintenanceWindow(t *testing.T) { CheckDestroy: testAccCheckJobDestroy(ctx), Steps: []resource.TestStep{ { - Config: testAccJobConfig_maintenanceWindow(rName, "sun:23:00"), + Config: testAccJobConfig_maintenanceWindow(rName, "sun:23"), Check: resource.ComposeTestCheckFunc( testAccCheckJobExists(ctx, resourceName, &job), acctest.CheckResourceAttrRegionalARN(resourceName, names.AttrARN, "glue", fmt.Sprintf("job/%s", rName)), - resource.TestCheckResourceAttr(resourceName, "maintenance_window", "sun:23:00"), + resource.TestCheckResourceAttr(resourceName, "maintenance_window", "sun:23"), ), }, { From f65be7e753c73450b5a0c8dd1df822f9c691cc35 Mon Sep 17 00:00:00 2001 From: nikhil Date: Wed, 29 May 2024 21:50:36 +0100 Subject: [PATCH 7/9] glue job --- internal/service/glue/job.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/service/glue/job.go b/internal/service/glue/job.go index 2281f79a670..ca55693b5e3 100644 --- a/internal/service/glue/job.go +++ b/internal/service/glue/job.go @@ -120,8 +120,8 @@ func ResourceJob() *schema.Resource { ConflictsWith: []string{"number_of_workers", "worker_type"}, }, "maintenance_window": { - Type: schema.TypeString, - Optional: true, + Type: schema.TypeString, + Optional: true, }, "max_retries": { Type: schema.TypeInt, From 06389df4812cfe65a69621756871278fab7dc537 Mon Sep 17 00:00:00 2001 From: nikhil Date: Wed, 29 May 2024 21:51:39 +0100 Subject: [PATCH 8/9] glue job --- internal/service/glue/job_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/service/glue/job_test.go b/internal/service/glue/job_test.go index d1249d5e423..bd50759c6dd 100644 --- a/internal/service/glue/job_test.go +++ b/internal/service/glue/job_test.go @@ -1160,8 +1160,8 @@ resource "aws_glue_job" "test" { func testAccJobConfig_tags1(rName, tagKey1, tagValue1 string) string { return acctest.ConfigCompose(testAccJobConfig_base(rName), fmt.Sprintf(` resource "aws_glue_job" "test" { - name = %[1]q - role_arn = aws_iam_role.test.arn + name = %[1]q + role_arn = aws_iam_role.test.arn command { script_location = "testscriptlocation" From 891a677a3f95df79bed7017be98e81355f806fb0 Mon Sep 17 00:00:00 2001 From: Adrian Johnson Date: Thu, 20 Jun 2024 11:31:14 -0400 Subject: [PATCH 9/9] aws_glue_job: update job as streaming --- internal/service/glue/job_test.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/internal/service/glue/job_test.go b/internal/service/glue/job_test.go index bd50759c6dd..a7748baeab6 100644 --- a/internal/service/glue/job_test.go +++ b/internal/service/glue/job_test.go @@ -393,6 +393,7 @@ func TestAccGlueJob_maintenanceWindow(t *testing.T) { var job glue.Job rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) resourceName := "aws_glue_job.test" + maintenanceWindow := "Sun:23" resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { acctest.PreCheck(ctx, t) }, @@ -401,11 +402,10 @@ func TestAccGlueJob_maintenanceWindow(t *testing.T) { CheckDestroy: testAccCheckJobDestroy(ctx), Steps: []resource.TestStep{ { - Config: testAccJobConfig_maintenanceWindow(rName, "sun:23"), + Config: testAccJobConfig_maintenanceWindow(rName, maintenanceWindow), Check: resource.ComposeTestCheckFunc( testAccCheckJobExists(ctx, resourceName, &job), - acctest.CheckResourceAttrRegionalARN(resourceName, names.AttrARN, "glue", fmt.Sprintf("job/%s", rName)), - resource.TestCheckResourceAttr(resourceName, "maintenance_window", "sun:23"), + resource.TestCheckResourceAttr(resourceName, "maintenance_window", "Sun:23"), ), }, { @@ -1079,6 +1079,7 @@ resource "aws_glue_job" "test" { maintenance_window = %[2]q command { + name = "gluestreaming" script_location = "testscriptlocation" }