我们可以 link List Grants API 中的 Grantee Principal 返回到 User/Role 哪个是授予的吗?

Can we link the GranteePrincipal from List Grants API back to User/Role which is issued the grant?

在亚马逊密钥管理服务中,可以列出对客户主密钥的授权。此 returns GrantListEntry 对象列表。每个都有一个 getGranteePrincipal() 方法,该方法 returns 类似于 AIDAJBVZPN4EIJ44R7AZM 的字符串。这应该映射到与此授权相关的 user/role 但是,我无法弄清楚如何将此字符串映射到用户。这不是他们的 IAM 密钥或 ARN。有什么方法可以将此字符串与原始用户相关联吗?

您最有可能正在查看 Unique ID:

When IAM creates a user, group, role, policy, instance profile, or server certificate, it assigns to each entity a unique ID that looks like the following example:

AIDAJQABLZS4A3QDU576Q

For the most part, you use friendly names and ARNs when you work with IAM entities, so you don't need to know the unique ID for a specific entity. However, the unique ID can sometimes be useful when it isn't practical to use friendly names.

如上一段所述(并在参考文档中进一步概述),唯一 ID 通常被隐藏起来以支持友好名称,但需要保证用户离开组织时的唯一性以及另一个具有相同 ID 的组织例如,友好名称可能会加入。

另一个提供的示例似乎解释了手头的场景(显然也适用于您自己的用例):

Another example where user IDs can be useful is if you maintain your own database (or other store) of IAM user information. The unique ID can provide a unique identifier for each IAM user you create, even if over time you have IAM users that reuse a name, as in the previous example.

获取唯一 ID

如响应中所述。部分,IAM 实体的唯一 ID 在 IAM 控制台中不可用。但是,您可以使用 AWS CLI 命令或 IAM API 调用来获取它,例如对于用户:

不幸的是,似乎无法直接搜索它,因此您需要遍历所有用户并单独检索它以生成所需的映射。

  • 如果您碰巧以编程方式生成 users/roles,则相应的唯一 ID 将返回。至少马上打电话,见例如CreateUser.