Skip to main content
Use AWS PrivateLink to connect your Aurora PostgreSQL database to Unblocked without VPC peering or internet exposure. You publish a VPC endpoint service in front of your database. Unblocked verifies that you own the service, creates an interface endpoint from its AWS account, and you approve the connection. Unblocked reaches only the database port on the IP addresses you register. Complete both parts to connect your database and grant read-only access.
  1. Set up AWS PrivateLink.
  2. Set up a read-only role.
Choose one setup option:

Before you start

Use an AWS identity that can describe your VPC and database instances, manage security groups, create Network Load Balancers and target groups, manage VPC endpoint services, and create IAM roles and inline policies. For cross-region access, it also needs vpce:AllowMultiRegion.

What you will build

Each option creates:
  • A security group for the load balancer with no inbound rules and outbound access only to your database security group on the database port.
  • An inbound rule on your database security group that allows the load balancer on that port.
  • A TCP target group containing the private IP addresses you register and maintain.
  • An internal Network Load Balancer (NLB) in your private subnets, forwarding the database port to the target group.
  • A VPC endpoint service that allows only Unblocked’s endpoint-manager role to connect.
  • A verification role in the account that owns the endpoint service. Unblocked assumes it with your organization’s external ID to confirm ownership. It can read only the endpoint service’s allowed principals and its own trust policy.

Finding the target IPs

An NLB forwards to IP addresses, not RDS endpoint names. Find each database instance’s endpoint, then resolve its private IPv4 address. Replace INSTANCE_ID with your instance identifier and DATABASE_REGION with its AWS region.
Register the reader instances if Unblocked should connect only to replicas. Keep the target list current when instance roles change; TCP health checks do not distinguish readers from writers.

Keeping the target IPs current

You own the target group and must update it when instance IP addresses or reader roles change. Unblocked cannot see or change your targets. Check them after:
  • Failover, when a reader becomes the writer and the old writer may return as a reader.
  • AWS maintenance or hardware recovery that moves an instance to a new host.
  • Changes to instance classes or the number of readers.
Stale IP addresses can interrupt connectivity. Do not rely on health checks to block traffic: an NLB fails open when all targets are unhealthy. You can automate updates with an EventBridge rule on RDS events and a Lambda function that resolves instance endpoints and updates the target group. AWS provides a sample in Access Amazon RDS across VPCs using AWS PrivateLink and Network Load Balancer. The sample tracks the writer’s IP; extend it if you register readers.

Same region or cross-region

If your database is in us-west-2, Unblocked matches your NLB’s Availability Zones by AZ ID, such as usw2-az1. For a database in another region, add us-west-2 as a supported region of the endpoint service. The Terraform module does this automatically. AWS charges inter-region data transfer to the sending side. Choose NLB subnets in Availability Zones that support cross-region PrivateLink.
Use Terraform when you manage your AWS infrastructure with Terraform. The Unblocked PrivateLink module creates the network resources and verification role in your AWS provider’s region. It requires Terraform 1.5 or later and AWS provider 6.0 or later.

Add the module

Add this configuration to your Terraform project. Replace the VPC, subnet, security group, and external ID values. Configure your AWS provider for the database’s region.In the Aurora PostgreSQL PrivateLink connection setup in Unblocked, click Copy under External ID generated by Unblocked. Use the full copied value for verification_external_id, replacing YOUR_EXTERNAL_ID below.External ID generated by Unblocked with the organization-specific suffix masked and a Copy button
The module prefixes the verification role name with UnblockedPrivateLink-, so this example creates UnblockedPrivateLink-verification. Set port if your database uses a port other than 5432. Set auto_accept_connections = true to accept connections from the allowed principal automatically.
If Terraform manages your database security group with inline ingress blocks, omit database_security_group_id and allow the module’s nlb_security_group_id output on the database port in your own configuration. Otherwise, the next apply of that security group removes the module’s rule. When you omit this input, the NLB’s outbound access uses the VPC CIDR, or the CIDRs you specify in target_cidr_blocks, on the database port.

Apply and register the targets

Apply the configuration:
The module creates an empty target group. Register your target IPs in the database’s region. Replace the example IPs and adjust the port if needed.
Keep the IPs current as described above. Do not manage targets with aws_lb_target_group_attachment resources alongside external target updates: a later apply can restore stale IPs and remove targets added by your automation.Print the service name and verification role ARN, and save the service ID for accepting the connection:
Continue with Connect in Unblocked.
Run these commands in Bash with AWS credentials for the account that owns your database. If you use zsh, including the default macOS shell, start bash first. These examples rely on Bash splitting the subnet and target IP lists into separate arguments.In the Aurora PostgreSQL PrivateLink connection setup in Unblocked, click Copy under External ID generated by Unblocked. Use the full copied value for EXTERNAL_ID, replacing YOUR_EXTERNAL_ID below.External ID generated by Unblocked with the organization-specific suffix masked and a Copy buttonReplace the example region, resource IDs, and target IPs with your values:

Create the security groups

Create the NLB security group. It starts with no inbound rules. Remove its default outbound rule, then allow only the database port to your database security group. Allow that traffic into your database security group:

Create the target group

Create a TCP target group with IP targets and TCP health checks every 10 seconds. Set a 30-second deregistration delay and register your target IPs:

Create the Network Load Balancer

Create an internal NLB in your private subnets with the security group you created:
Disable inbound security group enforcement for PrivateLink traffic. Without this setting, the empty inbound rules block Unblocked’s connections. Enable cross-zone load balancing and forward the database port to your target group:
Wait until every target shows healthy.

Create the endpoint service

Create a service that requires you to accept each connection. For automatic acceptance instead, replace --acceptance-required with --no-acceptance-required.For a database in us-west-2:
For a database in another region, run this version instead to add us-west-2 as a supported region:
Allow only Unblocked’s endpoint-manager role to create endpoints, then print the service details:

Create the verification role

Unblocked assumes this role to confirm that you own the endpoint service before it creates its endpoint. The role name must start with UnblockedPrivateLink. Use the EXTERNAL_ID value you copied from Unblocked earlier, including the unblocked_privatelink_ prefix.Create a trust policy allowing only Unblocked’s endpoint-manager role, with your external ID:
Allow the role to read only your endpoint service’s allowed principals and its own trust policy:
Continue with Connect in Unblocked.
Work in your database’s region. These steps use port 5432; substitute your database port if it differs.
1

Create the security groups

Open EC2 › Security Groups and choose Create security group. Name it unblocked-privatelink-nlb and select your database’s VPC.Leave Inbound rules empty. Under Outbound rules, delete the default All traffic rule. Add Custom TCP, port 5432, with your database security group as the destination. Create the group.Open your database security group and edit its inbound rules. Add Custom TCP, port 5432, with the NLB security group as the source. Save.
2

Create the target group

Open EC2 › Target Groups and choose Create target group. Choose IP addresses, name it unblocked-privatelink, and select TCP, port 5432, and your database’s VPC.Set the health check protocol to TCP. Under advanced health check settings, set the healthy and unhealthy thresholds to 2 and the interval to 10 seconds.Choose Next, enter each target IP on port 5432, and choose Include as pending below. Create the target group. On its Attributes tab, set the deregistration delay to 30 seconds.
3

Create the Network Load Balancer

Open EC2 › Load Balancers and create a Network Load Balancer named unblocked-privatelink. Choose Internal and IPv4.Select your database’s VPC and at least two Availability Zones with private subnets. Select the NLB security group instead of the default group. Configure a TCP listener on port 5432 that forwards to your target group. Create the load balancer and wait for Active.On the Security tab, edit the security settings and clear Enforce inbound rules on PrivateLink traffic. Save. On the Attributes tab, enable Cross-zone load balancing.Open your target group’s Targets tab and wait for every target to become Healthy.
4

Create the endpoint service

Open VPC › Endpoint services and choose Create endpoint service. Choose Network and select your NLB.Keep Require acceptance for endpoint selected, or clear it to accept connections from allowed principals automatically. Leave Enable private DNS name cleared. For cross-region access, add us-west-2 under Supported Regions. Choose IPv4 and create the service.On Allow principals, add arn:aws:iam::029574882031:role/ExternalConnectionsEndpointManager.Copy the Service name and Service ID from Details.
5

Create the verification role

In the Aurora PostgreSQL PrivateLink connection setup in Unblocked, click Copy under External ID generated by Unblocked.External ID generated by Unblocked with the organization-specific suffix masked and a Copy buttonOpen IAM › Roles and choose Create role. Choose Custom trust policy to trust only Unblocked’s endpoint-manager role. Replace YOUR_EXTERNAL_ID in this policy with the full copied value:
Choose Next, leave Add permissions empty, then choose Next again. Name the role UnblockedPrivateLinkVerification and create it. If you choose another name, it must start with UnblockedPrivateLink.Open the role and choose Add permissions › Create inline policy. Choose JSON and enter this policy with your region, account ID, service ID, and role name:
Name the policy verify-endpoint-service and create it. Copy the role’s ARN from its summary.

Connect in Unblocked

Provide these values in your Aurora PostgreSQL PrivateLink setup: Aurora PostgreSQL settings in Unblocked showing the new PrivateLink connection form with external ID, endpoint service name, AWS account ID, and verification role ARN

Accept Unblocked’s connection

After Unblocked verifies the service and creates its endpoint, the connection waits in Pending acceptance. Check that its owner is Unblocked’s account, 029574882031, before accepting. With automatic acceptance enabled, the connection becomes Available without this step. In the console, open VPC › Endpoint services, select your service, and open Endpoint connections. Select Unblocked’s pending connection, then choose Actions › Accept endpoint connection request. With the CLI, set the database region and service ID if they are not already set, then list requests:
Accept the endpoint owned by 029574882031, replacing the example endpoint ID:
Wait for the connection to become Available, then tell Unblocked it is accepted.

Removing access

Reject Unblocked’s endpoint connection to cut off access. Removing its role from the allowed principals stops new endpoints but does not revoke an accepted connection.
In the console, select the connection on Endpoint connections and choose Actions › Reject endpoint connection request. To remove the resources, delete the endpoint service, NLB, target group, inbound rule on your database security group, NLB security group, and verification role, in that order. For Terraform, remove the module and apply. Use terraform destroy only if the Terraform configuration is dedicated to this integration.

Troubleshooting

Part 2: Set up a read-only role

If you already have a read-only role with access to the data you want Unblocked to read, and have granted it to a login user, skip the role and user setup below. Use that user’s credentials and continue to Enter database details in Unblocked.
With PrivateLink configured, provide your database’s hostname, port, and name, and create a dedicated login for Unblocked. Unblocked opens connections with default_transaction_read_only=on and a statement timeout. Give its login read permissions on only the data you want it to access.

Database prerequisites

Find the hostname, port, and database name

Use your cluster’s reader endpoint as the hostname, in the format CLUSTER.cluster-ro-ID.REGION.rds.amazonaws.com. Unblocked routes traffic through PrivateLink and verifies the database’s TLS certificate against this hostname using the Amazon RDS certificate authority. Provide the RDS reader endpoint, rather than an IP address, NLB or VPC endpoint DNS name, custom endpoint, or your own DNS alias.

AWS console

  1. Open RDS in your database’s region and choose Databases.
  2. Select your cluster’s identifier, whose role is Regional cluster.
  3. On Connectivity & security, under Connect using, choose Endpoints. Note the Database name, Master username, and Port. Copy the endpoint whose Type is Reader; its name contains .cluster-ro-. Also note the Writer endpoint for creating the database user. If the database name is empty, see If there is no database name.
Aurora cluster connection details showing database name, master username, port, and writer and reader endpoints

AWS CLI

Run these commands in Bash with AWS credentials for your account. Replace the cluster identifier and region:
If you do not know your cluster identifier, list the Aurora PostgreSQL clusters in the region:
Get the reader hostname, port, and database name. The database name is None if none was specified when the cluster was created:
Get the writer hostname and master username for the next step:

If there is no database name

The cluster’s database name is specified at creation time. If it is empty, connect to the postgres database using one of the methods below and list the databases:
In psql, you can also use \l. Choose the database containing your data. Set DB_NAME to that name before continuing with the CLI examples.

Create a read-only role and user

Create database users with SQL inside PostgreSQL. Run the following SQL as your cluster’s master user, with schema and table owners applying grants where required. Connect to the writer endpoint and to the database Unblocked will read. Readers cannot create roles, and schema and table grants apply within the database you connect to.

Connect with RDS Query Editor

The Query Editor requires RDS Data API, which is not supported on T instance classes such as db.t3 and db.t4g. Your AWS identity needs AmazonRDSDataFullAccess or the permissions listed in Using the Aurora query editor.
  1. If Data API is disabled, open your cluster and choose Actions › Enable RDS Data API. You can also enable it with the CLI, replacing CLUSTER_ARN:
  2. On Connectivity & security, under Connect using, choose Query Editor, then Navigate to Query Editor. You can also choose Query editor in the RDS navigation.
  3. In Connect to database, choose your cluster. Under Database username, choose Add new database credentials and enter your master username and password. Enter your database name, then connect. Query Editor stores these credentials in AWS Secrets Manager. RDS Query Editor Connect to database dialog with cluster, username, password, and database name fields
  4. Run the statements in Run the SQL in order.

Connect with psql

From a host that can reach the cluster, download the RDS certificate bundle:
Using the values you collected earlier, connect to the writer endpoint as your administrator. psql prompts for your password:

Run the SQL

The role unblocked_readonly holds read permissions; the login unblocked inherits them. You can choose other names. Replace <database>, <schema>, <table>, and <password> with your own values wherever they appear.
1

Create the read-only role

This role cannot log in. You grant it to the login user later.
2

Allow database connections

3

List your schemas

Exclude PostgreSQL’s system schemas:
4

Grant read access

Run this block to grant schema usage and read access to existing tables and views, plus tables created later by the role running it:
To choose schemas individually, or if Query Editor rejects the block, run these statements for each schema instead:
Apply existing-object grants as an owner or a role with the required grant options. Missing grant authority can produce permission errors or warnings that no privileges were granted.Default privileges apply only to objects created by the specified role, or the current role when none is specified. If an application or migration role creates tables, configure its defaults too: run the statements as that role, or use ALTER DEFAULT PRIVILEGES FOR ROLE with the appropriate role name and permissions. Repeat the schema grants for schemas added later. See PostgreSQL default privileges.
5

Create the login user

Use a strong password. If you plan to test this login through Query Editor on Aurora PostgreSQL 14 or later, its password must use SCRAM-SHA-256. This is the default for new clusters on these versions. See Aurora password encryption if you use a custom configuration.
In psql, you can omit the password from CREATE USER and set it with \password unblocked to keep it out of command history.
6

Grant the role to the user

7

Make sessions read-only by default (optional)

Unblocked already sets this on its connections. Set it on the login too if you want the same default for other clients. The read-only default does not replace permission grants.
Instead of creating and granting the custom role, create the login user as above and grant the predefined pg_read_all_data role:
This grants read access to tables, views, and sequences in every schema, including ones created later. It applies across every database in the cluster that the login can connect to. Use it only if that scope is appropriate. Row-level security policies still apply. See PostgreSQL predefined roles.
Instead of the schema-wide table grants, grant schema usage:
To expose all columns from specific tables:
To expose only selected columns from a table instead:
Table-level SELECT allows every column. Use column grants on a table only when you have not also granted table-level SELECT. Unblocked lists ordinary and partitioned tables, and exposes only columns its user can read. It does not list views.See Managing PostgreSQL users and roles and PostgreSQL GRANT.

Check the database user

Use psql from the host you used for setup. Query Editor can check permissions and list tables, but it cannot test the reader hostname or the PrivateLink network path.
  1. Connect to the reader endpoint as unblocked with TLS certificate verification:
  2. If you set the login’s read-only default, confirm that it returns on:
  3. List the tables Unblocked can see:
  4. Check write privileges on a table, including column-level grants. Replace <schema>.<table>. The result should be f:
  5. Optionally, connect to the writer endpoint as unblocked and try this against a disposable test table. The insert should fail with permission denied for table:

Enter database details in Unblocked

Enter these values in the Aurora PostgreSQL connection settings, alongside your PrivateLink values: Aurora PostgreSQL settings in Unblocked showing the database connection fields for Aurora hostname, port, database, username, and password Complete connection verification in Unblocked to check the PrivateLink path as well as your database credentials and TLS configuration.

Choose your environment

After verifying the connection, open Settings › Data Sources › Aurora PostgreSQL. Under Environment, choose Production for real business data or Development for test and sample data. If you change the environment, click Save Settings. Check Exposed tables to see which tables Unblocked can read with the configured database role. Aurora PostgreSQL settings with the Environment dropdown, Exposed tables list, and Save Settings button

Database troubleshooting

References