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 support for job run queuing #39027

Merged
merged 7 commits into from
Aug 29, 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/39027.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resource/aws_glue_job: Add `job_run_queuing_enabled` argument
```
13 changes: 13 additions & 0 deletions internal/service/glue/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ func ResourceJob() *schema.Resource {
Optional: true,
Computed: true,
},
"job_run_queuing_enabled": {
Type: schema.TypeBool,
Optional: true,
},
names.AttrMaxCapacity: {
Type: schema.TypeFloat,
Optional: true,
Expand Down Expand Up @@ -229,6 +233,10 @@ func resourceJobCreate(ctx context.Context, d *schema.ResourceData, meta interfa
input.GlueVersion = aws.String(v.(string))
}

if v, ok := d.GetOk("job_run_queuing_enabled"); ok {
input.JobRunQueuingEnabled = aws.Bool(v.(bool))
}

if v, ok := d.GetOk(names.AttrMaxCapacity); ok {
input.MaxCapacity = aws.Float64(v.(float64))
}
Expand Down Expand Up @@ -313,6 +321,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("job_run_queuing_enabled", job.JobRunQueuingEnabled)
d.Set("maintenance_window", job.MaintenanceWindow)
d.Set(names.AttrMaxCapacity, job.MaxCapacity)
d.Set("max_retries", job.MaxRetries)
Expand Down Expand Up @@ -366,6 +375,10 @@ func resourceJobUpdate(ctx context.Context, d *schema.ResourceData, meta interfa
jobUpdate.GlueVersion = aws.String(v.(string))
}

if v, ok := d.GetOk("job_run_queuing_enabled"); ok {
jobUpdate.JobRunQueuingEnabled = aws.Bool(v.(bool))
}

if v, ok := d.GetOk("maintenance_window"); ok {
jobUpdate.MaintenanceWindow = aws.String(v.(string))
}
Expand Down
54 changes: 54 additions & 0 deletions internal/service/glue/job_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,43 @@ func TestAccGlueJob_executionProperty(t *testing.T) {
})
}

func TestAccGlueJob_jobRunQueuingEnabled(t *testing.T) {
ctx := acctest.Context(t)
var job awstypes.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_jobRunQueuingEnabled(rName, true),
Check: resource.ComposeTestCheckFunc(
testAccCheckJobExists(ctx, resourceName, &job),
resource.TestCheckResourceAttr(resourceName, names.AttrName, rName),
resource.TestCheckResourceAttr(resourceName, "job_run_queuing_enabled", acctest.CtTrue),
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
{
Config: testAccJobConfig_jobRunQueuingEnabled(rName, false),
Check: resource.ComposeTestCheckFunc(
testAccCheckJobExists(ctx, resourceName, &job),
resource.TestCheckResourceAttr(resourceName, names.AttrName, rName),
resource.TestCheckResourceAttr(resourceName, "job_run_queuing_enabled", acctest.CtFalse),
),
},
},
})
}

func TestAccGlueJob_maintenanceWindow(t *testing.T) {
ctx := acctest.Context(t)
var job awstypes.Job
Expand Down Expand Up @@ -1158,6 +1195,23 @@ resource "aws_glue_job" "test" {
`, rName))
}

func testAccJobConfig_jobRunQueuingEnabled(rName string, jobRunQueuingEnabled bool) string {
return acctest.ConfigCompose(testAccJobConfig_base(rName), fmt.Sprintf(`
resource "aws_glue_job" "test" {
max_capacity = 10
name = %[1]q
role_arn = aws_iam_role.test.arn
job_run_queuing_enabled = %[2]t

command {
script_location = "testscriptlocation"
}

depends_on = [aws_iam_role_policy_attachment.test]
}
`, rName, jobRunQueuingEnabled))
}

func testAccJobConfig_tags1(rName, tagKey1, tagValue1 string) string {
return acctest.ConfigCompose(testAccJobConfig_base(rName), fmt.Sprintf(`
resource "aws_glue_job" "test" {
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 @@ -108,6 +108,7 @@ This resource supports the following arguments:
* `description` – (Optional) Description of the job.
* `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).
* `job_run_queuing_enabled` - (Optional) Specifies whether job run queuing is enabled for the job runs for this job. A value of true means job run queuing is enabled for the job runs. If false or not populated, the job runs will not be considered for queueing.
* `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.
Expand Down
Loading