【问题标题】:How to descibe endpoints in the redshift如何描述红移中的端点
【发布时间】:2020-11-27 01:37:28
【问题描述】:

我有错误

"errorMessage": "调用 DescribeClusters 操作时发生错误 (AccessDenied):用户:arn:aws:sts::XX:assumed-role/xx/axx 无权执行:redshift:DescribeClusters on resource: arn:aws:xx:*",

下面是RDS的代码

client = boto3.client('rds')
cluster_list = client.describe_db_cluster_endpoints()
print(cluster_list)

下面是redshift的代码

client = boto3.client('redshift', 'us-east-2')
cluster_list = client.describe_clusters()
print(cluster_list)

我的角色有以下服务如下

AWSTemplateFormatVersion: 2010-09-09

Parameters: 

  testlambdarole:
    Type: String
    Default: role-name
      
Resources: 

  Role:  
    Type: AWS::IAM::Role
    Properties:
      RoleName: !Ref testlambdarole
      AssumeRolePolicyDocument:
        Version: '2012-10-17'               
        Statement:
          - Effect: Allow
            Principal:
              Service:
                - lambda.amazonaws.com
                - redshift.amazonaws.com
            Action: ['sts:AssumeRole']      
      ManagedPolicyArns:
        - arn:aws:iam::aws:policy/AWSLambdaExecute
      Policies:
        - PolicyName: RdsAccess
          PolicyDocument: 
            Version: "2012-10-17"
            Statement: 
              - Effect: "Allow"
                Action: 
                  - rds-db:connect
                Resource: "*"

【问题讨论】:

  • 您的 IAM 角色无权执行该操作,如错误所示。
  • 你可以看到 - redshift.amazonaws.com 存在
  • Redshift 被称为服务主体,请阅读 IAM 文档。
  • 你的意思是说我还需要添加策略?
  • 检查我的答案

标签: python amazon-web-services aws-lambda yaml


【解决方案1】:

您的 IAM 角色中缺少允许您想要在 Redshift 上执行的操作的策略,如下所示:

- PolicyName: RSDescribeClusters
  PolicyDocument: 
    Version: "2012-10-17"
    Statement: 
      - Effect: "Allow"
      Action: 
        - redshift:DescribeClusters
      Resource: "*"

从您的设置方式来看,您只是允许 Redshift 服务承担该 IAM 角色。

redshift:DescribeClusters 操作在您发布的错误消息中指定;此外,您可以在开发者文档的Actions, resources, and condition keys for Amazon Redshift 页面上找到 Redshift 支持的所有操作。

例如,如果您想为 RDS 添加一个,也可以使用它(经过测试并且有效):

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": "rds:DescribeDBClusterEndpoints",
            "Resource": [
                "arn:aws:rds:*:ACCOUNT_ID:cluster:*",
                "arn:aws:rds:*:ACCOUNT_ID:cluster-endpoint:*"
            ]
        }
    ]
}

您需要自己替换您的帐户 ID 和/或将其转换为 CloudFormation。

【讨论】:

  • 你是如何得到这个红移的:DescribeClusters
  • 还请为 RDS 添加 describe_db_cluster_endpoints
  • 添加了说明,您可以在 AWS 文档中找到每个服务的所有操作,您通常可以在 Google 上搜索“iam 服务操作”之类的内容(即“iam redshift 操作”或“iam rds 操作”)
  • 我添加了 - rds-db:connect - rds-db:DescribeDBClusterEndpoints 它不工作
  • 添加了一个我已经测试过并且有效的示例。这是我最后一次编辑,祝你好运。
猜你喜欢
  • 1970-01-01
  • 2013-11-03
  • 1970-01-01
  • 1970-01-01
  • 2018-09-01
  • 2018-08-11
  • 1970-01-01
  • 2020-03-27
  • 2018-02-18
相关资源
最近更新 更多