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.72k stars 3.94k forks source link

ecs.ExternalService: `daemon` and `placementConstraints` not implemented #31204

Open mattstam opened 3 months ago

mattstam commented 3 months ago

Describe the bug

Extension of this: https://github.com/aws/containers-roadmap/issues/2395

I would like to enable daemon-type scheduling for services running on External instances through ECS-Anywhere. If the daemon boolean option is not available, then a workaround would simply to be to do use placementConstraints with the DistinctInstance option.

At first, it appeared as if this was unsupported on ECS External services in AWS. However, it appears that placement constraints are already supported in AWS, but just not added to the CDK client - I believe this is the case because if I go edit an existing ecs.ExternalService on the console, I have the option to add placement constraints, but if I use the CDK, it is not an option and gives the following errors when I try on either the External Task Definition or External Service:

- Object literal may only specify known properties, and 'placementConstraints' does not exist in type 'ExternalTaskDefinitionProps'.
- Object literal may only specify known properties, and 'placementConstraints' does not exist in type 'ExternalServiceProps'.

I think a simple fix here is to simply add those fields on either of the ecs.ExternalTaskDefition or ecs.ExternalService types. Longer-term, a daemon option might be nice, but as I understand it, this is basically just syntax sugar around placementConstraints: distinctInstance()?

Regression Issue

Last Known Working CDK Version

No response

Expected Behavior

I would expect this:

  return new cdk.aws_ecs.ExternalService(stack, `MyService`, {
    cluster,
    taskDefinition,
    securityGroups,
    daemon: true,
  });

or this:

  return new cdk.aws_ecs.ExternalService(stack, `MyService`, {
    cluster,
    taskDefinition,
    securityGroups,
    placementConstraints: [
      // ...
    ],
  });

to work.

Current Behavior

Those fields are not available.

Reproduction Steps

To reproduce, try the code in the expected behavior

Possible Solution

It's already added to AWS it seems, so in the CDK we just need to add the fields

Additional Information/Context

No response

CDK CLI Version

2.130.0 (build bd6e5ee)

Framework Version

No response

Node.js Version

20

OS

Ubuntu

Language

TypeScript

Language Version

No response

Other information

No response

ashishdhingra commented 3 months ago

Perhaps we need to add support of these properties in ExternalService.

mattstam commented 3 months ago

Thanks for the overview @ashishdhingra - based on the proposed implementation steps, do you have an ETA on when this could be added?