For one of my projects, I’ve been playing around with AWS for some time. Amazon Web Services (AWS) is pretty much a huge collection of amazing computing, networking, databasing, etc. resources which you can use to create just about anything!
Among the many obstacles I’ve encountered along the way – wouldn’t be fun without them – my latest one was connecting to the RDS instance so I can actually see what’s happening. I mean, I can SSH into EC2, and probably access RDS from there. But I want the convenience of popping up a local terminal and running one command to get into my RDS instance. Even better, I want MySQL Workbench to access my RDS instance so that I can visualize things a little more easily (I’m not a SQL-guru yet). Anyway, it’s probably worth noting also that I provisioned all these resources (including RDS) through Elastic Beanstalk. Shouldn’t really make a difference, as this solution has nothing to with EB, really.
Here’s what you do:
- In your AWS Management Console, go to RDS
- Click on the RDS DB instance you are trying to access
- In the drop-down area, you should see additional details. Of particular interest is the RDS security group name. Click on that, and you should find yourself in the Security Groups area of EC2.
- Click on the RDS security group associated with the RDS instance instance you are interested in (you identified this in steps 2 and 3).
- The drop-down menu for that security group should present you with 3 tabs (Details, Inbound, Outbound). Click Inbound.
- If you created your RDS instance through EB also, then you should see a rule for your EB security group already. You pretty much need to add a new rule for your local computer.
- Find your public IP address. If you’re on linux (hopefully you are), run
sudo apt-get install curland then
curl http://ipecho.net/plain. Your IP address should be echoed. If this is not suitable for you, just go to http://whatismyip.com/.
- Back in the AWS console, choose “MySQL” in “Create New Rule”. You need to access port 3306, which should be applied correctly automatically if you chose the right rule. In the “Source” field, add your IP address, with a “/32″ (your CIDR) at the end – something like “000.00.00.00/32″.
- Click “Add Rule”, and then “Apply Rule Changes”. Done!
- Now, back in a local terminal, follow this tutorial from AWS to get things working in your MySQL monitor. Just replace text where necessary, and it should work right away. Let me know if you have problems.
- If you are using MySQL Workbench, it’s pretty much the same thing as Step 10. Fire up the program, click “New Connection”, and fill in the appropriate details. The hostname is your RDS DB Instance endpoint (you’ll see it at the top of the drop-down in Step 3), port is 3306, and you should know your own username and password – feel free to tell me though, I promise not to do anything mean . Done!
That’s it, everything should work as planned now. The only thing I have yet to figure out is what happens when my public IP address changes. I’m not a sys-admin in any way, so I’m new to all this stuff. I’ll find out, and update this post at some point. But if anyone knows, please let me know also!