aws / aws-cdk

The AWS Cloud Development Kit is a framework for defining cloud infrastructure in code
https://aws.amazon.com/cdk
Apache License 2.0
11.41k stars 3.8k forks source link

(ecs): Incorrect ECS Fargate cpu/memory settings are not detected #22216

Open watany-dev opened 1 year ago

watany-dev commented 1 year ago

Describe the bug

Now this setting succeeds, but this is the wrong cpu/memory ratio for a Fargate setting. It may be necessary to add a checkFargateWindowsBasedTasksSize type of determination method to Fargate as well!

    const taskDefinitiongraviton2 = new ecs.FargateTaskDefinition(this, 'TaskDefGraviton2', {
      runtimePlatform: {
        operatingSystemFamily: ecs.OperatingSystemFamily.LINUX,
        cpuArchitecture: ecs.CpuArchitecture.ARM64,
      },
      cpu: 256,
      memoryLimitMiB: 122880
    });

Expected Behavior

Before cdk synth, CDK will determine the wrong configuration.

Current Behavior

Generate unsuccessful task definitions as CFn templates

Reproduction Steps

Here's the sample code I wrote above

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.41.1

Framework Version

No response

Node.js Version

any

OS

any

Language

Typescript

Language Version

No response

Other information

No response

peterwoodworth commented 1 year ago

It would be nice to detect this before deployment. Do you know where we can read documentation on the exact specifications for these inputs?

watany-dev commented 1 year ago

The three links given in the PR below are helpful. Allowable values ​​in the 1st line, you can see whether or not there is a runtime constraint in the 2nd and 3rd lines

https://github.com/aws/aws-cdk/pull/22209

watany-dev commented 1 year ago

It is also possible to define the CPU corresponding to memory as an enum, or vice versa. However, it is assumed that it is necessary to allow ″type number″ when considering backward compatibility. Therefore, the value check process is recognized with higher priority.