【问题标题】:Get list clusters Amazon Redshift using Python with Boto3使用 Python 和 Boto3 获取列表集群 Amazon Redshift
【发布时间】:2015-12-16 10:10:51
【问题描述】:

我想要一个使用 Python (boto3) 的集群列表。我做了一些研究,在 boto3 文档 (http://boto3.readthedocs.org/en/latest/reference/services/redshift.html#paginators) 中找到了这个命令来加载 redshift。

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

但我收到此错误:

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

其他信息:

我可以使用 psycopg2 访问红移。我可以对其执行 sql 命令,但无法获取集群列表。我正在使用 python 3.4.3。

【问题讨论】:

    标签: python amazon-web-services psycopg2 amazon-redshift boto3


    【解决方案1】:

    您是否已经设置了 boto3 会话,或者您是在 AWS 中的机器上执行此操作吗?

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

    还有许多其他选项可以设置客户端,包括:

    client = boto3.client(SERVICE_NAME, AWS_REGION)
    

    所以在您的情况下,如果您在 AWS 区域“us-west-1”中运行:

    client = boto3('redshift', 'us-west-1')
    cluster_list = client.describe_clusters()
    

    【讨论】:

    • 谢谢我忘记了会议。但是主机名和用户名等呢?我现在用一个 JSON 文件来做,然后从那里读/写。但是没有更节省/安全的方式吗?加密?
    • 你还没有说明你是从哪里做的。最安全的方法是从 AWS 中的机器上执行此操作,该机器附加了具有必要权限的 IAM 角色。然后 Boto3 应该会自动从机器中获取凭据。如果它从其他地方运行,您将需要以某种方式拥有本地密钥,there's a number of ways to do this.
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-02-03
    • 1970-01-01
    • 2015-10-21
    • 1970-01-01
    • 2015-02-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多