Python program to list the details of all the redshift clusters across all regions.
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
__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) |
is there any method to get the redshift supported regions ??
As far as I know, currently there is no official API from AWS that provides this information. The details of supported regions are mentioned in the documentation, but not exposed through an API