This solution uses SSH Tunnel. Tunnel will port forward your connection from ec2 instance to rds. Not sure if any ec2 instance will work, I checked only for ElasticBeanstalk stack with attached rds instance. I’ll explain how to setup connection on PgAdmin4 and IntelliJ.

Before Anything…

Try connecting to your ec2-instance:

ssh -i your.pem ec2-user@ip-address

If connection doesn’t go through, you might want to check my other post for connecting to ec2.

Configure PgAdmin4

Open pgadmin4, add a new server. Give it a name, click on the Connection tab. Fill the fields with your connection details for rds (host, user, pass). Leave the maintenance database to be postgres.

Create PG Server -  RDS Connection

Click on SSH Tunnel, and fill tunnel host, username and identity file.

Don’t have an identity file?

Create PG Server RDS - SSH Tunnel

Click on Save, you should be able to connect to your server and see ebdb database in list.

Configure IntelliJ IDEA

Add a new datasource – Click on Database tab -> + sign -> Datasource -> PostgreSQL. Like shown in the screenshot:

IntelliJ Idea add new datasource
IntelliJ Idea add new datasource

Fill the fields with your connection details for rds (host, user, pass). Database will probably be ebdb.Click on SSH/SSL, check Use SSH tunnel, add a new configuration by clicking three dots on the right. Fill tunnel host, username and identity file.

Configure SSH tunnel Intellij IDEA
Configure SSH tunnel Intellij IDEA

Don’t have an identity file?

Click on Apply, update driver if you need to, and test the connection.


Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x