-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
AWS Glue worker_type feature #9115
Changes from all commits
e0d271b
dab64a0
6ec6da0
dc59a64
6246b77
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -3,6 +3,7 @@ package aws | |||||||||||||
import ( | ||||||||||||||
"fmt" | ||||||||||||||
"log" | ||||||||||||||
"regexp" | ||||||||||||||
|
||||||||||||||
"github.com/aws/aws-sdk-go/aws" | ||||||||||||||
"github.com/aws/aws-sdk-go/service/glue" | ||||||||||||||
|
@@ -25,7 +26,7 @@ func resourceAwsGlueJob() *schema.Resource { | |||||||||||||
Type: schema.TypeInt, | ||||||||||||||
Optional: true, | ||||||||||||||
Computed: true, | ||||||||||||||
ConflictsWith: []string{"max_capacity"}, | ||||||||||||||
ConflictsWith: []string{"max_capacity", "number_of_workers", "worker_type"}, | ||||||||||||||
Deprecated: "Please use attribute `max_capacity' instead. This attribute might be removed in future releases.", | ||||||||||||||
ValidateFunc: validation.IntAtLeast(2), | ||||||||||||||
}, | ||||||||||||||
|
@@ -86,7 +87,7 @@ func resourceAwsGlueJob() *schema.Resource { | |||||||||||||
Type: schema.TypeFloat, | ||||||||||||||
Optional: true, | ||||||||||||||
Computed: true, | ||||||||||||||
ConflictsWith: []string{"allocated_capacity"}, | ||||||||||||||
ConflictsWith: []string{"allocated_capacity", "number_of_workers", "worker_type"}, | ||||||||||||||
}, | ||||||||||||||
"max_retries": { | ||||||||||||||
Type: schema.TypeInt, | ||||||||||||||
|
@@ -113,6 +114,18 @@ func resourceAwsGlueJob() *schema.Resource { | |||||||||||||
Type: schema.TypeString, | ||||||||||||||
Optional: true, | ||||||||||||||
}, | ||||||||||||||
"worker_type": { | ||||||||||||||
Type: schema.TypeString, | ||||||||||||||
Optional: true, | ||||||||||||||
ConflictsWith: []string{"allocated_capacity", "max_capacity", "allocated_capacity"}, | ||||||||||||||
ValidateFunc: validation.StringMatch(regexp.MustCompile(`^Standard|G.1X|G.2X`), "Must be one of Standard, G.1X or G.2X. See https://docs.aws.amazon.com/glue/latest/dg/aws-glue-api-jobs-job.html"), | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: We typically prefer to use the
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not formatted through Here's the diff after pulling the latest master and running diff --git a/aws/resource_aws_glue_job.go b/aws/resource_aws_glue_job.go
index 19468747d..4e2aa2945 100644
--- a/aws/resource_aws_glue_job.go
+++ b/aws/resource_aws_glue_job.go
@@ -122,7 +122,7 @@ func resourceAwsGlueJob() *schema.Resource {
Type: schema.TypeString,
Optional: true,
ConflictsWith: []string{"allocated_capacity", "max_capacity"},
- ValidateFunc: validation.StringInSlice([]string{
+ ValidateFunc: validation.StringInSlice([]string{
glue.WorkerTypeG1x,
glue.WorkerTypeG2x,
glue.WorkerTypeStandard, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think I ran There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No problem, fixed by 4e449b0, master is now passing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thank you, sorry for an inconvenience! |
||||||||||||||
}, | ||||||||||||||
"number_of_workers": { | ||||||||||||||
Type: schema.TypeInt, | ||||||||||||||
Optional: true, | ||||||||||||||
ConflictsWith: []string{"allocated_capacity", "max_capacity", "allocated_capacity"}, | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: |
||||||||||||||
ValidateFunc: validation.IntAtLeast(2), | ||||||||||||||
}, | ||||||||||||||
}, | ||||||||||||||
} | ||||||||||||||
} | ||||||||||||||
|
@@ -167,6 +180,14 @@ func resourceAwsGlueJobCreate(d *schema.ResourceData, meta interface{}) error { | |||||||||||||
input.SecurityConfiguration = aws.String(v.(string)) | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
if v, ok := d.GetOk("worker_type"); ok { | ||||||||||||||
input.WorkerType = aws.String(v.(string)) | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
if v, ok := d.GetOk("number_of_workers"); ok { | ||||||||||||||
input.NumberOfWorkers = aws.Int64(int64(v.(int))) | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
log.Printf("[DEBUG] Creating Glue Job: %s", input) | ||||||||||||||
_, err := conn.CreateJob(input) | ||||||||||||||
if err != nil { | ||||||||||||||
|
@@ -225,6 +246,9 @@ func resourceAwsGlueJobRead(d *schema.ResourceData, meta interface{}) error { | |||||||||||||
return fmt.Errorf("error setting security_configuration: %s", err) | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
d.Set("worker_type", job.WorkerType) | ||||||||||||||
d.Set("number_of_workers", int(aws.Int64Value(job.NumberOfWorkers))) | ||||||||||||||
|
||||||||||||||
// TODO: Deprecated fields - remove in next major version | ||||||||||||||
d.Set("allocated_capacity", int(aws.Int64Value(job.AllocatedCapacity))) | ||||||||||||||
|
||||||||||||||
|
@@ -240,13 +264,16 @@ func resourceAwsGlueJobUpdate(d *schema.ResourceData, meta interface{}) error { | |||||||||||||
Timeout: aws.Int64(int64(d.Get("timeout").(int))), | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
if v, ok := d.GetOk("max_capacity"); ok { | ||||||||||||||
jobUpdate.MaxCapacity = aws.Float64(v.(float64)) | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
if d.HasChange("allocated_capacity") { | ||||||||||||||
jobUpdate.MaxCapacity = aws.Float64(float64(d.Get("allocated_capacity").(int))) | ||||||||||||||
log.Printf("[WARN] Using deprecated `allocated_capacity' attribute.") | ||||||||||||||
if v, ok := d.GetOk("number_of_workers"); ok { | ||||||||||||||
jobUpdate.NumberOfWorkers = aws.Int64(int64(v.(int))) | ||||||||||||||
} else { | ||||||||||||||
if v, ok := d.GetOk("max_capacity"); ok { | ||||||||||||||
jobUpdate.MaxCapacity = aws.Float64(v.(float64)) | ||||||||||||||
} | ||||||||||||||
if d.HasChange("allocated_capacity") { | ||||||||||||||
jobUpdate.MaxCapacity = aws.Float64(float64(d.Get("allocated_capacity").(int))) | ||||||||||||||
log.Printf("[WARN] Using deprecated `allocated_capacity' attribute.") | ||||||||||||||
} | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
if v, ok := d.GetOk("connections"); ok { | ||||||||||||||
|
@@ -279,6 +306,10 @@ func resourceAwsGlueJobUpdate(d *schema.ResourceData, meta interface{}) error { | |||||||||||||
jobUpdate.SecurityConfiguration = aws.String(v.(string)) | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
if v, ok := d.GetOk("worker_type"); ok { | ||||||||||||||
jobUpdate.WorkerType = aws.String(v.(string)) | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
input := &glue.UpdateJobInput{ | ||||||||||||||
JobName: aws.String(d.Id()), | ||||||||||||||
JobUpdate: jobUpdate, | ||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit:
allocated_capacity
is declared twice