简体   繁体   English

在不使用 aws 凭据的情况下连接 Redshift 和 Python(在 emr 上运行)

[英]Connect Redshift and Python without using aws credentials (running on emr)

Hi I am new to AWS world, I need help in connecting Python to Redshift Database.嗨,我是 AWS 世界的新手,我需要帮助将 Python 连接到 Redshift 数据库。 How can I do it without giving the credentials as I am running it on the EMR provided I am not using any third party services如果我不使用任何第三方服务,我在 EMR 上运行它时如何在不提供凭据的情况下执行此操作

Amazon EMR runs on Amazon EC2 instances. Amazon EMR 在 Amazon EC2 实例上运行。 These instances are assigned an IAM Role, which grants permission to software running on the instances when they use an AWS SDK.这些实例被分配了一个 IAM 角色,当它们使用 AWS SDK 时,该角色授予实例上运行的软件的权限。

For example, when software running on EMR access S3 it obtains credentials via EC2 instance metadata , which includes a set of temporary credentials associated with the IAM Role assigned to the instance.例如,当在 EMR 上运行的软件访问 S3 时,它通过EC2 实例元数据获取凭证,其中包括一组与分配给实例的 IAM 角色相关联的临时凭证。

You can call the Amazon Redshift Data API in a similar manner and it will use credentials provided through the IAM Role.您可以以类似方式调用Amazon Redshift Data API ,它将使用通过 IAM 角色提供的凭证。

You are using Python, so you can use the boto3 RedshiftDataAPIService — Boto3 documentation to query an Amazon Redshift cluster using permission supplied by the IAM Role.您正在使用 Python,因此您可以使用 boto3 RedshiftDataAPIService — Boto3 文档使用 IAM 角色提供的权限查询 Amazon Redshift 集群。

You would need to add appropriate permissions to the IAM Role being used by the EMR cluster.您需要为 EMR 集群使用的 IAM 角色添加适当的权限。 See: Configure IAM service roles for Amazon EMR permissions to AWS services and resources - Amazon EMR请参阅: 为 AWS 服务和资源的 Amazon EMR 权限配置 IAM 服务角色 - Amazon EMR

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM