How to access RDS from local machine?

0

This is a follow up of my earlier question https://repost.aws/questions/QUTz5jDAAkSZaWFNKQTVbTyA/how-to-run-rds-without-getting-charged

I wanted to access the RDS instance from my local machine, so i have created the RDS with a public IP and everything is fine except, i was charged which i don't want. So as suggested in my earlier question, "Use port forwarding in AWS Systems Manager Session Manager to connect to remote hosts". But I could not use AWS CLI in my machine (for other permission related reasons), i want to achieve the same without using AWS CLI.

What i have completed so far.

  • I have created and EC2 instance.
  • Connected via SSH and enabled ssm Agent.
  • Now my EC2 instance is appearing under Managed Nodes in the Fleet Manager console.

What i am going to to

  • I will create a RDS instance but wont enable public IP.

What to do next?

Can someone help me with the next steps without AWS CLI.

Thanks

2 Answers
3

Hello.

If you cannot use Session Manager, why not try using SSH port forwarding using an EC2 instance as a stepping stone?
If you allow SSH in the inbound rules of the EC2 instance's security group so that you can access it from your local PC, you can use SSH port forwarding with the command introduced in the GitHub blog below.
https://gist.github.com/todgru/9609262?permalink_comment_id=2237371

profile picture
EXPERT
answered 2 months ago
profile picture
EXPERT
reviewed 2 months ago
profile picture
EXPERT
reviewed 2 months ago
  • Thanks for the quick help. I will try this. Besides, I can use the Session Manager (AWS Session Manager Console) but i don't have AWS CLI installed in my local machine. Is there a way i can use this solution "https://repost.aws/questions/QUpMJkHUzZSuezkyCz1ksQng/how-to-access-rds-from-local-machine" without AWS CLI.

  • You cannot use Session Manager from your local machine unless the AWS CLI is installed on your local machine.

  • ThankQ so much. It worked. Just curious. What does the "AWS Session Manager Console" do?. I can create/start a session linking an EC2 instance and it opens a terminal environment in a new tab.

  • What does the "AWS Session Manager Console" do?

    Connecting with Session Manager from the AWS Management Console is a feature that allows you to connect to the EC2 OS directly from a web browser. Since it is not possible to configure port forwarding using Session Manager from a web browser, please use port forwarding using SSH this time.

2
Accepted Answer

Hello,

If you had deployed the EC2 instance in a Public subnet, you can perform port forwarding using SSH command:

ssh -i "your-private-key.pem" -L <local_port>:your-rds-endpoint:<target_port_rds> ec2-user@your-ec2-public-dns

You can take a look at this documentation on how to access RDS inside the VPC, https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_VPC.Scenarios.html

profile picture
EXPERT
answered 2 months ago
profile picture
EXPERT
reviewed 2 months ago
  • Thanks for the quick help. I will try this. Besides, I can use the Session Manager (AWS Session Manager Console) but i don't have AWS CLI installed in my local machine. Is there a way i can use this solution "https://repost.aws/questions/QUpMJkHUzZSuezkyCz1ksQng/how-to-access-rds-from-local-machine" without AWS CLI.

    My Apologies. I am pasting the same comment.

  • ThankQ so much. It worked. Just curious. What does the "AWS Session Manager Console" do?. I can create/start a session linking an EC2 instance and it opens a terminal environment in a new tab.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions