![]() |
As we know, Amazon Web Services (AWS) provides more than 200 IT and infrastructure management services. The question arises: can we only access and manage those services through the AWS Management Console? The answer is no. We can access and interact with those services through the AWS Management Console, which is a web-based interface, the AWS Command Line Interface (AWS CLI), which is used through a terminal; and the AWS SDK (AWS Software Development Kit), which is basically used in applications. Here we are deep diving into the AWS CLI and exploring how it interacts with the AWS RDS. Here, RDS supports various popular database engines such as MySQL, PostgreSQL, MariaDB, Oracle, and Microsoft SQL Server. A basic understanding of best practices that enhance your skill to use AWS CLI with RDS to automate database tasks, manage resources, and integrate RDS with other resources in an efficient manner. Primary Terminologies
Step-by-Step Guide for Relational Database Service using AWS CLIBefore starting, Make sure that you have an have AWS Account with needed permission to manage RDS resources and AWS CLI installed and configured on your system. Step 1: Configuring AWS CLI
aws configure
After that you enter some necessary information such as,
![]() IAM PermissionIf you want to manage the RDS resources using AWS CLI, first check that the IAM user or role has the following permissions:
Creating and attaching custom IAM Policyaws iam create-policy \ Attach the policy to your IAM user or role: aws iam attach-user-policy Step 2: Creating a DB InstanceTo create a new DB instance, use the following command: aws rds create-db-instance Above command will create a MySQL DB instance named ‘mydbinstance‘ with the specified instance class, storage, and credentials. You can check the result in the AWS Command Line interface by using the command given above. ![]() You can check the result in the AWS Management Console by using the command given above. ![]() Step 3: Modifying a DB InstanceTo modify an existing DB instance, such as changing the allocated storage, use the following command: aws rds modify-db-instance This command increases the storage size of ‘mydbinstance‘ to 30 GiB. You can check the result in the AWS Command Line interface by using the command given above. ![]() You can check the result in the AWS Management Console by using the command given above. ![]() Step 4: Creating a DB SnapshotTo create a snapshot of your DB instance, use the following command: aws rds create-db-snapshot This command creates a snapshot named ‘mydbsnapshot’. Note: When you write this command, that time snapshot will be created automatically, but in the terminal, there is no output data until you restore a DB instance from a snapshot. You can check the result in the AWS Management Console by using the command given above. ![]() Step 5: Restoring a DB Instance from a SnapshotHere we are restoring DB instance from a snapshot, use the following command: aws rds restore-db-instance-from-db-snapshot Above command through we can create a new DB instance ‘mynewdbinstance‘ from existing ‘mydbsnapshot‘ snapshot. You can check the result in the AWS Command Line interface by using the command given above. ![]() You can check the result in the AWS Management Console by using the command given above. ![]() Step 6: Finally Deleting a DB InstanceTo delete a DB instance, use the following command: aws rds delete-db-instance This command deletes ‘mydbinstance’ without creating a final snapshot. To delete a DB instance that was created through a snapshot, use the following command: aws rds delete-db-instance This command deletes ‘mynewdbinstance‘ without creating a final snapshot. You can check the result in the AWS Command Line interface by using the command given above. Picture 5.1: That shows when you delete ‘mydbinstance’ instance. ![]() Picture 5.1 Picture 5.2: That shows when you delete ‘mynewdbinstance’ instance. ![]() Picture 5.2 You can check the result in the AWS Management Console by using the command given above. Picture 5.1: That shows when you delete ‘mydbinstance‘ instance. ![]() Picture 5.1 Picture 5.2: That shows when you delete ‘mynewdbinstance‘ instance. ![]() Picture 5.2 Picture 5.3: That shows finally all the instances are deleted, Nothing any instance here. ![]() Picture 5.3 ConclusionThe AWS CLI is a powerful tool for managing AWS services, including Amazon RDS, that enables high-performance deployment and scripting of database services. With the necessary IAM permissions, you can create, modify, copy, restore, and delete RDS instances with simple commands, saving time and reducing human error. This approach optimizes resource management, ensures scalability and cost effectiveness in your cloud infrastructure deployment. AWS CLI for AWS RDS – FAQsWhy we are using AWS CLI ?
Why we are using AWS RDS?
How much charge AWS CLI takes?
How much charge AWS RDS takes?
If we stop the AWS RDS service, will there be any charges?
|
Reffered: https://www.geeksforgeeks.org
Amazon Web Services |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 17 |