Skip to main content

ECS Run Task

Stable

Type: DEVRAMPS:ECS:RUN_TASK

Category: deploy

Version: 1.0.0


Description

Run a one-off Fargate task and wait for it to complete.

Runs a standalone Amazon ECS Fargate task as part of a deployment pipeline. Launches the task using a specified task definition, polls for completion, and streams container logs from CloudWatch into the deployment log in near-real-time. Fails the step if any essential container exits with a non-zero exit code. Common use cases include database migrations, smoke tests, cache warming, and seed scripts.

Parameters

Required Parameters

ParameterTypeDescription
cluster_namestringThe name of the ECS cluster to run the task on.
task_definitionstringThe task definition family name or full ARN (with optional revision) to run.
subnetsarray<string>List of subnet IDs for the task's network configuration.
security_groupsarray<string>List of security group IDs for the task.

Optional Parameters

ParameterTypeDefaultDescription
account_idstring-The AWS account ID where the ECS cluster is located. Defaults to stage account.
regionstring-The AWS region of the ECS cluster. Defaults to stage region.
container_overridesarray<object>-Per-container overrides for command and environment variables.
timeoutinteger60Maximum time in minutes to wait for the task to complete.
assign_public_ipbooleanfalseWhether to assign a public IP to the task. Defaults to false.

Example Usage

- type: DEVRAMPS:ECS:RUN_TASK
name: Run Database Migration
params:
cluster_name: my-cluster
task_definition: my-app-migration
subnets:
- subnet-abc123
- subnet-def456
security_groups:
- sg-xyz789
container_overrides:
- container_name: migration
command: ["npm", "run", "migrate"]
environment:
- name: DATABASE_URL
value: "${{ secrets.DATABASE_URL }}"
timeout: 30