首页 > 解决方案 > 如何使用 AccountB 的用户 CLI 凭证从 AccountA 访问 DynamoDB 表?

问题描述

我在 Dynamodb 中创建了一个表,并在 IAM 中设置了角色,并附加了以下策略:

{
  "Version": "2012-10-17",
  "Statement": [{
        "Effect": "Allow",
        "Action": "dynamodb:*",
        "Resource": "arn:aws:dynamodb:ap-south-1:**AccountAID**:table/employee"
  }]
}

我在角色中添加了可信实体 AccountB ID。然后我还在 AccountB 中创建了策略,用于访问在 AccountA 中创建的 dynamodb 表,其策略如下:

{
    "Version": "2012-10-17",
    "Statement": [{
            "Effect": "Allow",
            "Action": "*",
            "Resource": "arn:aws:iam::**AccountAID**:role/DynamodbCrossAccountAccessRole"
    }]
}

我已经配置了 AccountA 用户和 AccountB 用户的配置文件,并且使用 AccountA 的配置文件用户的凭据,我可以列出 dynamodb 的表,但是在尝试使用 AccountB 的配置文件用户时,我总是返回空表列表。

Krunal-MacBook-Air:.aws krunal$ aws dynamodb list-tables --profile Krunal { "TableNames": [ "employee" ] } Krunal-MacBook-Air:.aws krunal$ aws dynamodb list-tables --profile Krunal2 { "TableNames": [] }

谁能帮我解决这个问题,为什么我无法使用 AccountB 的个人资料访问 dynamodb?策略分别附加到帐户用户。

标签: amazon-web-servicesamazon-dynamodbamazon-iam

解决方案


根据评论。

通过担任 AccountB 中的角色解决了该问题。显示如何执行此操作的有用链接是:


推荐阅读