Table of contents
- What is AWS Relational Database Service or RDS?
- Why use AWS RDS?
- Task-01:
- <mark>Before Creating RDS Instance let's create an EC2 Instance which we will use to connect to our RDS Instance.</mark>
- <mark>Create a Free tier RDS instance of MySQL.</mark>
- <mark>Assign the role to EC2 so that your EC2 Instance can connect with RDS Instance.</mark>
- <mark>Once the RDS instance is up and running, get the credentials and connect your EC2 instance using a MySQL client.</mark>
- Happy Learning :)
Today I have covered,
What is AWS Relational Database Service or RDS?
Why should we use RDS?
How to Connect RDS to an EC2 Instance?
What is AWS Relational Database Service or RDS?
AWS RDS (Amazon Relational Database Service)
is acloud-based service
provided by Amazon Web Services which simplifies the process of setting up, operating, and scaling relational databases. It is designed to make it easier for developers to managedatabases
without the need to worry about theunderlying infrastructure
.In simple terms,
AWS RDS
allows you tocreate
andmanage databases
in the cloud without having toset up
andmaintain your own database servers
. It supports popular relational database engines likeMySQL
,PostgreSQL
,Oracle
,SQL Server
, andMariaDB
.With AWS RDS, you can perform tasks such as creating a
new database instance
,scaling your database to handle increased traffic
, andautomating backups
. It handles many administrative tasks for you, such as software patching, database backups, and system maintenance, so you can focus more on building your applications.AWS RDS offers features like automated backups, which can be scheduled to occur at regular intervals, and you can
restore your database
to any point in time within the backup retention period. It also provideshigh availability
andfault tolerance
by automatically replicating your database across multiple availability zones, ensuring that your data is safe and accessible even if one zone fails.Furthermore, AWS RDS allows you to
easily scale your database
resources up or down based on your application's needs. This means you can increase the processing power, memory, or storage capacity of your database instance as your application demands grow, without significant downtime or manual intervention.
Why use AWS RDS?
AWS RDS is a
fully managed service
thatsimplifies
theprocess
ofsetting up
,operating
, andscaling
relational databases. Iteliminates
theneed
toprovision
andmanage
your owndatabase servers
,install
andconfigure
database software, andperform
ongoingmaintenance
tasks such assoftware patching
,database backups
, andsystem maintenance
.
Task-01:
Before Creating RDS Instance let's create an EC2 Instance which we will use to connect to our RDS Instance.
Step-01: Go to AWS Console
>> Services
>> EC2
.
Step-02: Click on Launch Instance
.
Step-03: Give a Name to your Instance and Select Ubuntu and it Version
.
Step-04: Select t2.micro
as your Instance Type
and also key pair
.
Step-05: Click on Review and Launch
and check dashboard for your instance.
Create a Free tier RDS instance of MySQL.
- Step-01: Go to
AWS Console
>>Services
>>RDS
.
- Step-02: Click on
Create database
.
- Step-03: Select
MySQL
as theDatabase creation method
.
- Step-04: Select Engine Version and then Select
Free tier
inTemplates
.
- Step-05: Now we will set the
DB instance identifier
andMaster username
andMaster password
and make sure a
- Step-06: Instance Configuration >>
Burstable classes
>>db.t3.micro
.
- Step-07:
Connectivity
with yourEC2 instance
which we created previously forRDS connection
.
- Step-08: Add the VPC security group (launch-wizard-23) which we will configure in the EC2 instance of the Security group >> Edit inbound rules.
- Step-09: Thus we have created a RDS instance.
Assign the role to EC2 so that your EC2 Instance can connect with RDS Instance.
- Step-01: Go to
AWS Console
>>Services
>>IAM
>>Roles
>>Create Role
and also select EC2 as the service.
- Step-02: Add the
AmazonRDSFullAccess
policy to the role.
- Step-03: Give a name to the role and create the role and review it.
- Step-04: Now check whether the role is created or not.
- Step-05: Now go to
EC2
and select themInstance
and click onActions
>>Instance Settings
>>Modify IAM Role
.
- Step-06: Select the role which we created previously and click on
Save
.
Once the RDS instance is up and running, get the credentials and connect your EC2 instance using a MySQL client.
- Step-01: Go to
AWS Console
>>Services
>>RDS
>>Databases
>>Connectivity & security
>>Endpoint
.
- Step-02: Now Open the EC2 instance and install the MySQL client.
sudo apt-get install mysql-client
mysql --version
- Step-03: Now Let's configure the Security group of the EC2 instance to allow the inbound traffic from the RDS instance.
- Here we have configured the port MySQL (3306) and source as the security group of the RDS instance.
- Step-04: Now connect the RDS instance with the EC2 instance using the MySQL client.
mysql -h <endpoint-name> -P <port-name> -u <username> -p
- At last, verify your password and we are connected to MySQL.
Thus we have connected our Relational Database (MySql) to an EC2 instance using IAM roles.