<a id="create-provider-integration-aws"></a>

# Create an AWS Provider Integration in Confluent Cloud

This topic how to create a provider integration within Confluent Cloud that uses AWS IAM Assume role
to securely access your AWS resources.

<div style="position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden; max-width: 100%; height: auto;">
   <iframe src="https://www.youtube.com/embed/k0ObOFugGKI" title="Using AWS IAM AssumeRole in Confluent Cloud" frameborder="0" allowfullscreen style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;"></iframe>
</div>

## Prerequisites

Before you begin, ensure you have:

- Access to the [AWS IAM Dashboard](https://console.aws.amazon.com/iam/home).
- [Access to the Confluent Cloud Console <https://confluent.cloud](https://confluent.cloud).
- A Confluent Cloud user account that is granted the [OrganizationAdmin](../../security/access-control/rbac/predefined-rbac-roles.md#organizationadmin-role)
  or [EnvironmentAdmin](../../security/access-control/rbac/predefined-rbac-roles.md#environmentadmin-role) role. These roles allow you to create
  and manage provider integrations. If you have the [ResourceOwner](../../security/access-control/rbac/predefined-rbac-roles.md#resourceowner-role)
  or [Assigner](../../security/access-control/rbac/predefined-rbac-roles.md#assigner-role) role, you can create a connector using the provider
  integration resource.
- The environment ID for the Confluent Cloud environment you want to create the
  provider integration in.
- To use the Confluent Cloud APIs, you need to have a Confluent Cloud API key. For details, see
  [Manage API keys in Confluent Cloud](../../security/authenticate/workload-identities/service-accounts/api-keys/manage-api-keys.md#manage-api-keys).
- To use the API request examples on this page, you must have cURL and jq
  installed.

## Limitations

Be sure to review the following information:

- AWS Provider Integration is only supported for AWS clusters in Confluent Cloud.
- By default, the resource quota for number of integrations per **Organization** is set to 100.
  Contact Confluent [Support](https://support.confluent.io/) if you want to increase the quota limit.

<a id="create-provider-integration-aws-steps"></a>

## Create an AWS Provider Integration

Configuring an AWS Provider Integration involves three primary steps:

- Select a role type (new or existing) and create an IAM permission policy in AWS.
- Create a new AWS role and map it within Confluent Cloud.
- Update the AWS trust policy with the Confluent IAM role configurations to complete the setup.

Follow the steps below to create an AWS Provider Integration in a Confluent Cloud
environment using the Confluent Cloud Console, Confluent CLI, or Confluent Cloud APIs.

<a id="create-provider-integration-aws-ui"></a>

### Using the Confluent Cloud Console

Sign in to your Confluent Cloud account and go through the following instructions to configure your first provider integration
in Confluent Cloud.

<a id="create-provider-integration-aws-uistep"></a>

#### Step 1: Select AWS Provider Integration in Confluent

1. Go to the environment you want to create the provider integration in.
2. In the left navigation menu, click **Integrations** > **Provider Integrations**.
3. Click **Add integration**.
4. Select **AWS IAM role**. The **Configure role in AWS** screen appears.

<a id="create-provider-integration-aws-uistep1"></a>

#### Step 2: Configure a role in AWS

You can create a new role or select an existing role to create an AWS Provider Integration in your AWS account. If
you choose to create a new role, perform the following:

1. Under **Select role**, choose **New role** to create a new role in your AWS account.
2. Click **Continue**.

<a id="create-provider-integration-aws-uistep2"></a>

#### Step 3: Create permission policy in AWS

In this step, you will create an IAM permission policy in your AWS account.

1. Open the AWS console at [https://console.aws.amazon.com/iam/](https://console.aws.amazon.com/iam/)
   and create a new permission policy. For more information, see [Create AWS IAM Policies](#create-provider-integration-aws-apistep1).
2. In Confluent Cloud console, select an AWS resource to view the permission policy. Copy the prescribed
   `Permission-policy.json` and paste it into the policy editor in the AWS console. Then, update
   the placeholders in the provided policy with the relevant resource identifiers. Save your new IAM
   permission policy.
3. Click **Continue**.

<a id="create-provider-integration-aws-uistep3"></a>

#### Step 4: Create a new role in AWS and map in Confluent

In this step, you will create a new IAM role in your AWS account and map the role in Confluent.

### Create a new role in AWS

1. Open the AWS console at [https://console.aws.amazon.com/iam/](https://console.aws.amazon.com/iam/) and
   create a new IAM role. For more information, see [Create AWS IAM Roles](#create-provider-integration-aws-apistep1).
2. In the **Trusted entity type** screen, select **Custom trust policy**. In Confluent Cloud console,
   copy the `Trust-policy.json` and
   paste it into the policy editor in the AWS console. Save your new IAM role.

   #### NOTE
   You will need to update the policy with the Confluent-specific configurations
   such as `Confluent ARN` and `ExternalID` after mapping the role in Confluent.
3. Copy the `ARN` of the IAM role you just created for use in mapping the role in Confluent.

### Map the role in Confluent

1. In the **AWS ARN** field, paste the ARN copied during the creation of a new IAM role in Amazon Web Services.
2. In the **Provider integration name** field, specify a name for the integration.
3. Click **Continue**.

#### NOTE
Copy the `ARN` of the IAM role you just created for use in the provider integration setup in Confluent.

<a id="create-provider-integration-aws-uistep4"></a>

#### Step 5: Update trust policy in AWS

In this step, you will update the trust policy in the AWS account with Confluent IAM role configurations.
This allows the Confluent IAM role to assume the role in your AWS account.

1. Open the AWS console at [https://console.aws.amazon.com/iam/](https://console.aws.amazon.com/iam/) and
   edit the trust policy you created in the [Step 3](#create-provider-integration-aws-uistep3). For more information,
   see [Edit trust policies](#create-provider-integration-aws-apistep3).
2. In Confluent Cloud console, copy the updated `Trust-policy.json` and paste it into the trust policy
   editor in the AWS console.

<a id="create-provider-integration-aws-clistep"></a>

### Using the Confluent CLI

<a id="create-provider-integration-aws-clistep1"></a>

#### Step 1: Create an IAM policy and role in AWS

Follow the [AWS instructions](#create-provider-integration-aws-apistep1) to create an IAM policy and
role in your AWS account.

<a id="create-provider-integration-aws-clistep2"></a>

#### Step 2: Create an IAM role mapping in Confluent

Enter the following command to set up a provider integration and create an IAM role mapping in Confluent:

```none
confluent provider-integration create <name> [flags]
```

For example, to create a provider integration named **s3-provider-integration**, add
AWS ARN in `--customer-role-arn` and environment ID in `--environment` string.

```none
confluent provider-integration create s3-provider-integration --cloud aws --customer-role-arn arn:aws:iam::000000000000:role/my-test-aws-role --environment env-abcdef
```

Example output:

```none
+-------------------+--------------------------------------------------------+
| ID                | cspi-12345                                             |
| Name              | s3-provider-integration                                |
| Provider          | aws                                                    |
| Environment       | env-abcdef                                             |
| IAM Role ARN      | arn:aws:iam::123456777:role/cspi-12345              |
| External ID       | 123456-2312-21bc-n2xx-oo1a7b7890                       |
| Customer Role ARN | arn:aws:iam::037803949979:role/test-iam-role9999999    |
+-------------------+--------------------------------------------------------+
```

<a id="create-provider-integration-aws-clistep3"></a>

#### Step 3: Update trust policy in AWS

Follow the [AWS instructions](#create-provider-integration-aws-apistep3) to update the trust policy
in the AWS account with Confluent IAM role configurations. This allows the Confluent IAM role to
assume the role in your AWS account.

<a id="create-provider-integration-aws-apistep"></a>

### Using the Confluent APIs

<a id="create-provider-integration-aws-apistep1"></a>

#### Step 1: Create an IAM policy and role in AWS

Follow the instructions to create an IAM policy and role in your AWS account.

### Create an IAM Policy

1. Open the AWS console at [https://console.aws.amazon.com/iam/](https://console.aws.amazon.com/iam/).
2. Navigate to **Policies**, and then click **Create policy**.
3. In the **Policy editor** screen, select the **JSON** option.
4. Copy and paste the [S3](../../connectors/cc-s3-sink/cc-s3-sink.md#cc-s3-bucket-policy) or [DynamoDB](../../connectors/cc-amazon-dynamodb-cdc-source/cc-amazon-dynamodb-cdc-source.md#cc-dynamodb-cdc-policy)
   permission policy document in the editor screen.
5. Click **Next** to review the permissions.
6. In the **Review and create** page, enter a **Policy name** and a **Description**.
7. Click **Create policy** to save your new IAM policy.

   #### NOTE
   For more information about AWS IAM Policies, see [Create AWS IAM
   Policies](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_create-console.html#access_policies_create-json-editor).

Now you can get started creating IAM roles in your AWS account.

### Create an IAM Role

1. Navigate to **Roles**, and then click **Create role**.
2. In the **Trusted entity type** screen, select **Custom trust policy**.
3. In the **Custom trust policy** editor, copy and paste the following trust policy.
   Note that the `Principal` and `ExternalID` value will be added after you set up
   the Provider Integration in Confluent via Confluent Cloud APIs.
   ```json
   {
     "Version": "2012-10-17",
     "Statement": [
     {
       "Effect": "Deny",
       "Principal": {
          "AWS": "*"
       },
       "Action": "sts:AssumeRole"
      }
    ]
   }
   ```
4. Click **Next** to review the permissions, and then click **Add permissions**. Select the
   permission policy you created earlier for the S3 bucket.
5. In the **Name, review, and create** screen, enter a **Role name** and a **Description**.
6. Click **Create role** to save your new IAM role.

#### NOTE
Copy the `ARN` of the IAM role you just created for use in the provider integration setup in Confluent.

<a id="create-provider-integration-aws-apistep2"></a>

#### Step 2: Create an IAM role mapping in Confluent

Use [Register a provider integration](../../api-docs/pi-api.md#ccloud-pi-api-create) API to set up a provider integration and create an IAM role mapping in Confluent.

1. Add `environment ID` and `customer_iam_role_arn` in the POST API request.
   ```bash
   curl --request POST \
    --url https://api.confluent.cloud/pim/v1/integrations \
    --header 'Authorization: Basic <base64-encoded-key-and-secret>' \
    --header 'content-type: application/json' \
    --data '{
      "display_name":"s3_provider_integration",
      "provider":"AWS",
      "config":{
            "customer_iam_role_arn":"arn:aws:iam::000000000000:role/my-test-aws-role",
            "kind":"AwsIntegrationConfig"
        },
      "environment":{
      "id":"env-00000"
     }
   }'
   ```
2. Make a note of the `iam_role_arn` and `external_id` generated in the output for each IAM
   role association. These configurations are used by Confluent when assuming the IAM role in your AWS account.

#### NOTE
Use [Read a provider integration](../../api-docs/pi-api.md#ccloud-pi-api-read) API to fetch Confluent IAM role configurations in your environment.

<a id="create-provider-integration-aws-apistep3"></a>

#### Step 3: Update trust policy in AWS

Follow the steps to update the trust policy with Confluent IAM role configurations in the AWS account.
This allows the Confluent IAM role to assume the role in your AWS account.

1. Open the AWS console at [https://console.aws.amazon.com/iam/](https://console.aws.amazon.com/iam/)
2. Navigate to **Roles**, and then open the IAM role you created in the [Step 1](#create-provider-integration-aws-apistep1).
3. In **Trust relationships** tab, click **Edit trust policy** and update the following configurations:
   ```json
   {
     "Version": "2012-10-17",
     "Statement": [
       {
         "Effect": "Allow",
         "Principal": {
           "AWS": "arn:aws:iam::1234567:role/cspi-12345"
         },
         "Action": "sts:AssumeRole",
         "Condition": {
           "StringEquals": {
             "sts:ExternalId": "4xxxa23-ad2q-123d-1234-9d08bed527zz"
           }
         }
       },
       {
         "Effect": "Allow",
         "Principal": {
           "AWS": "arn:aws:iam::12345678:role/cspi-12345"
         },
         "Action": "sts:TagSession"
       }
     ]
   }
   ```
4. Click **Update policy** to update the trust policy.

## Related content

**Confluent Cloud documentation:**

- [Manage Provider Integration for Fully Managed Connectors](../../connectors/provider-integration.md#cloud-pi-quickstart)
- [Enhancing Security with IAM Roles in Confluent Managed Connectors [Confluent Blog]](https://www.confluent.io/blog/enhancing-security-with-iam-roles-in-confluent-managed-connectors/) (blog post)
- [Create an integration](https://docs.confluent.io/cloud/current/ccloud/create-pim-v-1-integration/)
- [Confluent Provider Integration CLI Command Reference](https://docs.confluent.io/confluent-cli/current/command-reference/provider-integration/index.html)
- [Confluent Provider Integration API Reference](https://docs.confluent.io/cloud/current/ccloud/integrations-pim-v-1/)

**AWS documentation:**

- [Creating IAM policies (AWS Documentation)](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_create.html)
- [Creating a role using custom trust policies (AWS Documentation)](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_create_for-custom.html)
- [IAM policy simulator (AWS Documentation)](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_testing-policies.html)
