aws / aws/containers-roadmap

[ECS] [Cloudformation]: Add ECS::Service CreationPolicy and UpdatePolicy with Resource Signaling

Open
#639 2 comments 24 reactions 0 assignees View on GitHub
ECS Proposed
Dominant language
Shell
Stars
5.4k
Forks
334
PR merge metrics
No merged PRs in 30d

Description

### Community Note

* Please vote on this issue by adding a 👍 [reaction](https://blog.github.com/2016-03-10-add-reactions-to-pull-requests-issues-and-comments/) to the original issue to help the community and maintainers prioritize this request
* Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
* If you are interested in working on this issue or have submitted a pull request, please leave a comment

**Tell us about your request**

This is a request for 2 changes:

1. Add CreationPolicy and UpdatePolicy resource signaling for AWS::ECS::Service in the same way that it exists for AutoScaling

```
UpdatePolicy:
ECSServiceUpdatePolicy:
WaitOnResourceSignals: Boolean
CreationPolicy:
ECSServiceCreationPolicy:
MinSuccessfulTaskPercent: Integer
ResourceSignal:
Count: Integer
Timeout: String
```

2. Add additional ECS Task ContainerDependency conditions `UNHEALTHY` and/or `FAILED` to perform signaling in failure scenarios.

```
FAILED - This condition is the same as COMPLETE, but it also requires that the container exits with a non-zero status.

UNHEALTHY - This condition is satisfied when a dependent container fails its Docker health check. This requires that the dependent container has health checks configured.
```

***Signaling of the AWS::ECS::Service resource would then be accomplished by a appended non-essential container on the ECS task with a ContainerDependency***
```
ContainerDefinitions:
-
Name: MyTask
-
Name: CloudformationSuccessReply
Image: amazon/awscli:latest
Command:
- aws
- signal-resource
- '--stack-name'
- !Ref 'AWS::StackId'
- '--logical-resource-id'
- ECSService
- '--status'
- SUCCESS
DependsOn:
-
Condition: 'HEALTHY'
ContainerName: MyTask
Essential: false
-
Name: CloudformationFailureReply
Image: amazon/awscli:latest
Command:
- aws
- signal-resource
- '--stack-name'
- !Ref 'AWS::StackId'
- '--logical-resource-id'
- ECSService
- '--status'
- FAILURE
DependsOn:
-
Condition: 'UNHEALTHY'
ContainerName: MyTask
Essential: false
```

A POC of this using `WaitCondition` can be found here: https://github.com/deuscapturus/cloudformation-macro-WaitConditionUpdate/blob/master/example-ecs-service.yaml

**Which service(s) is this request for?**
Fargate, ECS, Cloudformation

**Tell us about the problem you're trying to solve. What are you trying to do, and why is it hard?**

Currently when updating an ECS Service with Cloudformation there is no way to handle scenarios where the service tasks fails to "stabilize". Cloudformation will remain in UPDATE_IN_PROGRESS until a 3 hour timeout or manual intervention. This problem is made worse by the fact that Cloudformation offers no way to set a stack update timeout.

The additional UNHEALTHY and FAILURE conditions could also be useful in other situations.

**Are you currently working around this issue?**

Workaround using WaitCondition that only works on stack update with a macro. The workaround is very limited and is failure prone because it can't always determine when a ECS Service resource will be updated.

Link to workaround macro: https://github.com/deuscapturus/cloudformation-macro-WaitConditionUpdate

Contributor guide

Open the contributing guide

Research direction

Start by reviewing the linked example-ecs-service.yaml POC and the WaitConditionUpdate workaround macro. Done would require the requested ECS Service CreationPolicy and UpdatePolicy signaling behavior, plus the proposed failure conditions, but this issue does not identify repository files or tests to modify.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws
Domain
cloud, infrastructure
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.