Understanding AWS RDS: A Beginner's Guide

Understanding AWS RDS: A Beginner's Guide

In today's digital age, data is at the heart of every business operation. Whether you run a small blog or a large enterprise, managing your data efficiently is crucial. This is where AWS RDS (Amazon Relational Database Service) comes into play. In this beginner's guide, we'll explore what AWS RDS is and why it's an essential tool for anyone dealing with data.

What is AWS RDS?

AWS RDS is a fully-managed relational database service provided by Amazon Web Services (AWS). But what does that mean exactly? Let's break it down.

Relational Database

A relational database is a type of database that stores and organizes data in a structured way, using tables with rows and columns. This makes it easy to establish relationships between different pieces of information.

Fully-Managed

The term "fully-managed" is key here. With AWS RDS, you don't need to worry about the nitty-gritty details of setting up, maintaining, and securing a database. AWS handles all the heavy lifting for you, allowing you to focus on using the data rather than managing the infrastructure.

Why Use AWS RDS?

Now that we have a basic understanding of what AWS RDS is, let's explore why it's beneficial for both tech and non-tech individuals.

1. Ease of Use

AWS RDS makes database management accessible to everyone, regardless of technical expertise. Setting up a database instance is as simple as a few clicks in the AWS Management Console.

2. Automatic Backups and Updates

Imagine never having to worry about backing up your data or updating your database software. AWS RDS takes care of this automatically, ensuring that your data is secure and your database software is up to date.

3. Scalability

As your business grows, so does your data. AWS RDS allows you to easily scale your database resources to accommodate increased demand without disrupting your operations.

4. Security

Data security is a top priority, and AWS RDS provides several layers of security, including encryption, network isolation, and regular security patches. Your data is in safe hands.

How to Get Started with AWS RDS

Let's do a project on this -

Project: Setting Up AWS RDS, Connecting with EC2, and Performing Database Operations

If you're ready to dip your toes into AWS RDS, here's a quick step-by-step guide:

1. Sign Up for AWS

If you don't have an AWS account, you'll need to sign up. Go to the AWS website, click on "Create an AWS Account," and follow the instructions.

2. Access AWS Management Console

Once your account is set up, log in to the AWS Management Console.

3. Navigate to RDS

In the console, find the "Services" dropdown and select "RDS" under the "Database" section.

Click on "RDS".

4. Create a Database Instance

Click the "Create Database" button, and the wizard will guide you through the process. You'll need to choose a database engine, specify settings, and set up security measures.

Click on "Create database".

Select Database Engine: MySQL as the Database Engine for RDS.

Configure Database Settings: In the settings options, name your database and configure credentials in the "Credentials settings" option.

In the Instance configuration option, choose your preferred instance class; for this project, we are using the default class.

Configure Storage: In the "Storage" section, opt for 20GB of space.

Configure Connectivity: In the connectivity option, leave all options at default, including the choice not to connect any specific EC2 instance with your DB.

Configure Public Access: In the "Public access" section, select "NO" to restrict public internet access to your DB.

In the "Database authentication" option, choose "Password authentication" and keep all options unchanged.

Review the estimated monthly costs of your DB instance.

Click on "Create database".

Database creation is in progress; please allow some time for completion.

Congratulations! Our first RDS DB has been created successfully.

5. Create an EC2 instance to connect to our RDS DB and log in to the EC2 instance.

Log in to your EC2 instance (Ubuntu in our project).

Check if the MySQL client package is installed or not.

If not, install the mysql-client package.

Check after the installation.

It means the MySQL client is installed, and no DB instance is running locally on my EC2 instance.

6. Create a Role for accessing RDS from EC2

Go to IAM dashbaord.

Click on "Roles".

Click on "Create role".

Select the trusted entity as "AWS service" since we are creating a role for AWS service, and in the use case, we are selecting EC2.

Scroll down and click on "Next".

Select the policies for RDS full access and CloudWatch that you want to associate with EC2.

Give a name to your role and review it.

Click on "Create role".

Congratulations, our role has been successfully created!

It's time to assign this role to our EC2 instance.

Go to EC2 and select your instance.

Go to Actions -> Security -> Modify IAM role (Click on this)

Now modify the IAM role for our EC2 instance. Select the IAM role.

Click on "Update IAM role".

7. Configuring the EC2 instance with our RDS database.

Go to the Amazon RDS dashboard and select "Databases."

Our database is in an available state. Click on the database that we created. We will be directed to the following screen:

In the "Connectivity & security" tab, copy the Endpoint value (e.g., my-database.ciztdzgq76lk.us-east-2.rds.amazonaws.com) as this is required to connect to the RDS DB from EC2. Scroll down and look for "Connected compute resources."

Click on "Set up EC2 connection".

Select your EC2 instance and continue.

On the next page, it shows that a private network has been created between the EC2 instance and the RDS database.

Review everything and click on "Set up."

8. Connect to your DB instance from EC2

Login to the EC2 instance and run the below command -

mysql -u admin -h my-database.ciztdzgq76lk.us-east-2.rds.amazonaws.com -P 3306 -p

In the above command, we are connecting with the MySQL client using the user (-u) 'admin' to the host (-h) with our endpoint value that we copied. The option (-P) is for the port, which is set to 3306, and (-p) is for entering the DB password. Enter your database password when prompted.Hurray!! we successfully connected with our RDS database from our EC2 instance.

Let's list the databases in our RDS database.

Let's create a database named 'aws,' create a table, and perform some insertions.

There are no entries present in your database. Let's add some entries.

And we have performed some insertions in our table in our database.

Let's perform some deletions as well.

Whoa! We have successfully deleted the entries from our table.

We have successfully created an RDS DB, connected it to an EC2 instance, and performed various MySQL operations.

Congratulations! You've just set up a fully-managed relational database with AWS RDS.

Conclusion

AWS RDS is a game-changer for anyone looking to manage data without the hassle of database administration. Its user-friendly interface, automatic features, and robust security make it an ideal choice for beginners and seasoned professionals alike. So, whether you're running a personal blog or a thriving business, AWS RDS has got your data management needs covered.

Happy data managing!