Skip to content

Instantly share code, notes, and snippets.

@thilinapiy
Last active November 13, 2018 05:16
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 thilinapiy/f95533d4643e21985d06352759fff3d3 to your computer and use it in GitHub Desktop.
Save thilinapiy/f95533d4643e21985d06352759fff3d3 to your computer and use it in GitHub Desktop.
import boto3
ClusterID = "db-cluster"
session = boto3.Session(
region_name='ap-southeast-2',
aws_access_key_id='',
aws_secret_access_key='',
)
rds = session.client('rds')
response = rds.describe_db_clusters(DBClusterIdentifier=ClusterID)
for cluster in response['DBClusters']:
status = cluster['Status']
print("%s is %s" % (ClusterID , status))
if status == 'available':
print("shutting down cluster: %s" % ClusterID)
rds.stop_db_cluster(DBClusterIdentifier=ClusterID)
elif status == 'stopped':
print("starting up cluster: %s" % ClusterID)
rds.start_db_cluster(DBClusterIdentifier=ClusterID)
else:
print("Cluster is in " + status + " status!")
print("Try again later ...!")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment