The database sat locked away inside a VPC private subnet, unreachable from the outside world. You needed to query it fast, but a direct connection was impossible. The solution: deploy Pgcli with a secure proxy inside the private subnet and bridge access through a controlled entry point.
Pgcli is a powerful Postgres command-line client with auto-completion and syntax highlighting. Running it inside a VPC private subnet makes it possible to interact with protected databases without breaking network boundaries. The challenge is creating a proxy that lets you connect from a public workstation while keeping all database traffic inside the VPC’s secure environment.
First, provision a small instance inside the subnet where the database lives. Install Pgcli there. This instance will act as your proxy host. Ensure it has an IAM role or credential method that allows connection to the database. From your local machine, you connect through an SSH tunnel or a managed proxy service that routes traffic into the instance.
For AWS, configure the subnet routing to restrict outbound traffic and allow inbound proxy connections only from trusted IPs. Use Security Groups to lock down the instance’s ports, exposing 22 for SSH or the port used by your proxy. The database’s own Security Group should whitelist only the proxy host’s private IP.