1

I need to check if the Redshift cluster is paused or available using Python. I am aware of the module boto3 which further provides a method describe_clusters(). I am not sure how to proceed further to write a Python script for that.

1 Answer 1

3

You could try

    import boto3
    import pandas as pd

    DWH_CLUSTER_IDENTIFIER = 'Your clusterId'
    KEY='Your AWS Key'
    SECRET='Your AWS Secret'
    
    # Get client to connect redshift
    redshift = boto3.client('redshift',
                           region_name="us-east-1",
                           aws_access_key_id=KEY,
                           aws_secret_access_key=SECRET
                           )
   
    # Get cluster list as it is in AWS console
    myClusters = redshift.describe_clusters()['Clusters']
    
    if len(myClusters) > 0:
        df = pd.DataFrame(myClusters)
        myCluster=df[df.ClusterIdentifier==DWH_CLUSTER_IDENTIFIER.lower()]
        
        print("My cluster status is: {}".format(myCluster['ClusterAvailabilityStatus'].item()))
    else:
        print('No clusters available')
Sign up to request clarification or add additional context in comments.

1 Comment

Please add some explanation to your answer such that others can learn from it

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.