Monday, April 28, 2025

AWS RDS Commands

 Here are some commonly used AWS RDS (Relational Database Service) commands using the AWS CLI, along with practical examples for each:


πŸ”§ 1. Create a New RDS Instance

aws rds create-db-instance \
--db-instance-identifier mydbinstance \ --db-instance-class db.t3.micro \ --engine mysql \ --master-username admin \ --master-user-password MySecurePassword123 \ --allocated-storage 20

πŸ“ Creates a MySQL RDS instance with 20GB of storage.


πŸ” 2. Describe RDS Instances


aws rds describe-db-instances

πŸ“ Lists all your RDS instances and their details.


πŸ›‘ 3. Stop an RDS Instance (only supported for certain instance types)

aws rds stop-db-instance \
--db-instance-identifier mydbinstance

πŸ“ Stops a running instance to save costs (only for non-multi-AZ).


▶️ 4. Start a Stopped RDS Instance


aws rds start-db-instance \ --db-instance-identifier mydbinstance

πŸ“ Starts an RDS instance previously stopped.


🚫 5. Delete an RDS Instance

aws rds delete-db-instance \
--db-instance-identifier mydbinstance \ --skip-final-snapshot

πŸ“ Deletes the RDS instance. Use --final-db-snapshot-identifier if you want a backup.


πŸ’Ύ 6. Create a Snapshot

aws rds create-db-snapshot \
--db-snapshot-identifier mydbsnapshot \ --db-instance-identifier mydbinstance

πŸ“ Creates a manual backup (snapshot) of your DB instance.


πŸ” 7. Restore from Snapshot

aws rds restore-db-instance-from-db-snapshot \
--db-instance-identifier restoredinstance \ --db-snapshot-identifier mydbsnapshot

πŸ“ Restores a new DB instance from a snapshot.


πŸ›‘️ 8. Modify DB Instance (e.g., instance class)

aws rds modify-db-instance \
--db-instance-identifier mydbinstance \ --db-instance-class db.t3.small \ --apply-immediately

πŸ“ Changes instance type and applies it immediately.


🌐 9. Create a Parameter Group

aws rds create-db-parameter-group \
--db-parameter-group-name myparamgroup \ --db-parameter-group-family mysql8.0 \ --description "My custom params"

πŸ“ Used to customize DB settings, like enabling slow query logs.


πŸ“„ 10. List Snapshots

aws rds describe-db-snapshots

πŸ“ Displays available snapshots you can restore from.