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
已提問 9 個月前檢視次數 2799 次
1 個回答
1
已接受的答案

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
專家
已回答 9 個月前
profile picture
專家
已審閱 7 個月前
  • 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.

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南