Let's connect VS Code with RDS for MySQL

What is Amazon Relational Database Service (RDS)?
Amazon Relational Database Service (Amazon RDS) is a web service that makes it easier to set up, operate, and scale a relational database in the AWS Cloud. It provides cost-efficient, resizable capacity for an industry-standard relational database and manages common database administration tasks.
LAB: Connect VS Code with Amazon RDS
In this lab, we are going to create a basic database in RDS to understand how to establish the connection between the RDS database and VS Code. So that we can access the database created in RDS and use it from VS Code text editor.
Step 1: Create a Database in RDS
Search RDS and Select it

Then Click on Create database and config as the information given:
Choose a database creation method:
StandardEngine option:
MySQLTemplates:
Free tierSettings:
DB instance identifier:
demo-dbCredentials Settings > Master Username:
adminCredentials Settings > Master password:
**********Credentials Settings > Confirm master password:
**********
Storage:
Storage type:
General Purpose SSD(gp2)Storage autoscaling: you can uncheck
Enable storage autoscaling
Connectivity:
Compute resource:
Don’t connect to an EC2 compute resourceVirtual private cloud (VPC):
Default VPC{ Note: If you don't have Default VPC and don't know how to create VPC you can learn from my Here and comment if any doubt. }
Public access:
YesVPC security group (firewall): Leave
defaultAvailability Zone:
You can choose any
Database authentication: Check
Password authenticationMonitoring:
UncheckedAdditional configuration:
Initial database name:
demoBackup: Uncheck
enable automated backupsEncryption: Uncheck
Enable encryption
Leave all Default and Create database
After sometime when
Statusof databasemodifyingorAvailableclick on
demo-bd-> Scroll down inConnectivity & SecurityFor future use Copy
Endpointmarked as:
Step 2: Update VPC Default Security group as:
Search VPC and Select it
Scroll the left-side-bar and select the
security groupsClick on the Security group ID which has the Security group name:
defaultClick on
Edit inbound rulesClick
Add ruleType:
MYSQL/AuroraSource:
Anywhere-IPv4i.e.0.0.0.0/0(- If you created a new security group add this rule as inbound as well )
Save rules
Step 3: Work with VS Code
Install VS Code
Download following extensions
Create any directory or folder on your computer
open the folder and right click

Click on Open in Terminal and type the following command to open that folder in VS Code directly
code .Click on
SQLToolssymbol
Also, click on
Add New Connection
Select
MySQLand fill as:
Click on
TEST CONNECTIONenter the password you set above while creating RDSYou should get
Successfully connected!message
Now Click on SAVE CONNECTION -> CONNECT NOW
CONGRATULATIONS YOU HAVE SUCCESSFULLY CONNECTED WITH RDS
Now you can do any SQL query and run on VS Code...




