Skip to content

(aws_ecs): TaskDefinition rejects runtimePlatform property for non-Fargate tasks #39330

Open

Description

@Lexy2

Describe the bug

When passing runtimePlatform property to new ecs.TaskDefinition(..., that is only EC2-compatible, synthesis fails with an error

«CannotSpecifyRuntimePlatform» Cannot specify runtimePlatform in non-Fargate and non-Managed Instances compatible tasks
      ...new TaskDefinition2 in aws-cdk-lib...

Regression Issue

  • Select this option if this issue appears to be a regression.

Last Known Working CDK Library Version

No response

Expected Behavior

Synthesis succeeds, and deployed task definition contains the runtimePlatform property.

RuntimePlatform property should be supported for all tasks as per CloudFormation documentation, and set the property in the task definition which claims to be compatible with EC2 instances only.

Current Behavior

«CannotSpecifyRuntimePlatform» Cannot specify runtimePlatform in non-Fargate and non-Managed Instances compatible tasks
      ...new TaskDefinition2 in aws-cdk-lib...

The error seems to be coming from here: https://github.com/aws/aws-cdk/blob/main/packages/aws-cdk-lib/aws-ecs/lib/base/task-definition.ts#L559

Reproduction Steps

        new ecs.TaskDefinition(this, "Resource", {
            runtimePlatform: {
                cpuArchitecture: ecs.CpuArchitecture.X86_64,
                operatingSystemFamily: ecs.OperatingSystemFamily.LINUX,
            },
            compatibility: ecs.Compatibility.EC2,
        });

Possible Solution

Drop that if in the aforementioned source code as runtimePlatform is now supported in all capacity providers and launch types.

Additional Information/Context

No response

AWS CDK Library version (aws-cdk-lib)

2.273.0

AWS CDK CLI version

2.1139.0

Node.js Version

v24.21.0

OS

Windows 11

Language

TypeScript

Language Version

TypeScript (5.9.2)

Other information

No response

Activity

  1. added
    bugThis issue is a bug.
    needs-triageThis issue or PR still needs to be triaged.
    on Oct 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    @aws-cdk/aws-ecsRelated to Amazon Elastic ContainerbugThis issue is a bug.needs-triageThis issue or PR still needs to be triaged.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions