Skip to content

(aws_events_targets): Creating an ECS target with launchType EXTERNAL does not work #35877

@liquidpele

Description

@liquidpele

Describe the bug

Creating a rule target like this:

            const rule = new Rule(this, `${prefix}Schedule`, {
                ruleName: `${prefix}Schedule`,
                // run at 10am PT everyday
                schedule: Schedule.cron({ minute: "0", hour: "18" }),
            })
            rule.addTarget(
                new event_targets.EcsTask({
                    cluster: this.prodCluster,
                    taskDefinition: ourSuperNeatTaskDef,
                    taskCount: 1,
                    launchType: LaunchType.EXTERNAL,
                }),
            )  

builds to the following CFN:

  "ThingSchedule132E3117": {
   "Type": "AWS::Events::Rule",
   "Properties": {
    "Name": "ThingSchedule",
    "ScheduleExpression": "cron(0 18 * * ? *)",
    "State": "ENABLED",
    "Targets": [
     {
      "Arn": {
       "Fn::GetAtt": [
        "ThingProdCluster9D714E1F",
        "Arn"
       ]
      },
      "EcsParameters": {
       "TaskCount": 1,
       "TaskDefinitionArn": {
        "Ref": "ThingTaskDefinition0DCE5395"
       }
      },
      "Id": "Target0",
      "Input": "{}",
      "RoleArn": {
       "Fn::GetAtt": [
        "ThingTaskDefinitionEventsRole720F2DE3",
        "Arn"
       ]
      }
     }
    ]
   },

As you can see, it just drops the launchType entirely, which means it will use the default logic of either ec2 or fargate...

Regression Issue

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

Last Known Working CDK Library Version

No response

Expected Behavior

CDK should either use the launchType specified, or give an error that it's not supported... but it should not silently ignore it. I think it should be supported since you can manually launch tasks with EXTERNAL launch type with the apis directly e.g. with boto3.

Current Behavior

The scheduled is created, but with the default launch type... this deploys, and then fails to ever run because the cluster only consists of ecs anywhere hosts (external launch type hosts).

Reproduction Steps

See description of example cdk.

Possible Solution

No response

Additional Information/Context

No response

AWS CDK Library version (aws-cdk-lib)

2.213.0

AWS CDK CLI version

2.207.0

Node.js Version

20.19.5

OS

AL2

Language

TypeScript

Language Version

No response

Other information

"aws-sdk": "^2.1690.0"
"aws-cdk": "^2.207.0",
"aws-cdk-lib": "^2.213.0",
"@aws-cdk/cx-api": "^2.207.0",
"aws-sdk": "^2.1227.0",
"constructs": "^10.4.0",

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions