Last active
November 13, 2018 05:16
-
-
Save thilinapiy/f95533d4643e21985d06352759fff3d3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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