How to get to mysql prompt using CloudShell

0

AWS newbie here. I’ve setup an AWS MySQL RDS. Now … How do I get to the mysql prompt using CloudShell? I mean it seems like it should be easy to do right? 🤔 Also, can I import my mysqldump.sql file from the CloudShell terminal? Thanks for any insight!

profile picture
dbob
asked 8 months ago2625 views
1 Answer
1
Accepted Answer

Hello.
As described in the following document, private resources in a VPC cannot be accessed by CloudShell.
https://aws.amazon.com/jp/cloudshell/faqs/

Q: Can I access resources in a VPC with CloudShell?

No, you cannot currently access resources that are in your private VPC in this release of CloudShell.

One way to access RDS publicly from CloudShell is to configure RDS to allow public access.
https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_VPC.WorkingWithRDSInstanceinaVPC.html#USER_VPC.Hiding

You can check the public IP address by executing the following command in CloudShell.
Set this IP address to be allowed in the RDS security group.

curl ifconfig.io

After that, it can be accessed from CloudShell by setting RDS to allow public access.
However, the IP address of CloudShell is not fixed, so if the IP address is changed, the RDS security group must also be modified.

The other way is to launch an EC2 in the same VPC as the RDS and set it up so that the EC2 can connect to the RDS.
You can connect to that EC2 using Systems Manager's Session Manager, for example.
Doing so allows connection to RDS using SSM's port forwarding feature, as shown in the following document.
https://aws.amazon.com/jp/blogs/mt/use-port-forwarding-in-aws-systems-manager-session-manager-to-connect-to-remote-hosts/

profile picture
EXPERT
answered 8 months ago
profile picture
EXPERT
reviewed 6 months ago
  • Thanks for your answer … but i need to keep the database private. Seems nuts that the CloudShell running in the VPC instance that contains the database can’t access it. Ugh. Thanks again!

  • Updated answers.

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