aws / aws/aws-cdk

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

Open
#35,877 1 comment 0 reactions 0 assignees View on GitHub
@aws-cdk/aws-events-targets 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

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",

Contributor guide

Open the contributing guide

Research direction

Start at the event_targets.EcsTask entry point and inspect how its launchType is translated into the synthesized AWS::Events::Rule EcsParameters. Compare the expected EXTERNAL behavior with the generated CloudFormation and determine whether the value can be represented or must be rejected; done means it is no longer silently ignored, with the relevant behavior covered by tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, typescript
Domain
cloud
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 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.