---
title: AWS ECS actions
source: https://docs.newrelic.com/docs/workflow-automation/setup-and-configure/actions-catalog/aws/ecs/aws-ecs
---

Use these actions to manage ECS clusters, capacity providers, container instances, services, task definitions, tasks, account settings, and resource tags directly from a workflow.

## Prerequisites

For prerequisites and credentials setup, see [Set up AWS credentials](https://docs.newrelic.com/docs/workflow-automation/setup-and-configure/set-up-aws-credentials).

All ECS actions accept the same auth inputs. Use `awsRoleArn` (recommended) or the access key pair (`awsAccessKeyId` and `awsSecretAccessKey`).

> #### 💡 TIP
>
> We recommend two separate roles: a read-only role for list and describe actions, and a state-changing role for update, run, stop, register, and tag actions. Use the `awsRoleArn` input per step to switch between them in a single workflow.
>
> Several actions return a `failures[]` array alongside the main response object (for example, `describeTasks`, `describeContainerInstances`, `runTask`). A non-empty `failures[]` indicates partial failure — the action itself returns `success: true` but one or more resources could not be retrieved or acted on. Use a selector to check `failures[]` in downstream steps when processing multiple resources.

**Shared inputs**

The following inputs apply to all ECS actions. Use `awsRoleArn` (recommended) or the access key pair.

| Input                | Type   | Description                                                       |
| -------------------- | ------ | ----------------------------------------------------------------- |
| `awsRoleArn`         | String | IAM role ARN to assume for this call.                             |
| `awsAccessKeyId`     | String | AWS access key ID. Pass as a secret.                              |
| `awsSecretAccessKey` | String | AWS secret access key. Pass as a secret.                          |
| `awsSessionToken`    | String | Temporary session token for STS authentication. Pass as a secret. |
| `selectors`          | List   | JQ selectors to extract specific fields from the action output.   |

## IAM permissions [#iam-permissions]

Each action requires a single ECS permission matching its API name. The following table lists the required permission for each action.

| **Action**                      | **Required IAM permission**         | **Additional permissions**                                                                                |
| ------------------------------- | ----------------------------------- | --------------------------------------------------------------------------------------------------------- |
| `listClusters`                  | `ecs:ListClusters`                  | None                                                                                                      |
| `describeClusters`              | `ecs:DescribeClusters`              | None                                                                                                      |
| `updateCluster`                 | `ecs:UpdateCluster`                 | None                                                                                                      |
| `updateClusterSettings`         | `ecs:UpdateClusterSettings`         | None                                                                                                      |
| `describeCapacityProviders`     | `ecs:DescribeCapacityProviders`     | None                                                                                                      |
| `updateCapacityProvider`        | `ecs:UpdateCapacityProvider`        | None                                                                                                      |
| `putClusterCapacityProviders`   | `ecs:PutClusterCapacityProviders`   | None                                                                                                      |
| `listContainerInstances`        | `ecs:ListContainerInstances`        | None                                                                                                      |
| `describeContainerInstances`    | `ecs:DescribeContainerInstances`    | None                                                                                                      |
| `updateContainerInstancesState` | `ecs:UpdateContainerInstancesState` | None                                                                                                      |
| `listServices`                  | `ecs:ListServices`                  | None                                                                                                      |
| `describeServices`              | `ecs:DescribeServices`              | None                                                                                                      |
| `updateService`                 | `ecs:UpdateService`                 | None                                                                                                      |
| `listServicesByNamespace`       | `ecs:ListServicesByNamespace`       | None                                                                                                      |
| `describeTaskSets`              | `ecs:DescribeTaskSets`              | None                                                                                                      |
| `listTaskDefinitions`           | `ecs:ListTaskDefinitions`           | None                                                                                                      |
| `describeTaskDefinition`        | `ecs:DescribeTaskDefinition`        | None                                                                                                      |
| `registerTaskDefinition`        | `ecs:RegisterTaskDefinition`        | `iam:PassRole` on the roles passed as `taskRoleArn` or `executionRoleArn`, only when those inputs are set |
| `deregisterTaskDefinition`      | `ecs:DeregisterTaskDefinition`      | None                                                                                                      |
| `deleteTaskDefinitions`         | `ecs:DeleteTaskDefinitions`         | None                                                                                                      |
| `listTaskDefinitionFamilies`    | `ecs:ListTaskDefinitionFamilies`    | None                                                                                                      |
| `listTasks`                     | `ecs:ListTasks`                     | None                                                                                                      |
| `describeTasks`                 | `ecs:DescribeTasks`                 | None                                                                                                      |
| `runTask`                       | `ecs:RunTask`                       | `iam:PassRole` on the execution role, only when `executionRoleArn` is set via task overrides              |
| `startTask`                     | `ecs:StartTask`                     | None                                                                                                      |
| `stopTask`                      | `ecs:StopTask`                      | None                                                                                                      |
| `getTaskProtection`             | `ecs:GetTaskProtection`             | None                                                                                                      |
| `updateTaskProtection`          | `ecs:UpdateTaskProtection`          | None                                                                                                      |
| `listAccountSettings`           | `ecs:ListAccountSettings`           | None                                                                                                      |
| `putAccountSetting`             | `ecs:PutAccountSetting`             | None                                                                                                      |
| `deleteAccountSetting`          | `ecs:DeleteAccountSetting`          | None                                                                                                      |
| `tagResource`                   | `ecs:TagResource`                   | None                                                                                                      |
| `untagResource`                 | `ecs:UntagResource`                 | None                                                                                                      |
| `listTagsForResource`           | `ecs:ListTagsForResource`           | None                                                                                                      |

> #### 💡 TIP
>
> `updateCluster` and `updateClusterSettings` both update Container Insights. Use `updateClusterSettings` when you only need to change settings — it takes only `cluster` and `settings`. Use `updateCluster` when you also need to change execute-command configuration or Service Connect defaults in the same call.

## List clusters [#list-clusters]

**Action identifier:** `aws.ecs.listClusters`

Returns a list of ECS cluster ARNs in the account and region. The response is paginated — use `nextToken` from the previous response to retrieve the next page.

### Inputs

| Input        | Type    | Description                                                 |
| ------------ | ------- | ----------------------------------------------------------- |
| `region`     | String  | **Required.** AWS region to query.                          |
| `maxResults` | Integer | **Optional.** Maximum number of results to return per page. |
| `nextToken`  | String  | **Optional.** Pagination token from a previous response.    |

For auth and selector inputs, see [Prerequisites](#prerequisites).

### Outputs

| Output         | Type    | Description                                                                                                                                                                                                        |
| -------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `response`     | Object  | See the [list_clusters boto3 reference](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ecs/client/list_clusters.html). Contains `clusterArns[]` and `nextToken` when more pages exist. |
| `success`      | Boolean | `true` or `false`                                                                                                                                                                                                  |
| `errorMessage` | String  | Error message on failure.                                                                                                                                                                                          |

### Example

```yaml
name: list-ecs-clusters
description: List all ECS cluster ARNs in a region
steps:
  - name: listClusters
    type: action
    action: aws.ecs.listClusters
    version: '1'
    inputs:
      awsRoleArn: ${{ :secrets:awsRoleArn }}
      region: us-east-1
      selectors:
        - name: clusterArns
          expression: ".response.clusterArns"
```

## Describe clusters [#describe-clusters]

**Action identifier:** `aws.ecs.describeClusters`

Returns detailed configuration and status information for one or more ECS clusters. Omit `clusters` to describe the default cluster. Use the `include` field to request additional details such as settings or statistics.

### Inputs

| Input      | Type   | Description                                                                                                                  |
| ---------- | ------ | ---------------------------------------------------------------------------------------------------------------------------- |
| `region`   | String | **Required.** AWS region of the target clusters.                                                                             |
| `clusters` | List   | **Optional.** List of cluster names or ARNs. Omit to describe the default cluster.                                           |
| `include`  | List   | **Optional.** Additional fields to include. Valid values: `ATTACHMENTS`, `CONFIGURATIONS`, `SETTINGS`, `STATISTICS`, `TAGS`. |

For auth and selector inputs, see [Prerequisites](#prerequisites).

### Outputs

| Output         | Type    | Description                                                                                                                                                                                        |
| -------------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `response`     | Object  | See the [describe_clusters boto3 reference](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ecs/client/describe_clusters.html). Contains `clusters[]` and `failures[]`. |
| `success`      | Boolean | `true` or `false`                                                                                                                                                                                  |
| `errorMessage` | String  | Error message on failure.                                                                                                                                                                          |

### Example

```yaml
name: describe-ecs-cluster
description: Get cluster settings including Container Insights status
steps:
  - name: describeClusters
    type: action
    action: aws.ecs.describeClusters
    version: '1'
    inputs:
      awsRoleArn: ${{ :secrets:awsRoleArn }}
      region: us-east-1
      clusters:
        - my-cluster
      include:
        - SETTINGS
      selectors:
        - name: settings
          expression: ".response.clusters[0].settings"
```

## Update a cluster [#update-cluster]

**Action identifier:** `aws.ecs.updateCluster`

Updates a cluster's configuration, including Container Insights settings, execute-command configuration, and Service Connect defaults. Use this action when you need to change multiple cluster properties at once. To update only settings, [`aws.ecs.updateClusterSettings`](#update-cluster-settings) is simpler.

### Inputs

| Input                    | Type   | Description                                                                                                                  |
| ------------------------ | ------ | ---------------------------------------------------------------------------------------------------------------------------- |
| `region`                 | String | **Required.** AWS region of the target cluster.                                                                              |
| `cluster`                | String | **Required.** Cluster name or ARN to update.                                                                                 |
| `settings`               | List   | **Optional.** List of `{name, value}` objects. Valid setting name: `containerInsights`. Valid values: `enabled`, `disabled`. |
| `configuration`          | Object | **Optional.** Cluster configuration including execute-command settings.                                                      |
| `serviceConnectDefaults` | Object | **Optional.** Default Service Connect namespace for the cluster.                                                             |

For auth and selector inputs, see [Prerequisites](#prerequisites).

### Outputs

| Output         | Type    | Description                                                                                                                                                              |
| -------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `response`     | Object  | See the [update_cluster boto3 reference](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ecs/client/update_cluster.html). Contains `cluster`. |
| `success`      | Boolean | `true` or `false`                                                                                                                                                        |
| `errorMessage` | String  | Error message on failure.                                                                                                                                                |

### Example

```yaml
name: enable-container-insights
description: Enable Container Insights on an ECS cluster
steps:
  - name: updateCluster
    type: action
    action: aws.ecs.updateCluster
    version: '1'
    inputs:
      awsRoleArn: ${{ :secrets:awsRoleArn }}
      region: us-east-1
      cluster: my-cluster
      settings:
        - name: containerInsights
          value: enabled
```

## Update cluster settings [#update-cluster-settings]

**Action identifier:** `aws.ecs.updateClusterSettings`

Updates a cluster's settings only (for example, enabling or disabling Container Insights). This is a simpler alternative to [`aws.ecs.updateCluster`](#update-cluster) when you only need to change settings.

### Inputs

| Input      | Type   | Description                                                                                                                  |
| ---------- | ------ | ---------------------------------------------------------------------------------------------------------------------------- |
| `region`   | String | **Required.** AWS region of the target cluster.                                                                              |
| `cluster`  | String | **Required.** Cluster name or ARN to update.                                                                                 |
| `settings` | List   | **Required.** List of `{name, value}` objects. Valid setting name: `containerInsights`. Valid values: `enabled`, `disabled`. |

For auth and selector inputs, see [Prerequisites](#prerequisites).

### Outputs

| Output         | Type    | Description                                                                                                                                                                                |
| -------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `response`     | Object  | See the [update_cluster_settings boto3 reference](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ecs/client/update_cluster_settings.html). Contains `cluster`. |
| `success`      | Boolean | `true` or `false`                                                                                                                                                                          |
| `errorMessage` | String  | Error message on failure.                                                                                                                                                                  |

### Example

```yaml
name: update-cluster-settings
description: Enable Container Insights using the settings-only update action
steps:
  - name: updateClusterSettings
    type: action
    action: aws.ecs.updateClusterSettings
    version: '1'
    inputs:
      awsRoleArn: ${{ :secrets:awsRoleArn }}
      region: us-east-1
      cluster: my-cluster
      settings:
        - name: containerInsights
          value: enabled
```

## Describe capacity providers [#describe-capacity-providers]

**Action identifier:** `aws.ecs.describeCapacityProviders`

Returns detailed information about capacity providers. Omit `capacityProviders` to describe all capacity providers in the account. The response is paginated — use `nextToken` from the previous response to retrieve the next page.

### Inputs

| Input               | Type    | Description                                                                                     |
| ------------------- | ------- | ----------------------------------------------------------------------------------------------- |
| `region`            | String  | **Required.** AWS region to query.                                                              |
| `capacityProviders` | List    | **Optional.** List of capacity provider names or ARNs. Omit to describe all capacity providers. |
| `include`           | List    | **Optional.** Additional fields to include. Valid value: `TAGS`.                                |
| `maxResults`        | Integer | **Optional.** Maximum number of results per page.                                               |
| `nextToken`         | String  | **Optional.** Pagination token from a previous response.                                        |

For auth and selector inputs, see [Prerequisites](#prerequisites).

### Outputs

| Output         | Type    | Description                                                                                                                                                                                                                                          |
| -------------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `response`     | Object  | See the [describe_capacity_providers boto3 reference](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ecs/client/describe_capacity_providers.html). Contains `capacityProviders[]` and `nextToken` when more pages exist. |
| `success`      | Boolean | `true` or `false`                                                                                                                                                                                                                                    |
| `errorMessage` | String  | Error message on failure.                                                                                                                                                                                                                            |

### Example

```yaml
name: describe-capacity-providers
description: List all capacity providers in a region
steps:
  - name: describeCapacityProviders
    type: action
    action: aws.ecs.describeCapacityProviders
    version: '1'
    inputs:
      awsRoleArn: ${{ :secrets:awsRoleArn }}
      region: us-east-1
      selectors:
        - name: capacityProviders
          expression: ".response.capacityProviders"
```

## Update a capacity provider [#update-capacity-provider]

**Action identifier:** `aws.ecs.updateCapacityProvider`

Updates an Auto Scaling group-backed capacity provider's managed scaling configuration, including target capacity and managed termination protection.

### Inputs

| Input                      | Type   | Description                                                                                                                                                                                    |
| -------------------------- | ------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `region`                   | String | **Required.** AWS region of the capacity provider.                                                                                                                                             |
| `name`                     | String | **Required.** Name of the capacity provider to update.                                                                                                                                         |
| `autoScalingGroupProvider` | Object | **Required.** Updated configuration including `managedScaling` (`status`, `targetCapacity`, `minimumScalingStepSize`, `maximumScalingStepSize`) and optionally `managedTerminationProtection`. |

For auth and selector inputs, see [Prerequisites](#prerequisites).

### Outputs

| Output         | Type    | Description                                                                                                                                                                                           |
| -------------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `response`     | Object  | See the [update_capacity_provider boto3 reference](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ecs/client/update_capacity_provider.html). Contains `capacityProvider`. |
| `success`      | Boolean | `true` or `false`                                                                                                                                                                                     |
| `errorMessage` | String  | Error message on failure.                                                                                                                                                                             |

### Example

```yaml
name: update-capacity-provider
description: Set managed scaling target to 100% for an ASG-backed capacity provider
steps:
  - name: updateCapacityProvider
    type: action
    action: aws.ecs.updateCapacityProvider
    version: '1'
    inputs:
      awsRoleArn: ${{ :secrets:awsRoleArn }}
      region: us-east-1
      name: my-asg-capacity-provider
      autoScalingGroupProvider:
        managedScaling:
          status: ENABLED
          targetCapacity: 100
```

## Put cluster capacity providers [#put-cluster-capacity-providers]

**Action identifier:** `aws.ecs.putClusterCapacityProviders`

Attaches capacity providers to a cluster and sets the default capacity provider strategy. Replaces the full set of capacity providers on the cluster — include all providers you want attached, not just the ones you are adding.

### Inputs

| Input                             | Type   | Description                                                                                     |
| --------------------------------- | ------ | ----------------------------------------------------------------------------------------------- |
| `region`                          | String | **Required.** AWS region of the target cluster.                                                 |
| `cluster`                         | String | **Required.** Cluster name or ARN.                                                              |
| `capacityProviders`               | List   | **Required.** Complete list of capacity provider names to attach to the cluster.                |
| `defaultCapacityProviderStrategy` | List   | **Required.** List of `{capacityProvider, weight, base}` objects defining the default strategy. |

For auth and selector inputs, see [Prerequisites](#prerequisites).

### Outputs

| Output         | Type    | Description                                                                                                                                                                                              |
| -------------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `response`     | Object  | See the [put_cluster_capacity_providers boto3 reference](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ecs/client/put_cluster_capacity_providers.html). Contains `cluster`. |
| `success`      | Boolean | `true` or `false`                                                                                                                                                                                        |
| `errorMessage` | String  | Error message on failure.                                                                                                                                                                                |

### Example

```yaml
name: attach-capacity-providers
description: Attach Fargate and Fargate Spot to a cluster with a default strategy
steps:
  - name: putClusterCapacityProviders
    type: action
    action: aws.ecs.putClusterCapacityProviders
    version: '1'
    inputs:
      awsRoleArn: ${{ :secrets:awsRoleArn }}
      region: us-east-1
      cluster: my-cluster
      capacityProviders:
        - FARGATE
        - FARGATE_SPOT
      defaultCapacityProviderStrategy:
        - capacityProvider: FARGATE
          weight: 1
          base: 0
```

## List container instances [#list-container-instances]

**Action identifier:** `aws.ecs.listContainerInstances`

Returns a list of container instance ARNs registered to a cluster. The response is paginated — use `nextToken` from the previous response to retrieve the next page.

### Inputs

| Input        | Type    | Description                                                                                                                        |
| ------------ | ------- | ---------------------------------------------------------------------------------------------------------------------------------- |
| `region`     | String  | **Required.** AWS region of the target cluster.                                                                                    |
| `cluster`    | String  | **Optional.** Cluster name or ARN. Defaults to the default cluster.                                                                |
| `filter`     | String  | **Optional.** Filter expression to narrow results.                                                                                 |
| `status`     | String  | **Optional.** Filter by instance state. Valid values: `ACTIVE`, `DRAINING`, `REGISTERING`, `DEREGISTERING`, `REGISTRATION_FAILED`. |
| `maxResults` | Integer | **Optional.** Maximum number of results per page.                                                                                  |
| `nextToken`  | String  | **Optional.** Pagination token from a previous response.                                                                           |

For auth and selector inputs, see [Prerequisites](#prerequisites).

### Outputs

| Output         | Type    | Description                                                                                                                                                                                                                                        |
| -------------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `response`     | Object  | See the [list_container_instances boto3 reference](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ecs/client/list_container_instances.html). Contains `containerInstanceArns[]` and `nextToken` when more pages exist. |
| `success`      | Boolean | `true` or `false`                                                                                                                                                                                                                                  |
| `errorMessage` | String  | Error message on failure.                                                                                                                                                                                                                          |

### Example

```yaml
name: list-container-instances
description: List active container instances in a cluster
steps:
  - name: listContainerInstances
    type: action
    action: aws.ecs.listContainerInstances
    version: '1'
    inputs:
      awsRoleArn: ${{ :secrets:awsRoleArn }}
      region: us-east-1
      cluster: my-cluster
      status: ACTIVE
      selectors:
        - name: containerInstanceArns
          expression: ".response.containerInstanceArns"
```

## Describe container instances [#describe-container-instances]

**Action identifier:** `aws.ecs.describeContainerInstances`

Returns detailed information about one or more container instances registered to a cluster.

### Inputs

| Input                | Type   | Description                                                         |
| -------------------- | ------ | ------------------------------------------------------------------- |
| `region`             | String | **Required.** AWS region of the target cluster.                     |
| `containerInstances` | List   | **Required.** List of container instance ARNs or IDs to describe.   |
| `cluster`            | String | **Optional.** Cluster name or ARN. Defaults to the default cluster. |
| `include`            | List   | **Optional.** Additional fields to include. Valid value: `TAGS`.    |

For auth and selector inputs, see [Prerequisites](#prerequisites).

### Outputs

| Output         | Type    | Description                                                                                                                                                                                                                        |
| -------------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `response`     | Object  | See the [describe_container_instances boto3 reference](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ecs/client/describe_container_instances.html). Contains `containerInstances[]` and `failures[]`. |
| `success`      | Boolean | `true` or `false`                                                                                                                                                                                                                  |
| `errorMessage` | String  | Error message on failure.                                                                                                                                                                                                          |

### Example

```yaml
name: describe-container-instances
description: Get status of specific container instances
steps:
  - name: describeContainerInstances
    type: action
    action: aws.ecs.describeContainerInstances
    version: '1'
    inputs:
      awsRoleArn: ${{ :secrets:awsRoleArn }}
      region: us-east-1
      cluster: my-cluster
      containerInstances:
        - ${{ .steps.listContainerInstances.outputs.containerInstanceArns[0] }}
```

## Update container instances state [#update-container-instances-state]

**Action identifier:** `aws.ecs.updateContainerInstancesState`

Changes the state of one or more container instances. Set `status` to `DRAINING` to prevent new tasks from being placed on the instances before maintenance, or back to `ACTIVE` when maintenance is complete.

### Inputs

| Input                | Type   | Description                                                         |
| -------------------- | ------ | ------------------------------------------------------------------- |
| `region`             | String | **Required.** AWS region of the target cluster.                     |
| `containerInstances` | List   | **Required.** List of container instance ARNs or IDs to update.     |
| `status`             | String | **Required.** Target state. Valid values: `ACTIVE`, `DRAINING`.     |
| `cluster`            | String | **Optional.** Cluster name or ARN. Defaults to the default cluster. |

For auth and selector inputs, see [Prerequisites](#prerequisites).

### Outputs

| Output         | Type    | Description                                                                                                                                                                                                                                |
| -------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `response`     | Object  | See the [update_container_instances_state boto3 reference](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ecs/client/update_container_instances_state.html). Contains `containerInstances[]` and `failures[]`. |
| `success`      | Boolean | `true` or `false`                                                                                                                                                                                                                          |
| `errorMessage` | String  | Error message on failure.                                                                                                                                                                                                                  |

### Example

```yaml
name: drain-container-instances
description: Drain container instances before maintenance
steps:
  - name: listInstances
    type: action
    action: aws.ecs.listContainerInstances
    version: '1'
    inputs:
      awsRoleArn: ${{ :secrets:awsRoleArn }}
      region: us-east-1
      cluster: my-cluster
      selectors:
        - name: containerInstanceArns
          expression: ".response.containerInstanceArns"
  - name: drainInstances
    type: action
    action: aws.ecs.updateContainerInstancesState
    version: '1'
    inputs:
      awsRoleArn: ${{ :secrets:awsRoleArn }}
      region: us-east-1
      cluster: my-cluster
      containerInstances: ${{ .steps.listInstances.outputs.containerInstanceArns }}
      status: DRAINING
```

## List services [#list-services]

**Action identifier:** `aws.ecs.listServices`

Returns a list of service ARNs running on a cluster. The response is paginated — use `nextToken` from the previous response to retrieve the next page.

### Inputs

| Input                | Type    | Description                                                                      |
| -------------------- | ------- | -------------------------------------------------------------------------------- |
| `region`             | String  | **Required.** AWS region to query.                                               |
| `cluster`            | String  | **Optional.** Cluster name or ARN. Defaults to the default cluster.              |
| `launchType`         | String  | **Optional.** Filter by launch type. Valid values: `EC2`, `FARGATE`, `EXTERNAL`. |
| `schedulingStrategy` | String  | **Optional.** Filter by scheduling strategy. Valid values: `REPLICA`, `DAEMON`.  |
| `maxResults`         | Integer | **Optional.** Maximum number of results per page.                                |
| `nextToken`          | String  | **Optional.** Pagination token from a previous response.                         |

For auth and selector inputs, see [Prerequisites](#prerequisites).

### Outputs

| Output         | Type    | Description                                                                                                                                                                                                        |
| -------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `response`     | Object  | See the [list_services boto3 reference](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ecs/client/list_services.html). Contains `serviceArns[]` and `nextToken` when more pages exist. |
| `success`      | Boolean | `true` or `false`                                                                                                                                                                                                  |
| `errorMessage` | String  | Error message on failure.                                                                                                                                                                                          |

### Example

```yaml
name: list-ecs-services
description: List all services on an ECS cluster
steps:
  - name: listServices
    type: action
    action: aws.ecs.listServices
    version: '1'
    inputs:
      awsRoleArn: ${{ :secrets:awsRoleArn }}
      region: us-east-1
      cluster: my-cluster
      selectors:
        - name: serviceArns
          expression: ".response.serviceArns"
```

## Describe services [#describe-services]

**Action identifier:** `aws.ecs.describeServices`

Returns detailed configuration and status for one or more ECS services, including running count, task definition, and deployment status.

### Inputs

| Input      | Type   | Description                                                         |
| ---------- | ------ | ------------------------------------------------------------------- |
| `region`   | String | **Required.** AWS region of the target cluster.                     |
| `services` | List   | **Required.** List of service names or ARNs to describe.            |
| `cluster`  | String | **Optional.** Cluster name or ARN. Defaults to the default cluster. |
| `include`  | List   | **Optional.** Additional fields to include. Valid value: `TAGS`.    |

For auth and selector inputs, see [Prerequisites](#prerequisites).

### Outputs

| Output         | Type    | Description                                                                                                                                                                                        |
| -------------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `response`     | Object  | See the [describe_services boto3 reference](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ecs/client/describe_services.html). Contains `services[]` and `failures[]`. |
| `success`      | Boolean | `true` or `false`                                                                                                                                                                                  |
| `errorMessage` | String  | Error message on failure.                                                                                                                                                                          |

### Example

```yaml
name: describe-ecs-service
description: Get current task definition of a service
steps:
  - name: describeServices
    type: action
    action: aws.ecs.describeServices
    version: '1'
    inputs:
      awsRoleArn: ${{ :secrets:awsRoleArn }}
      region: us-east-1
      cluster: my-cluster
      services:
        - my-service
      selectors:
        - name: taskDefinition
          expression: ".response.services[0].taskDefinition"
```

## Update a service [#update-service]

**Action identifier:** `aws.ecs.updateService`

Updates an ECS service's desired count, task definition, or deployment configuration. Set `forceNewDeployment` to `true` to trigger a redeployment without changing the task definition.

### Inputs

| Input                     | Type    | Description                                                                                 |
| ------------------------- | ------- | ------------------------------------------------------------------------------------------- |
| `region`                  | String  | **Required.** AWS region of the target cluster.                                             |
| `service`                 | String  | **Required.** Service name or ARN to update.                                                |
| `cluster`                 | String  | **Optional.** Cluster name or ARN. Defaults to the default cluster.                         |
| `desiredCount`            | Integer | **Optional.** New desired task count for the service.                                       |
| `taskDefinition`          | String  | **Optional.** New task definition (family:revision or ARN) to deploy.                       |
| `forceNewDeployment`      | Boolean | **Optional.** Set to `true` to force a new deployment without changing the task definition. |
| `deploymentConfiguration` | Object  | **Optional.** Deployment parameters including `maximumPercent` and `minimumHealthyPercent`. |

For auth and selector inputs, see [Prerequisites](#prerequisites).

### Outputs

| Output         | Type    | Description                                                                                                                                                              |
| -------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `response`     | Object  | See the [update_service boto3 reference](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ecs/client/update_service.html). Contains `service`. |
| `success`      | Boolean | `true` or `false`                                                                                                                                                        |
| `errorMessage` | String  | Error message on failure.                                                                                                                                                |

### Example

```yaml
name: force-service-redeployment
description: Force a new deployment of an ECS service
steps:
  - name: updateService
    type: action
    action: aws.ecs.updateService
    version: '1'
    inputs:
      awsRoleArn: ${{ :secrets:awsRoleArn }}
      region: us-east-1
      cluster: my-cluster
      service: my-service
      forceNewDeployment: true
```

## List services by namespace [#list-services-by-namespace]

**Action identifier:** `aws.ecs.listServicesByNamespace`

Returns a list of service ARNs registered under a Cloud Map namespace. The response is paginated — use `nextToken` from the previous response to retrieve the next page.

### Inputs

| Input        | Type    | Description                                              |
| ------------ | ------- | -------------------------------------------------------- |
| `region`     | String  | **Required.** AWS region to query.                       |
| `namespace`  | String  | **Required.** Cloud Map namespace name or ARN.           |
| `maxResults` | Integer | **Optional.** Maximum number of results per page.        |
| `nextToken`  | String  | **Optional.** Pagination token from a previous response. |

For auth and selector inputs, see [Prerequisites](#prerequisites).

### Outputs

| Output         | Type    | Description                                                                                                                                                                                                                                  |
| -------------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `response`     | Object  | See the [list_services_by_namespace boto3 reference](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ecs/client/list_services_by_namespace.html). Contains `serviceArns[]` and `nextToken` when more pages exist. |
| `success`      | Boolean | `true` or `false`                                                                                                                                                                                                                            |
| `errorMessage` | String  | Error message on failure.                                                                                                                                                                                                                    |

### Example

```yaml
name: list-services-by-namespace
description: List services registered under a Cloud Map namespace
steps:
  - name: listServicesByNamespace
    type: action
    action: aws.ecs.listServicesByNamespace
    version: '1'
    inputs:
      awsRoleArn: ${{ :secrets:awsRoleArn }}
      region: us-east-1
      namespace: my-namespace
      selectors:
        - name: serviceArns
          expression: ".response.serviceArns"
```

## Describe task sets [#describe-task-sets]

**Action identifier:** `aws.ecs.describeTaskSets`

Returns detailed information about EXTERNAL-deployment-controller task sets. Only applies to services using the `EXTERNAL` deployment controller — returns an error for services using `ECS` or `CODE_DEPLOY` controllers. The `taskSets` input is required and must not be empty.

### Inputs

| Input      | Type   | Description                                                                       |
| ---------- | ------ | --------------------------------------------------------------------------------- |
| `region`   | String | **Required.** AWS region of the target cluster.                                   |
| `cluster`  | String | **Required.** Cluster name or ARN.                                                |
| `service`  | String | **Required.** Service name or ARN. Must use the `EXTERNAL` deployment controller. |
| `taskSets` | List   | **Required.** List of task set IDs or ARNs to describe. Must not be empty.        |
| `include`  | List   | **Optional.** Additional fields to include. Valid value: `TAGS`.                  |

For auth and selector inputs, see [Prerequisites](#prerequisites).

### Outputs

| Output         | Type    | Description                                                                                                                                                                                          |
| -------------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `response`     | Object  | See the [describe_task_sets boto3 reference](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ecs/client/describe_task_sets.html). Contains `taskSets[]` and `failures[]`. |
| `success`      | Boolean | `true` or `false`                                                                                                                                                                                    |
| `errorMessage` | String  | Error message on failure.                                                                                                                                                                            |

### Example

```yaml
name: describe-task-sets
description: Inspect an EXTERNAL-controller task set
steps:
  - name: describeTaskSets
    type: action
    action: aws.ecs.describeTaskSets
    version: '1'
    inputs:
      awsRoleArn: ${{ :secrets:awsRoleArn }}
      region: us-east-1
      cluster: my-cluster
      service: my-external-service
      taskSets:
        - arn:aws:ecs:us-east-1:123456789012:task-set/my-cluster/my-service/ecs-svc-abc123
```

> #### 💡 TIP
>
> Deleting a task definition revision is a two-step process: first deregister it with `aws.ecs.deregisterTaskDefinition` (sets status to `INACTIVE`), then permanently delete it with `aws.ecs.deleteTaskDefinitions`. You cannot delete an `ACTIVE` revision directly.

## List task definitions [#list-task-definitions]

**Action identifier:** `aws.ecs.listTaskDefinitions`

Returns a list of task definition ARNs. Filter by family prefix, status, or sort order. The response is paginated — use `nextToken` from the previous response to retrieve the next page.

### Inputs

| Input          | Type    | Description                                                                               |
| -------------- | ------- | ----------------------------------------------------------------------------------------- |
| `region`       | String  | **Required.** AWS region to query.                                                        |
| `familyPrefix` | String  | **Optional.** Filter to task definitions whose family name starts with this prefix.       |
| `status`       | String  | **Optional.** Filter by status. Valid values: `ACTIVE`, `INACTIVE`, `DELETE_IN_PROGRESS`. |
| `sort`         | String  | **Optional.** Sort order for results. Valid values: `ASC`, `DESC`.                        |
| `maxResults`   | Integer | **Optional.** Maximum number of results per page.                                         |
| `nextToken`    | String  | **Optional.** Pagination token from a previous response.                                  |

For auth and selector inputs, see [Prerequisites](#prerequisites).

### Outputs

| Output         | Type    | Description                                                                                                                                                                                                                               |
| -------------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `response`     | Object  | See the [list_task_definitions boto3 reference](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ecs/client/list_task_definitions.html). Contains `taskDefinitionArns[]` and `nextToken` when more pages exist. |
| `success`      | Boolean | `true` or `false`                                                                                                                                                                                                                         |
| `errorMessage` | String  | Error message on failure.                                                                                                                                                                                                                 |

### Example

```yaml
name: list-task-definitions
description: List active task definition revisions for a family
steps:
  - name: listTaskDefinitions
    type: action
    action: aws.ecs.listTaskDefinitions
    version: '1'
    inputs:
      awsRoleArn: ${{ :secrets:awsRoleArn }}
      region: us-east-1
      familyPrefix: my-task
      status: ACTIVE
      sort: DESC
      selectors:
        - name: taskDefinitionArns
          expression: ".response.taskDefinitionArns"
```

## Describe a task definition [#describe-task-definition]

**Action identifier:** `aws.ecs.describeTaskDefinition`

Returns the full specification for a task definition revision.

### Inputs

| Input            | Type   | Description                                                                        |
| ---------------- | ------ | ---------------------------------------------------------------------------------- |
| `region`         | String | **Required.** AWS region to query.                                                 |
| `taskDefinition` | String | **Required.** Task definition family and revision (`family:revision`) or full ARN. |
| `include`        | List   | **Optional.** Additional fields to include. Valid value: `TAGS`.                   |

For auth and selector inputs, see [Prerequisites](#prerequisites).

### Outputs

| Output         | Type    | Description                                                                                                                                                                                                      |
| -------------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `response`     | Object  | See the [describe_task_definition boto3 reference](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ecs/client/describe_task_definition.html). Contains `taskDefinition` and `tags[]`. |
| `success`      | Boolean | `true` or `false`                                                                                                                                                                                                |
| `errorMessage` | String  | Error message on failure.                                                                                                                                                                                        |

### Example

```yaml
name: describe-task-definition
description: Get the full specification for a task definition revision
steps:
  - name: describeTaskDefinition
    type: action
    action: aws.ecs.describeTaskDefinition
    version: '1'
    inputs:
      awsRoleArn: ${{ :secrets:awsRoleArn }}
      region: us-east-1
      taskDefinition: my-task:5
      selectors:
        - name: containerDefinitions
          expression: ".response.taskDefinition.containerDefinitions"
```

## Register a task definition [#register-task-definition]

**Action identifier:** `aws.ecs.registerTaskDefinition`

Registers a new revision of a task definition. Each call to this action creates a new revision number within the same family.

> #### ⚠️ IMPORTANT
>
> When `taskRoleArn` or `executionRoleArn` is set, the calling role also needs `iam:PassRole` on those role ARNs.

### Inputs

| Input                     | Type   | Description                                                                             |
| ------------------------- | ------ | --------------------------------------------------------------------------------------- |
| `region`                  | String | **Required.** AWS region to register the task definition in.                            |
| `family`                  | String | **Required.** Task definition family name.                                              |
| `containerDefinitions`    | List   | **Required.** List of container definition objects.                                     |
| `networkMode`             | String | **Optional.** Docker networking mode. Valid values: `bridge`, `host`, `awsvpc`, `none`. |
| `requiresCompatibilities` | List   | **Optional.** Launch type compatibility. Valid values: `EC2`, `FARGATE`.                |
| `cpu`                     | String | **Optional.** CPU units for the task (required for Fargate).                            |
| `memory`                  | String | **Optional.** Memory in MiB for the task (required for Fargate).                        |
| `executionRoleArn`        | String | **Optional.** ARN of the task execution IAM role.                                       |
| `taskRoleArn`             | String | **Optional.** ARN of the IAM role that containers in this task can assume.              |

For auth and selector inputs, see [Prerequisites](#prerequisites).

### Outputs

| Output         | Type    | Description                                                                                                                                                                                                      |
| -------------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `response`     | Object  | See the [register_task_definition boto3 reference](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ecs/client/register_task_definition.html). Contains `taskDefinition` and `tags[]`. |
| `success`      | Boolean | `true` or `false`                                                                                                                                                                                                |
| `errorMessage` | String  | Error message on failure.                                                                                                                                                                                        |

### Example

This example registers a new task definition revision and immediately deploys it to a service. This is the typical CD pattern: register a new image, then update the service to roll it out.

```yaml
name: deploy-new-task-revision
description: Register a new task definition revision and deploy it to a service
steps:
  - name: registerTaskDefinition
    type: action
    action: aws.ecs.registerTaskDefinition
    version: '1'
    inputs:
      awsRoleArn: ${{ :secrets:awsRoleArn }}
      region: us-east-1
      family: my-task
      networkMode: awsvpc
      requiresCompatibilities:
        - FARGATE
      cpu: "256"
      memory: "512"
      containerDefinitions:
        - name: app
          image: public.ecr.aws/nginx/nginx:1.25
          essential: true
      selectors:
        - name: taskDefinitionArn
          expression: ".response.taskDefinition.taskDefinitionArn"
  - name: deployToService
    type: action
    action: aws.ecs.updateService
    version: '1'
    inputs:
      awsRoleArn: ${{ :secrets:awsRoleArn }}
      region: us-east-1
      cluster: my-cluster
      service: my-service
      taskDefinition: ${{ .steps.registerTaskDefinition.outputs.taskDefinitionArn }}
      selectors:
        - name: serviceArn
          expression: ".response.service.serviceArn"
```

## Deregister a task definition [#deregister-task-definition]

**Action identifier:** `aws.ecs.deregisterTaskDefinition`

Deregisters (soft-deletes) a task definition revision, changing its status from `ACTIVE` to `INACTIVE`. Deregistered revisions can still be described but cannot be used to run new tasks. Use [`aws.ecs.deleteTaskDefinitions`](#delete-task-definitions) to permanently delete deregistered revisions.

### Inputs

| Input            | Type   | Description                                                                                      |
| ---------------- | ------ | ------------------------------------------------------------------------------------------------ |
| `region`         | String | **Required.** AWS region of the task definition.                                                 |
| `taskDefinition` | String | **Required.** Task definition family and revision (`family:revision`) or full ARN to deregister. |

For auth and selector inputs, see [Prerequisites](#prerequisites).

### Outputs

| Output         | Type    | Description                                                                                                                                                                                             |
| -------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `response`     | Object  | See the [deregister_task_definition boto3 reference](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ecs/client/deregister_task_definition.html). Contains `taskDefinition`. |
| `success`      | Boolean | `true` or `false`                                                                                                                                                                                       |
| `errorMessage` | String  | Error message on failure.                                                                                                                                                                               |

### Example

```yaml
name: deregister-task-definition
description: Deregister an old task definition revision
steps:
  - name: deregisterTaskDefinition
    type: action
    action: aws.ecs.deregisterTaskDefinition
    version: '1'
    inputs:
      awsRoleArn: ${{ :secrets:awsRoleArn }}
      region: us-east-1
      taskDefinition: my-task:3
```

## Delete task definitions [#delete-task-definitions]

**Action identifier:** `aws.ecs.deleteTaskDefinitions`

Permanently deletes one or more deregistered task definition revisions. Only revisions with status `INACTIVE` can be deleted — deregister them first with [`aws.ecs.deregisterTaskDefinition`](#deregister-task-definition) if needed.

### Inputs

| Input             | Type   | Description                                                                                       |
| ----------------- | ------ | ------------------------------------------------------------------------------------------------- |
| `region`          | String | **Required.** AWS region of the task definitions.                                                 |
| `taskDefinitions` | List   | **Required.** List of task definition revisions to delete, each as `family:revision` or full ARN. |

For auth and selector inputs, see [Prerequisites](#prerequisites).

### Outputs

| Output         | Type    | Description                                                                                                                                                                                                           |
| -------------- | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `response`     | Object  | See the [delete_task_definitions boto3 reference](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ecs/client/delete_task_definitions.html). Contains `taskDefinitions[]` and `failures[]`. |
| `success`      | Boolean | `true` or `false`                                                                                                                                                                                                     |
| `errorMessage` | String  | Error message on failure.                                                                                                                                                                                             |

### Example

```yaml
name: delete-task-definitions
description: Permanently delete deregistered task definition revisions
steps:
  - name: deleteTaskDefinitions
    type: action
    action: aws.ecs.deleteTaskDefinitions
    version: '1'
    inputs:
      awsRoleArn: ${{ :secrets:awsRoleArn }}
      region: us-east-1
      taskDefinitions:
        - my-task:3
        - my-task:4
```

## List task definition families [#list-task-definition-families]

**Action identifier:** `aws.ecs.listTaskDefinitionFamilies`

Returns a list of task definition family names. The response is paginated — use `nextToken` from the previous response to retrieve the next page.

### Inputs

| Input          | Type    | Description                                                                       |
| -------------- | ------- | --------------------------------------------------------------------------------- |
| `region`       | String  | **Required.** AWS region to query.                                                |
| `familyPrefix` | String  | **Optional.** Filter to families whose name starts with this prefix.              |
| `status`       | String  | **Optional.** Filter by family status. Valid values: `ACTIVE`, `INACTIVE`, `ALL`. |
| `maxResults`   | Integer | **Optional.** Maximum number of results per page.                                 |
| `nextToken`    | String  | **Optional.** Pagination token from a previous response.                          |

For auth and selector inputs, see [Prerequisites](#prerequisites).

### Outputs

| Output         | Type    | Description                                                                                                                                                                                                                                     |
| -------------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `response`     | Object  | See the [list_task_definition_families boto3 reference](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ecs/client/list_task_definition_families.html). Contains `families[]` and `nextToken` when more pages exist. |
| `success`      | Boolean | `true` or `false`                                                                                                                                                                                                                               |
| `errorMessage` | String  | Error message on failure.                                                                                                                                                                                                                       |

### Example

```yaml
name: list-task-definition-families
description: List active task definition families with a name prefix
steps:
  - name: listTaskDefinitionFamilies
    type: action
    action: aws.ecs.listTaskDefinitionFamilies
    version: '1'
    inputs:
      awsRoleArn: ${{ :secrets:awsRoleArn }}
      region: us-east-1
      familyPrefix: my-task
      status: ACTIVE
      selectors:
        - name: families
          expression: ".response.families"
```

> #### ⚠️ IMPORTANT
>
> `runTask` and `stopTask` are asynchronous — they return as soon as ECS accepts the request, before the task has actually started or stopped. Always poll with [`aws.ecs.describeTasks`](#describe-tasks) until `lastStatus` reaches a terminal state (`RUNNING` after launch, `STOPPED` after stop). Do not assume the task is in its final state after a single call.
>
> `startTask` only works on EC2 container instances — it fails on Fargate-only clusters.

## List tasks [#list-tasks]

**Action identifier:** `aws.ecs.listTasks`

Returns a list of task ARNs on a cluster. Filter by service, family, desired status, or launch type. The response is paginated — use `nextToken` from the previous response to retrieve the next page.

### Inputs

| Input           | Type    | Description                                                                            |
| --------------- | ------- | -------------------------------------------------------------------------------------- |
| `region`        | String  | **Required.** AWS region to query.                                                     |
| `cluster`       | String  | **Optional.** Cluster name or ARN. Defaults to the default cluster.                    |
| `serviceName`   | String  | **Optional.** Filter to tasks started by this service.                                 |
| `family`        | String  | **Optional.** Filter to tasks using this task definition family.                       |
| `desiredStatus` | String  | **Optional.** Filter by desired status. Valid values: `RUNNING`, `PENDING`, `STOPPED`. |
| `launchType`    | String  | **Optional.** Filter by launch type. Valid values: `EC2`, `FARGATE`, `EXTERNAL`.       |
| `maxResults`    | Integer | **Optional.** Maximum number of results per page.                                      |
| `nextToken`     | String  | **Optional.** Pagination token from a previous response.                               |

For auth and selector inputs, see [Prerequisites](#prerequisites).

### Outputs

| Output         | Type    | Description                                                                                                                                                                                               |
| -------------- | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `response`     | Object  | See the [list_tasks boto3 reference](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ecs/client/list_tasks.html). Contains `taskArns[]` and `nextToken` when more pages exist. |
| `success`      | Boolean | `true` or `false`                                                                                                                                                                                         |
| `errorMessage` | String  | Error message on failure.                                                                                                                                                                                 |

### Example

```yaml
name: list-running-tasks
description: List running tasks on a cluster
steps:
  - name: listTasks
    type: action
    action: aws.ecs.listTasks
    version: '1'
    inputs:
      awsRoleArn: ${{ :secrets:awsRoleArn }}
      region: us-east-1
      cluster: my-cluster
      desiredStatus: RUNNING
      selectors:
        - name: taskArns
          expression: ".response.taskArns"
```

## Describe tasks [#describe-tasks]

**Action identifier:** `aws.ecs.describeTasks`

Returns detailed status and configuration for one or more ECS tasks.

### Inputs

| Input     | Type   | Description                                                         |
| --------- | ------ | ------------------------------------------------------------------- |
| `region`  | String | **Required.** AWS region of the target tasks.                       |
| `tasks`   | List   | **Required.** List of task ARNs or IDs to describe.                 |
| `cluster` | String | **Optional.** Cluster name or ARN. Defaults to the default cluster. |
| `include` | List   | **Optional.** Additional fields to include. Valid value: `TAGS`.    |

For auth and selector inputs, see [Prerequisites](#prerequisites).

### Outputs

| Output         | Type    | Description                                                                                                                                                                               |
| -------------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `response`     | Object  | See the [describe_tasks boto3 reference](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ecs/client/describe_tasks.html). Contains `tasks[]` and `failures[]`. |
| `success`      | Boolean | `true` or `false`                                                                                                                                                                         |
| `errorMessage` | String  | Error message on failure.                                                                                                                                                                 |

### Example

```yaml
name: describe-tasks
description: Get status of specific ECS tasks
steps:
  - name: describeTasks
    type: action
    action: aws.ecs.describeTasks
    version: '1'
    inputs:
      awsRoleArn: ${{ :secrets:awsRoleArn }}
      region: us-east-1
      cluster: my-cluster
      tasks:
        - ${{ .steps.listTasks.outputs.taskArns[0] }}
      selectors:
        - name: lastStatus
          expression: ".response.tasks[0].lastStatus"
```

## Run a task [#run-task]

**Action identifier:** `aws.ecs.runTask`

Runs a new standalone task on a cluster. Asynchronous — returns as soon as ECS accepts the request. Use [`aws.ecs.describeTasks`](#describe-tasks) to poll until the task reaches a terminal status.

### Inputs

| Input                  | Type    | Description                                                                                                                              |
| ---------------------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
| `region`               | String  | **Required.** AWS region to run the task in.                                                                                             |
| `taskDefinition`       | String  | **Required.** Task definition family and revision (`family:revision`) or full ARN.                                                       |
| `cluster`              | String  | **Optional.** Cluster name or ARN. Defaults to the default cluster.                                                                      |
| `launchType`           | String  | **Optional.** Launch type. Valid values: `EC2`, `FARGATE`, `EXTERNAL`.                                                                   |
| `networkConfiguration` | Object  | **Optional.** Required for `awsvpc` network mode. Contains `awsvpcConfiguration` with `subnets`, `securityGroups`, and `assignPublicIp`. |
| `count`                | Integer | **Optional.** Number of task instances to run. Defaults to 1.                                                                            |
| `startedBy`            | String  | **Optional.** Tag to identify who started the task.                                                                                      |
| `overrides`            | Object  | **Optional.** Container and task overrides such as environment variables or commands.                                                    |

For auth and selector inputs, see [Prerequisites](#prerequisites).

### Outputs

| Output         | Type    | Description                                                                                                                                                                   |
| -------------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `response`     | Object  | See the [run_task boto3 reference](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ecs/client/run_task.html). Contains `tasks[]` and `failures[]`. |
| `success`      | Boolean | `true` or `false`                                                                                                                                                             |
| `errorMessage` | String  | Error message on failure.                                                                                                                                                     |

### Example

This example runs a Fargate task and polls `describeTasks` until the task reaches a terminal status. `runTask` is asynchronous — the task may still be in `PENDING` when the action returns.

```yaml
name: run-and-monitor-fargate-task
description: Run a Fargate task and poll until it reaches RUNNING or STOPPED
steps:
  - name: runTask
    type: action
    action: aws.ecs.runTask
    version: '1'
    inputs:
      awsRoleArn: ${{ :secrets:awsRoleArn }}
      region: us-east-1
      cluster: my-cluster
      taskDefinition: my-task:5
      launchType: FARGATE
      networkConfiguration:
        awsvpcConfiguration:
          subnets:
            - subnet-abc123
          securityGroups:
            - sg-xyz456
          assignPublicIp: ENABLED
      selectors:
        - name: taskArn
          expression: ".response.tasks[0].taskArn"
  - name: waitForStart
    type: wait
    seconds: 10
  - name: pollTaskStatus
    type: action
    action: aws.ecs.describeTasks
    version: '1'
    inputs:
      awsRoleArn: ${{ :secrets:awsRoleArn }}
      region: us-east-1
      cluster: my-cluster
      tasks:
        - ${{ .steps.runTask.outputs.taskArn }}
      selectors:
        - name: lastStatus
          expression: ".response.tasks[0].lastStatus"
  - name: checkTerminal
    type: switch
    switch:
      - condition: ${{ .steps.pollTaskStatus.outputs.lastStatus == "RUNNING" or .steps.pollTaskStatus.outputs.lastStatus == "STOPPED" }}
        next: logResult
    next: waitForStart
  - name: logResult
    type: action
    action: newrelic.ingest.sendLogs
    version: '1'
    inputs:
      logs:
        - message: "Task reached terminal status"
          attributes:
            taskArn: ${{ .steps.runTask.outputs.taskArn }}
            lastStatus: ${{ .steps.pollTaskStatus.outputs.lastStatus }}
```

## Start a task [#start-task]

**Action identifier:** `aws.ecs.startTask`

Starts a task on specific EC2 container instances. Unlike [`aws.ecs.runTask`](#run-task), places the task on instances you specify rather than letting ECS choose. Requires EC2 container instances — does not work on Fargate-only clusters.

### Inputs

| Input                | Type   | Description                                                                        |
| -------------------- | ------ | ---------------------------------------------------------------------------------- |
| `region`             | String | **Required.** AWS region of the target cluster.                                    |
| `taskDefinition`     | String | **Required.** Task definition family and revision (`family:revision`) or full ARN. |
| `containerInstances` | List   | **Required.** List of container instance ARNs or IDs to place the task on.         |
| `cluster`            | String | **Optional.** Cluster name or ARN. Defaults to the default cluster.                |
| `startedBy`          | String | **Optional.** Tag to identify who started the task.                                |
| `overrides`          | Object | **Optional.** Container and task overrides.                                        |

For auth and selector inputs, see [Prerequisites](#prerequisites).

### Outputs

| Output         | Type    | Description                                                                                                                                                                       |
| -------------- | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `response`     | Object  | See the [start_task boto3 reference](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ecs/client/start_task.html). Contains `tasks[]` and `failures[]`. |
| `success`      | Boolean | `true` or `false`                                                                                                                                                                 |
| `errorMessage` | String  | Error message on failure.                                                                                                                                                         |

### Example

```yaml
name: start-task-on-instance
description: Start a task on a specific EC2 container instance
steps:
  - name: startTask
    type: action
    action: aws.ecs.startTask
    version: '1'
    inputs:
      awsRoleArn: ${{ :secrets:awsRoleArn }}
      region: us-east-1
      cluster: my-cluster
      taskDefinition: my-task:5
      containerInstances:
        - arn:aws:ecs:us-east-1:123456789012:container-instance/my-cluster/abc123
```

## Stop a task [#stop-task]

**Action identifier:** `aws.ecs.stopTask`

Stops a running ECS task. The task moves to `STOPPED` status and ECS records the reason. Asynchronous — the task may not be fully stopped immediately.

### Inputs

| Input     | Type   | Description                                                                             |
| --------- | ------ | --------------------------------------------------------------------------------------- |
| `region`  | String | **Required.** AWS region of the target task.                                            |
| `task`    | String | **Required.** Task ARN or ID to stop.                                                   |
| `cluster` | String | **Optional.** Cluster name or ARN. Defaults to the default cluster.                     |
| `reason`  | String | **Optional.** Reason for stopping the task. Stored in the task's `stoppedReason` field. |

For auth and selector inputs, see [Prerequisites](#prerequisites).

### Outputs

| Output         | Type    | Description                                                                                                                                                 |
| -------------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `response`     | Object  | See the [stop_task boto3 reference](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ecs/client/stop_task.html). Contains `task`. |
| `success`      | Boolean | `true` or `false`                                                                                                                                           |
| `errorMessage` | String  | Error message on failure.                                                                                                                                   |

### Example

```yaml
name: stop-ecs-task
description: Stop a running ECS task with a reason
steps:
  - name: stopTask
    type: action
    action: aws.ecs.stopTask
    version: '1'
    inputs:
      awsRoleArn: ${{ :secrets:awsRoleArn }}
      region: us-east-1
      cluster: my-cluster
      task: ${{ .steps.runTask.outputs.taskArn }}
      reason: Stopped by workflow automation
```

## Get task protection [#get-task-protection]

**Action identifier:** `aws.ecs.getTaskProtection`

Retrieves the scale-in protection status of one or more tasks. Omit `tasks` to get protection status for all tasks in the cluster.

### Inputs

| Input     | Type   | Description                                                                              |
| --------- | ------ | ---------------------------------------------------------------------------------------- |
| `region`  | String | **Required.** AWS region of the target cluster.                                          |
| `cluster` | String | **Required.** Cluster name or ARN.                                                       |
| `tasks`   | List   | **Optional.** List of task ARNs or IDs to query. Omit to query all tasks in the cluster. |

For auth and selector inputs, see [Prerequisites](#prerequisites).

### Outputs

| Output         | Type    | Description                                                                                                                                                                                                  |
| -------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `response`     | Object  | See the [get_task_protection boto3 reference](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ecs/client/get_task_protection.html). Contains `protectedTasks[]` and `failures[]`. |
| `success`      | Boolean | `true` or `false`                                                                                                                                                                                            |
| `errorMessage` | String  | Error message on failure.                                                                                                                                                                                    |

### Example

```yaml
name: get-task-protection
description: Check scale-in protection status for a task
steps:
  - name: getTaskProtection
    type: action
    action: aws.ecs.getTaskProtection
    version: '1'
    inputs:
      awsRoleArn: ${{ :secrets:awsRoleArn }}
      region: us-east-1
      cluster: my-cluster
      tasks:
        - ${{ .steps.runTask.outputs.taskArn }}
      selectors:
        - name: protectedTasks
          expression: ".response.protectedTasks"
```

## Update task protection [#update-task-protection]

**Action identifier:** `aws.ecs.updateTaskProtection`

Enables or disables scale-in protection for one or more ECS tasks. Protected tasks are not terminated when the service scales in. Set `expiresInMinutes` to automatically expire the protection after a set time.

### Inputs

| Input               | Type    | Description                                                                                                            |
| ------------------- | ------- | ---------------------------------------------------------------------------------------------------------------------- |
| `region`            | String  | **Required.** AWS region of the target cluster.                                                                        |
| `cluster`           | String  | **Required.** Cluster name or ARN.                                                                                     |
| `tasks`             | List    | **Required.** List of task ARNs or IDs to update.                                                                      |
| `protectionEnabled` | Boolean | **Required.** Set to `true` to enable protection, `false` to disable.                                                  |
| `expiresInMinutes`  | String  | **Optional.** Number of minutes until protection expires automatically. Only valid when `protectionEnabled` is `true`. |

For auth and selector inputs, see [Prerequisites](#prerequisites).

### Outputs

| Output         | Type    | Description                                                                                                                                                                                                        |
| -------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `response`     | Object  | See the [update_task_protection boto3 reference](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ecs/client/update_task_protection.html). Contains `protectedTasks[]` and `failures[]`. |
| `success`      | Boolean | `true` or `false`                                                                                                                                                                                                  |
| `errorMessage` | String  | Error message on failure.                                                                                                                                                                                          |

### Example

```yaml
name: protect-task-during-operation
description: Enable scale-in protection on a task for 60 minutes
steps:
  - name: updateTaskProtection
    type: action
    action: aws.ecs.updateTaskProtection
    version: '1'
    inputs:
      awsRoleArn: ${{ :secrets:awsRoleArn }}
      region: us-east-1
      cluster: my-cluster
      tasks:
        - ${{ .steps.runTask.outputs.taskArn }}
      protectionEnabled: true
      expiresInMinutes: "60"
```

## List account settings [#list-account-settings]

**Action identifier:** `aws.ecs.listAccountSettings`

Lists ECS account settings for the calling principal or for a specified principal. Use `effectiveSettings: true` to return the effective settings (including account defaults) rather than only principal-scoped overrides. The response is paginated — use `nextToken` from the previous response to retrieve the next page.

### Inputs

| Input               | Type    | Description                                                                                                                                                               |
| ------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `region`            | String  | **Required.** AWS region to query.                                                                                                                                        |
| `name`              | String  | **Optional.** Filter by setting name. Valid values: `containerInsights`, `serviceLongArnFormat`, `taskLongArnFormat`, `containerInstanceLongArnFormat`, `awsvpcTrunking`. |
| `value`             | String  | **Optional.** Filter by setting value.                                                                                                                                    |
| `principalArn`      | String  | **Optional.** ARN of the principal whose settings to list. Requires `ecs:ListAccountSettings` on behalf of the principal.                                                 |
| `effectiveSettings` | Boolean | **Optional.** Set to `true` to return effective settings including account-level defaults.                                                                                |
| `maxResults`        | Integer | **Optional.** Maximum number of results per page.                                                                                                                         |
| `nextToken`         | String  | **Optional.** Pagination token from a previous response.                                                                                                                  |

For auth and selector inputs, see [Prerequisites](#prerequisites).

### Outputs

| Output         | Type    | Description                                                                                                                                                                                                                     |
| -------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `response`     | Object  | See the [list_account_settings boto3 reference](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ecs/client/list_account_settings.html). Contains `settings[]` and `nextToken` when more pages exist. |
| `success`      | Boolean | `true` or `false`                                                                                                                                                                                                               |
| `errorMessage` | String  | Error message on failure.                                                                                                                                                                                                       |

### Example

```yaml
name: list-ecs-account-settings
description: Get the effective Container Insights setting for the calling principal
steps:
  - name: listAccountSettings
    type: action
    action: aws.ecs.listAccountSettings
    version: '1'
    inputs:
      awsRoleArn: ${{ :secrets:awsRoleArn }}
      region: us-east-1
      name: containerInsights
      effectiveSettings: true
      selectors:
        - name: settings
          expression: ".response.settings"
```

## Put an account setting [#put-account-setting]

**Action identifier:** `aws.ecs.putAccountSetting`

Sets a principal-scoped ECS account setting for the calling principal or a specified principal. This overrides the account default for the principal only.

### Inputs

| Input          | Type   | Description                                                                                                                                                     |
| -------------- | ------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `region`       | String | **Required.** AWS region to apply the setting in.                                                                                                               |
| `name`         | String | **Required.** Setting name. Valid values: `containerInsights`, `serviceLongArnFormat`, `taskLongArnFormat`, `containerInstanceLongArnFormat`, `awsvpcTrunking`. |
| `value`        | String | **Required.** Setting value. Valid values: `enabled`, `disabled`.                                                                                               |
| `principalArn` | String | **Optional.** ARN of the principal to apply the setting for. Defaults to the calling principal.                                                                 |

For auth and selector inputs, see [Prerequisites](#prerequisites).

### Outputs

| Output         | Type    | Description                                                                                                                                                                        |
| -------------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `response`     | Object  | See the [put_account_setting boto3 reference](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ecs/client/put_account_setting.html). Contains `setting`. |
| `success`      | Boolean | `true` or `false`                                                                                                                                                                  |
| `errorMessage` | String  | Error message on failure.                                                                                                                                                          |

### Example

```yaml
name: enable-container-insights-setting
description: Enable Container Insights for the calling principal
steps:
  - name: putAccountSetting
    type: action
    action: aws.ecs.putAccountSetting
    version: '1'
    inputs:
      awsRoleArn: ${{ :secrets:awsRoleArn }}
      region: us-east-1
      name: containerInsights
      value: enabled
```

## Delete an account setting [#delete-account-setting]

**Action identifier:** `aws.ecs.deleteAccountSetting`

Clears a principal-scoped ECS account setting override, restoring the account default for that principal.

### Inputs

| Input          | Type   | Description                                                                                                                                                              |
| -------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `region`       | String | **Required.** AWS region to apply the change in.                                                                                                                         |
| `name`         | String | **Required.** Setting name to clear. Valid values: `containerInsights`, `serviceLongArnFormat`, `taskLongArnFormat`, `containerInstanceLongArnFormat`, `awsvpcTrunking`. |
| `principalArn` | String | **Optional.** ARN of the principal whose override to clear. Defaults to the calling principal.                                                                           |

For auth and selector inputs, see [Prerequisites](#prerequisites).

### Outputs

| Output         | Type    | Description                                                                                                                                                                              |
| -------------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `response`     | Object  | See the [delete_account_setting boto3 reference](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ecs/client/delete_account_setting.html). Contains `setting`. |
| `success`      | Boolean | `true` or `false`                                                                                                                                                                        |
| `errorMessage` | String  | Error message on failure.                                                                                                                                                                |

### Example

```yaml
name: clear-account-setting
description: Clear a principal-scoped Container Insights override
steps:
  - name: deleteAccountSetting
    type: action
    action: aws.ecs.deleteAccountSetting
    version: '1'
    inputs:
      awsRoleArn: ${{ :secrets:awsRoleArn }}
      region: us-east-1
      name: containerInsights
```

## Tag a resource [#tag-resource]

**Action identifier:** `aws.ecs.tagResource`

Adds or updates tags on an ECS resource. Existing tags with the same key are overwritten.

### Inputs

| Input         | Type   | Description                                                |
| ------------- | ------ | ---------------------------------------------------------- |
| `region`      | String | **Required.** AWS region of the target resource.           |
| `resourceArn` | String | **Required.** ARN of the ECS resource to tag.              |
| `tags`        | List   | **Required.** List of `{key, value}` tag objects to apply. |

For auth and selector inputs, see [Prerequisites](#prerequisites).

### Outputs

| Output         | Type    | Description                                                                                                                                                                          |
| -------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `response`     | Object  | See the [tag_resource boto3 reference](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ecs/client/tag_resource.html). Returns an empty object on success. |
| `success`      | Boolean | `true` or `false`                                                                                                                                                                    |
| `errorMessage` | String  | Error message on failure.                                                                                                                                                            |

### Example

```yaml
name: tag-ecs-service
description: Tag an ECS service for cost attribution
steps:
  - name: tagResource
    type: action
    action: aws.ecs.tagResource
    version: '1'
    inputs:
      awsRoleArn: ${{ :secrets:awsRoleArn }}
      region: us-east-1
      resourceArn: arn:aws:ecs:us-east-1:123456789012:service/my-cluster/my-service
      tags:
        - key: ManagedBy
          value: workflow-automation
        - key: Environment
          value: production
```

## Untag a resource [#untag-resource]

**Action identifier:** `aws.ecs.untagResource`

Removes one or more tags from an ECS resource.

### Inputs

| Input         | Type   | Description                                      |
| ------------- | ------ | ------------------------------------------------ |
| `region`      | String | **Required.** AWS region of the target resource. |
| `resourceArn` | String | **Required.** ARN of the ECS resource to untag.  |
| `tagKeys`     | List   | **Required.** List of tag key strings to remove. |

For auth and selector inputs, see [Prerequisites](#prerequisites).

### Outputs

| Output         | Type    | Description                                                                                                                                                                              |
| -------------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `response`     | Object  | See the [untag_resource boto3 reference](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ecs/client/untag_resource.html). Returns an empty object on success. |
| `success`      | Boolean | `true` or `false`                                                                                                                                                                        |
| `errorMessage` | String  | Error message on failure.                                                                                                                                                                |

### Example

```yaml
name: untag-ecs-resource
description: Remove tags from an ECS service
steps:
  - name: untagResource
    type: action
    action: aws.ecs.untagResource
    version: '1'
    inputs:
      awsRoleArn: ${{ :secrets:awsRoleArn }}
      region: us-east-1
      resourceArn: arn:aws:ecs:us-east-1:123456789012:service/my-cluster/my-service
      tagKeys:
        - ManagedBy
```

## List tags for a resource [#list-tags-for-resource]

**Action identifier:** `aws.ecs.listTagsForResource`

Returns all tags attached to an ECS resource.

### Inputs

| Input         | Type   | Description                                             |
| ------------- | ------ | ------------------------------------------------------- |
| `region`      | String | **Required.** AWS region of the target resource.        |
| `resourceArn` | String | **Required.** ARN of the ECS resource to list tags for. |

For auth and selector inputs, see [Prerequisites](#prerequisites).

### Outputs

| Output         | Type    | Description                                                                                                                                                                             |
| -------------- | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `response`     | Object  | See the [list_tags_for_resource boto3 reference](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ecs/client/list_tags_for_resource.html). Contains `tags[]`. |
| `success`      | Boolean | `true` or `false`                                                                                                                                                                       |
| `errorMessage` | String  | Error message on failure.                                                                                                                                                               |

### Example

```yaml
name: list-resource-tags
description: List all tags on an ECS service
steps:
  - name: listTagsForResource
    type: action
    action: aws.ecs.listTagsForResource
    version: '1'
    inputs:
      awsRoleArn: ${{ :secrets:awsRoleArn }}
      region: us-east-1
      resourceArn: arn:aws:ecs:us-east-1:123456789012:service/my-cluster/my-service
      selectors:
        - name: tags
          expression: ".response.tags"
```
