@@ -309,8 +309,9 @@ func resourceApplicationCreate(ctx context.Context, d *schema.ResourceData, meta
309
309
input .NetworkConfiguration = expandNetworkConfiguration (v .([]any )[0 ].(map [string ]any ))
310
310
}
311
311
312
- if v , ok := d .GetOk ("scheduler_configuration" ); ok && len (v .([]any )) > 0 && v .([]any )[0 ] != nil {
313
- input .SchedulerConfiguration = expandSchedulerConfiguration (v .([]any )[0 ].(map [string ]any ))
312
+ // Empty block (len(v.([]any)) > 0 but v.([]any)[0] == nil) is allowed to enable scheduler_configuration with default values
313
+ if v , ok := d .GetOk ("scheduler_configuration" ); ok && len (v .([]any )) > 0 {
314
+ input .SchedulerConfiguration = expandSchedulerConfiguration (v .([]any ))
314
315
}
315
316
316
317
output , err := conn .CreateApplication (ctx , input )
@@ -429,10 +430,14 @@ func resourceApplicationUpdate(ctx context.Context, d *schema.ResourceData, meta
429
430
input .NetworkConfiguration = expandNetworkConfiguration (v .([]any )[0 ].(map [string ]any ))
430
431
}
431
432
432
- if v , ok := d .GetOk ("scheduler_configuration" ); ok && len (v .([]any )) > 0 && v .([]any )[0 ] != nil {
433
- input .SchedulerConfiguration = expandSchedulerConfiguration (v .([]any )[0 ].(map [string ]any ))
434
- } else {
435
- input .SchedulerConfiguration = & types.SchedulerConfiguration {}
433
+ if d .HasChange ("scheduler_configuration" ) {
434
+ // Empty block (len(v.([]any)) > 0 but v.([]any)[0] == nil) is allowed to enable scheduler_configuration with default values
435
+ if v , ok := d .GetOk ("scheduler_configuration" ); ok && len (v .([]any )) > 0 {
436
+ input .SchedulerConfiguration = expandSchedulerConfiguration (v .([]any ))
437
+ } else {
438
+ // scheduler_configuration block is removed
439
+ input .SchedulerConfiguration = & types.SchedulerConfiguration {}
440
+ }
436
441
}
437
442
438
443
if v , ok := d .GetOk ("release_label" ); ok {
@@ -898,18 +903,24 @@ func flattenWorkerResourceConfig(apiObject *types.WorkerResourceConfig) map[stri
898
903
return tfMap
899
904
}
900
905
901
- func expandSchedulerConfiguration (tfMap map [string ]any ) * types.SchedulerConfiguration {
902
- if tfMap == nil {
903
- return nil
906
+ func expandSchedulerConfiguration (tfList []any ) * types.SchedulerConfiguration {
907
+ // SchedulerConfiguration without any attributes disables the scheduler_configuration.
908
+ // If an empty block is specified, the scheduler_configuration is enabled with default values.
909
+ if tfList [0 ] == nil {
910
+ return & types.SchedulerConfiguration {
911
+ MaxConcurrentRuns : aws .Int32 (15 ), // default
912
+ QueueTimeoutMinutes : aws .Int32 (360 ), // default
913
+ }
904
914
}
905
915
906
916
apiObject := & types.SchedulerConfiguration {}
917
+ m := tfList [0 ].(map [string ]any )
907
918
908
- if v , ok := tfMap ["max_concurrent_runs" ].(int ); ok {
919
+ if v , ok := m ["max_concurrent_runs" ].(int ); ok && v != 0 {
909
920
apiObject .MaxConcurrentRuns = aws .Int32 (int32 (v ))
910
921
}
911
922
912
- if v , ok := tfMap ["queue_timeout_minutes" ].(int ); ok {
923
+ if v , ok := m ["queue_timeout_minutes" ].(int ); ok && v != 0 {
913
924
apiObject .QueueTimeoutMinutes = aws .Int32 (int32 (v ))
914
925
}
915
926
0 commit comments