<a id="flink-sql-manage-compute-pool"></a>

# Manage Compute Pools in Confluent Cloud for Apache Flink

A [compute pool](../concepts/compute-pools.md#flink-sql-compute-pools) represents the compute
resources that run your [SQL statements](../concepts/statements.md#flink-sql-statements).
All statements that use a compute pool share its resources, so you can limit
or guarantee resources as your use cases require. A compute pool belongs to
a region. There is no cost for creating compute pools.

When you create a workspace or run a Flink SQL statement, Confluent Cloud for Apache Flink automatically
uses a default compute pool in your environment and region. You don’t need to
create a compute pool manually to get started.

You can create a compute pool manually for these reasons:

- **Workload isolation**: Separate production workloads from development or ad hoc
  queries to prevent resource contention.
- **Cost control**: Set specific CFU limits for different teams or projects.
- **Security isolation**: For fine-grained access control of statements,
  separate different workloads, for example, by team, and grant the
  FlinkDeveloper role at the pool level.

To create a compute pool manually, you need the OrganizationAdmin,
EnvironmentAdmin, or FlinkAdmin RBAC role. For more information, see
[Grant Role-Based Access in Confluent Cloud for Apache Flink](flink-rbac.md#flink-rbac).

In addition to the Cloud Console, Confluent provides these tools
for creating and managing explicit Flink compute pools:

- [Confluent CLI](../reference/flink-sql-cli.md#flink-cli-manage-compute-pools)
- [Confluent Cloud REST API](flink-rest-api.md#flink-rest-api-manage-compute-pools)
- [Confluent Terraform provider](../../clusters/terraform-provider.md#confluent-terraform-provider-resources-flink)

<a id="flink-sql-manage-compute-pool-create"></a>

## Create a compute pool manually

### Confluent Cloud Console

1. In the navigation menu, click **Environments**, and click the tile for the
   environment where you want to use Flink SQL.
2. In the environment details page, click **Flink**.
3. In the **Flink** page, click **Compute pools**, if it’s not
   selected already.
4. Click **Create compute pool** to open the **Create compute pool** page.
5. In the **Region** dropdown, select the region that hosts the data you want to
   process with SQL, or use any region if you want to try out Flink
   using sample data. Click **Continue**.
6. In the **Pool name** textbox, enter “my-compute-pool”.
7. In the **Max CFUs** dropdown, select **10**. For more information, see
   [CFUs](../concepts/flink-billing.md#flink-sql-cfus).

   #### NOTE
   You can increase the Max CFUs value later, but you can’t decrease
   Max CFUs.
8. Click **Continue**, and on the **Review and create** page, click **Finish**.

   A tile for your compute pool appears on the **Flink** page. It
   shows the pool in the **Provisioning** state. It can take a few minutes for
   the pool to enter the **Running** state.

### Confluent CLI

Run the
[confluent flink compute-pool create](https://docs.confluent.io/confluent-cli/current/command-reference/flink/compute-pool/confluent_flink_compute-pool_create.html)
command to create a compute pool.

Creating a compute pool requires the following inputs:

```bash
export COMPUTE_POOL_NAME=<compute-pool-name> # human-readable name, for example, "my-compute-pool"
export CLOUD_PROVIDER="<cloud-provider>" # example: "aws"
export CLOUD_REGION="<cloud-region>" # example: "us-east-1"
export ENV_ID="<environment-id>" # example: "env-z3y2x1"
export MAX_CFU="<max-cfu>" # example: 5
```

Run the following command to create a compute pool in the specified cloud
provider and environment.

```bash
confluent flink compute-pool create ${COMPUTE_POOL_NAME} \
  --cloud ${CLOUD_PROVIDER} \
  --region ${CLOUD_REGION} \
  --max-cfu ${MAX_CFU} \
  --environment ${ENV_ID}
```

Your output should resemble:

```none
+-------------+-----------------+
| Current     | false           |
| ID          | lfcp-xxd6og     |
| Name        | my-compute-pool |
| Environment | env-z3y2x1      |
| Current CFU | 0               |
| Max CFU     | 5               |
| Cloud       | AWS             |
| Region      | us-east-1       |
| Status      | PROVISIONING    |
+-------------+-----------------+
```

#### NOTE
To create a default compute pool manually, add the `--default-pool` flag to
the command. This pre-provisions a default pool with your specified configuration
before users start running statements. The `FlinkAdmin` role or higher is
required to create default pools.

```bash
confluent flink compute-pool create ${COMPUTE_POOL_NAME} \
  --cloud ${CLOUD_PROVIDER} \
  --region ${CLOUD_REGION} \
  --max-cfu ${MAX_CFU} \
  --environment ${ENV_ID} \
  --default-pool
```

### REST API

Create a compute pool in your environment by sending a POST request to the
[Compute Pools endpoint](/cloud/current/api.html#tag/Compute-Pools-(fcpmv2)/operation/createFcpmV2ComputePool).

- This request uses your Cloud API key instead of the Flink API key.

Creating a compute pool requires the following inputs:

```bash
export COMPUTE_POOL_NAME="<compute-pool-name>" # human readable name, for example: "my-compute-pool"
export CLOUD_API_KEY="<cloud-api-key>"
export CLOUD_API_SECRET="<cloud-api-secret>"
export BASE64_CLOUD_KEY_AND_SECRET=$(echo -n "${CLOUD_API_KEY}:${CLOUD_API_SECRET}" | base64 -w 0)
export ENV_ID="<environment-id>" # example: "env-z3y2x1"
export CLOUD_PROVIDER="<cloud-provider>" # example: "aws"
export CLOUD_REGION="<cloud-region>" # example: "us-east-1"
export MAX_CFU="<max-cfu>" # example: 5
export JSON_DATA="<payload-string>"
```

The following JSON shows an example payload. The `network` and `default_pool` keys are optional.

```json
{
  "spec": {
    "display_name": "${COMPUTE_POOL_NAME}",
    "cloud": "${CLOUD_PROVIDER}",
    "region": "${CLOUD_REGION}",
    "max_cfu": ${MAX_CFU},
    "environment": {
      "id": "${ENV_ID}"
    },
    "network": {
      "id": "n-00000",
      "environment": "string"
    },
    "default_pool": false
  }
}
```

#### NOTE
Set `default_pool` to `true` to create a default compute pool manually.
This pre-provisions a default pool with your specified configuration before
users start running statements. Creating default pools requires the
`FlinkAdmin` role or higher.

Escape the quotation mark characters in the JSON string. The payload
string to send resembles the following:

```bash
export JSON_DATA="{
  \"spec\": {
    \"display_name\": \"${COMPUTE_POOL_NAME}\",
    \"cloud\": \"${CLOUD_PROVIDER}\",
    \"region\": \"${CLOUD_REGION}\",
    \"max_cfu\": ${MAX_CFU},
    \"environment\": {
      \"id\": \"${ENV_ID}\"
    }
  }
}"
```

The following command sends a POST request to create a compute pool.

```bash
curl --request POST \
  --url https://api.confluent.cloud/fcpm/v2/compute-pools \
  --header "Authorization: Basic ${BASE64_CLOUD_KEY_AND_SECRET}" \
  --header 'content-type: application/json' \
  --data "${JSON_DATA}"
```

Your output should resemble:

<details id="target-details">
<summary id="target-summary" style="display: list-item; cursor:pointer; color:#337ab7;">
  Response from a request to create a compute pool
</summary>
```json
{
    "api_version": "fcpm/v2",
    "id": "lfcp-6g7h8i",
    "kind": "ComputePool",
    "metadata": {
        "created_at": "2024-02-27T22:44:27.18964Z",
        "resource_name": "crn://confluent.cloud/organization=b0b21724-4586-4a07-b787-d0bb5aacbf87/environment=env-z3y2x1/flink-region=aws.us-east-1/compute-pool=lfcp-6g7h8i",
        "self": "https://api.confluent.cloud/fcpm/v2/compute-pools/lfcp-6g7h8i",
        "updated_at": "2024-02-27T22:44:27.18964Z"
    },
    "spec": {
        "cloud": "AWS",
        "display_name": "my-compute-pool",
        "environment": {
            "id": "env-z3y2x1",
            "related": "https://api.confluent.cloud/fcpm/v2/compute-pools/lfcp-6g7h8i",
            "resource_name": "crn://confluent.cloud/organization=b0b21724-4586-4a07-b787-d0bb5aacbf87/environment=env-z3y2x1"
        },
        "http_endpoint": "https://flink.us-east-1.aws.confluent.cloud/sql/v1/organizations/b0b21724-4586-4a07-b787-d0bb5aacbf87/environments/env-z3y2x1",
        "max_cfu": 5,
        "region": "us-east-1"
    },
    "status": {
        "current_cfu": 0,
        "phase": "PROVISIONING"
    }
}
```

</details>
<br/>

### Terraform

To create a compute pool by using the Confluent Terraform provider, use the
[confluent_flink_compute_pool](https://registry.terraform.io/providers/confluentinc/confluent/latest/docs/resources/confluent_flink_compute_pool)
resource.

1. Configure your Terraform file. Provide your Confluent Cloud API key and secret.
   ```terraform
   terraform {
     required_providers {
       confluent = {
         source = "confluentinc/confluent"
         version = "2.76.0"
       }
     }
   }

   provider "confluent" {
     cloud_api_key    = var.confluent_cloud_api_key    # optionally use CONFLUENT_CLOUD_API_KEY env var
     cloud_api_secret = var.confluent_cloud_api_secret # optionally use CONFLUENT_CLOUD_API_SECRET env var
   }
   ```
2. Define the environment where the compute pool is created.
   ```terraform
   resource "confluent_environment" "development" {
     display_name = "Development"
     lifecycle {
       prevent_destroy = true
     }
   }
   ```
3. Define the `confluent_flink_compute_pool` resource with the required
   parameters, like `display_name`, `cloud`, `region`, `max_cfu`, and
   the environment ID.
   ```terraform
   resource "confluent_flink_compute_pool" "main" {
     display_name = "standard_compute_pool"
     cloud        = "AWS"
     region       = "us-east-1"
     max_cfu      = 5

     environment {
       id = confluent_environment.development.id
     }
   }
   ```

   #### NOTE
   To create a default compute pool manually, add `default_pool = true` to
   the resource definition. This pre-provisions a default pool with your specified
   configuration before users start running statements. The `FlinkAdmin` role
   or higher is required to create default pools.
   ```terraform
   resource "confluent_flink_compute_pool" "main" {
     display_name = "default_compute_pool"
     cloud        = "AWS"
     region       = "us-east-1"
     max_cfu      = 50
     default_pool = true

     environment {
       id = confluent_environment.development.id
     }
   }
   ```
4. Run the `terraform apply` command to create the resources.
   ```bash
   terraform apply
   ```
5. If you need to import an existing compute pool, use the `terraform import`
   command.
   ```bash
   export CONFLUENT_CLOUD_API_KEY="<cloud_api_key>"
   export CONFLUENT_CLOUD_API_SECRET="<cloud_api_secret>"
   terraform import confluent_flink_compute_pool.main <your-environment-id>/<compute-pool-id>
   ```

For more information, see
[confluent_flink_compute_pool resource](https://registry.terraform.io/providers/confluentinc/confluent/latest/docs/resources/confluent_flink_compute_pool).

<a id="flink-sql-manage-compute-pool-view"></a>

## View details for a compute pool

### Confluent Cloud Console

1. In the navigation menu, click **Environments**, and click the tile for the
   environment where you use Flink SQL.
2. In the environment details page, click **Flink**.
3. In the **Flink** page, click **Compute pools**, if it’s not
   selected already.

   The available compute pools are listed as tiles, with details like
   **Max CFUs** and the cloud provider and region.
4. If the tile for your compute pool isn’t visible, start typing in the
   **Search pools** textbox to filter the view.
5. Click the tile for your compute pool to open the details page, which shows
   information like consumption metrics and Flink SQL statements that are
   associated with the compute pool.

### Confluent CLI

Run the
[confluent flink compute-pool describe](https://docs.confluent.io/confluent-cli/current/command-reference/flink/compute-pool/confluent_flink_compute-pool_describe.html)
command to get details about a compute pool.

Describing a compute pool requires the following inputs:

```bash
export COMPUTE_POOL_ID="<compute-pool-id>" # example: "lfcp-8m03rm"
export ENV_ID="<environment-id>" # example: "env-z3y2x1"
```

Run the following command to get details about a compute pool in the specified
environment.

```bash
confluent flink compute-pool describe ${COMPUTE_POOL_ID} \
  --environment ${ENV_ID}
```

Your output should resemble:

```none
+-------------+-----------------+
| Current     | false           |
| ID          | lfcp-xxd6og     |
| Name        | my-compute-pool |
| Environment | env-z3y2x1      |
| Current CFU | 0               |
| Max CFU     | 5               |
| Cloud       | AWS             |
| Region      | us-east-1       |
| Status      | PROVISIONED     |
+-------------+-----------------+
```

### REST API

Get the details about a compute pool in your environment by sending a GET request to the
[Compute Pools endpoint](/cloud/current/api.html#tag/Compute-Pools-(fcpmv2)/operation/getFcpmV2ComputePool).

- This request uses your Cloud API key instead of the Flink API key.

Getting details about a compute pool requires the following inputs:

```bash
export COMPUTE_POOL_ID="<compute-pool-id>" # example: "lfcp-8m03rm"
export CLOUD_API_KEY="<cloud-api-key>"
export CLOUD_API_SECRET="<cloud-api-secret>"
export BASE64_CLOUD_KEY_AND_SECRET=$(echo -n "${CLOUD_API_KEY}:${CLOUD_API_SECRET}" | base64 -w 0)
export ENV_ID="<environment-id>" # example: "env-z3y2x1"
```

Run the following command to get details about the compute pool specified in
the COMPUTE_POOL_ID environment variable.

```bash
curl --request GET \
  --url "https://api.confluent.cloud/fcpm/v2/compute-pools/${COMPUTE_POOL_ID}?environment=${ENV_ID}" \
  --header "Authorization: Basic ${BASE64_CLOUD_KEY_AND_SECRET}"
```

Your output should resemble:

<details id="target-details">
<summary id="target-summary" style="display: list-item; cursor:pointer; color:#337ab7;">
  Response from a request to read a compute pool
</summary>
```json
{
    "api_version": "fcpm/v2",
    "id": "lfcp-6g7h8i",
    "kind": "ComputePool",
    "metadata": {
        "created_at": "2024-02-27T22:44:27.18964Z",
        "resource_name": "crn://confluent.cloud/organization=b0b21724-4586-4a07-b787-d0bb5aacbf87/environment=env-z3y2x1/flink-region=aws.us-east-1/compute-pool=lfcp-6g7h8i",
        "self": "https://api.confluent.cloud/fcpm/v2/compute-pools/lfcp-6g7h8i",
        "updated_at": "2024-02-27T22:44:27.18964Z"
    },
    "spec": {
        "cloud": "AWS",
        "display_name": "my-compute-pool",
        "environment": {
            "id": "env-z3y2x1",
            "related": "https://api.confluent.cloud/fcpm/v2/compute-pools/lfcp-6g7h8i",
            "resource_name": "crn://confluent.cloud/organization=b0b21724-4586-4a07-b787-d0bb5aacbf87/environment=env-z3y2x1"
        },
        "http_endpoint": "https://flink.us-east-1.aws.confluent.cloud/sql/v1/organizations/b0b21724-4586-4a07-b787-d0bb5aacbf87/environments/env-z3y2x1",
        "max_cfu": 5,
        "region": "us-east-1"
    },
    "status": {
        "current_cfu": 0,
        "phase": "PROVISIONED"
    }
}
```

</details>
<br/>

### Terraform

To view details for a compute pool by using the Confluent Terraform provider,
use the
[confluent_flink_compute_pool](https://registry.terraform.io/providers/confluentinc/confluent/latest/docs/data-sources/confluent_flink_compute_pool)
data source and the `data` argument.

```terraform
data "confluent_flink_compute_pool" "example_using_id" {
  id = "lfcp-abc123"
  environment {
    id = "<your-environment-id>"
  }
}

output "example_using_id" {
  value = data.confluent_flink_compute_pool.example_using_id
}

data "confluent_flink_compute_pool" "example_using_name" {
  display_name = "my_compute_pool"
  environment {
    id = "<your-environment-id>"
  }
}

output "example_using_name" {
  value = data.confluent_flink_compute_pool.example_using_name
}
```

Run the `terraform apply` or `terraform output` command. The
`example_using_id` and `example_using_name` output contains details for the
compute pool with the specified ID or name.

For more information, see
[confluent_flink_compute_pool data source](https://registry.terraform.io/providers/confluentinc/confluent/latest/docs/data-sources/confluent_flink_compute_pool).

<a id="flink-sql-manage-compute-pool-list"></a>

## List compute pools

### Confluent Cloud Console

1. In the navigation menu, click **Environments**, and click the tile for the
   environment where you use Flink SQL.
2. In the environment details page, click **Flink**.
3. In the **Flink** page, click **Compute pools**, if it’s not
   selected already.

   The available compute pools are listed as tiles, with details like
   **Max CFUs** and the cloud provider and region.

### Confluent CLI

Run the
[confluent flink compute-pool list](https://docs.confluent.io/confluent-cli/current/command-reference/flink/compute-pool/confluent_flink_compute-pool_list.html)
command to compute pools in the specified environment.

Listing compute pools can require the following inputs, depending on the
command:

```bash
export CLOUD_REGION="<cloud-region>" # example: "us-east-1"
export ENV_ID="<environment-id>" # example: "env-z3y2x1"
```

Run the following command to get details about a compute pool in the specified
environment.

```bash
confluent flink compute-pool list --environment ${ENV_ID}
```

Your output should resemble:

```none
  Current |     ID      |           Name            | Environment | Current CFU | Max CFU | Cloud |  Region   |   Status
----------+-------------+---------------------------+-------------+-------------+---------+-------+-----------+--------------
  *       | lfcp-xxd6og | my-compute-pool           | env-z3y2x1  |           0 |       5 | AWS   | us-east-1 | PROVISIONED
          | lfcp-8m03rm | test-blue-compute-pool    | env-z3q9rd  |           0 |      10 | AWS   | us-east-1 | PROVISIONED
...
```

### REST API

List the compute pools in your environment by sending a GET request to the
[Compute Pools endpoint](/cloud/current/api.html#tag/Compute-Pools-(fcpmv2)/operation/listFcpmV2ComputePools).

- This request uses your Cloud API key instead of the Flink API key.

Listing the compute pools in your environment requires the following inputs:

```bash
export CLOUD_API_KEY="<cloud-api-key>"
export CLOUD_API_SECRET="<cloud-api-secret>"
export BASE64_CLOUD_KEY_AND_SECRET=$(echo -n "${CLOUD_API_KEY}:${CLOUD_API_SECRET}" | base64 -w 0)
export ENV_ID="<environment-id>" # example: "env-z3y2x1"
```

Run the following command to list the compute pools in your environment.

```bash
curl --request GET \
     --url "https://confluent.cloud/api/fcpm/v2/compute-pools?environment=${ENV_ID}&page_size=100" \
     --header "Authorization: Basic ${BASE64_CLOUD_KEY_AND_SECRET}" \
     | jq -r '.data[] | .spec.display_name, {id}'
```

Your output should resemble:

```none
compute_pool_0
{
  "id": "lfcp-j123kl"
}
compute_pool_2
{
  "id": "lfcp-abc1de"
}
my-lfcp-01
{
  "id": "lfcp-l2mn3o"
}
...
```

Find your compute pool in the list and save its ID in an environment variable.

```bash
export COMPUTE_POOL_ID="<your-compute-pool-id>"
```

### Terraform

To list all compute pools using the Confluent Terraform provider, use the
[confluent_flink_compute_pool](https://registry.terraform.io/providers/confluentinc/confluent/latest/docs/data-sources/confluent_flink_compute_pool)
data source and the `data` argument.

```terraform
provider "confluent" {
  cloud_api_key    = var.confluent_cloud_api_key
  cloud_api_secret = var.confluent_cloud_api_secret
}

data "confluent_flink_compute_pools" "all_pools" {
  environment_id = "<your-environment-id>"
}

output "compute_pools" {
  value = data.confluent_flink_compute_pools.all_pools.compute_pools
}
```

Run the `terraform apply` or `terraform output` command. The
`compute_pools` output contains a list of all compute pools in your
environment.

To filter the compute pools by a specific attribute, region, availability,
or name, use the `filter` argument within the `data` block.

```terraform
data "confluent_flink_compute_pools" "pools_in_us_east" {
  environment_id = "<your-environment-id>"
  filter = "region == '<region-id>'"
}
```

For more information, see
[confluent_flink_compute_pool](https://registry.terraform.io/providers/confluentinc/confluent/latest/docs/data-sources/confluent_flink_compute_pool).

<a id="flink-sql-manage-compute-pool-update"></a>

## Update a compute pool

You can update the name of the compute pool, its environment, and the
MAX_CFUs setting. You can increase the MAX_CFUs value, but you can’t
decrease MAX_CFUs.

#### NOTE
Compute pools with up to 1,000 CFU capacity are available as a Limited
Availability feature for customers with large Flink job fleets. To participate
in the Limited Availability Program, sign up at
[Scale Apache Flink® compute pools to 1,000 CFUs](https://events.confluent.io/signup-for-1000cfus-flink).

The maximum size of a single job remains 50 CFUs. The total CFU usage of all
concurrently running jobs in a pool cannot exceed the pool’s CFU capacity.
For example, a 1,000 CFU pool can run up to twenty 50-CFU jobs concurrently,
or a larger number of smaller jobs, as long as the total CFUs in use do not
exceed 1,000.

With higher CFU limits available during Limited Availability, you can
consolidate multiple smaller compute pools into a single larger pool to
simplify architecture and management. For more information about moving
statements between pools, see [Update metadata for a statement](flink-rest-api.md#flink-rest-api-update-statement).

### Confluent Cloud Console

1. In the navigation menu, click **Environments**, and click the tile for the
   environment where you use Flink SQL.
2. In the environment details page, click **Flink**.
3. In the **Flink** page, click **Compute pools**, if it’s not
   selected already.
4. In the listed compute pools, find the one you want to update, and click the
   options icon (**⋮**).
5. In the context menu, click either **Edit display name** or **Edit max CFUs**
   and follow the instructions in the dialog.
6. Click the tile for your compute pool to open the details page.

   In the details page, you can update the compute pool’s description or add
   metadata tags. Also, you can manage Flink SQL statements that are
   associated with the compute pool.

### Confluent CLI

Run the
[confluent flink compute-pool update](https://docs.confluent.io/confluent-cli/current/command-reference/flink/compute-pool/confluent_flink_compute-pool_update.html)
command to update a compute pool.

Updating a compute pool can require the following inputs, depending on the
command:

```bash
export COMPUTE_POOL_NAME=<compute-pool-name> # human-readable name, for example, "my-compute-pool"
export COMPUTE_POOL_ID="<compute-pool-id>" # example: "lfcp-8m03rm"
export ENV_ID="<environment-id>" # example: "env-z3y2x1"
export MAX_CFU="<max-cfu>" # example: 5
```

Run the following command to update a compute pool in the specified
environment.

```bash
confluent flink compute-pool update ${COMPUTE_POOL_ID} \
  --environment ${ENV_ID} \
  --name ${COMPUTE_POOL_NAME} \
  --max-cfu ${MAX_CFU}
```

Your output should resemble:

```none
+-------------+----------------------+
| Current     | false                |
| ID          | lfcp-xxd6og          |
| Name        | renamed-compute-pool |
| Environment | env-z3y2x1           |
| Current CFU | 0                    |
| Max CFU     | 10                   |
| Cloud       | AWS                  |
| Region      | us-east-1            |
| Status      | PROVISIONED          |
+-------------+----------------------+
```

### REST API

Update a compute pool in your environment by sending a PATCH request to the
[Compute Pools endpoint](/cloud/current/api.html#tag/Compute-Pools-(fcpmv2)/operation/updateFcpmV2ComputePool).

- This request uses your Cloud API key instead of the Flink API key.

Updating a compute pool requires the following inputs:

```bash
export COMPUTE_POOL_ID="<compute-pool-id>" # example: "lfcp-8m03rm"
export CLOUD_API_KEY="<cloud-api-key>"
export CLOUD_API_SECRET="<cloud-api-secret>"
export BASE64_CLOUD_KEY_AND_SECRET=$(echo -n "${CLOUD_API_KEY}:${CLOUD_API_SECRET}" | base64 -w 0)
export ENV_ID="<environment-id>" # example: "env-z3y2x1"
export MAX_CFU="<max-cfu>" # example: 5
export JSON_DATA="<payload-string>"
```

The following JSON shows an example payload. The `network` key is optional.

```json
{
  "spec": {
    "display_name": "${COMPUTE_POOL_NAME}",
    "max_cfu": ${MAX_CFU},
    "environment": {
      "id": "${ENV_ID}"
    }
  }
}
```

Escape the quotation mark characters in the JSON string. The payload
string to send resembles the following:

```bash
export JSON_DATA="{
  \"spec\": {
    \"display_name\": \"${COMPUTE_POOL_NAME}\",
    \"max_cfu\": ${MAX_CFU},
    \"environment\": {
      \"id\": \"${ENV_ID}\"
    }
  }
}"
```

Run the following command to update the compute pool specified in the
COMPUTE_POOL_ID environment variable.

```bash
curl --request PATCH \
  --url "https://api.confluent.cloud/fcpm/v2/compute-pools/${COMPUTE_POOL_ID}" \
  --header "Authorization: Basic ${BASE64_CLOUD_KEY_AND_SECRET}" \
  --header 'content-type: application/json' \
  --data "${JSON_DATA}"
```

### Terraform

To update a compute pool by using the Confluent Terraform provider, use the
[confluent_flink_compute_pool](https://registry.terraform.io/providers/confluentinc/confluent/latest/docs/resources/confluent_flink_compute_pool)
resource.

1. Find the definition for the compute pool resource in your Terraform
   configuration, for example:
   ```terraform
   resource "confluent_flink_compute_pool" "example" {
     cloud  = "AWS"
     region = "us-west-2"
     max_cfu = 10
     # other required parameters
   }
   ```
2. Modify the attributes of the `confluent_flink_compute_pool` resource in
   the Terraform configuration file. The following example updates the
   `max_cfu` attribute.
   ```terraform
   resource "confluent_flink_compute_pool" "example" {
     cloud  = "AWS"
     region = "us-west-2"
     max_cfu = 20 # Updated value
     # other required parameters
   }
   ```
3. Run the `terraform apply` command to update the compute pool with the new
   configuration.
   ```bash
   terraform apply
   ```

For more information, see
[confluent_flink_compute_pool](https://registry.terraform.io/providers/confluentinc/confluent/latest/docs/resources/confluent_flink_compute_pool).

<a id="flink-sql-manage-compute-pool-delete"></a>

## Delete a compute pool

### Confluent Cloud Console

1. In the navigation menu, click **Environments**, and click the tile for the
   environment where you want to use Flink SQL.
2. In the environment details page, click **Flink**.
3. In the **Flink** page, click **Compute pools**, if it’s not
   selected already.
4. In the listed compute pools, find the one you want to delete, and click the
   options icon (**⋮**).
5. In the context menu, click **Delete compute pool**, and in the dialog, enter
   the compute pool name to confirm deletion.

### Confluent CLI

Run the
[confluent flink compute-pool delete](https://docs.confluent.io/confluent-cli/current/command-reference/flink/compute-pool/confluent_flink_compute-pool_delete.html)
command to delete a compute pool.

Run the following command to delete a compute pool in the specified
environment. The optional `--force` flag skips the confirmation prompt.

```bash
confluent flink compute-pool delete ${COMPUTE_POOL_ID} \
  --environment ${ENV_ID}
  --force
```

Your output should resemble:

```none
Deleted Flink compute pool "lfcp-xxd6og".
```

### REST API

Delete a compute pool in your environment by sending a DELETE request to the
[Compute Pools endpoint](/cloud/current/api.html#tag/Compute-Pools-(fcpmv2)/operation/deleteFcpmV2ComputePool).

- This request uses your Cloud API key instead of the Flink API key.

Deleting a compute pool requires the following inputs:

```bash
export COMPUTE_POOL_ID="<compute-pool-id>" # example: "lfcp-8m03rm"
export CLOUD_API_KEY="<cloud-api-key>"
export CLOUD_API_SECRET="<cloud-api-secret>"
export BASE64_CLOUD_KEY_AND_SECRET=$(echo -n "${CLOUD_API_KEY}:${CLOUD_API_SECRET}" | base64 -w 0)
export ENV_ID="<environment-id>" # example: "env-z3y2x1"
```

Run the following command to delete the compute pool specified in the
COMPUTE_POOL_ID environment variable.

```bash
curl --request DELETE \
  --url "https://api.confluent.cloud/fcpm/v2/compute-pools/${COMPUTE_POOL_ID}?environment=${ENV_ID}" \
  --header "Authorization: Basic ${BASE64_CLOUD_KEY_AND_SECRET}"
```

### Terraform

To delete a compute pool by using the Confluent Terraform provider, use the
[confluent_flink_compute_pool](https://registry.terraform.io/providers/confluentinc/confluent/latest/docs/resources/confluent_flink_compute_pool)
resource.

1. Define the compute pool resource in your Terraform configuration file, for
   example:
   ```terraform
   resource "confluent_flink_compute_pool" "main" {
     display_name = "standard_compute_pool"
     cloud        = "AWS"
     region       = "us-east-1"
     max_cfu      = 5
     environment {
       id = "<your-environment-id>"
     }
   }
   ```
2. To avoid accidental deletions, review the plan before applying the
   `destroy` command.
   ```bash
   terraform plan -destroy -target=confluent_flink_compute_pool.main
   ```
3. To delete the compute pool, run the following command to target the specific
   resource. This command deletes only the compute pool and not other resources.
   ```bash
   terraform apply -destroy -target=confluent_flink_compute_pool.main
   ```

   To remove all resources defined in your Terraform configuration file,
   including the compute pool, run the `terraform destroy` command.
   ```bash
   terraform destroy
   ```

For more information, see
[confluent_flink_compute_pool](https://registry.terraform.io/providers/confluentinc/confluent/latest/docs/resources/confluent_flink_compute_pool).

## Related content

- [Flink Compute Pools](../concepts/compute-pools.md#flink-sql-compute-pools)
- [Billing on Confluent Cloud for Apache Flink](../concepts/flink-billing.md#flink-sql-billing)

#### NOTE
This website includes content developed at the [Apache Software Foundation](https://www.apache.org/)
under the terms of the [Apache License v2](https://www.apache.org/licenses/LICENSE-2.0.html).
