# Aws (RDS)

To connect to your PostgreSQL RDS instance, in addition to the access credentials, there are specific configurations that need to be made.

## Setup

### ARN RDS

To grant the database access to pipeline data stored in S3, you’ll first need to associate an appropriate IAM role with the RDS instance.. First, you’ll need the ARN of the database. To do this, go to **RDS** and select **Databases**.

In the **Databases** table, click on the desired RDS instance to open its main page. Under the **Configuration** tab, copy the value under **Amazon Resource Name (ARN)**.

<figure><img src="/files/9ZpkYUj0ujrJOzXqcAEP" alt=""><figcaption></figcaption></figure>

In the JSON below:

1. Replace `ARN_RDS` with the ARN value copied in the previous step.
2. Replace `ID_AWS_ACC` with your AWS Account ID.

```json
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow", 
            "Principal": {
                "Service": "rds.amazonaws.com"
            }, 
            "Action": "sts:AssumeRole",
            "Condition": {
                "StringEquals": {
                    "aws:SourceArn": "<ARN_RDS>", 
                    "aws:SourceAccount": "<ID_AWS_ACC>"
                }
            }
        }
    ]
}
```

### IAM Role

To create the role that will be used by RDS to authenticate access to S3, navigate to **IAM** > **Roles** and selected the action to Create role.

Select **Custom trust policy** under **Trusted entity type** and paste the JSON generated in the **ARN RDS** step into **Custom trust policy**.

<figure><img src="/files/Pc1Tll6XWG3XHaMPwWye" alt=""><figcaption></figcaption></figure>

Skip **Step 2** and finalize the creation by naming the new role and reviewing the **Trust policy JSON** during **Step 3**.

After creating the role, navigate to its main page. Click the **Attach policies** button and then **Create inline policy**.

<figure><img src="/files/Y8Fz8B6hA5wMFznD5l2x" alt=""><figcaption></figcaption></figure>

On the loaded page, select the **JSON** option and paste the policy below, which will allow the database to use the S3 service:

{% code overflow="wrap" %}

```json
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow", 
            "Action": ["s3:GetObject", "s3:ListBucket", "s3:GetBucketLocation"],
            "Resource": ["arn:aws:s3:::*", "arn:aws:s3:::*/*"]
        }
    ]
}
```

{% endcode %}

Click **Next** to proceed to the final stage of policy creation. Once named, click **Create policy** to complete the process.

{% hint style="info" %}
**Note**: Remember the chosen name, as it will be needed in the next step.
{% endhint %}

Navigate to the main page of the desired instance as explained in **Step 1**. Under the initial **Connectivity & security** tab, scroll to the bottom of the page to view the **Manage IAM roles** table.

Choose the name of the IAM role created in **Step 2** and the **s3Import** feature, then click **Add role**.

<figure><img src="/files/BQcRTLxfZuuuuDlQtyZh" alt=""><figcaption></figcaption></figure>

Wait a few moments until the association status changes from **Pending** to **Active**.

### Install Extension

In your PostgreSQL Database, execute the following query to install the additional functionalities related to Storage:

```sql
CREATE EXTENSION aws_s3 CASCADE;
```

## Connect to Erathos

To connect Erathos to your RDS PostgreSQL (Aws):

1. **Create a New Destination**
   * Go to **Settings** > **Data Warehouse**.
   * Select **PostgreSQL**.
2. **Fill Out the Form**
   * Input your credentials, such as **Host**, **Database name**, **User**, **Password,** **Port** and **Region**.
3. **Advanced Options (Optional)**
   * Define if the connection should be made through a Static IP or SSH. For more information, plese referer to [Databases connection types](/connectors/databases.md#connection-types).

{% hint style="info" %}
If you need help connecting to your PostgreSQL, reach out to our team at <support@erathos.com>.
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.erathos.com/destinations/postgresql/aws-rds.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
