Amazon RDS PostgreSQL

You can set up, operate, and scale PostgreSQL deployments in the cloud with Amazon RDS. Amazon RDS for PostgreSQL gives you access to the capabilities of the familiar PostgreSQL database engine. This means that the code, applications, and tools you already use today with your existing databases can be used with Amazon RDS.

You can ingest data from your Amazon RDS PostgreSQL database using Hevo Pipelines and replicate it to a warehouse of your choice.

Prerequisites

Setting up Log-based Incremental Replication

Hevo supports data ingestion from PostgreSQL servers via Write Ahead Logs set at the logical level (available on PostgreSQL version 9.4). A Write Ahead Log(WAL) is a collection of log files that record information about data modifications and data object modifications made on a PostgreSQL server instance. Typically WAL is used for data replication and data recovery.

To set up log-based replication, follow these steps:

1. Create a parameter group

  1. Log in to the Amazon RDS console.
  2. Click Parameter groups in the left sidebar.

    Parameter groups

  3. Select the parameter group corresponding to your PostgreSQL instance, to edit.

    If this is the default Parameter group, RDS restricts you from editing it. In such a case, create a parameter group.

    1. Select the instance with Type as DB cluster parameter group. Example: postgresql cluster parameter group
    2. Specify the parameter group details and click Create.

      Create parameter group

2. Configure the parameters

For the parameter group you just created:

  1. Click Edit parameters in the top right.

  2. Search and update the following parameters:

    edit parameters

    Parameter Value Description
    rds.logical_replication 1 The value of 1 is require to enable WAL logs at the logical level.
    max_wal_senders 5 The number of processes that can simultaneously transmit the WAL log. RDS recommends to set this value to at least 5 so that the internal replication by RDS is not affected.
    max_replication_slots 5 The number of clients that can connect to the server. RDS recommends to set this value to at least 5 so that internal replication by RDS is not affected.

2. Apply the parameter group to your PostgreSQL database

  1. In the Databases page, select the DB Identifier for your PostgreSQL instance, and click Modify on the top bar.
  2. In the Additional configuration page:

    1. Select the DB cluster parameter group you just created.
    2. Specify the Backup retention period, and click Next.

    Backup settings

  3. View the Summary of modifications and click Modify cluster.

    Modify cluster

Whitelisting Hevo’s IP Addresses

You need to whitelist the Hevo IP addresses for your region to enable Hevo to connect to your PostgreSQL database. To do this:

1. Add inbound and outbound rules

  1. Open the Amazon RDS console.
  2. In the left navigation pane, click Databases (or Instances if you’re using an older version).
  3. In the Databases section on the right, click the DB identifier of the Amazon Aurora instance to configure a security group on.

    Select DB identifier

  4. In the Connectivity & security tab, click the security group ID under Security, VPC security groups.

    Select security group ID

  5. In the Actions drop-down on the top right, select Edit inbound rules. Then, in the Inbound rules tab, click Edit Inbound Rules.

    Edit inbound rules

  6. In the Edit inbound rules page:
    1. Click Add rule.
    2. Add a new rule either with 0.0.0.0/0 or Hevo’s IP addresses for your region to give access to the PostgreSQL instance.
    3. Click Save rules.

    The rules are now visible under Security groups.

    Newly added rules

  7. Click the Outbound Rules tab and repeat the above step to add rules for each IP address.

2. Configure Virtual Private Cloud (VPC)

  1. In the Connectivity & security tab, click the VPC link under VPC:

  2. In the page that is displayed, click on the VPC ID.

  3. In the Inbound Rules tab, ensure Allow/Deny field is set to ALLOW. Else, click Edit inbound rules to do this.

    Modify inbound rules

  4. Similarly, in the Outbound Rules tab, ensure Allow/Deny field is set to ALLOW. Else, click Edit outbound rules to do this.

Granting Privileges to a User

Grant privileges to the database user connecting to the PostgreSQL database as follows:

  1. Log into your Amazon RDS PostgreSQL database as a user with grant privilege.
  2. Enter the following commands to give accesses to the database user: GRANT CONNECT ON DATABASE <database_name> TO <database_username>; GRANT USAGE ON DATABASE <database_name> TO <database_username>; GRANT SELECT ON DATABASE <database_name> TO <database_username>;

  3. Alter the schema’s default privileges to grant SELECT privileges on tables to the database user ALTER DEFAULT PRIVILEGES IN SCHEMA <schema_name> GRANT SELECT ON TABLES TO <database_username>;
Last updated on 26 Oct 2020