Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.