Skip to content

Commit 364d9a1

Browse files
committed
Ensure scheduler configuration is disabled when the argument is removed
1 parent 49a9b20 commit 364d9a1

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

internal/service/emrserverless/application.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,6 @@ func resourceApplication() *schema.Resource {
232232
"scheduler_configuration": {
233233
Type: schema.TypeList,
234234
Optional: true,
235-
Computed: true,
236235
MaxItems: 1,
237236
Elem: &schema.Resource{
238237
Schema: map[string]*schema.Schema{
@@ -379,7 +378,7 @@ func resourceApplicationRead(ctx context.Context, d *schema.ResourceData, meta a
379378
return sdkdiag.AppendErrorf(diags, "setting network_configuration: %s", err)
380379
}
381380

382-
if err := d.Set("scheduler_configuration", []any{flattenSchedulerConfiguration(application.SchedulerConfiguration)}); err != nil {
381+
if err := d.Set("scheduler_configuration", flattenSchedulerConfiguration(application.SchedulerConfiguration)); err != nil {
383382
return sdkdiag.AppendErrorf(diags, "setting scheduler_configuration: %s", err)
384383
}
385384

@@ -432,6 +431,8 @@ func resourceApplicationUpdate(ctx context.Context, d *schema.ResourceData, meta
432431

433432
if v, ok := d.GetOk("scheduler_configuration"); ok && len(v.([]any)) > 0 && v.([]any)[0] != nil {
434433
input.SchedulerConfiguration = expandSchedulerConfiguration(v.([]any)[0].(map[string]any))
434+
} else {
435+
input.SchedulerConfiguration = &types.SchedulerConfiguration{}
435436
}
436437

437438
if v, ok := d.GetOk("release_label"); ok {
@@ -915,7 +916,7 @@ func expandSchedulerConfiguration(tfMap map[string]any) *types.SchedulerConfigur
915916
return apiObject
916917
}
917918

918-
func flattenSchedulerConfiguration(apiObject *types.SchedulerConfiguration) map[string]any {
919+
func flattenSchedulerConfiguration(apiObject *types.SchedulerConfiguration) []any {
919920
if apiObject == nil {
920921
return nil
921922
}
@@ -928,5 +929,5 @@ func flattenSchedulerConfiguration(apiObject *types.SchedulerConfiguration) map[
928929
if v := apiObject.QueueTimeoutMinutes; v != nil {
929930
tfMap["queue_timeout_minutes"] = aws.ToInt32(v)
930931
}
931-
return tfMap
932+
return []any{tfMap}
932933
}

internal/service/emrserverless/application_test.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -483,13 +483,11 @@ func TestAccEMRServerlessApplication_schedulerConfiguration(t *testing.T) {
483483
resource.TestCheckResourceAttr(resourceName, "scheduler_configuration.0.queue_timeout_minutes", "120"),
484484
),
485485
},
486-
{
486+
{ // When `scheduler_configuration` is removed, scheduler configuration is disabled
487487
Config: testAccApplicationConfig_basic(rName, "emr-7.1.0"),
488488
Check: resource.ComposeTestCheckFunc(
489489
testAccCheckApplicationExists(ctx, t, resourceName, &application),
490-
resource.TestCheckResourceAttr(resourceName, "scheduler_configuration.#", "1"),
491-
resource.TestCheckResourceAttr(resourceName, "scheduler_configuration.0.max_concurrent_runs", "20"),
492-
resource.TestCheckResourceAttr(resourceName, "scheduler_configuration.0.queue_timeout_minutes", "120"),
490+
resource.TestCheckResourceAttr(resourceName, "scheduler_configuration.#", "0"),
493491
),
494492
},
495493
},

0 commit comments

Comments
 (0)