aws / aws/aws-cdk

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

Open
#31,204 3 comments 1 reaction 0 assignees View on GitHub
@aws-cdk/aws-ecs bug effort/medium p2
Dominant language
TypeScript
Stars
12.9k
Forks
4.6k
Avg merge
2d 3h
Merged PRs (30d)
83

Description

### 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:

```sh
- 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

- [ ] Select this option if this issue appears to be a regression.

### Last Known Working CDK Version

_No response_

### Expected Behavior

I would expect this:
```ts
return new cdk.aws_ecs.ExternalService(stack, `MyService`, {
cluster,
taskDefinition,
securityGroups,
daemon: true,
});
```
or this:
```ts
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_

Contributor guide

Open the contributing guide

Research direction

Start from the ExternalServiceProps and ExternalTaskDefinitionProps entry points named in the issue, then inspect how ECS service options are exposed to the CDK client. Reproduce the TypeScript errors with the shown examples and verify that the supported placementConstraints or daemon option can be configured successfully.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, typescript
Domain
cloud, devops
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.