2

I want a list of clusters using Python (boto3). I did some research and found this command in the boto3 documentation (http://boto3.readthedocs.org/en/latest/reference/services/redshift.html#paginators) to load redshift.

self.client = boto3.resource('redshift')

but I get this error :

botocore.exceptions.DataNotFoundError: Unable to load data for: redshift

Other information:

I can access redshift with psycopg2. I can do sql commands on it, but there is no way to get a list of the clusters. I'm using python 3.4.3.

1 Answer 1

1

Have you already set up the boto3 session or are you doing this on a machine in AWS?

The boto3.resource() method will only work if there's already a session created.

There are a number of other options to set up the client, including:

client = boto3.client(SERVICE_NAME, AWS_REGION)

So in your case, if you were running in AWS region 'us-west-1':

client = boto3('redshift', 'us-west-1')
cluster_list = client.describe_clusters()
Sign up to request clarification or add additional context in comments.

2 Comments

thx I forgot the session. But what with the host name and user name etc.. I'm now doing it with a JSON file and then read/write from there. But isn't there a more save/secure way? with encryption?
You've not clarified where you're doing this from. The most secure way is to do it from a machine in AWS that has an IAM role attached to it with the necessary permissions. Boto3 should then automatically pick up the credentials from the machine. If it's running from somewhere else you'll need to have local keys somehow, there's a number of ways to do this.

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.