Skip to content

Commit

Permalink
r/aws_ecs_service: service connect configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
johnsonaj committed Nov 29, 2022
1 parent 6a2d9b7 commit e5495cc
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions internal/service/ecs/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,14 @@ func ResourceService() *schema.Resource {
Type: schema.TypeString,
Optional: true,
},
// modeled after null_resource & aws_api_gateway_deployment
// only for _updates in-place_ rather than replacements
"triggers": {
Type: schema.TypeMap,
Optional: true,
Computed: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
"wait_for_steady_state": {
Type: schema.TypeBool,
Optional: true,
Expand All @@ -443,10 +451,34 @@ func ResourceService() *schema.Resource {
CustomizeDiff: customdiff.Sequence(
verify.SetTagsDiff,
capacityProviderStrategyCustomizeDiff,
triggersCustomizeDiff,
),
}
}

func triggersCustomizeDiff(_ context.Context, d *schema.ResourceDiff, meta interface{}) error {
// clears diff to avoid extraneous diffs but lets it pass for triggering update
fnd := false
if v, ok := d.GetOk("force_new_deployment"); ok {
fnd = v.(bool)
}

if d.HasChange("triggers") && !fnd {
return d.Clear("triggers")
}

if d.HasChange("triggers") && fnd {
o, n := d.GetChange("triggers")
if len(o.(map[string]interface{})) > 0 && len(n.(map[string]interface{})) == 0 {
return d.Clear("triggers")
}

return nil
}

return nil
}

func capacityProviderStrategyCustomizeDiff(_ context.Context, d *schema.ResourceDiff, meta interface{}) error {
// to be backward compatible, should ForceNew almost always (previous behavior), unless:
// force_new_deployment is true and
Expand Down

0 comments on commit e5495cc

Please sign in to comment.