> ## Documentation Index
> Fetch the complete documentation index at: /docs/llms.txt
> Use this file to discover all available pages before exploring further.

# ecs

# `prefect.infrastructure.provisioners.ecs`

## Functions

### `console_context` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L46](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L46)</sup>

```python theme={null}
console_context(value: Console) -> Generator[None, None, None]
```

## Classes

### `IamPolicyResource` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L54](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L54)</sup>

Represents an IAM policy resource for managing ECS tasks.

**Args:**

* `policy_name`: The name of the IAM policy. Defaults to "prefect-ecs-policy".

**Methods:**

#### `get_planned_actions` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L109](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L109)</sup>

```python theme={null}
get_planned_actions(self) -> List[str]
```

Returns a description of the planned actions for provisioning this resource.

**Returns:**

* Optional\[str]: A description of the planned actions for provisioning the resource,
  or None if provisioning is not required.

#### `get_task_count` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L71](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L71)</sup>

```python theme={null}
get_task_count(self) -> int
```

Returns the number of tasks that will be executed to provision this resource.

**Returns:**

* The number of tasks to be provisioned.

#### `next_steps` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L160](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L160)</sup>

```python theme={null}
next_steps(self) -> list[str]
```

#### `provision` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L124](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L124)</sup>

```python theme={null}
provision(self, policy_document: dict[str, Any], advance: Callable[[], None]) -> str
```

Provisions an IAM policy.

**Args:**

* `advance`: A callback function to indicate progress.

**Returns:**

* The ARN (Amazon Resource Name) of the created IAM policy.

#### `requires_provisioning` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L90](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L90)</sup>

```python theme={null}
requires_provisioning(self) -> bool
```

Check if this resource requires provisioning.

**Returns:**

* True if provisioning is required, False otherwise.

### `IamUserResource` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L164](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L164)</sup>

Represents an IAM user resource for managing ECS tasks.

**Args:**

* `user_name`: The desired name of the IAM user.

**Methods:**

#### `get_planned_actions` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L204](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L204)</sup>

```python theme={null}
get_planned_actions(self) -> List[str]
```

Returns a description of the planned actions for provisioning this resource.

**Returns:**

* Optional\[str]: A description of the planned actions for provisioning the resource,
  or None if provisioning is not required.

#### `get_task_count` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L177](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L177)</sup>

```python theme={null}
get_task_count(self) -> int
```

Returns the number of tasks that will be executed to provision this resource.

**Returns:**

* The number of tasks to be provisioned.

#### `next_steps` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L238](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L238)</sup>

```python theme={null}
next_steps(self) -> list[str]
```

#### `provision` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L219](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L219)</sup>

```python theme={null}
provision(self, advance: Callable[[], None]) -> None
```

Provisions an IAM user.

**Args:**

* `advance`: A callback function to indicate progress.

#### `requires_provisioning` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L186](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L186)</sup>

```python theme={null}
requires_provisioning(self) -> bool
```

Check if this resource requires provisioning.

**Returns:**

* True if provisioning is required, False otherwise.

### `CredentialsBlockResource` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L242](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L242)</sup>

**Methods:**

#### `get_planned_actions` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L272](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L272)</sup>

```python theme={null}
get_planned_actions(self) -> List[str]
```

Returns a description of the planned actions for provisioning this resource.

**Returns:**

* Optional\[str]: A description of the planned actions for provisioning the resource,
  or None if provisioning is not required.

#### `get_task_count` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L248](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L248)</sup>

```python theme={null}
get_task_count(self) -> int
```

Returns the number of tasks that will be executed to provision this resource.

**Returns:**

* The number of tasks to be provisioned.

#### `next_steps` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L364](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L364)</sup>

```python theme={null}
next_steps(self) -> list[str]
```

#### `provision` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L285](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L285)</sup>

```python theme={null}
provision(self, base_job_template: Dict[str, Any], advance: Callable[[], None], client: Optional['PrefectClient'] = None)
```

Provisions an AWS credentials block.

Will generate new credentials if the block does not already exist. Updates
the `aws_credentials` variable in the job template to reference the block.

**Args:**

* `base_job_template`: The base job template.
* `advance`: A callback function to indicate progress.
* `client`: A Prefect client to use for interacting with the Prefect API.

#### `requires_provisioning` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L258](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L258)</sup>

```python theme={null}
requires_provisioning(self, client: Optional['PrefectClient'] = None) -> bool
```

### `AuthenticationResource` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L368](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L368)</sup>

**Methods:**

#### `get_planned_actions` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L456](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L456)</sup>

```python theme={null}
get_planned_actions(self) -> List[str]
```

Returns a description of the planned actions for provisioning this resource.

**Returns:**

* Optional\[str]: A description of the planned actions for provisioning the resource,
  or None if provisioning is not required.

#### `get_task_count` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L436](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L436)</sup>

```python theme={null}
get_task_count(self) -> int
```

Returns the number of tasks that will be executed to provision this resource.

**Returns:**

* The number of tasks to be provisioned.

#### `next_steps` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L518](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L518)</sup>

```python theme={null}
next_steps(self) -> list[str]
```

#### `provision` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L470](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L470)</sup>

```python theme={null}
provision(self, base_job_template: dict[str, Any], advance: Callable[[], None]) -> None
```

Provisions the authentication resources.

**Args:**

* `base_job_template`: The base job template of the work pool to provision
  infrastructure for.
* `advance`: A callback function to indicate progress.

#### `requires_provisioning` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L445](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L445)</sup>

```python theme={null}
requires_provisioning(self) -> bool
```

Check if this resource requires provisioning.

**Returns:**

* True if provisioning is required, False otherwise.

#### `resources` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L424](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L424)</sup>

```python theme={null}
resources(self) -> list['ExecutionRoleResource | IamUserResource | IamPolicyResource | CredentialsBlockResource']
```

### `ClusterResource` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L526](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L526)</sup>

**Methods:**

#### `get_planned_actions` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L560](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L560)</sup>

```python theme={null}
get_planned_actions(self) -> List[str]
```

Returns a description of the planned actions for provisioning this resource.

**Returns:**

* Optional\[str]: A description of the planned actions for provisioning the resource,
  or None if provisioning is not required.

#### `get_task_count` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L532](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L532)</sup>

```python theme={null}
get_task_count(self) -> int
```

Returns the number of tasks that will be executed to provision this resource.

**Returns:**

* The number of tasks to be provisioned.

#### `next_steps` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L603](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L603)</sup>

```python theme={null}
next_steps(self) -> list[str]
```

#### `provision` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L575](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L575)</sup>

```python theme={null}
provision(self, base_job_template: dict[str, Any], advance: Callable[[], None]) -> None
```

Provisions an ECS cluster.

Will update the `cluster` variable in the job template to reference the cluster.

**Args:**

* `base_job_template`: The base job template of the work pool to provision
  infrastructure for.
* `advance`: A callback function to indicate progress.

#### `requires_provisioning` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L541](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L541)</sup>

```python theme={null}
requires_provisioning(self) -> bool
```

Check if this resource requires provisioning.

**Returns:**

* True if provisioning is required, False otherwise.

### `VpcResource` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L607](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L607)</sup>

**Methods:**

#### `get_planned_actions` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L703](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L703)</sup>

```python theme={null}
get_planned_actions(self) -> List[str]
```

Returns a description of the planned actions for provisioning this resource.

**Returns:**

* Optional\[str]: A description of the planned actions for provisioning the resource,
  or None if provisioning is not required.

#### `get_task_count` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L619](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L619)</sup>

```python theme={null}
get_task_count(self) -> int
```

Returns the number of tasks that will be executed to provision this resource.

**Returns:**

* The number of tasks to be provisioned.

#### `next_steps` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L841](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L841)</sup>

```python theme={null}
next_steps(self) -> list[str]
```

#### `provision` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L719](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L719)</sup>

```python theme={null}
provision(self, base_job_template: dict[str, Any], advance: Callable[[], None]) -> None
```

Provisions a VPC.

Chooses a CIDR block to avoid conflicting with any existing VPCs. Will update
the `vpc_id` variable in the job template to reference the VPC.

**Args:**

* `base_job_template`: The base job template of the work pool to provision
  infrastructure for.
* `advance`: A callback function to indicate progress.

#### `requires_provisioning` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L682](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L682)</sup>

```python theme={null}
requires_provisioning(self) -> bool
```

Check if this resource requires provisioning.

**Returns:**

* True if provisioning is required, False otherwise.

### `ContainerRepositoryResource` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L845](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L845)</sup>

**Methods:**

#### `get_planned_actions` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L891](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L891)</sup>

```python theme={null}
get_planned_actions(self) -> List[str]
```

Returns a description of the planned actions for provisioning this resource.

**Returns:**

* Optional\[str]: A description of the planned actions for provisioning the resource,
  or None if provisioning is not required.

#### `get_task_count` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L853](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L853)</sup>

```python theme={null}
get_task_count(self) -> int
```

Returns the number of tasks that will be executed to provision this resource.

**Returns:**

* The number of tasks to be provisioned.

#### `next_steps` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L988](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L988)</sup>

```python theme={null}
next_steps(self) -> list[str | Syntax]
```

#### `provision` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L906](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L906)</sup>

```python theme={null}
provision(self, base_job_template: dict[str, Any], advance: Callable[[], None]) -> None
```

Provisions an ECR repository.

**Args:**

* `base_job_template`: The base job template of the work pool to provision
  infrastructure for.
* `advance`: A callback function to indicate progress.

#### `requires_provisioning` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L874](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L874)</sup>

```python theme={null}
requires_provisioning(self) -> bool
```

Check if this resource requires provisioning.

**Returns:**

* True if provisioning is required, False otherwise.

### `ExecutionRoleResource` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L992](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L992)</sup>

**Methods:**

#### `get_planned_actions` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L1039](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L1039)</sup>

```python theme={null}
get_planned_actions(self) -> List[str]
```

Returns a description of the planned actions for provisioning this resource.

**Returns:**

* Optional\[str]: A description of the planned actions for provisioning the resource,
  or None if provisioning is not required.

#### `get_task_count` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L1010](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L1010)</sup>

```python theme={null}
get_task_count(self) -> int
```

Returns the number of tasks that will be executed to provision this resource.

**Returns:**

* The number of tasks to be provisioned.

#### `next_steps` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L1097](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L1097)</sup>

```python theme={null}
next_steps(self) -> list[str]
```

#### `provision` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L1054](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L1054)</sup>

```python theme={null}
provision(self, base_job_template: dict[str, Any], advance: Callable[[], None]) -> str
```

Provisions an IAM role.

**Args:**

* `base_job_template`: The base job template of the work pool to provision
  infrastructure for.
* `advance`: A callback function to indicate progress.

#### `requires_provisioning` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L1019](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L1019)</sup>

```python theme={null}
requires_provisioning(self) -> bool
```

Check if this resource requires provisioning.

**Returns:**

* True if provisioning is required, False otherwise.

### `ElasticContainerServicePushProvisioner` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L1101](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L1101)</sup>

An infrastructure provisioner for ECS push work pools.

**Methods:**

#### `console` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L1110](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L1110)</sup>

```python theme={null}
console(self) -> Console
```

#### `console` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L1114](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L1114)</sup>

```python theme={null}
console(self, value: Console) -> None
```

#### `is_boto3_installed` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L1123](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L1123)</sup>

```python theme={null}
is_boto3_installed() -> bool
```

Check if boto3 is installed.

#### `provision` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L1162](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/ecs.py#L1162)</sup>

```python theme={null}
provision(self, work_pool_name: str, base_job_template: dict[str, Any]) -> dict[str, Any]
```

Provisions the infrastructure for an ECS push work pool.

**Args:**

* `work_pool_name`: The name of the work pool to provision infrastructure for.
* `base_job_template`: The base job template of the work pool to provision
  infrastructure for.

**Returns:**

* An updated copy base job template.
