|
| 1 | +--- |
| 2 | +slug: /integrations/clickpipes/secure-rds |
| 3 | +sidebar_label: 'AWS IAM DB Authentication (RDS/Aurora)' |
| 4 | +title: 'AWS IAM DB Authentication (RDS/Aurora)' |
| 5 | +description: 'This article demonstrates how ClickPipes customers can leverage role-based access to authenticate with Amazon RDS/Aurora and access their database securely.' |
| 6 | +--- |
| 7 | + |
| 8 | +import secures3_arn from '@site/static/images/cloud/security/secures3_arn.png'; |
| 9 | +import Image from '@theme/IdealImage'; |
| 10 | + |
| 11 | +This article demonstrates how ClickPipes customers can leverage role-based access to authenticate with Amazon Aurora and RDS and access their databases securely. |
| 12 | + |
| 13 | +:::warning |
| 14 | +For AWS RDS Postgres and Aurora Postgres you can only run `Initial Load Only` ClickPipes due to the limitations of the AWS IAM DB Authentication. |
| 15 | + |
| 16 | +For MySQL and MariaDB, this limitation does not apply, and you can run both `Initial Load Only` and `CDC` ClickPipes. |
| 17 | +::: |
| 18 | + |
| 19 | +## Setup {#setup} |
| 20 | + |
| 21 | +### Obtaining the ClickHouse service IAM role Arn {#obtaining-the-clickhouse-service-iam-role-arn} |
| 22 | + |
| 23 | +1 - Login to your ClickHouse cloud account. |
| 24 | + |
| 25 | +2 - Select the ClickHouse service you want to create the integration |
| 26 | + |
| 27 | +3 - Select the **Settings** tab |
| 28 | + |
| 29 | +4 - Scroll down to the **Network security information** section at the bottom of the page |
| 30 | + |
| 31 | +5 - Copy the **Service role ID (IAM)** value belong to the service as shown below. |
| 32 | + |
| 33 | +<Image img={secures3_arn} alt="Secure S3 ARN" size="lg" border/> |
| 34 | + |
| 35 | +Let's call this value `{ClickHouse_IAM_ARN}`. This is the IAM role that will be used to access your RDS/Aurora instance. |
| 36 | + |
| 37 | +### Configuring the RDS/Aurora instance {#configuring-the-rds-aurora-instance} |
| 38 | + |
| 39 | +#### Enabling IAM DB Authentication {#enabling-iam-db-authentication} |
| 40 | +1. Login to your AWS Account and navigate to the RDS instance you want to configure. |
| 41 | +2. Click on the **Modify** button. |
| 42 | +3. Scroll down to the **Database authentication** section. |
| 43 | +4. Enable the **Password and IAM database authentication** option. |
| 44 | +5. Click on the **Continue** button. |
| 45 | +6. Review the changes and click on the **Apply immediately** option. |
| 46 | + |
| 47 | +#### Obtaining the RDS/Aurora Resource ID {#obtaining-the-rds-resource-id} |
| 48 | + |
| 49 | +1. Login to your AWS Account and navigate to the RDS/Aurora instance you want to configure. |
| 50 | +2. Click on the **Configuration** tab. |
| 51 | +3. Note the **Resource ID** value. It should look like `db-xxxxxxxxxxxxxx`. Let's call this value `{RDS_RESOURCE_ID}`. This is the resource ID that will be used in the IAM policy to allow access to the RDS instance. |
| 52 | + |
| 53 | +#### Setting up the Database User {#setting-up-the-database-user} |
| 54 | + |
| 55 | +##### PostgreSQL {#setting-up-the-database-user-postgres} |
| 56 | + |
| 57 | +1. Connect to your RDS/Aurora instance and create a new database user with the following command: |
| 58 | + ```sql |
| 59 | + CREATE USER clickpipes_iam_user; |
| 60 | + GRANT rds_iam TO clickpipes_iam_user; |
| 61 | + ``` |
| 62 | +2. Follow the rest of the steps in the [PostgreSQL source setup guide](postgres/source/rds) to configure your RDS instance for ClickPipes. |
| 63 | + |
| 64 | +##### MySQL / MariaDB {#setting-up-the-database-user-mysql} |
| 65 | + |
| 66 | +1. Connect to your RDS/Aurora instance and create a new database user with the following command: |
| 67 | + ```sql |
| 68 | + CREATE USER 'clickpipes_iam_user' IDENTIFIED WITH AWSAuthenticationPlugin AS 'RDS'; |
| 69 | + ``` |
| 70 | +2. Follow the rest of the steps in the [MySQL source setup guide](mysql/source/rds) to configure your RDS/Aurora instance for ClickPipes. |
| 71 | + |
| 72 | +### Setting up the IAM role {#setting-up-iam-role} |
| 73 | + |
| 74 | +#### Manually create IAM role. {#manually-create-iam-role} |
| 75 | + |
| 76 | +1 - Login to your AWS Account in the web browser with an IAM user that has permission to create & manage IAM role. |
| 77 | + |
| 78 | +2 - Browse to IAM Service Console |
| 79 | + |
| 80 | +3 - Create a new IAM role with the following IAM & Trust policy. |
| 81 | + |
| 82 | +Trust policy (Please replace `{ClickHouse_IAM_ARN}` with the IAM Role arn belong to your ClickHouse instance): |
| 83 | + |
| 84 | +```json |
| 85 | +{ |
| 86 | + "Version": "2012-10-17", |
| 87 | + "Statement": [ |
| 88 | + { |
| 89 | + "Effect": "Allow", |
| 90 | + "Principal": { |
| 91 | + "AWS": "{ClickHouse_IAM_ARN}" |
| 92 | + }, |
| 93 | + "Action": [ |
| 94 | + "sts:AssumeRole", |
| 95 | + "sts:TagSession" |
| 96 | + ] |
| 97 | + } |
| 98 | + ] |
| 99 | +} |
| 100 | +``` |
| 101 | + |
| 102 | +IAM policy (Please replace `{RDS_RESOURCE_ID}` with the Resource ID of your RDS instance). Please make sure to replace `{RDS_REGION}` with the region of your RDS/Aurora instance and `{AWS_ACCOUNT}` with your AWS account ID: |
| 103 | + |
| 104 | +```json |
| 105 | +{ |
| 106 | + "Version": "2012-10-17", |
| 107 | + "Statement": [ |
| 108 | + { |
| 109 | + "Effect": "Allow", |
| 110 | + "Action": [ |
| 111 | + "rds-db:connect" |
| 112 | + ], |
| 113 | + "Resource": [ |
| 114 | + "arn:aws:rds-db:{RDS_REGION}:{AWS_ACCOUNT}:dbuser:{RDS_RESOURCE_ID}/clickpipes_iam_user" |
| 115 | + ] |
| 116 | + } |
| 117 | + ] |
| 118 | +} |
| 119 | +``` |
| 120 | + |
| 121 | +4 - Copy the new **IAM Role Arn** after creation. This is what needed to access your AWS Database securely from ClickPipes. Let's call this `{RDS_ACCESS_IAM_ROLE_ARN}`. |
| 122 | +
|
| 123 | +You can now use this IAM role to authenticate with your RDS/Aurora instance from ClickPipes. |
0 commit comments