Skip to content

StartTask

Source: src/AWS/ECS/StartTask.ts

Runtime binding for ecs:StartTask.

Bind this operation to a Cluster and Task inside a function runtime to get a callable that places the bound task definition on specific container instances (EC2/EXTERNAL launch types — unlike RunTask, which lets ECS pick placement). The cluster and task definition ARNs are injected automatically; the host is granted ecs:StartTask on the task definition plus iam:PassRole on the task and execution roles.

const controller = yield* AWS.Lambda.Function(
"PlacementController",
{ main: import.meta.url },
Effect.gen(function* () {
// init: bind the launch (IAM grants happen here)
const startTask = yield* AWS.ECS.StartTask(cluster, task);
return {
fetch: Effect.gen(function* () {
// runtime: place the task on a chosen instance
const response = yield* startTask({
containerInstances: [containerInstanceArn],
startedBy: "placement-controller",
});
return yield* HttpServerResponse.json({
taskArn: response.tasks?.[0]?.taskArn,
});
}),
};
}),
);