@@ -2337,31 +2337,11 @@ func triggersCustomizeDiff(_ context.Context, d *schema.ResourceDiff, meta any)
2337
2337
}
2338
2338
2339
2339
func capacityProviderStrategyCustomizeDiff (_ context.Context , d * schema.ResourceDiff , meta any ) error {
2340
- // to be backward compatible, should ForceNew almost always (previous behavior), unless:
2341
- // force_new_deployment is true and
2342
- // neither the old set nor new set is 0 length
2343
- if v := d .Get ("force_new_deployment" ).(bool ); ! v {
2344
- return capacityProviderStrategyForceNew (d )
2345
- }
2346
-
2347
- old , new := d .GetChange (names .AttrCapacityProviderStrategy )
2348
-
2349
- ol := old .(* schema.Set ).Len ()
2350
- nl := new .(* schema.Set ).Len ()
2351
-
2352
- if (ol == 0 && nl > 0 ) || (ol > 0 && nl == 0 ) {
2353
- return capacityProviderStrategyForceNew (d )
2354
- }
2355
-
2356
- return nil
2357
- }
2358
-
2359
- func capacityProviderStrategyForceNew (d * schema.ResourceDiff ) error {
2360
- for _ , key := range d .GetChangedKeysPrefix (names .AttrCapacityProviderStrategy ) {
2361
- if d .HasChange (key ) {
2362
- if err := d .ForceNew (key ); err != nil {
2363
- return fmt .Errorf ("while attempting to force a new ECS service for capacity_provider_strategy: %w" , err )
2364
- }
2340
+ // This if-statement is true only when the resource is being updated.
2341
+ // d.Id() != "" means the resource (ecs service) already exists.
2342
+ if d .Id () != "" && d .HasChange (names .AttrCapacityProviderStrategy ) {
2343
+ if v := d .Get ("force_new_deployment" ).(bool ); ! v {
2344
+ return fmt .Errorf ("force_new_deployment should be true when capacity_provider_strategy is being updated" )
2365
2345
}
2366
2346
}
2367
2347
return nil
0 commit comments