To manage your RDS instances using the CLI (Command Line Interface), you will need:
- to download the RDSCli.zip file here...
- know your AWS credentials...
- ensure that Java version 1.6 or higher is installed...
Once you have downloaded the zip file, unzip the contents :
oracle 11g Test: unzip RDSCli.zip
oracle 11g Test: pwd
/home/oracle/rds
oracle 11g Test: cd RDSCli-1.14.001
oracle 11g Test: pwd
/home/oracle/rds/RDSCli-1.14.001
oracle 11g Test: ls -l
total 132
drwxr-xr-x. 2 oracle oinstall 12288 May 16 2013 bin
-rw-r--r--. 1 oracle oinstall 206 May 15 2013 credential-file-path.template
drwxr-xr-x. 2 oracle oinstall 4096 May 16 2013 lib
-rw-r--r--. 1 oracle oinstall 5111 May 15 2013 license.txt
-rw-r--r--. 1 oracle oinstall 1813 May 15 2013 notice.txt
-rw-r--r--. 1 oracle oinstall 2651 May 15 2013 README.TXT
-rw-r--r--. 1 oracle oinstall 11445 May 15 2013 RELEASENOTES.TXT
-rw-r--r--. 1 oracle oinstall 83461 May 15 2013 THIRDPARTYLICENSE.TXT
Then create you environment file:
oracle 11g Test: vi set_cli.env
export JAVA_HOME=/usr/java/jre1.7.0_15
export AWS_RDS_HOME=/home/oracle/rds/RDSCli-1.14.001
export AWS_ACCESS_KEY=AKI******************
export AWS_SECRET_KEY=Ttq***************************
export PATH=$PATH:$AWS_RDS_HOME/bin:/home/oracle/cli_tools/scripts
export PS1="`id -un` AWS CLI: "
Set your environment up:
oracle 11g Test: chmod u+x set_cli.env
oracle 11g Test: . ./set_cli.env
There are a list of standard scripts, i.e
oracle AWS CLI: cd /home/oracle/rds/RDSCli-1.14.001/bin
oracle AWS CLI: rds-describe-db-instances
DBINSTANCE dbtest 2014-01-15T14:39:45.708Z db.m1.small oracle-ee 10 awsuser available dbtest.********************.rds.amazonaws.com 1521 eu-west-1b 1 n 11.2.0.3.v1
bring-your-own-license AL32UTF8 n
VPCSECGROUP sg-******* active
PARAMGRP default.oracle-ee-11.2 in-sync
SUBNETGROUP tvpc Complete
OPTIONGROUP default in-sync
However, it is probably best to create your own using the standard scripts so you can format the output:
oracle AWS CLI: ./list_rds_instances
Instance Name Created Class Engine GB IOPS Port Avail-Zone DB-Name Version Auto License-status Char-set Pub
------------------ ---------- ------------- ---------- ----- ----- ---- ---------- -------- ----------- ---- ---------------- -------- ------
dbtest 2014-01-15 db.m1.small oracle-ee 10 (nil) 1521 eu-west-1b MYRDSDB 11.2.0.3.v1 n bring-your-own-license AL32UTF8 n
You can then combine these to create you own "clone" script:
. /home/oracle/rds/RDSCli-1.14.001/set_cli.env
NEW_INSTANCE=new_db
## Delete the existing RDS instance to be replaced.
rds-delete-db-instance $NEW_INSTANCE --force --skip-final-snapshot
echo "Deleting instance $NEW_INSTANCE - this takes a few minutes"
DONE="false"
while [ "$DONE" = "false" ]
do
STATUS=`rds-describe-db-instances $NEW_INSTANCE --show-long | grep DBINSTANCE | cut -f 9 -d ,`
if [ "$STATUS" = "" ]; then
DONE="true"
else
echo "Waiting...$STATUS"
sleep 30
fi
done
echo "$NEW_INSTANCE Has Been Terminated"
sleep 10
## Take a snapshot of existing db to clone
rds-create-db-snapshot old_db -s old_db-snap
## wait for completion status
wait_for_status snapshot old_db-snap available
sleep 10
## Create new RDS instance from snapshot
rds-restore-db-instance-from-db-snapshot $NEW_INSTANCE -s old_db-snap -e oracle-se1 -lm license-included -c db.m1.large -z eu-west-1b -n NEWDB -p 1521 -m false -pub false -au false -sn vpct -og default:oracle-se1-11-2
## Wait for completion status
wait_for_status instance $NEW_INSTANCE available
## Delete the snapshot taken earlier
rds-delete-db-snapshot old_db-snap -f
sleep 10
## Wait for completion status
wait_for_status snapshot old_db-snap nonexistent
sleep 10
## Modify new instance for security groups and backup retention
rds-modify-db-instance $NEW_INSTANCE -sg sg-******* --backup-retention-period 0 --apply-immediately
sleep 10
## Wait for completion status
wait_for_status instance $NEW_INSTANCE available
## DB Creation Finished
echo "Creation of $NEW_INSTANCE finished"
sleep 10