Relational Database Service in AWS

Relational Database Service in AWS

ยท

7 min read

Introduction

In this blog post, we delved into the powerful capabilities of Amazon Relational Database Service (Amazon RDS) - a fully managed database solution by AWS. This marks the 44th day of our 90DaysOfDevOps journey. We embarked on a journey to create a free-tier MySQL RDS instance. Additionally, we seamlessly integrated an EC2 instance with RDS, paving the way for a secure and efficient connection.

AWS-Relational Database Service

Amazon Relational Database Service (Amazon RDS) is a fully-managed database service provided by Amazon Web Services (AWS). It simplifies the process of setting up, operating, and scaling relational databases in the cloud. Amazon RDS supports several popular database engines, including:

  1. MySQL

  2. PostgreSQL

  3. MariaDB

  4. Oracle Database

  5. Microsoft SQL Server

  6. Amazon Aurora (which is a MySQL- and PostgreSQL-compatible database built for the cloud)

Key Features:

  1. Automated Backups: RDS automatically backs up your database and retains backups for a user-defined period. This ensures data durability and provides a point-in-time recovery option.

  2. High Availability: RDS offers Multi-AZ deployments for high availability. In a Multi-AZ configuration, the database is automatically replicated in a different Availability Zone to provide fault tolerance.

  3. Scalability: You can easily scale your database instance up or down based on your application's requirements.

  4. Security: RDS offers features like network isolation, encryption at rest, and in-transit, as well as automated software patching to enhance the security of your databases.

  5. Automated Software Patching: RDS manages database engine updates, including backups and automated failover, to help maintain the health of your database.

  6. Affordable: Paying for the consumed resources is enough in the case of Amazon Relation Database Services. There are no long term commitments or up-front charges and, therefore, one of the cost- effective services.

Tasks: Setting Up MySQL RDS and EC2 Connectivity :)

Task 1: Create a Free tier RDS instance of MySQL

Step 1: Log in to your AWS Management Console.

Step 2: Navigate to the RDS service.

Step 3: Click on "Create database".

Step 4: Select "MySQL" as the database engine.

Step 5: Choose "Free Tier" in the "Templates" section.

Step 6: Configure other settings (DB instance size, storage, instance identifier, master username, password, additional configuration ).

  • Setting > DB instance identifier

  • Setting > credential

  • Instance configuration

    I selected t2.micro for free tier

  • Storage

    20GB storage are freely available for the free tier.

  • Connectivity > public access

    Under connectivity, VPC (Virtual Private Cloud) concept are there. For now make the vpc as default and

    I gave the public access so that i can access the RDS from the anywhere

  • Additional configuration

    Note: If you do not specify a database name, Amazon RDS does not create a database.

Step 7: Click "Create database".

Note: The creation of the RDS instance may take more than 5 minutes, and sometimes even up to 10 minutes. Please be patient and allow AWS the necessary time for the successful setup of the RDS instance.

Step 8: Congratulation

You successfully created your first RDS

Task 2: Create an EC2 instance

  1. Log in to your AWS Management Console.

  2. Navigate to the EC2 service.

  3. Click on "Launch Instance" to start the instance creation process.

  4. Choose an Amazon Machine Image (AMI) based on your requirements (e.g., Amazon Linux 2).

  5. Select an instance type (e.g., t2.micro, which is part of the free tier).

  6. Configure the instance details (e.g., number of instances, network settings, etc.)

  7. Configure security groups to control inbound and outbound traffic (you'll need to allow traffic on port 22 for SSH access).

  8. Review the instance details and click "Launch."

  9. Choose an existing key pair or create a new one for SSH access.

  10. Finally, click "Launch Instances

For more detailed information on AWS EC2 and account setup, you can refer to this comprehensive guide:

Task 3: Create an IAM role with RDS access

  1. Sign in to the AWS Management Console:

    • Go to the AWS Management Console and sign in with your AWS account credentials.
  2. Open the IAM Console:

    • Navigate to the IAM service.

  3. Create a New Role:

    • Click on "Roles" in the left-hand menu and then click on the "Create role" button.

  4. Choose the Trusted Entity:

    • Select "AWS service" as the trusted entity.

    • Select EC2 and then click "next"

  5. Attach Policies:

    • In the "Permissions" step, search for policies that provide access to RDS resources. You can either select existing policies like AmazonRDSfullAccess or create a custom policy.

    • click Next

  6. Name the Role:

    • Provide a name for the role, e.g., RDSAccessRole, and optionally provide a description.

  7. Review:

    • Review the settings and policies you've selected. If everything looks correct, click "Create role."
  8. Successfully created

Task 4: Assign the role to EC2 so that your EC2 Instance can connect with RDS

  1. Open the EC2 Console

    • Sign in to the AWS Management Console, go to the EC2 service.

  2. Locate the EC2 Instance

    • Find the EC2 instance that you want to assign the IAM role to.

      I newly ceated the instance named "my-db-demo"

  3. Stop the Instance (if necessary)

    • If the instance is running, you might need to stop it to modify its configuration. Right-click on the instance, select "Instance State", and then click "Stop".

  4. Associate IAM Role

    • Select the EC2 instance in the console.

    • Click on "Actions" and go to "security".

    • Click on "Modify IAM Role".

  5. Choose the IAM Role

    • In the "Attach/Replace IAM Role" dialog box, select the role you created earlier (e.g., RDSAccessRole).

    • Click "update IAM role" to attach the role.

  6. Start the Instance (if it was stopped)

    • If you stopped the instance, right-click on it, select "Instance State", and then click "Start".

Task 5: Once the RDS instance is up and running, get the credentials and connect your EC2 instance using a MySQL client.

  1. SSH into EC2: Use the SSH command to connect to your EC2 instance. Replace <your-key.pem> and <your-ec2-instance-ip> with your actual key file and EC2 instance IP:

     ssh -i <your-key.pem> ec2-user@<your-ec2-instance-ip>
    

  2. Install MySQL Client: Update package information and install the MySQL client:

     sudo apt-get update
     sudo apt-get install mysql-client
    

  3. Check MySQL Version: Verify that the MySQL client is installed correctly:

     mysql --version
    

  4. Connect to RDS: Use the MySQL client to connect to your RDS instance.

    Replace <RDS-endpoint>, <port>, <username>, and <password> with your actual RDS endpoint, port, username, and password:

    • RDs-endpoint

    • port is 3306

    • username and password were created above when creating the RDS

    mysql -h <RDS-endpoint> -P <port> -u <username> -p

  1. Congrulation

    You successfully connected EC2 with the MySQL RDS

Conclusion :)

With each step, we achieved significant milestones in setting up a robust AWS environment. We successfully created a free-tier MySQL RDS instance, forged an EC2 instance, and established a secure bridge between them. This accomplishment not only expands our capabilities in cloud computing but also lays a strong foundation for future endeavours in AWS services.


Thank you for diving into this blog with me! I trust you found the information both helpful and enlightening. To stay updated on the latest in DevOps ๐Ÿš€, make sure to follow me. Remember, staying informed means staying ahead in the dynamic world of DevOps!

Feel free to connect with me on:

LinkedIn

Twitter

GitHub

For more updates and engaging discussions on DevOps, let's connect! ๐Ÿš€ #DevOpsCommunity

Happy Learning! Keep pushing those boundaries! ๐Ÿ˜Š

ย