fix(events-targets): launchType not included for non-AWS_VPC network mode #35989
+2,103
−2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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