fix(events-targets): launchType not included for non-AWS_VPC network mode#35989
fix(events-targets): launchType not included for non-AWS_VPC network mode#35989newlinedeveloper wants to merge 10 commits intoaws:mainfrom
Conversation
5472f26 to
73c8304
Compare
…cs-external-launch-type
|
Hi @pahud . This PR needs review and approval. Please check it out. Thanks |
|
I just clicked CI approval button to trigger the CI run for this PR. After CI passes you should get pr/pending-community-review label and you are all set. Do not click Update branch after your PR is ready as this triggers another CI build attempt. Thank you. |
…cs-external-launch-type
…ws-cdk into fix/ecs-external-launch-type
|
|
||||||||||||||
|
|
||||||||||||||
…ws-cdk into fix/ecs-external-launch-type
|
|
||
| // Create a Task Definition with EXTERNAL compatibility | ||
| const taskDefinition = new ecs.TaskDefinition(stack, 'TaskDef', { | ||
| networkMode: ecs.NetworkMode.BRIDGE, // Non-AWS_VPC network mode |
There was a problem hiding this comment.
I want to test all the different NetworkMode with this setup. It can be done easily by encapsulating from line 12 to 32 to into cdk.Construct and add a single input to this construct NetworkMode and iterate over NetworkMode and pass the different values to this construct.
I'm just afraid of in the future a network mode add that doesn't accept external launch type and no one will think of this edge case.
Can you help us doing that?
|
@newlinedeveloper the build is failing, let me know if u need help with this |
Description
Fixes an issue where the
launchTypeproperty (includingEXTERNAL) was being silently dropped from the CloudFormation template when creating an ECS event target with non-AWS_VPC network modes.Root Cause
The
EcsTaskconstruct only includedlaunchTypein theEcsParameterswhen the task definition usedAWS_VPCnetwork mode. For other network modes (likeBRIDGE,HOST,NONE), thelaunchTypewas omitted entirely from the generated CloudFormation template, causing EventBridge to use default launch type logic instead of the specified launch type.This was particularly problematic for
EXTERNALlaunch type, which requires ECS Anywhere infrastructure. When the launch type was dropped, the scheduled task would fail to run because it would try to use EC2 or Fargate launch types instead of EXTERNAL.Solution
Modified the
bind()method inecs-task.tsto always includelaunchTypeinbaseEcsParameters, regardless of network mode. ThelaunchTypeis now included in the CloudFormation template for all network modes, not justAWS_VPC.Changes:
launchTypefrom the conditional AWS_VPC branch intobaseEcsParameterslaunchTypeis always included when specified (or computed from task definition compatibility)networkConfiguration) remains only for AWS_VPC network mode, as required by CloudFormationTesting
launch type EXTERNAL is included for non-AWS_VPC network modeto verify the fixinteg.event-external-task.tsto verify the stack synthesizes correctlyLaunchType: 'EXTERNAL'appears in the CloudFormation template for BRIDGE network modeRelated Issue
Fixes #35877
Verification
The fix was verified by:
LaunchType: 'EXTERNAL'is included in the CloudFormation templateLaunchTypefor all network modesCloudFormation Template Change
Before:
"EcsParameters": {
"TaskCount": 1,
"TaskDefinitionArn": { "Ref": "TaskDef" }
}
After:
"EcsParameters": {
"TaskCount": 1,
"TaskDefinitionArn": { "Ref": "TaskDef" },
"LaunchType": "EXTERNAL"
}---
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license