Skip to content

aws_ecs: TaskDefinition constraint.type 'distinctInstance' is not supported #25905

@IllarionovDimitri

Description

@IllarionovDimitri

Describe the bug

According to the documentation ecs.Ec2Taskdefinition supports placement_constraints attribute (which looks kinda redundant, because ecs.Ec2Service supports both placement_constraints and placement_strategies)

ecs.Ec2TaskDefinition(
  self,
  id",
  family="ecs-family",
  task_role=task_role,
  placement_constraints=[ecs.PlacementConstraint.distinct_instances()],
)

Stack deployment raises following exception

Resource handler returned message: "Invalid request provided: Create TaskDefinition: constraint.type 'distinctInstance' is not supported. (Service: AmazonECS; Status Code: 400; Error Code: ClientException; Request ID: 71214110-96ed-4631-a83e-74a3
8206a8db; Proxy: null)" (RequestToken: 59dedc0b-cb70-0b09-c0f5-9b580c5fe3da, HandlerErrorCode: InvalidRequest)

Expected Behavior

Either the ecs.Ec2Taskdefinition can be properly deployed with set placement_constraints attribute or it can be only defined in ecs.Ec2Service (regarding redundancy I am no quite sure, probably there are cases where definition of placement_constraints in ecs.Ec2Taskdefinition also makes sense)

Current Behavior

Error during stack deployment if placement_constraints is defined in ecs.Ec2Taskdefinition

Reproduction Steps

Define placement_constraints as follows in ecs.Ec2Taskdefinition and deploy the esc stack ()there is no error with cdk synth or cdk ls)

ecs.Ec2TaskDefinition(
  self,
  id",
  family="ecs-family",
  task_role=task_role,
  placement_constraints=[ecs.PlacementConstraint.distinct_instances()],
)

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.83.0

Framework Version

No response

Node.js Version

18

OS

Ubuntu 20.04.5 LTS

Language

Python

Language Version

3.10.6

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    @aws-cdk/aws-ecsRelated to Amazon Elastic ContainerbugThis issue is a bug.documentationThis is a problem with documentation.effort/smallSmall work item – less than a day of effortgood first issueRelated to contributions. See CONTRIBUTING.mdp2

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions