PG_GET_GRANTEE_BY_IAM_ROLE - Amazon Redshift
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

PG_GET_GRANTEE_BY_IAM_ROLE

返回被授予指定 IAM 角色的所有用户和组。

语法

pg_get_grantee_by_iam_role('iam_role_arn')

参数

iam_role_arn

用于返回已被授予此角色的用户和组的 IAM 角色。

返回类型

VARCHAR

使用说明

PG_GET_GRANTEE_BY_IAM_ROLE 函数为每个用户或组返回一行。每行都包含被授权者名称、被授权者类型和授予的权限。被授权者类型的可能值如下:对于公有为 p,对于用户为 u,对于组为 g

您必须是超级用户才能使用函数。

示例

以下示例指示 IAM 角色 Redshift-S3-Write 被授予给 group1reg_user1group_1 中的用户只能为 COPY 操作指定角色,用户 reg_user1 可以指定仅用于执行 UNLOAD 操作的角色。

select pg_get_grantee_by_iam_role('arn:aws:iam::123456789012:role/Redshift-S3-Write');
pg_get_grantee_by_iam_role ----------------------------- (group_1,g,COPY) (reg_user1,u,UNLOAD)

下面的 PG_GET_GRANTEE_BY_IAM_ROLE 函数示例将结果格式化为表格。

select grantee, grantee_type, cmd_type FROM pg_get_grantee_by_iam_role('arn:aws:iam::123456789012:role/Redshift-S3-Write') res_grantee(grantee text, grantee_type text, cmd_type text) ORDER BY 1,2,3;
grantee | grantee_type | cmd_type -----------+--------------+---------- group_1 | g | COPY reg_user1 | u | UNLOAD