How To Connect a Private Amazon RDS DB To Local Machine

Posted By : Aman Saini | 29-Sep-2021

AWS

Loading...


Steps To Connect

  • Launch and configure your EC2 instance and configure the instance's network settings.
  • Configure the security groups of the RDS DB instance.
  • Connect to Amazon Relational Database [ SERVICES] DB instance from your LM ( local machine).
  • To connect to a private Amazon RDS or Amazon Aurora Database instance, it is best to use a VPN or AWS [Amazon web services] Direct Connect. If you can't use a VPN or Direct Connect, use a strong host.
  • Configuration restricts access using the security groups, but you can also restrict a subnet's network access control list (network ACL) to make the connection more secure. You can restrict the Internet gateway routes scope to use a smaller range instead of 0.0.0.0/0.

For example: When you add an Internet gateway, you can add only the required CIDR range to the routing table for the destination, see Example routing options and use for another IP to create EC2 Instance and allow all privileges conditions or also allow to PORTS.


configuration is for an RDS MYSQL Database Management System instance that is in a Virtual Private Cloud System and has security groups set up for the EC-2 instances.

configure and Launch Amazon EC-2 instance

Open Amazon EC2 Console, and select Launch Instance.

Select an (AMI) Amazon Machine Image

Choose instance type, select Next: click Configure Instance Details.

For Network, select the [Amazon Virtual Private Cloud] VPC that the RDS DB instance uses.

  • Select the option subnet that has an Internet gateway in its table routing. If you don't already have an Internet gateway, you can add it to the SUBNET once the EC-2 instance is created.
  • Select Next: Add storage, and modify storage as needed.
  • Select Next: Add Tags, and add tags as needed.
  • Select Next: Configure Security Group, select Add Rule, and enter the following:
    • Type: Custom TCP Rules
    • Protocol: TCP
    • Port Range: 22
    • Enter the IP [Internet-Protocol] address of your local machine. source IP is open to all. But only you can restrict access to the only local IP addresses.
    • Select Review and Launch.
    • Click the launch button
    • Configure-security groups of RDS Database instances
  • Open the Amazon RDS console and select Databases from the navigation pane.
  • Select the name of the RDS DB instance. Create RDS instance
  • Select the Connectivity and Security tab.
  • From the Security section, select the link under VPC Security Groups.
  • Select the options of a security group, choose Actions hn you are using, and select the Edit-Inbound Rules option.
  • Select Add Rule and enter the following:
    • Type: Custom TCP Rules
    • Protocol: TCP
    • Port Range: Enter the port-number of your RDS Database instance
    • Source: Enter the Secure private IP of your EC-2 instance
    • click to save button

This configuration for the security group allows traffic from the private IP address of the EC2 instance. If the EC2 instance and the RDS DB instance use the same VPC, you do not need to modify the route tables used by the RDS DB instance. If the VPC is different, create a VPC peering connection to allow connections between those VPCs.

Connect to RDS DB Instance from your local machine

The steps to connect to an RDS DB instance differ depending on the client you use.

Example: uses the Workbench(MYSQL) client to connect to the host:

Start a new connection, and choose Standard TCP/IP over SSH for the connection method.

  • Enter details about the EC-2 for SSH [Secure Shell is a network communication protocol] settings:
  • SSH hostname: Using the public DNS name of the EC-2 instance.
  • SSH Username: Fill out the username for your EC2 instance Name. For example, "ec2-user LINUX MACHINE"
  • SSH Key File: Select the private key that was used when creating the EC2 instance.

MySQL instance settings Details:

  • MySQL Hostname: Enter RDS DB Instance Endpoint
  • Enter MySQL Server Port: 3306
  • Username: username of the RDS DB instance.
  • Password: password of the RDS DB instance.
  • Finally Test Connection.
  • After the connection is successful
  • Type the name of the connection and save the connection LM.

We are an ERP development company that offers complete enterprise software solutions for diverse business applications and use-cases. Our development team specializes in using the latest tech stack and next-gen to build scalable business solutions. To learn more about our custom ERP development services, contact us at [email protected].