-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Description
Describe the feature
Add a warning message when minimumHealthyPercent isn't set for an ECS service, resulting in the implicit use of CDK's default value of 50%. This warning wouldn't appear if minimumHealthyPercent is explicitly set to 50%.
Use Case
CDK overrides the default value of 100% used by CloudFormation's AWS::ECS::Service and the CreateService API. This allows the number of running tasks to drop by up to 50% during deployments and Fargate maintenance etc.
This is an unsafe default for services which must support a consistent load e.g. handle web traffic via an ALB.
Proposed Solution
Implementation would be similar to the warning when creating an ASG with an explicit desired capacity.
Wording would be along the lines of:
minimumHealthyPercent has not been configured so the default value of 50% is used. The number of running tasks will decrease below the desired count during deployments etc. See [link to this issue]
Other Information
#14277 proposed changing the default value to 50%. This is a breaking change (e.g. it can cause stuck deployments) so I believe a warning is more practical. I also considered implementing this as a cdk-nag rule, but I believe a warning in "mainstream CDK" is warranted as this is a quirk of CDK itself.
I wasn't able to find any context for why CDK chose to override CloudFormation's default value. The ECS Developer Guide says 50% should be used to speed up deployments for services which are "idle for some time and don't have a high utilization rate." (source), but 100% is recommended for stateless workloads:
For example, when deploying a stateless application as an Amazon ECS service, such as a web or API server, customers should deploy multiple task replicas and set the minimumHealthyPercent to 100% (source)
I'm happy to open a PR but just wanted to get thoughts on this before putting pen to paper :)
Acknowledgements
- I may be able to implement this feature request
- This feature might incur a breaking change
CDK version used
Latest
Environment details (OS name and version, etc.)
N/A