Overview
Follow the steps below to let a workload connect to an Amazon RDS database that has no public access. An agent running in the same VPC as the database tunnels the connection, and an identity grants access to the database host and port from the workload to the database, tunneling through the agent.To connect to RDS without running an agent, use AWS PrivateLink instead.
Prerequisites
- Review the Agent and Identity reference pages.
- An AWS account and permission to manage EC2, RDS, and VPC security groups.
- A Control Plane GVC and a workload (or an image to deploy) that needs to reach the database.
Step One - Prepare the RDS Instance
- In the AWS Console, navigate to
RDSand create (or select) your database. Note the VPC it runs in. - Under
Connectivity, setPublic accesstoNo. The database does not need a public IP address because the agent reaches it from inside the VPC. - Create a dedicated security group for the database (e.g.,
rds-private-sg) and attach it to the instance. You will add its inbound rule in step three. - Once the database is available, copy its endpoint hostname from the
Connectivity & securitytab (e.g.,mydb.abc123xyz.us-east-1.rds.amazonaws.com) and its port. The default port is5432for PostgreSQL and3306for MySQL.
Always use the endpoint hostname, not an IP address. RDS can change the IP address behind an endpoint, for example during a Multi-AZ failover.
Step Two - Deploy an Agent in the Same VPC
Follow the AWS section of the Configure an Agent guide, and choose the same VPC that the RDS instance runs in when you create the Auto Scaling Group. Give the agent’s launch template its own security group (e.g.,cpln-agent-sg) so you can reference it in the next step. The agent opens outbound connections to Control Plane, so follow that guide’s networking notes: the VPC must have an Internet Gateway attached and the agent’s subnet must assign a public IPv4 address. For production, run at least two agents for redundancy.
When the agent’s heartbeat is green in the Agents page of the Control Plane UI, continue.
Step Three - Allow the Agent to Reach RDS
The agent connects to the database from inside the VPC, so the database’s security group must allow inbound traffic from the agent’s security group on the database port.- In the AWS Console, navigate to
VPC, clickSecurity Groups, and select the database’s security group (rds-private-sg). - Click
Edit inbound rules, thenAdd rule. - Set
TypetoPostgreSQL(port5432) orMYSQL/Aurora(port3306), or chooseCustom TCPand enter the port used by your database. - Set
Sourceto the agent’s security group (cpln-agent-sg). - Click
Save rules.
Step Four - Create the Identity Network Resource
Create an identity in the same GVC as your workload with a network resource that points at the RDS endpoint through the agent.- Console
- CLI
- Follow the Create an Identity guide to create a new identity in your GVC, or open an existing one to edit.
- Under
Cloud Wormhole, selectFQDN Resourcesand clickAdd FQDN. - Enter the RDS endpoint hostname as the
FQDN(e.g.,mydb.abc123xyz.us-east-1.rds.amazonaws.com). - Enter a unique
namefor the resource that differs from the FQDN (e.g.,my-rds). - Select the agent you created in step two.
- Under
Ports, add the database port (5432or3306). - Click
Add, then clickCreate.
FQDNandIPsare mutually exclusive, and one of them is required. Use the RDS endpoint as theFQDN. The agent resolves the hostname from inside your VPC, so it resolves to the database’s private address. Optionally setresolverIPto the IPv4 address of a DNS server the agent queries to resolve theFQDN, instead of its default resolver.portsmust list every port your application connects to. A resource accepts 1 to 10 ports.agentLinkis the link to the agent. All agents referenced by one identity must have the same protocol version.namemust be unique within the identity and must not match anyFQDNin it.- If you connect to more than one endpoint of an Aurora cluster or Multi-AZ DB cluster (for example, the writer and the reader endpoints), create one network resource per endpoint.
Step Five - Attach the Identity to the Workload
An identity only takes effect once it is attached to the workload that needs the connection.- Console: Open the workload, click
Identityin the left pane, select the identity, and clickSave. See the workload general settings. - CLI/YAML: Set
spec.identityLinkon the workload to//identity/rds-identity.
Step Six - Connect from the Workload
Inside the workload, connect to the database using the same hostname as the identity’sFQDN and the database port. No client library or code changes are required. For example, with PostgreSQL:
3306.
TLS
The workload can call the resource using either the FQDN or thename from the identity. If the database uses TLS, the FQDN must be used. RDS certificates are issued for the endpoint hostname, so connecting by name fails hostname verification (for example with sslmode=verify-full). The sslmode=require examples above do not verify the hostname, so they also work with the name. Connect with the FQDN and, to validate the server certificate, provide the RDS certificate bundle to your client (for example, sslmode=verify-full with sslrootcert for PostgreSQL).
Troubleshooting
Agent shows no recent heartbeat
Agent shows no recent heartbeat
Cause: The agent cannot open outbound connections to Control Plane.Fix: Confirm the agent’s VPC has an
Internet Gateway, its subnet assigns a public IPv4 address, and the instance can make outbound connections. See Configure an Agent.connection timed out
connection timed out
Cause: The agent cannot reach the database on its port. Typically the database security group does not allow the agent, or the agent runs in a different, unrouted VPC.Fix: Allow inbound traffic on the database port from the agent’s security group, and run the agent in the same VPC (or a routed one).
could not translate host name
could not translate host name
Cause: The hostname does not resolve in the workload. The identity is not applied to the workload, or the connection uses a hostname that is not the identity’s
FQDN or name.Fix: Attach the identity to the workload, make sure it is in the same GVC, wait for the workload rollout to finish, and connect with the exact FQDN.Certificate or hostname verification error
Certificate or hostname verification error
Cause: The client verifies the server certificate hostname (for example with
sslmode=verify-full) but connects with the resource name. RDS certificates are issued for the endpoint hostname.Fix: Connect with the FQDN, not the resource name.Connection refused
Connection refused
Cause: The agent reached the database host, but nothing is listening on the port used.Fix: Make sure the port in the network resource matches the port the database listens on.
Next Steps
- Review the identity network resources reference.
- Run at least two agents for high availability.