Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@amalgjose
Created October 11, 2015 05:45
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 amalgjose/a60f9614cc48c5fe4264 to your computer and use it in GitHub Desktop.
Save amalgjose/a60f9614cc48c5fe4264 to your computer and use it in GitHub Desktop.
Program to list all the redshift clusters across all regions.
__author__ = 'Amal G Jose'
import boto
class GetRedShiftDetails(object):
def __init__(self):
self.aws_access_key = "XXXXXXXX"
self.aws_secret_key = "XXXXXXXX"
##Method for getting the details of RedShift Clusters
def get_redshift(self, region):
try:
host_name = 'redshift.' + region + '.amazonaws.com'
redshift_conn = boto.connect_redshift(aws_access_key_id=self.aws_access_key,
aws_secret_access_key=self.aws_secret_key,
region=region,
host=host_name)
clusters = redshift_conn.describe_clusters()
cluster_details = clusters['DescribeClustersResponse']['DescribeClustersResult']['Clusters']
for cluster in cluster_details:
print cluster['ClusterIdentifier'], str(cluster['NumberOfNodes']), cluster['NodeType'], region
except Exception, e:
print "Exception occurred while reading redshift cluster details " + str(e)
if __name__== '__main__':
regions = ['ap-southeast-1', 'ap-southeast-2', 'ap-northeast-1',
'us-east-1','us-west-1', 'us-west-2','eu-west-1', 'sa-east-1']
get_details = GetRedShiftDetails()
for region in regions:
get_details.get_redshift(region)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment