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/aws_glue_job: add maintenance_window attribute #37760

Merged
merged 11 commits into from
Jun 20, 2024
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
3 changes: 3 additions & 0 deletions .changelog/37760.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resource/aws_glue_job: Add `maintenance_window` argument
```
13 changes: 13 additions & 0 deletions internal/service/glue/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ func ResourceJob() *schema.Resource {
Computed: true,
ConflictsWith: []string{"number_of_workers", "worker_type"},
},
"maintenance_window": {
Type: schema.TypeString,
Optional: true,
},
"max_retries": {
Type: schema.TypeInt,
Optional: true,
Expand Down Expand Up @@ -227,6 +231,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)))
}
Expand Down Expand Up @@ -303,6 +311,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)
Expand Down Expand Up @@ -355,6 +364,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)))
}
Expand Down
52 changes: 48 additions & 4 deletions internal/service/glue/job_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
maintenanceWindow := "Sun:23"

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, maintenanceWindow),
Check: resource.ComposeTestCheckFunc(
testAccCheckJobExists(ctx, resourceName, &job),
resource.TestCheckResourceAttr(resourceName, "maintenance_window", "Sun:23"),
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
},
})
}

func TestAccGlueJob_maxRetries(t *testing.T) {
ctx := acctest.Context(t)
var job glue.Job
Expand Down Expand Up @@ -1042,6 +1071,23 @@ 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 {
name = "gluestreaming"
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" {
Expand Down Expand Up @@ -1115,10 +1161,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
number_of_workers = 1
role_arn = aws_iam_role.test.arn
worker_type = "Standard"
name = %[1]q
role_arn = aws_iam_role.test.arn

command {
script_location = "testscriptlocation"
Expand Down
1 change: 1 addition & 0 deletions website/docs/r/glue_job.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Loading