Skip to content

Commit

Permalink
Merge pull request #37347 from DanielRieske/fix/nil-check-job-notific…
Browse files Browse the repository at this point in the history
…ation-property

Added `nil` check for `notification_property` on the `glue_job` resource
  • Loading branch information
jar-b authored May 10, 2024
2 parents 939765d + 9eb9ae6 commit 18ca4ad
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
3 changes: 3 additions & 0 deletions .changelog/37347.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
resource/aws_glue_job: Fix `interface conversion: interface {} is nil, not map[string]interface {}` panic when `notify_delay_after` is empty (`null`)
```
20 changes: 12 additions & 8 deletions internal/service/glue/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,8 @@ func resourceJobCreate(ctx context.Context, d *schema.ResourceData, meta interfa
input.NonOverridableArguments = flex.ExpandStringMap(v.(map[string]interface{}))
}

if v, ok := d.GetOk("notification_property"); ok {
input.NotificationProperty = expandNotificationProperty(v.([]interface{}))
if v, ok := d.GetOk("notification_property"); ok && len(v.([]interface{})) > 0 && v.([]interface{})[0] != nil {
input.NotificationProperty = expandNotificationProperty(v.([]interface{})[0].(map[string]interface{}))
}

if v, ok := d.GetOk("number_of_workers"); ok {
Expand Down Expand Up @@ -363,8 +363,8 @@ func resourceJobUpdate(ctx context.Context, d *schema.ResourceData, meta interfa
jobUpdate.NonOverridableArguments = flex.ExpandStringMap(kv.(map[string]interface{}))
}

if v, ok := d.GetOk("notification_property"); ok {
jobUpdate.NotificationProperty = expandNotificationProperty(v.([]interface{}))
if v, ok := d.GetOk("notification_property"); ok && len(v.([]interface{})) > 0 && v.([]interface{})[0] != nil {
jobUpdate.NotificationProperty = expandNotificationProperty(v.([]interface{})[0].(map[string]interface{}))
}

if v, ok := d.GetOk("number_of_workers"); ok {
Expand Down Expand Up @@ -451,11 +451,15 @@ func expandJobCommand(l []interface{}) *glue.JobCommand {
return jobCommand
}

func expandNotificationProperty(l []interface{}) *glue.NotificationProperty {
m := l[0].(map[string]interface{})
func expandNotificationProperty(tfMap map[string]interface{}) *glue.NotificationProperty {
if tfMap == nil {
return nil
}

notificationProperty := &glue.NotificationProperty{}

notificationProperty := &glue.NotificationProperty{
NotifyDelayAfter: aws.Int64(int64(m["notify_delay_after"].(int))),
if v, ok := tfMap["notify_delay_after"].(int); ok && v != 0 {
notificationProperty.NotifyDelayAfter = aws.Int64(int64(v))
}

return notificationProperty
Expand Down

0 comments on commit 18ca4ad

Please sign in to comment.