Amazon Aurora PostgreSQL

Amazon Aurora PostgreSQL is a fully managed, PostgreSQL-compatible relational database engine that combines the speed and reliability of high-end commercial databases with the simplicity and cost-effectiveness of open-source databases. Its enterprise database capabilities combined with compatibility with PostgreSQL helps deliver throughput that is much higher compared to the standard PostgreSQL running on the same hardware.

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

Prerequisites

Setting up Log-based Incremental Replication

1. Create a parameter group

  1. Open the Amazon RDS console.
  2. In the left navigation pane, select Parameter groups.
  3. Click Create parameter group.
  4. Select the instance with Type as DB cluster parameter group. Example: postgresql cluster parameter group
  5. Specify the required fields and click Create.

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:

    Parameter Value
    rds.log_replication 1
    wal_sender_timeout 0
    max\_replication\_slots 5

3. Apply the parameter group to your PostgreSQL database

  1. In your Amazon RDS console, click Databases in the left navigation pane.
  2. In the Databases page, click the DB identifier for your database, and the, Modify.
  3. Select the DB cluster parameter group you just created.
  4. Set the backup retention period to at least 3 days. This setting defines the number of days for which automated backups are retained.

    Database settings

  5. For your settings to take affect, reboot the DB instance.

4. Create a replication slot

  1. Log in to the PostgreSQL master database as a Superuser.
  2. Create a replication slot using plugin test_decoding using following command: SELECT * FROM pg_create_logical_replication_slot('hevo_<database_name>', 'test_decoding’);

  3. Verify your changes:
    1. Log in to PostgreSQL server as the database user.
    2. Enter the following command:

      SELECT COUNT(*) FROM pg_logical_slot_peek_changes('hevo_<database_name>', null, null);

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({:target=”_blank”}).
  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.

    DB Identifier

  4. In the Connectivity & security tab, click the link text under Security, VPC security groups.

    VPC Security groups

  5. In the Actions drop-down on the top right, 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.

    Add rule

  7. Similarly, click the Outbound Rules tab, and add outbound rules.

2. Configure Virtual Private Cloud (VPC)

  1. In the Amazon RDS console, click the VPC link text.

    VPC link

  2. In the Your VPCs page, click on the VPC ID, and then, the Network ACL link. ACL link

  3. Click the Inbound Rules tab and ensure that the IP addresses you added have a setting of ALLOW. Check rules are enabled

  4. Click the Outbound Rules tab and repeat the above step for the outbound rules.

Granting Privileges to a User

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

  1. Log into your Amazon Aurora 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>;

    Note: If you want to use Log-based Incremental Replication, grant the rds_replication role to the database user. Log in to the database as a user with the rds_superuser role and run the following command:

    GRANT rds_replication TO <database_username>;

Last updated on 26 Oct 2020