aws-cloudformation / cfn-lint

CloudFormation Linter
MIT No Attribution
2.43k stars 590 forks source link

Validate Cpu/Memory combinations for Fargate AWS::ECS::TaskDefinition #3453

Closed trav-c closed 2 months ago

trav-c commented 3 months ago

Is this feature request related to a new rule or cfn-lint capabilities?

rules

Describe the feature you'd like to request

When creating an AWS::ECS::TaskDefinition with FARGATE in RequiresCompatibilities it would be helpful if cfn-lint could validate that the Cpu and Memory values are a combination that is compatible with Fargate.

Fargate ECS tasks impose restrictions on the specific values, and more to the point combinations of values that can be used for the Cpu and Memory as per https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-cpu-memory-error.html and the CloudFormation documentation for AWS::ECS::TaskDefinition.Memory

For example it is not possible to create a task with 1 vCPU (1024 CPU Shares) and 1GB (1024 MB) of Memory, the closest supported options are either

Describe the solution you'd like

Conditionally validate that the CPU and Memory properties are a supported combination when FARGATE is present in AWS::ECS::TaskDefinition.RequiresCompatibilities

Additional context

No response

Is this something that you'd be interested in working on?

Would this feature include a breaking change?

kddejong commented 3 months ago

@trav-c if you get a chance please look at the PR. I've included two new rules. 1/ that will validate the CPU/Memory values for Fargate tasks 2/ that will validate that CPU/Memory are required properties when using Fargate and additionally that CPU will have a valid value.