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

从 2025 年 11 月 1 日起,Amazon Redshift 将不再支持创建新的 Python UDF。如果您想要使用 Python UDF,请在该日期之前创建 UDF。现有的 Python UDF 将继续正常运行。有关更多信息,请参阅博客文章

先决条件

设置 Amazon Redshift 联合身份验证权限时的 IAM 策略要求

通过 Amazon Redshift 联合身份验证权限,您可以跨分析工作负载集中管理数据访问权限,而且联合身份验证权限由 Redshift 仓库直接管理。

要启用 Amazon Redshift 联合身份验证权限,除了创建 Redshift 预调配集群和 Serverless 命名空间所需的标准权限外,还需要特定的 IAM 权限。

要对 Redshift 预调配仓库启用 Redshift 联合身份验证权限,请执行以下操作:

  • redshift:ModifyLakehouseConfiguration

  • redshift:RegisterNamespace

要对 Redshift Serverless 仓库启用 Redshift 联合身份验证权限,请执行以下操作:

  • redshift-serverless:UpdateLakehouseConfiguration

  • redshift:RegisterNamespace

要让 Amazon Glue Data Catalog 集成创建具有 Redshift 联合身份验证权限的目录,请执行以下操作:

  • glue:CreateCatalog

  • glue:GetCatalog

要对 Lake Formation 资源进行一次性注册,以便从具有联合身份验证权限的远程仓库启用 Redshift 权限联合身份验证,请执行以下操作:

  • lakeformation:RegisterResource

  • lakeformation:RegisterResourceWithPrivilegedAccess

具有联合身份验证权限的 Redshift 仓库的 IAM Identity Center 应用程序配置

Amazon Redshift 支持 Identity Center 身份传播,这样就能够在 Redshift 实例与 Amazon Lake Formation 和 Amazon Glue 服务之间无缝传递用户身份。此功能需要配置专用 IdC 应用程序。

所需的 IAM 权限

要创建和管理用于 Identity Center 身份传播的 Identity Center 应用程序,请确保您的 IAM 权限包括以下权限:

对于 Amazon Redshift IdC 应用程序管理:

  • redshift:CreateRedshiftIdcApplication

  • redshift:ModifyRedshiftIdcApplication

  • redshift:DescribeRedshiftIdcApplications

对于 Lake Formation IdC 应用程序管理:

  • lakeformation:CreateLakeFormationIdentityCenterConfiguration

  • lakeformation:DescribeLakeFormationIdentityCenterConfiguration

  • lakeformation:UpdateLakeFormationIdentityCenterConfiguration

创建对应的 IdC 应用程序和配置

要为您的分析工作负载建立身份传播,请创建 Lakehouse 类型的 Amazon Redshift IdC 应用程序。该应用程序无需明确分配用户即可管理权限。链接到此应用程序的 Redshift 仓库要求 IdC 用户具备 CONNECT 权限以便对连接进行身份验证。

每个 Amazon Web Services 账户只能创建一个 Lakehouse 类型的 Amazon Redshift IdC 应用程序。该应用程序处理与 Lake Formation 和 Amazon Glue 服务集成的所有 Redshift 仓库上的身份传播。该应用程序只能用于注册到 Amazon Glue Data Catalog 的 Redshift 仓库。

准备由 Redshift 代入并由 IdC 身份传播使用的 IAM 角色

创建 Redshift Lakehouse IdC 应用程序时要求您账户中拥有具备某些 IAM 权限的 IAM 角色。您在 Redshift IdC 应用程序中使用的 IAM 角色应具有以下信任关系,以便允许 Redshift 代入该角色并为 IdC 身份传播设置上下文。

{ "Version": "2012-10-17", "Statement": [ { "Sid": "Statement1", "Effect": "Allow", "Principal": { "Service": [ "redshift-serverless.amazonaws.com", "redshift.amazonaws.com" ] }, "Action": [ "sts:AssumeRole", "sts:SetContext" ] } ] }

以下是您的 IdC IAM 角色支持 IdC 身份传播所需的权限。

  • AmazonRedshiftFederatedAuthorization:此策略使得 Amazon Redshift 可以通过联合身份验证权限查询 Amazon Glue Data Catalog 数据库。

  • AWSIDC 设置上下文策略

    { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "sts:SetContext" ], "Resource": "*" } ] }
  • 使用 Amazon IAM Identity Center 将 Redshift 设置为 Amazon 托管应用程序

  • AWSIDC Identity Center SSO IAM 策略:

    • sso:DescribeApplication – 需要在目录中创建身份提供者 (IdP) 条目。

    • sso:DescribeInstance – 用于手动创建 IdP 联合身份验证角色或用户。

      { "Sid": "VisualEditor1", "Effect": "Allow", "Action": [ "sso:DescribeApplication", "sso:DescribeInstance" ], "Resource": [ "arn:aws:sso:::instance/<IAM Identity Center Instance ID>", "arn:aws:sso::<Amazon-account-id>:application/<IAM Identity Center Instance ID>/*" ] }

创建一个 Lakehouse 类型的新 Redshift IdC 应用程序

CLI

通过在 create-redshift-idc-application 请求中指定 Lakehouse 应用程序类型来创建 Lakehouse IdC 应用程序,这样就无需在 Identity Center 中进行明确的用户分配,而且实现了 IdC 用户身份验证的 CONNECT 权限要求:

aws redshift create-redshift-idc-application \ --idc-instance-arn <your_idc_instance_arn> \ --idc-display-name '<name_of_idc_application_display_on_idc_console>' \ --iam-role-arn <idc_carrier_role_arn> \ --application-type Lakehouse \ --redshift-idc-application-name '<name_of_idc_display_on_redshift_console>' \ --service-integrations '[ { "LakeFormation":[ { "LakeFormationQuery":{"Authorization": "Enabled"} } ] }, { "Redshift":[ { "Connect" : { "Authorization": "Enabled" } } ] } ]'

此配置支持在 Redshift 和 Lake Formation 之间传播可信身份,让用户可以使用其 Identity Center 凭证跨服务访问数据,而无需额外分配权限。

Console
  1. 登录到 Amazon Web Services 管理控制台并打开 Amazon Redshift 控制台,网址:https://console.aws.amazon.com/redshiftv2/

  2. 导航到 IAM Identity Center 连接页面,然后选择创建应用程序

  3. 配置您的常规 IdC 应用程序设置。

  4. 选择使用 Amazon IAM Identity Center 配置 Amazon Redshift 联合身份验证权限(推荐)来设置应用程序类型。

  5. 默认情况下启用 Lake Formation 和 Redshift 连接身份传播集成。

  6. 完成剩余的集群设置,然后选择创建应用程序

修改现有的 Redshift IdC 应用程序

如果您现有的一个 Redshift IdC 应用程序未启用所需的服务集成,您可以更新该应用程序,使其支持服务与集群/命名空间之间的身份传播。

CLI

使用 modify-redshift-idc-application 命令启用 LakeFormation:query 授权和 Redshift:Connect 授权。这些集成对于跨服务和跨集群的 IdC 身份传播至关重要:

aws redshift modify-redshift-idc-application \ --redshift-idc-application-arn '<arn_of_the_target_redshift_idc_application>' \ --service-integrations '[ { "LakeFormation":[ { "LakeFormationQuery":{"Authorization": "Enabled"} } ] }, { "Redshift":[ { "Connect" : { "Authorization": "Enabled" } } ] } ]'
Console
  1. 登录到 Amazon Web Services 管理控制台并打开 Amazon Redshift 控制台,网址:https://console.aws.amazon.com/redshiftv2/

  2. 导航到 IAM Identity Center 连接页面,然后选择要编辑的现有 IdC 应用程序。

  3. 选择要启用的身份传播集成并配置其他设置,然后选择保存更改

创建 Lake Formation Identity Center 配置

Lake Formation 服务需要专用的 IdC 应用程序(如果尚未创建)。您还必须启用 Redshift:Connect 授权才能使配置正常运行。

CLI

使用 create-lake-formation-identity-center-configuration 命令启用 Redshift:Connect 授权。对于 Lake Formation 将 IdC 身份传播到 Redshift 集群和 Redshift Serverless 命名空间,这些集成至关重要。

aws lakeformation create-lake-formation-identity-center-configuration \ --instance-arn <your_idc_instance_arn> \ --service-integrations '[{ "Redshift": [{ "RedshiftConnect": { "Authorization": "ENABLED" } }] }]'
Console
  1. 登录 Amazon Web Services 管理控制台并打开 Lake Formation 控制台(https://console.aws.amazon.com/lakeformation/)。

  2. 在左侧导航窗格中,选择 IAM Identity Center 集成

  3. 在 IAM Identity Center 集成页面上,您可以为 Amazon Redshift 连接启用可信身份传播。Lake Formation 根据有效的权限向下游传播身份,这样获得授权的应用程序就能够代表用户访问数据。

更新 Lake Formation Identity Center 配置

如果您已配置的 Lake Formation IdC 应用程序未启用所需的服务集成,您可以更新该应用程序,使其支持服务与集群/命名空间之间的身份传播。

CLI

使用 update-lake-formation-identity-center-configuration 命令启用 Redshift:Connect 授权。这些集成对于跨服务和跨集群的 IdC 身份传播至关重要:

aws lakeformation update-lake-formation-identity-center-configuration \ --service-integrations '[{ "Redshift": [{ "RedshiftConnect": { "Authorization": "ENABLED" } }] }]'
Console
  1. 登录 Amazon Web Services 管理控制台并打开 Lake Formation 控制台(https://console.aws.amazon.com/lakeformation/)。

  2. 在左侧导航窗格中,选择 IAM Identity Center 集成

  3. 在 IAM Identity Center 集成页面上,您可以为 Amazon Redshift 连接启用可信身份传播。Lake Formation 根据有效的权限向下游传播身份,这样获得授权的应用程序就能够代表用户访问数据。

Lake Formation 先决条件

客户需要 Lake Formation CREATE_CATALOG 权限才能启用具有 Amazon Redshift 联合身份验证权限的 Amazon Glue Data Catalog。

  1. 如果该账户属于现有的 Lake Formation 客户,则 Lake Formation 管理员必须向每个集群创建者明确授予 CREATE_CATALOG 权限。使用以下示例 CLI 命令:

    aws lakeformation grant-permissions \ --cli-input-json \ '{ "Principal": { "DataLakePrincipalIdentifier": "<PrincipalArn>" }, "Resource": { "Catalog": {} }, "Permissions": [ "CREATE_CATALOG" ] }'
  2. 如果该账户从未使用过 Lake Formation,请在 Lake Formation 控制台的“管理角色和任务”页面中确认目录创建者是否已设置为 IAMAllowedPrincipals。如果未设置好,请按照创建数据湖管理员中的说明设置数据湖管理员。或者,如果您仅使用具有 Amazon Redshift 联合身份验证权限的 Amazon Glue Data Catalog,则可以创建具有最少所需策略的数据湖管理员。

    { "Version": "2012-10-17", "Statement": [ { "Sid": "Statement1", "Effect": "Allow", "Action": [ "lakeformation:PutDataLakeSettings", "lakeformation:GrantPermissions", "lakeformation:GetDataLakeSettings", "lakeformation:BatchGrantPermissions", "lakeformation:ListPermissions" ], "Resource": [ "*" ] } ] }
  3. 让数据湖管理员向 IAMAllowedPrincipals 授予创建目录的权限。在“管理角色和任务”页面上,可以通过授权按钮向目录创建者授予访问权限。

连接权限

作为 Amazon Redshift 联合身份验证权限的一部分,Amazon Redshift 引入了 CONNECT 权限,用于管理 Amazon IAM Identity Center 联合用户对 Amazon Redshift 工作组或集群的访问权限。当工作组或集群上启用了 Amazon Redshift 联合身份验证权限时,此功能可用。

此权限使管理员能够在每个已启用 Amazon Redshift 联合身份验证权限的 Amazon Redshift 工作组或集群中,通过精细权限控制用户访问。Amazon Redshift 管理员可以指定哪些 Amazon IAM Identity Center 联合用户或组有权直接连接到 Amazon Redshift 工作组或集群,从而提供对每个工作组或集群上的 Amazon IAM Identity Center 用户访问的精细控制。

语法

GRANT CONNECT [ON WORKGROUP] TO [USER] <prefix>:<username> | ROLE <prefix>:<rolename> | PUBLIC;
CONNECT [ON WORKGROUP]

授予连接工作组的权限。CONNECT 权限仅适用于 Amazon IAM Identity Center 身份(用户和角色)。

TO <prefix>:<username>

指示接收权限的 Amazon IAM Identity Center 联合用户。

TO ROLE <prefix>:<rolename>

指示接收权限的 Amazon IAM Identity Center 联合组。

PUBLIC

向所有 Amazon IAM Identity Center 联合用户授予 CONNECT 权限,包括以后创建的用户。