Skip to content

Instantly share code, notes, and snippets.

@pigeonflight
Last active July 11, 2019 12:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pigeonflight/ebdae7cb1835608598205ae2c503729b to your computer and use it in GitHub Desktop.
Save pigeonflight/ebdae7cb1835608598205ae2c503729b to your computer and use it in GitHub Desktop.
AWS CLI simple cluster management scripts

Installation

Download these scripts.

wget https://gist.github.com/pigeonflight/ebdae7cb1835608598205ae2c503729b/archive/cdca2598c2a664c765dc08f8befd14890b872289.zip

Setup

You will need to install awscli and jq and setup aws your credentials

sudo apt-get install jq
pip3 install awscli --user

Usage

List all clusters:

bash scripts/db-clusters-list.sh

Start a cluster:

bash scripts/db-cluster-start.sh <cluster-name>

Stop a cluster:

bash scripts/db-cluster-stop.sh <cluster-name>

Check the status of any cluster:

bash scripts/db-cluster-status.sh <cluster-name>
#!/bin/bash
aws rds start-db-cluster --db-cluster-identifier $1
if [ $? -eq 0 ]; then
echo OK
echo "------ attempting to start $1"
else
echo FAIL
echo "Not in the 'available' state"
fi
aws rds describe-db-clusters --db-cluster-identifier $1 | jq '.DBClusters[0]["Status"]'
#!/bin/bash
aws rds describe-db-clusters --db-cluster-identifier $1 | jq '.DBClusters[0]["Status"]'
#!/bin/bash
aws rds stop-db-cluster --db-cluster-identifier $1
if [ $? -eq 0 ]; then
echo OK
echo "------ attempting to stop $1"
else
echo FAIL
echo "Not in the 'available' state"
fi
aws rds describe-db-clusters --db-cluster-identifier $1 | jq '.DBClusters[0]["Status"]'
aws rds describe-db-clusters | jq '.DBClusters[] | .DBClusterIdentifier + " [" + .Status + "]"'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment