Skip to content

Commit

Permalink
Add enableExecuteCommand to sfn ECSRunTask
Browse files Browse the repository at this point in the history
Fixes #29637
  • Loading branch information
matthiasgubler committed Mar 28, 2024
1 parent 69cff2e commit 01ff241
Show file tree
Hide file tree
Showing 4 changed files with 238 additions and 135 deletions.
1 change: 1 addition & 0 deletions packages/aws-cdk-lib/aws-stepfunctions-tasks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,7 @@ const runTask = new tasks.EcsRunTask(this, 'Run', {
],
}),
propagatedTagSource: ecs.PropagatedTagSource.TASK_DEFINITION,
enableExecuteCommand: false,
});
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,37 +11,37 @@ import { getResourceArn } from '../resource-arn-suffix';
*/
export interface CommonEcsRunTaskProps {
/**
* The topic to run the task on
*/
* The topic to run the task on
*/
readonly cluster: ecs.ICluster;

/**
* Task Definition used for running tasks in the service.
*
* Note: this must be TaskDefinition, and not ITaskDefinition,
* as it requires properties that are not known for imported task definitions
* If you want to run a RunTask with an imported task definition,
* consider using CustomState
*/
* Task Definition used for running tasks in the service.
*
* Note: this must be TaskDefinition, and not ITaskDefinition,
* as it requires properties that are not known for imported task definitions
* If you want to run a RunTask with an imported task definition,
* consider using CustomState
*/
readonly taskDefinition: ecs.TaskDefinition;

/**
* Container setting overrides
*
* Key is the name of the container to override, value is the
* values you want to override.
*
* @default - No overrides
*/
* Container setting overrides
*
* Key is the name of the container to override, value is the
* values you want to override.
*
* @default - No overrides
*/
readonly containerOverrides?: ContainerOverride[];

/**
* The service integration pattern indicates different ways to call RunTask in ECS.
*
* The valid value for Lambda is FIRE_AND_FORGET, SYNC and WAIT_FOR_TASK_TOKEN.
*
* @default FIRE_AND_FORGET
*/
* The service integration pattern indicates different ways to call RunTask in ECS.
*
* The valid value for Lambda is FIRE_AND_FORGET, SYNC and WAIT_FOR_TASK_TOKEN.
*
* @default FIRE_AND_FORGET
*/
readonly integrationPattern?: sfn.ServiceIntegrationPattern;
}

Expand All @@ -51,11 +51,11 @@ export interface CommonEcsRunTaskProps {
*/
export interface EcsRunTaskBaseProps extends CommonEcsRunTaskProps {
/**
* Additional parameters to pass to the base task
*
* @default - No additional parameters passed
*/
readonly parameters?: {[key: string]: any};
* Additional parameters to pass to the base task
*
* @default - No additional parameters passed
*/
readonly parameters?: { [key: string]: any };
}

/**
Expand All @@ -64,8 +64,8 @@ export interface EcsRunTaskBaseProps extends CommonEcsRunTaskProps {
*/
export class EcsRunTaskBase implements ec2.IConnectable, sfn.IStepFunctionsTask {
/**
* Manage allowed network traffic for this service
*/
* Manage allowed network traffic for this service
*/
public readonly connections: ec2.Connections = new ec2.Connections();

private securityGroup?: ec2.ISecurityGroup;
Expand All @@ -86,7 +86,7 @@ export class EcsRunTaskBase implements ec2.IConnectable, sfn.IStepFunctionsTask
}

if (this.integrationPattern === sfn.ServiceIntegrationPattern.WAIT_FOR_TASK_TOKEN
&& !sfn.FieldUtils.containsTaskToken(props.containerOverrides?.map(override => override.environment))) {
&& !sfn.FieldUtils.containsTaskToken(props.containerOverrides?.map(override => override.environment))) {
throw new Error('Task Token is required in at least one `containerOverrides.environment` for callback. Use JsonPath.taskToken to set the token.');
}

Expand Down Expand Up @@ -190,7 +190,9 @@ export class EcsRunTaskBase implements ec2.IConnectable, sfn.IStepFunctionsTask
}

function renderOverrides(containerOverrides?: ContainerOverride[]) {
if (!containerOverrides) { return undefined; }
if (!containerOverrides) {
return undefined;
}

const ret = new Array<any>();
for (const override of containerOverrides) {
Expand Down

0 comments on commit 01ff241

Please sign in to comment.