

 从补丁 198 开始，Amazon Redshift 将不再支持创建新的 Python UDF。现有的 Python UDF 将继续正常运行至 2026 年 6 月 30 日。有关更多信息，请参阅[博客文章](https://aws.amazon.com/blogs/big-data/amazon-redshift-python-user-defined-functions-will-reach-end-of-support-after-june-30-2026/)。

# 将基于身份的策略（IAM 策略）用于 Amazon Redshift
<a name="redshift-iam-access-control-identity-based"></a>

本主题提供了基于身份的策略的示例，在这些策略中，账户管理员可以向 IAM 身份（即：用户、组和角色）附加权限策略。

**重要**  
我们建议您首先阅读以下介绍性主题，这些主题讲解了管理 Amazon Redshift 资源访问的基本概念和选项。有关更多信息，请参阅 [管理 Amazon Redshift 资源的访问权限的概览](redshift-iam-access-control-overview.md)。

下面介绍权限策略示例。该权限允许用户创建、删除、修改和重启所有集群，但拒绝删除或修改 AWS 区域 `us-west-2` 和 AWS 账户 `123456789012` 中集群标识符以 `production` 开头的任何集群的权限。

------
#### [ JSON ]

****  

```
{
  "Version":"2012-10-17",		 	 	 
  "Statement": [
    {
      "Sid":"AllowClusterManagement",
      "Action": [
        "redshift:CreateCluster",
        "redshift:DeleteCluster",
        "redshift:ModifyCluster",
        "redshift:RebootCluster"
      ],
      "Resource": [
        "*"
      ],
      "Effect": "Allow"
    },
    {
      "Sid":"DenyDeleteModifyProtected",
      "Action": [
        "redshift:DeleteCluster",
        "redshift:ModifyCluster"
      ],
      "Resource": [
        "arn:aws:redshift:us-west-2:123456789012:cluster:production*"
      ],
      "Effect": "Deny"
    }
  ]
}
```

------

该策略包含两条语句：
+ 第一条语句授予用户创建、删除、修改和重启集群的权限。该语句指定通配符 (\$1) 作为 `Resource` 的值，因此，该策略适用于归根 AWS 账户所有的一切 Amazon Redshift 资源。
+ 第二条语句拒绝删除或修改集群的权限。该语句指定包含通配符 (\$1) 的集群 Amazon 资源名称（ARN）作为 `Resource` 的值。因此，该语句适用于归根 AWS 账户所有的一切 Amazon Redshift 集群（集群标识符以 `production` 开头）。

## 适用于 Amazon Redshift 的 AWS 托管式策略
<a name="redshift-policy-resources.managed-policies"></a>

AWS通过提供由AWS创建和管理的独立 IAM 策略来满足许多常用案例的要求。托管策略可针对常见使用案例授予必要权限，因此，您无需自行调查具体需要哪些权限。有关更多信息，请参阅《IAM 用户指南》**中的 [AWS 托管式策略](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_managed-vs-inline.html#aws-managed-policies)。

此外，您还可以创建自定义 IAM 策略，以授予账户 Amazon Redshift API 操作和资源访问的权限。您可以将这些自定义策略附加到需要这些权限的 IAM 角色或组。

以下部分描述 Amazon Redshift 特有的 AWS 托管式策略（可附加至您账户中的用户）：

## AWS 托管式策略的 Amazon Redshift 更新
<a name="security-iam-awsmanpol-updates"></a>



查看有关 Amazon Redshift（自从其开始跟踪更新更改以来）的 AWS 托管式策略更新的详细信息。有关此页面更改的自动提示，请订阅 Amazon Redshift 文档历史记录页面上的 RSS 源。




| 更改 | 描述 | 日期 | 
| --- | --- | --- | 
|  [AmazonRedshiftFederatedAuthorization](#redshift-policy-managed-policies-federated-authorization) - 新策略  |   Amazon Redshift 新增了一项易用性策略，用于通过 Amazon Redshift 联合身份验证授权功能执行查询。  | 2025 年 11 月 21 日 | 
|  [AmazonRedshiftServiceLinkedRolePolicy](#redshift-policy-managed-policies-service-linked-role-policy)：对现有策略的更新  |   托管式策略增加了 `lakeformation:GetDataAccess` 操作的权限。添加此权限可授予从 AWS Lake Formation 中获取联合目录信息的权限。 操作 `glue:GetCatalog` 和 `glue:GetCatalogs` 的其它条件将添加到托管式策略中。  | 2025 年 3 月 13 日 | 
|  [AmazonRedshiftServiceLinkedRolePolicy](#redshift-policy-managed-policies-service-linked-role-policy)：对现有策略的更新  |   操作 `glue:GetCatalog` 和 `glue:GetCatalogs` 的权限将添加到托管式策略中。添加这些权限可授予从 AWS Glue 中获取目录信息的权限。  | 2024 年 12 月 3 日 | 
|  [AmazonRedshiftServiceLinkedRolePolicy](#redshift-policy-managed-policies-service-linked-role-policy)：对现有策略的更新  |  托管式策略增加了 `servicequotas:GetServiceQuota` 操作的权限。这为访问配额或限制提供了权限。  | 2024 年 3 月 8 日 | 
|  [AmazonRedshiftQueryEditorV2FullAccess](#redshift-policy-managed-policies-query-editor-V2)：对现有策略的更新  |  操作 `redshift-serverless:ListNamespaces` 和 `redshift-serverless:ListWorkgroups` 的权限将添加到托管式策略中。添加它们可授予在 Amazon Redshift 数据仓库中列出无服务器命名空间和无服务器工作组的权限。  | 2024 年 2 月 21 日 | 
|  [AmazonRedshiftQueryEditorV2NoSharing](#redshift-policy-managed-policies-query-editor-V2-no-sharing)：对现有策略的更新  |  操作 `redshift-serverless:ListNamespaces` 和 `redshift-serverless:ListWorkgroups` 的权限将添加到托管式策略中。添加它们可授予在 Amazon Redshift 数据仓库中列出无服务器命名空间和无服务器工作组的权限。  | 2024 年 2 月 21 日 | 
|  [AmazonRedshiftQueryEditorV2ReadSharing](#redshift-policy-managed-policies-query-editor-V2-read-sharing)：对现有策略的更新  |  操作 `redshift-serverless:ListNamespaces` 和 `redshift-serverless:ListWorkgroups` 的权限将添加到托管式策略中。添加它们可授予在 Amazon Redshift 数据仓库中列出无服务器命名空间和无服务器工作组的权限。  | 2024 年 2 月 21 日 | 
|  [AmazonRedshiftQueryEditorV2ReadWriteSharing](#redshift-policy-managed-policies-query-editor-V2-write-sharing)：对现有策略的更新  |  操作 `redshift-serverless:ListNamespaces` 和 `redshift-serverless:ListWorkgroups` 的权限将添加到托管式策略中。添加它们可授予在 Amazon Redshift 数据仓库中列出无服务器命名空间和无服务器工作组的权限。  | 2024 年 2 月 21 日 | 
|  [AmazonRedshiftReadOnlyAccess](#redshift-policy-managed-policies-read-only)：对现有策略的更新  |  托管式策略增加了 `redshift:ListRecommendations` 操作的权限。这将授予列出 Amazon Redshift Advisor 建议的权限。  | 2024 年 2 月 7 日 | 
|  [AmazonRedshiftServiceLinkedRolePolicy](#redshift-policy-managed-policies-service-linked-role-policy)：对现有策略的更新  |  操作 `ec2:AssignIpv6Addresses` 和 `ec2:UnassignIpv6Addresses` 的权限将添加到托管式策略中。添加这些权限可授予分配和取消分配 IP 地址的权限。  | 2023 年 10 月 31 日 | 
|  [AmazonRedshiftQueryEditorV2NoSharing](#redshift-policy-managed-policies-query-editor-V2-no-sharing)：对现有策略的更新  |  操作 `sqlworkbench:GetAutocompletionMetadata` 和 `sqlworkbench:GetAutocompletionResource` 的权限将添加到托管式策略中。添加它们可授予生成和检索数据库信息的权限，以便在编辑查询时自动完成 SQL。  | 2023 年 8 月 16 日 | 
|  [AmazonRedshiftQueryEditorV2ReadSharing](#redshift-policy-managed-policies-query-editor-V2-read-sharing)：对现有策略的更新  |  操作 `sqlworkbench:GetAutocompletionMetadata` 和 `sqlworkbench:GetAutocompletionResource` 的权限将添加到托管式策略中。添加它们可授予生成和检索数据库信息的权限，以便在编辑查询时自动完成 SQL。  | 2023 年 8 月 16 日 | 
|  [AmazonRedshiftQueryEditorV2ReadWriteSharing](#redshift-policy-managed-policies-query-editor-V2-write-sharing)：对现有策略的更新  |  操作 `sqlworkbench:GetAutocompletionMetadata` 和 `sqlworkbench:GetAutocompletionResource` 的权限将添加到托管式策略中。添加它们可授予生成和检索数据库信息的权限，以便在编辑查询时自动完成 SQL。  | 2023 年 8 月 16 日 | 
|  [AmazonRedshiftServiceLinkedRolePolicy](#redshift-policy-managed-policies-service-linked-role-policy)：对现有策略的更新  |  在托管式策略中增加了在 AWS Secrets Manager 中执行密钥创建和管理操作的权限。添加的权限如下： [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/redshift/latest/mgmt/redshift-iam-access-control-identity-based.html)  | 2023 年 8 月 14 日 | 
|  [AmazonRedshiftServiceLinkedRolePolicy](#redshift-policy-managed-policies-service-linked-role-policy)：对现有策略的更新  |  现在已从托管式策略删除了在 Amazon EC2 上执行操作以创建和管理安全组和路由规则的权限。这些权限与创建子网和 VPC 有关。移除的权限如下： [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/redshift/latest/mgmt/redshift-iam-access-control-identity-based.html) 它们与 Purpose:RedshiftMigrateToVpc 资源标签有关联。该标签将权限范围限制为从 Amazon EC2 Classic 到 Amazon EC2 VPC 迁移任务。有关更多信息，请参阅[控制对使用标签的 AWS 资源进行访问](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_tags.html)。 | 2023 年 5 月 8 日 | 
|  [AmazonRedshiftDataFullAccess](#redshift-policy-managed-policies-data-full-access)：对现有策略的更新  |  托管式策略增加了 `redshift:GetClusterCredentialsWithIAM` 操作的权限。增加此权限会授予获取增强型临时凭证以通过指定的 AWS 账户访问 Amazon Redshift 数据库的权限。  | 2023 年 4 月 7 日 | 
|  [AmazonRedshiftServiceLinkedRolePolicy](#redshift-policy-managed-policies-service-linked-role-policy)：对现有策略的更新  |  在托管式策略中，现在添加了在 Amazon EC2 上执行操作以创建和管理安全组规则的权限。这些安全组和规则特别关联到 Amazon Redshift `aws:RequestTag/Redshift` 资源标签。这样可以将权限的范围限制为特定 Amazon Redshift 资源。  | 2023 年 4 月 6 日 | 
|  [AmazonRedshiftQueryEditorV2NoSharing](#redshift-policy-managed-policies-query-editor-V2-no-sharing)：对现有策略的更新  |  托管式策略增加了 `sqlworkbench:GetSchemaInference` 操作的权限。添加此项会授予权限，以获取从文件推断的列和数据类型  | 2023 年 3 月 21 日 | 
|  [AmazonRedshiftQueryEditorV2ReadSharing](#redshift-policy-managed-policies-query-editor-V2-read-sharing)：对现有策略的更新  |  托管式策略增加了 `sqlworkbench:GetSchemaInference` 操作的权限。添加此项会授予权限，以获取从文件推断的列和数据类型  | 2023 年 3 月 21 日 | 
|  [AmazonRedshiftQueryEditorV2ReadWriteSharing](#redshift-policy-managed-policies-query-editor-V2-write-sharing)：对现有策略的更新  |  托管式策略增加了 `sqlworkbench:GetSchemaInference` 操作的权限。添加此项会授予权限，以获取从文件推断的列和数据类型  | 2023 年 3 月 21 日 | 
|  [AmazonRedshiftQueryEditorV2NoSharing](#redshift-policy-managed-policies-query-editor-V2-no-sharing)：对现有策略的更新  |  托管式策略增加了 `sqlworkbench:AssociateNotebookWithTab` 操作的权限。添加它会授予相关权限，以创建和更新链接到用户自己的笔记本的选项卡。  | 2023 年 2 月 2 日 | 
|  [AmazonRedshiftQueryEditorV2ReadSharing](#redshift-policy-managed-policies-query-editor-V2-read-sharing)：对现有策略的更新  |  托管式策略增加了 `sqlworkbench:AssociateNotebookWithTab` 操作的权限。添加它会授予相关权限，以创建和更新链接到用户自己的笔记本或链接到与其共享的笔记本的选项卡。  | 2023 年 2 月 2 日 | 
|  [AmazonRedshiftQueryEditorV2ReadWriteSharing](#redshift-policy-managed-policies-query-editor-V2-write-sharing)：对现有策略的更新  |  托管式策略增加了 `sqlworkbench:AssociateNotebookWithTab` 操作的权限。添加它会授予相关权限，以创建和更新链接到用户自己的笔记本或链接到与其共享的笔记本的选项卡。  | 2023 年 2 月 2 日 | 
|  [AmazonRedshiftQueryEditorV2NoSharing](#redshift-policy-managed-policies-query-editor-V2-no-sharing)：对现有策略的更新  |  为了授予使用笔记本的权限，Amazon Redshift 添加了以下操作的权限： [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/redshift/latest/mgmt/redshift-iam-access-control-identity-based.html)  | 2022 年 10 月 17 日 | 
|  [AmazonRedshiftQueryEditorV2ReadSharing](#redshift-policy-managed-policies-query-editor-V2-read-sharing)：对现有策略的更新  |  为了授予使用笔记本的权限，Amazon Redshift 添加了以下操作的权限： [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/redshift/latest/mgmt/redshift-iam-access-control-identity-based.html)  | 2022 年 10 月 17 日 | 
|  [AmazonRedshiftQueryEditorV2ReadWriteSharing](#redshift-policy-managed-policies-query-editor-V2-write-sharing)：对现有策略的更新  |  为了授予使用笔记本的权限，Amazon Redshift 添加了以下操作的权限： [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/redshift/latest/mgmt/redshift-iam-access-control-identity-based.html)  | 2022 年 10 月 17 日 | 
|  [AmazonRedshiftServiceLinkedRolePolicy](#redshift-policy-managed-policies-service-linked-role-policy)：对现有策略的更新  |  Amazon Redshift 添加了命名空间 `AWS/Redshift` 以允许向 CloudWatch 发布指标。  | 2022 年 9 月 7 日 | 
|  [AmazonRedshiftQueryEditorV2NoSharing](#redshift-policy-managed-policies-query-editor-V2-no-sharing)：对现有策略的更新  |  Amazon Redshift 添加了用于执行 `sqlworkbench:ListQueryExecutionHistory` 和 `sqlworkbench:GetQueryExecutionHistory` 操作的权限。这授予了查看查询历史记录的权限。  | 2022 年 8 月 30 日 | 
|  [AmazonRedshiftQueryEditorV2ReadSharing](#redshift-policy-managed-policies-query-editor-V2-read-sharing)：对现有策略的更新  |  Amazon Redshift 添加了用于执行 `sqlworkbench:ListQueryExecutionHistory` 和 `sqlworkbench:GetQueryExecutionHistory` 操作的权限。这授予了查看查询历史记录的权限。  | 2022 年 8 月 30 日 | 
|  [AmazonRedshiftQueryEditorV2ReadWriteSharing](#redshift-policy-managed-policies-query-editor-V2-write-sharing)：对现有策略的更新  |  Amazon Redshift 添加了用于执行 `sqlworkbench:ListQueryExecutionHistory` 和 `sqlworkbench:GetQueryExecutionHistory` 操作的权限。这授予了查看查询历史记录的权限。  | 2022 年 8 月 30 日 | 
|  [AmazonRedshiftFullAccess](#redshift-policy-managed-policies-full-access)：对现有策略的更新  |  Amazon Redshift Serverless 的权限已添加到现有的 AmazonRedshiftFullAccess 托管式策略中。  | 2022 年 7 月 22 日 | 
|  [AmazonRedshiftDataFullAccess](#redshift-policy-managed-policies-data-full-access)：对现有策略的更新  |  Amazon Redshift 已将标签 aws:ResourceTag/RedshiftDataFullAccess 权限的 redshift-serverless:GetCredentials 默认作用域条件从 StringEquals 更新为 StringLike，以授予对使用标签键 RedshiftDataFullAccess 和任何标签值标记的资源的访问权限。 | 2022 年 7 月 11 日 | 
|  [AmazonRedshiftDataFullAccess](#redshift-policy-managed-policies-data-full-access)：对现有策略的更新  |  Amazon Redshift 添加了新权限，以允许 redshift-serverless:GetCredentials 获得对 Amazon Redshift Serverless 的临时凭证。 | 2022 年 7 月 8 日 | 
|  [AmazonRedshiftQueryEditorV2NoSharing](#redshift-policy-managed-policies-query-editor-V2-no-sharing)：对现有策略的更新  |  Amazon Redshift 添加了用于执行 `sqlworkbench:GetAccountSettings` 操作的权限。这将授予获取账户设置的权限。  | 2022 年 6 月 15 日 | 
|  [AmazonRedshiftQueryEditorV2ReadSharing](#redshift-policy-managed-policies-query-editor-V2-read-sharing)：对现有策略的更新  |  Amazon Redshift 添加了用于执行 `sqlworkbench:GetAccountSettings` 操作的权限。这将授予获取账户设置的权限。  | 2022 年 6 月 15 日 | 
|  [AmazonRedshiftQueryEditorV2ReadWriteSharing](#redshift-policy-managed-policies-query-editor-V2-write-sharing)：对现有策略的更新  |  Amazon Redshift 添加了用于执行 `sqlworkbench:GetAccountSettings` 操作的权限。这将授予获取账户设置的权限。  | 2022 年 6 月 15 日 | 
|  [AmazonRedshiftServiceLinkedRolePolicy](#redshift-policy-managed-policies-service-linked-role-policy)：对现有策略的更新  |  为了允许对新的 Amazon Redshift Serverless 端点进行公有访问，Amazon Redshift 在客户账户中分配弹性 IP 地址并将其关联到 VPC 端点的弹性网络接口。它通过由服务相关角色提供的权限来完成此操作。要启用此使用案例，分配和释放弹性 IP 地址的操作将添加到 Amazon Redshift Serverless 服务相关角色中。  | 2022 年 5 月 26 日 | 
|  [AmazonRedshiftQueryEditorV2FullAccess](#redshift-policy-managed-policies-query-editor-V2)：对现有策略的更新  |  操作 `sqlworkbench:ListTaggedResources` 的权限。它专门适用于 Amazon Redshift 查询编辑器 v2 资源。此策略更新授予仅可通过查询编辑器 v2 调用 `tag:GetResources` 的权限。  | 2022 年 2 月 22 日 | 
|  [AmazonRedshiftQueryEditorV2NoSharing](#redshift-policy-managed-policies-query-editor-V2-no-sharing)：对现有策略的更新  |  操作 `sqlworkbench:ListTaggedResources` 的权限。它专门适用于 Amazon Redshift 查询编辑器 v2 资源。此策略更新授予仅可通过查询编辑器 v2 调用 `tag:GetResources` 的权限。  | 2022 年 2 月 22 日 | 
|  [AmazonRedshiftQueryEditorV2ReadSharing](#redshift-policy-managed-policies-query-editor-V2-read-sharing)：对现有策略的更新  |  操作 `sqlworkbench:ListTaggedResources` 的权限。它专门适用于 Amazon Redshift 查询编辑器 v2 资源。此策略更新授予仅可通过查询编辑器 v2 调用 `tag:GetResources` 的权限。  | 2022 年 2 月 22 日 | 
|  [AmazonRedshiftQueryEditorV2ReadWriteSharing](#redshift-policy-managed-policies-query-editor-V2-write-sharing)：对现有策略的更新  |  操作 `sqlworkbench:ListTaggedResources` 的权限。它专门适用于 Amazon Redshift 查询编辑器 v2 资源。此策略更新授予仅可通过查询编辑器 v2 调用 `tag:GetResources` 的权限。  | 2022 年 2 月 22 日 | 
|  [AmazonRedshiftQueryEditorV2ReadSharing](#redshift-policy-managed-policies-query-editor-V2-read-sharing)：对现有策略的更新  |  托管式策略增加了 `sqlworkbench:AssociateQueryWithTab` 操作的权限。增加此权限将允许客户创建编辑器选项卡，以链接到与其共享的查询。  | 2022 年 2 月 22 日 | 
|  [AmazonRedshiftServiceLinkedRolePolicy](#redshift-policy-managed-policies-service-linked-role-policy) – 对现有策略的更新  |  Amazon Redshift 添加了新操作的权限，允许对 Amazon Redshift 网络和 VPC 资源进行管理。  | 2021 年 11 月 22 日 | 
|  [AmazonRedshiftAllCommandsFullAccess](#redshift-policy-managed-policies-service-linked-role-commands) – 新策略  |  Amazon Redshift 添加了一项新策略，允许使用从 Amazon Redshift 控制台创建的 IAM 角色，并将其设置为默认角色，以便集群从 Amazon S3 运行 COPY、UNLOAD、CREATE EXTERNAL SCHEMA、CREATE EXTERNAL FUNCTION 和 CREATE MODEL 和 CREATE LIBRARY 命令。  | 2021 年 11 月 18 日 | 
|  [AmazonRedshiftServiceLinkedRolePolicy](#redshift-policy-managed-policies-service-linked-role-policy) – 对现有策略的更新  |  Amazon Redshift 添加了新操作的权限，允许管理 Amazon Redshift CloudWatch 日志组和日志流，包括审计日志导出。  | 2021 年 11 月 15 日 | 
|  [AmazonRedshiftFullAccess](#redshift-policy-managed-policies-full-access) – 对现有策略的更新  |  Amazon Redshift 添加了新权限。以允许模型可解释性、DynamoDB、Redshift Spectrum 和 Amazon RDS 联合身份验证等功能。 | 2021 年 10 月 7 日 | 
|  [AmazonRedshiftQueryEditorV2FullAccess](#redshift-policy-managed-policies-query-editor-V2) – 新策略  |  Amazon Redshift 添加了一项新策略，允许对 Amazon Redshift 查询编辑器 v2 的完全访问。  | 2021 年 9 月 24 日 | 
|  [AmazonRedshiftQueryEditorV2NoSharing](#redshift-policy-managed-policies-query-editor-V2-no-sharing) – 新策略  |  Amazon Redshift 添加了一项新策略，允许在不共享资源的情况下使用 Amazon Redshift 查询编辑器 v2。  | 2021 年 9 月 24 日 | 
|  [AmazonRedshiftQueryEditorV2ReadSharing](#redshift-policy-managed-policies-query-editor-V2-read-sharing) – 新策略  |  Amazon Redshift 添加了一项新策略，允许在 Amazon Redshift 查询编辑器 v2 中进行读取共享。  | 2021 年 9 月 24 日 | 
|  [AmazonRedshiftQueryEditorV2ReadWriteSharing](#redshift-policy-managed-policies-query-editor-V2-write-sharing) – 新策略  |  Amazon Redshift 添加了一项新策略，允许在 Amazon Redshift 查询编辑器 v2 中进行读取和更新共享。  | 2021 年 9 月 24 日 | 
|  [AmazonRedshiftFullAccess](#redshift-policy-managed-policies-full-access) – 对现有策略的更新  |  Amazon Redshift 添加了新的权限，以允许 `sagemaker:*Job*`。  | 2021 年 8 月 18 日 | 
|  [AmazonRedshiftDataFullAccess](#redshift-policy-managed-policies-data-full-access) – 对现有策略的更新  |  Amazon Redshift 添加了新的权限，以允许 `AuthorizeDataShare`。  | 2021 年 8 月 12 日 | 
|  [AmazonRedshiftDataFullAccess](#redshift-policy-managed-policies-data-full-access) – 对现有策略的更新  |  Amazon Redshift 添加了新的权限，以允许 `BatchExecuteStatement`。  | 2021 年 7 月 27 日 | 
|  Amazon Redshift 开始跟踪更改  |  Amazon Redshift 开始跟踪其 AWS 托管式策略的更改。  | 2021 年 7 月 27 日 | 

## AmazonRedshiftReadOnlyAccess
<a name="redshift-policy-managed-policies-read-only"></a>

授予 AWS 账户对所有 Amazon Redshift 资源的只读访问权限。

您可以在 IAM 控制台上找到 [AmazonRedshiftReadOnlyAccess](https://console.aws.amazon.com/iam/home#policies/arn:aws:iam::aws:policy/AmazonRedshiftReadOnlyAccess) 策略，可以在《AWS 托管式策略参考指南》**中找到 [AmazonRedshiftReadOnlyAccess](https://docs.aws.amazon.com/aws-managed-policy/latest/reference/AmazonRedshiftReadOnlyAccess.html) 相关信息。

## AmazonRedshiftFullAccess
<a name="redshift-policy-managed-policies-full-access"></a>

授予 AWS 账户对所有 Amazon Redshift 资源的完全访问权限。此外，此策略还授予对所有 Amazon Redshift Serverless 资源的完全访问权限。

您可以在 IAM 控制台上找到 [AmazonRedshiftFullAccess](https://console.aws.amazon.com/iam/home#policies/arn:aws:iam::aws:policy/AmazonRedshiftFullAccess) 策略，在《AWS 托管式策略参考指南》**中找到 [AmazonRedshiftFullAccess](https://docs.aws.amazon.com/aws-managed-policy/latest/reference/AmazonRedshiftFullAccess.html)。

## AmazonRedshiftQueryEditor
<a name="redshift-policy-managed-policies-query-editor"></a>

授予账户对 Amazon Redshift 控制台查询编辑器的完全访问权限。

您可以在 IAM 控制台上找到 [AmazonRedshiftQueryEditor](https://console.aws.amazon.com/iam/home#policies/arn:aws:iam::aws:policy/AmazonRedshiftQueryEditor) 策略，在《AWS 托管式策略参考指南》**中找到 [AmazonRedshiftQueryEditor](https://docs.aws.amazon.com/aws-managed-policy/latest/reference/AmazonRedshiftQueryEditor.html)。

## AmazonRedshiftDataFullAccess
<a name="redshift-policy-managed-policies-data-full-access"></a>

授予 AWS 账户对所有 Amazon Redshift 数据 API 操作和资源的完全访问权限。

您可以在 IAM 控制台上找到 [AmazonRedshiftDataFullAccess](https://console.aws.amazon.com/iam/home#policies/arn:aws:iam::aws:policy/AmazonRedshiftDataFullAccess) 策略，在《AWS 托管式策略参考指南》**中找到 [AmazonRedshiftDataFullAccess](https://docs.aws.amazon.com/aws-managed-policy/latest/reference/AmazonRedshiftDataFullAccess.html)。

## AmazonRedshiftQueryEditorV2FullAccess
<a name="redshift-policy-managed-policies-query-editor-V2"></a>

授予账户对 Amazon Redshift 查询编辑器 v2 的完全访问权限。此策略还授予访问其它所需服务的权限。

您可以在 IAM 控制台上找到 [AmazonRedshiftQueryEditorV2FullAccess](https://console.aws.amazon.com/iam/home#policies/arn:aws:iam::aws:policy/AmazonRedshiftQueryEditorV2FullAccess) 策略，在《AWS 托管式策略参考指南》**中找到 [AmazonRedshiftQueryEditorV2FullAccess](https://docs.aws.amazon.com/aws-managed-policy/latest/reference/AmazonRedshiftQueryEditorV2FullAccess.html)。

## AmazonRedshiftQueryEditorV2NoSharing
<a name="redshift-policy-managed-policies-query-editor-V2-no-sharing"></a>

授予账户使用 Amazon Redshift 查询编辑器 v2 的能力（资源不共享）。此策略还授予访问其它所需服务的权限。使用此策略的主体无法标记其资源（例如查询），因此无法与同一 AWS 账户 中的其它主体共享这些资源。

您可以在 IAM 控制台上找到 [AmazonRedshiftQueryEditorV2NoSharing](https://console.aws.amazon.com/iam/home#policies/arn:aws:iam::aws:policy/AmazonRedshiftQueryEditorV2NoSharing) 策略，在《AWS 托管式策略参考指南》**中找到 [AmazonRedshiftQueryEditorV2NoSharing](https://docs.aws.amazon.com/aws-managed-policy/latest/reference/AmazonRedshiftQueryEditorV2NoSharing.html)。

## AmazonRedshiftQueryEditorV2ReadSharing
<a name="redshift-policy-managed-policies-query-editor-V2-read-sharing"></a>

授予账户使用 Amazon Redshift 查询编辑器 v2 的能力（资源共享受限）。此策略还授予访问其它所需服务的权限。使用此策略的主体可以标记其资源（例如查询），以便与同一 AWS 账户 中的其它主体共享这些资源。获得授权的主体可读取其与团队共享的资源，但无法更新。

您可以在 IAM 控制台上找到 [AmazonRedshiftQueryEditorV2ReadSharing](https://console.aws.amazon.com/iam/home#policies/arn:aws:iam::aws:policy/AmazonRedshiftQueryEditorV2ReadSharing) 策略，在《AWS 托管式策略参考指南》**中找到 [AmazonRedshiftQueryEditorV2ReadSharing](https://docs.aws.amazon.com/aws-managed-policy/latest/reference/AmazonRedshiftQueryEditorV2ReadSharing.html)。

## AmazonRedshiftQueryEditorV2ReadWriteSharing
<a name="redshift-policy-managed-policies-query-editor-V2-write-sharing"></a>

授予账户使用 Amazon Redshift 查询编辑器 v2 共享资源的能力。此策略还授予访问其它所需服务的权限。使用此策略的主体可以标记其资源（例如查询），以便与同一 AWS 账户 中的其它主体共享这些资源。获得授权的主体可以读取和更新其与团队共享的资源。

您可以在 IAM 控制台上找到 [AmazonRedshiftQueryEditorV2ReadWriteSharing](https://console.aws.amazon.com/iam/home#policies/arn:aws:iam::aws:policy/AmazonRedshiftQueryEditorV2ReadWriteSharing) 策略，在《AWS 托管式策略参考指南》**中找到 [AmazonRedshiftQueryEditorV2ReadWriteSharing](https://docs.aws.amazon.com/aws-managed-policy/latest/reference/AmazonRedshiftQueryEditorV2ReadWriteSharing.html)。

## AmazonRedshiftServiceLinkedRolePolicy
<a name="redshift-policy-managed-policies-service-linked-role-policy"></a>

您无法将 AmazonRedshiftServiceLinkedRolePolicy 策略附加至您的 IAM 实体。把此策略附加至服务相关的角色，该角色允许 Amazon Redshift 访问账户资源。有关更多信息，请参阅[使用面向 Amazon Redshift 的服务相关角色](https://docs.aws.amazon.com/redshift/latest/mgmt/using-service-linked-roles.html)。

您可以在 IAM 控制台上找到 [AmazonRedshiftServiceLinkedRolePolicy](https://console.aws.amazon.com/iam/home#policies/arn:aws:iam::aws:policy/AmazonRedshiftServiceLinkedRolePolicy) 策略，在《AWS 托管式策略参考指南》**中找到 [AmazonRedshiftServiceLinkedRolePolicy](https://docs.aws.amazon.com/aws-managed-policy/latest/reference/AmazonRedshiftServiceLinkedRolePolicy.html)。

## AmazonRedshiftAllCommandsFullAccess
<a name="redshift-policy-managed-policies-service-linked-role-commands"></a>

授予账户使用从 Amazon Redshift 控制台创建的 IAM 角色的能力，并将其设置为默认角色，以便集群从 Amazon S3 运行 COPY、UNLOAD、CREATE EXTERNAL SCHEMA、CREATE EXTERNAL FUNCTION 和 CREATE MODEL 命令。该策略还授予账户为相关服务运行 SELECT 语句的权限，例如 Amazon S3、CloudWatch Logs、Amazon SageMaker AI 或 AWS Glue。

您可以在 IAM 控制台上找到 [AmazonRedshiftAllCommandsFullAccess](https://console.aws.amazon.com/iam/home#policies/arn:aws:iam::aws:policy/AmazonRedshiftAllCommandsFullAccess) 策略，在《AWS 托管式策略参考指南》**中找到 [AmazonRedshiftAllCommandsFullAccess](https://docs.aws.amazon.com/aws-managed-policy/latest/reference/AmazonRedshiftAllCommandsFullAccess.html)。

## AmazonRedshiftFederatedAuthorization
<a name="redshift-policy-managed-policies-federated-authorization"></a>

 该策略整合了使用 Amazon Redshift 联合身份验证权限对 Glue Data Catalog 数据库运行查询所需的 IAM 操作。此类查询通过 AWS Glue 执行，因此需要对目录对象执行 Get 操作来发现这些对象，并需要对目录对象执行 Create、Update、Rename 和 Delete 操作来修改这些对象。请注意，资源由 Amazon Redshift 管理，因此主体还需获得 Redshift 权限才能完成查询。`glue:FederateAuthorization` 操作允许 AWS Glue 将目录对象的授权决策委派给 Amazon Redshift。

 该策略允许主体使用 Amazon Redshift 联合身份验证权限对目录运行查询，但禁止向 AWS Glue 注册和取消注册 Amazon Redshift 命名空间。请参阅有关介绍 Amazon Redshift 联合身份验证权限设置的 IAM 策略要求的文档。

您可以在 IAM 控制台上找到 [AmazonRedshiftFederatedAuthorization](https://console.aws.amazon.com/iam/home#policies/arn:aws:iam::aws:policy/AmazonRedshiftFederatedAuthorization) 策略，在《AWS 托管式策略参考指南》**中找到 [AmazonRedshiftFederatedAuthorization](https://docs.aws.amazon.com/aws-managed-policy/latest/reference/AmazonRedshiftFederatedAuthorization.html)。

此外，您还可以创建自定义 IAM 策略，以授予账户 Amazon Redshift API 操作和资源访问的权限。您可以将这些自定义策略附加到需要这些权限的 IAM 角色或组。





## 使用 Redshift Spectrum 所需的权限
<a name="redshift-spectrum-policy-resources"></a>

Amazon Redshift Spectrum 需要其他 AWS 服务访问资源的权限。有关 Redshift Spectrum 的 IAM 策略中的权限的详细信息，请参阅 *Amazon Redshift 数据库开发人员指南*中的 [Amazon Redshift Spectrum 的 IAM 策略](https://docs.aws.amazon.com/redshift/latest/dg/c-spectrum-iam-policies.html)。

## 使用 Amazon Redshift 控制台所需的权限
<a name="redshift-policy-resources.required-permissions.console"></a>

用户若要能够使用 Amazon Redshift 控制台，则必须拥有一组最低的权限来允许用户为自己的 AWS 账户描述 Amazon Redshift 资源。这些权限还必须允许用户描述其他相关信息（包括 Amazon EC2 安全、Amazon CloudWatch、Amazon SNS 和网络信息）。

如果创建比必需的最低权限更为严格的 IAM 策略，对于附加了该 IAM 策略的用户，控制台无法按预期正常运行。要确保这些用户仍可使用 Amazon Redshift 控制台，也可向用户附加 `AmazonRedshiftReadOnlyAccess` 托管式策略。其操作方法，请见[适用于 Amazon Redshift 的 AWS 托管式策略](#redshift-policy-resources.managed-policies)所述。

有关授予用户访问 Amazon Redshift 控制台上的查询编辑器的权限，请参阅[使用 Amazon Redshift 控制台查询编辑器所需的权限](#redshift-policy-resources.required-permissions.query-editor)。

对于只需要调用 AWS CLI 或 Amazon Redshift API 的用户，无需为其提供最低限度的控制台权限。

## 使用 Amazon Redshift 控制台查询编辑器所需的权限
<a name="redshift-policy-resources.required-permissions.query-editor"></a>

一个用户若要使用 Amazon Redshift 查询编辑器，该用户必须具有一组 Amazon Redshift 和 Amazon Redshift 数据 API 操作的最低权限。要使用密钥连接到数据库，您还必须具有 Secrets Manager 权限。

要授予用户对 Amazon Redshift 控制台上的查询编辑器的访问权限，请附加 `AmazonRedshiftQueryEditor` 和 `AmazonRedshiftReadOnlyAccess` AWS 托管式策略。`AmazonRedshiftQueryEditor` 策略允许用户只检索其自己的 SQL 语句的结果。也就是说，相同 `aws:userid` 提交的语句，如 `AmazonRedshiftQueryEditor` AWS 托管式策略的此部分所示。

```
{
    "Sid":"DataAPIIAMStatementPermissionsRestriction",
    "Action": [
        "redshift-data:GetStatementResult",
        "redshift-data:CancelStatement",
        "redshift-data:DescribeStatement",
        "redshift-data:ListStatements"
    ],
    "Effect": "Allow",
    "Resource": "*",
    "Condition": {
        "StringEquals": {
            "redshift-data:statement-owner-iam-userid": "${aws:userid}"
        }
    }
}
```

要允许用户检索同一 IAM 角色中其他用户的 SQL 语句的结果，请创建您自己的策略，而不需要限制对当前用户的访问权限的条件。同时限制管理员更改策略的访问权限。

## 使用查询编辑器 v2 所需的权限
<a name="redshift-policy-resources.required-permissions.query-editor-v2"></a>

需要使用 Amazon Redshift 查询编辑器 v2 的用户必须拥有一组 Amazon Redshift、查询编辑器 v2 操作和其它操作的最低权限，以及其它 AWS 服务的权限，诸如 AWS Key Management Service、AWS Secrets Manager和标记服务。

要授予用户对查询编辑器 v2 的完全访问权，请附上 `AmazonRedshiftQueryEditorV2FullAccess` AWS 托管式策略。这些 `AmazonRedshiftQueryEditorV2FullAccess` 策略授权用户与同一团队中的其它人共享查询编辑器 v2 资源（例如查询）。有关如何控制查询编辑器 v2 资源访问的详细信息，请参阅 IAM 控制台上查询编辑器 v2 的特定托管式策略的定义。

一些 Amazon Redshift 查询编辑器 v2 AWS 托管式策略在条件中使用 AWS 标签，以限定对资源的访问。在查询编辑器 v2 中，共享查询的基础是附加至主体（IAM 角色）的 IAM 策略中的标签键和值 `"aws:ResourceTag/sqlworkbench-team": "${aws:PrincipalTag/sqlworkbench-team}"`。同样 AWS 账户 的主体具有相同标记值（例如 `accounting-team`），在查询编辑器 v2 中处于同一个团队。您同时只能与一个团队关联。具有管理权限的用户可以在 IAM 控制台上设置团队，方法是为所有团队成员提供相同的 `sqlworkbench-team` 标记值。如果标记值 `sqlworkbench-team` 已为 IAM 用户或 IAM 角色更改，可能要经过延迟后，更改才会反映在共享资源中。如果资源（例如查询）的标记值发生了更改，在更改生效之前可能再次出现延迟。团队成员还必须拥有 `tag:GetResources` 权限才能分享。

**示例：添加 IAM 角色的 `accounting-team` 标签**

1. 登录AWS 管理控制台，然后通过以下网址打开 IAM 控制台：[https://console.aws.amazon.com/iam/](https://console.aws.amazon.com/iam/)。

1. 在控制台的导航窗格中，选择**角色**，然后选择要编辑的角色的名称。

1. 选择**标签**选项卡，然后选择**添加**标签。

1. 添加标记密钥 **sqlworkbench-team** 和值 `accounting-team`。

1. 选择**保存更改**。

   现在，当 IAM 主体（附加了此 IAM 角色）与团队共享查询时，其它具有同样 `accounting-team` 标记值的主体可以查看查询。

有关如何将标签附加至主体（包括 IAM 角色和 IAM 用户）的更多信息，请参阅《IAM 用户指南》**中的[标记 IAM 资源](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_tags.html)部分。

您还可以使用身份提供者 (IdP) 在会话级别设置团队。这允许使用同一 IAM 角色的多个用户拥有不同的团队。IAM 角色信任策略必须允许 `sts:TagSession` 操作。有关更多信息，请参阅《IAM 用户指南》**中的[添加会话标签所需的权限](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_session-tags.html#id_session-tags_permissions-required)。将主标签属性添加到 IdP 提供的 SAML 断言中。

```
<Attribute Name="https://aws.amazon.com/SAML/Attributes/PrincipalTag:sqlworkbench-team">
    <AttributeValue>accounting-team</AttributeValue>
</Attribute>
```

按照身份提供者 (IdP) 提供的说明使用来自目录的内容填充 SAML 属性。有关身份提供者 (IdP) 和 Amazon Redshift 的更多信息，请参阅《IAM 用户指南》* *中的[使用 IAM 身份验证生成数据库用户凭证](generating-user-credentials.md)和[身份提供者和联合身份验证](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_providers.html)。

`sqlworkbench:CreateNotebookVersion` 授予在账户上获取笔记本单元格的当前内容和创建笔记本版本的权限。这意味着，在创建版本时，笔记本的当前内容与该版本的内容相同。稍后，在更新当前笔记本时，版本中单元格的内容保持不变。`sqlworkbench:GetNotebookVersion` 授予获取笔记本版本的权限。没有 `sqlworkbench:BatchGetNotebookCell` 权限但拥有笔记本的 `sqlworkbench:CreateNotebookVersion` 和 `sqlworkbench:GetNotebookVersion` 权限的用户可以访问该版本中的笔记本单元格。此用户没有 `sqlworkbench:BatchGetNotebookCell` 权限，但仍然能够通过先创建一个版本，然后获取这个已创建版本来检索笔记本单元格的内容。

## 使用 Amazon Redshift 调度程序所需的权限
<a name="iam-permission-scheduler"></a>

使用 Amazon Redshift 计划程序时，您应设置与 Amazon Redshift 计划程序 (**scheduler.redshift.amazonaws.com**) 具有信任关系的 IAM 角色，以便允许该计划程序代表您承担权限。您还可以为要计划的 Amazon Redshift API 操作将策略（权限）附加到角色。

以下示例演示 JSON 格式的策略文档，该策略用于在 Amazon Redshift 调度程序和 Amazon Redshift 之间设置信任关系。

------
#### [ JSON ]

****  

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

------

有关信任实体更多信息，请参阅 *IAM 用户指南*中的[创建向 AWS 服务委派权限的角色](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_create_for-service.html)。

您还必须为要计划的 Amazon Redshift 操作添加权限。

为使计划程序使用 `ResizeCluster` 操作，请为 IAM 策略添加如下权限。根据您的环境，您可能希望使策略限制更严格。

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Effect": "Allow",
            "Action": "redshift:ResizeCluster",
            "Resource": "*"
        }
    ]
}
```

------

有关为 Amazon Redshift 调度程序创建角色的步骤，请参阅《IAM 用户指南》**中的[为 AWS 服务创建角色（控制台）](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_create_for-service.html#roles-creatingrole-service-console)。在 IAM 控制台中创建角色时，请选择以下选项：
+ 对于**选择将使用此角色的服务**：选择 **Redshift**。
+ 对于**选择您的使用案例**，选择 **Redshift - 计划程序**。
+ 为允许计划的 Amazon Redshift 操作的角色创建或附加策略。选择**创建策略**或修改角色以便附加策略。输入计划操作的 JSON 策略。
+ 在创建角色后，编辑 IAM 角色的**信任关系**以便包含服务 `redshift.amazonaws.com`。

您创建的 IAM 角色具有信任实体 `scheduler.redshift.amazonaws.com` 和 `redshift.amazonaws.com`。它还具有附加策略，该策略允许支持的 Amazon Redshift API 操作，例如 `"redshift:ResizeCluster"`。

## 使用 Amazon EventBridge 调度程序所需的权限
<a name="iam-permission-eventbridge-scheduler"></a>

使用 Amazon EventBridge 调度程序时，您应设置与 EventBridge 计划程序 (**events.amazonaws.com**) 具有信任关系的 IAM 角色，以便允许该计划程序代表您承担权限。您还可以为要计划的 Amazon Redshift 数据 API 操作将策略（权限）附加到角色，并附加 Amazon EventBridge 操作的策略。

当您使用控制台上的 Amazon Redshift 查询编辑器创建计划查询时，您可以使用 EventBridge 调度程序。

您可以创建 IAM 角色以在 IAM 控制台上运行计划查询。在此 IAM 角色中，附加 `AmazonEventBridgeFullAccess` 和 `AmazonRedshiftDataFullAccess`。

以下示例演示 JSON 格式的策略文档，该策略用于设置与EventBridge 调度程序的信任关系。

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Effect": "Allow",
            "Principal": {
                "Service": [
                    "events.amazonaws.com"
                ]
            },
            "Action": "sts:AssumeRole"
        }
    ]
}
```

------

有关信任实体更多信息，请参阅 *IAM 用户指南*中的[创建向 AWS 服务委派权限的角色](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_create_for-service.html)。

有关为 EventBridge 调度程序创建角色的步骤，请参阅《IAM 用户指南》**中的[为 AWS 服务创建角色（控制台）](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_create_for-service.html#roles-creatingrole-service-console)。在 IAM 控制台中创建角色时，请选择以下选项：
+ 在**选择将使用此角色的服务**下，选择 **CloudWatch Events**。
+ 对于**选择您的使用案例**：选择 **CloudWatch Events**。
+ 附加以下权限策略：`AmazonEventBridgeFullAccess` 和 `AmazonRedshiftDataFullAccess`。

您创建的 IAM 角色具有信任实体 `events.amazonaws.com`。它还具有附加策略，该策略允许支持的 Amazon Redshift 数据 API 操作，例如 `"redshift-data:*"`。

## 使用 Amazon Redshift 机器学习 (ML) 所需的权限
<a name="iam-permission-ml"></a>

接下来，您可以找到使用 Amazon Redshift 机器学习 (ML) 所需权限的描述（针对不同的使用案例）。

为了让用户在 Amazon SageMaker AI 中使用 Amazon Redshift ML，请创建一个 IAM 角色，该角色拥有的策略比默认策略更具限制性。您可以使用以下策略。您还可以修改此策略以满足您的需求。

以下策略显示了从 Amazon Redshift 运行 SageMaker AI Autopilot（具备模型可解释性）所需的权限。

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "sagemaker:CreateTrainingJob",
                "sagemaker:CreateAutoMLJob",
                "sagemaker:CreateCompilationJob",
                "sagemaker:CreateEndpoint",
                "sagemaker:DescribeAutoMLJob",
                "sagemaker:DescribeTrainingJob",
                "sagemaker:DescribeCompilationJob",
                "sagemaker:DescribeProcessingJob",
                "sagemaker:DescribeTransformJob",
                "sagemaker:ListCandidatesForAutoMLJob",
                "sagemaker:StopAutoMLJob",
                "sagemaker:StopCompilationJob",
                "sagemaker:StopTrainingJob",
                "sagemaker:DescribeEndpoint",
                "sagemaker:InvokeEndpoint",
                "sagemaker:StopProcessingJob",
                "sagemaker:CreateModel",
                "sagemaker:CreateProcessingJob"
            ],
            "Resource": [
                "arn:aws:sagemaker:*:*:model/*redshift*",
                "arn:aws:sagemaker:*:*:training-job/*redshift*",
                "arn:aws:sagemaker:*:*:automl-job/*redshift*",
                "arn:aws:sagemaker:*:*:compilation-job/*redshift*",
                "arn:aws:sagemaker:*:*:processing-job/*redshift*",
                "arn:aws:sagemaker:*:*:transform-job/*redshift*",
                "arn:aws:sagemaker:*:*:endpoint/*redshift*"
            ]
        },
        {
            "Effect": "Allow",
            "Action": [
                "logs:CreateLogGroup",
                "logs:CreateLogStream",
                "logs:DescribeLogStreams",
                "logs:PutLogEvents"
            ],
            "Resource": [
                "arn:aws:logs:*:*:log-group:/aws/sagemaker/Endpoints/*redshift*",
                "arn:aws:logs:*:*:log-group:/aws/sagemaker/ProcessingJobs/*redshift*",
                "arn:aws:logs:*:*:log-group:/aws/sagemaker/TrainingJobs/*redshift*",
                "arn:aws:logs:*:*:log-group:/aws/sagemaker/TransformJobs/*redshift*"
            ]
        },
        {
            "Effect": "Allow",
            "Action": [
                "cloudwatch:PutMetricData"
            ],
            "Resource": "*",
            "Condition": {
                "StringEquals": {
                    "cloudwatch:namespace": [
                        "SageMaker",
                        "/aws/sagemaker/Endpoints",
                        "/aws/sagemaker/ProcessingJobs",
                        "/aws/sagemaker/TrainingJobs",
                        "/aws/sagemaker/TransformJobs"
                    ]
                }
            }
        },
        {
            "Effect": "Allow",
            "Action": [
                "ecr:BatchCheckLayerAvailability",
                "ecr:BatchGetImage",
                "ecr:GetAuthorizationToken",
                "ecr:GetDownloadUrlForLayer"
            ],
            "Resource": "*"
        },
        {
            "Effect": "Allow",
            "Action": [
                "s3:GetObject",
                "s3:GetBucketAcl",
                "s3:GetBucketCors",
                "s3:GetEncryptionConfiguration",
                "s3:GetBucketLocation",
                "s3:ListBucket",
                "s3:ListAllMyBuckets",
                "s3:ListMultipartUploadParts",
                "s3:ListBucketMultipartUploads",
                "s3:PutObject",
                "s3:PutBucketAcl",
                "s3:PutBucketCors",
                "s3:DeleteObject",
                "s3:AbortMultipartUpload",
                "s3:CreateBucket"
            ],
            "Resource": [
                "arn:aws:s3:::redshift-downloads",
                "arn:aws:s3:::redshift-downloads/*",
                "arn:aws:s3:::*redshift*",
                "arn:aws:s3:::*redshift*/*"
            ]
        },
        {
            "Effect": "Allow",
            "Action": [
                "s3:GetObject",
                "s3:GetBucketAcl",
                "s3:GetBucketCors",
                "s3:GetEncryptionConfiguration",
                "s3:GetBucketLocation",
                "s3:ListBucket",
                "s3:ListAllMyBuckets",
                "s3:ListMultipartUploadParts",
                "s3:ListBucketMultipartUploads",
                "s3:PutObject",
                "s3:PutBucketAcl",
                "s3:PutBucketCors",
                "s3:DeleteObject",
                "s3:AbortMultipartUpload",
                "s3:CreateBucket"
            ],
            "Resource": "*",
            "Condition": {
                "StringEqualsIgnoreCase": {
                    "s3:ExistingObjectTag/Redshift": "true"
                }
            }
        },
        {
            "Effect": "Allow",
            "Action": [
                "iam:PassRole"
            ],
            "Resource": "arn:aws:iam::*:role/*",
            "Condition": {
                "StringEquals": {
                    "iam:PassedToService": [
                        "redshift.amazonaws.com",
                        "sagemaker.amazonaws.com"
                    ]
                }
            }
        }
    ]
}
```

------

以下策略显示了允许访问 Amazon DynamoDB、Redshift Spectrum 和 Amazon RDS 联合身份验证的完全最低权限。

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "sagemaker:CreateTrainingJob",
                "sagemaker:CreateAutoMLJob",
                "sagemaker:CreateCompilationJob",
                "sagemaker:CreateEndpoint",
                "sagemaker:DescribeAutoMLJob",
                "sagemaker:DescribeTrainingJob",
                "sagemaker:DescribeCompilationJob",
                "sagemaker:DescribeProcessingJob",
                "sagemaker:DescribeTransformJob",
                "sagemaker:ListCandidatesForAutoMLJob",
                "sagemaker:StopAutoMLJob",
                "sagemaker:StopCompilationJob",
                "sagemaker:StopTrainingJob",
                "sagemaker:DescribeEndpoint",
                "sagemaker:InvokeEndpoint",
                "sagemaker:StopProcessingJob",
                "sagemaker:CreateModel",
                "sagemaker:CreateProcessingJob"
            ],
            "Resource": [
                "arn:aws:sagemaker:*:*:model/*redshift*",
                "arn:aws:sagemaker:*:*:training-job/*redshift*",
                "arn:aws:sagemaker:*:*:automl-job/*redshift*",
                "arn:aws:sagemaker:*:*:compilation-job/*redshift*",
                "arn:aws:sagemaker:*:*:processing-job/*redshift*",
                "arn:aws:sagemaker:*:*:transform-job/*redshift*",
                "arn:aws:sagemaker:*:*:endpoint/*redshift*"
            ]
        },
        {
            "Effect": "Allow",
            "Action": [
                "logs:CreateLogGroup",
                "logs:CreateLogStream",
                "logs:DescribeLogStreams",
                "logs:PutLogEvents"
            ],
            "Resource": [
                "arn:aws:logs:*:*:log-group:/aws/sagemaker/Endpoints/*redshift*",
                "arn:aws:logs:*:*:log-group:/aws/sagemaker/ProcessingJobs/*redshift*",
                "arn:aws:logs:*:*:log-group:/aws/sagemaker/TrainingJobs/*redshift*",
                "arn:aws:logs:*:*:log-group:/aws/sagemaker/TransformJobs/*redshift*"
            ]
        },
        {
            "Effect": "Allow",
            "Action": [
                "cloudwatch:PutMetricData"
            ],
            "Resource": "*",
            "Condition": {
                "StringEquals": {
                    "cloudwatch:namespace": [
                        "SageMaker",
                        "/aws/sagemaker/Endpoints",
                        "/aws/sagemaker/ProcessingJobs",
                        "/aws/sagemaker/TrainingJobs",
                        "/aws/sagemaker/TransformJobs"
                    ]
                }
            }
        },
        {
            "Effect": "Allow",
            "Action": [
                "ecr:BatchCheckLayerAvailability",
                "ecr:BatchGetImage",
                "ecr:GetAuthorizationToken",
                "ecr:GetDownloadUrlForLayer"
            ],
            "Resource": "*"
        },
        {
            "Effect": "Allow",
            "Action": [
                "s3:GetObject",
                "s3:GetBucketAcl",
                "s3:GetBucketCors",
                "s3:GetEncryptionConfiguration",
                "s3:GetBucketLocation",
                "s3:ListBucket",
                "s3:ListAllMyBuckets",
                "s3:ListMultipartUploadParts",
                "s3:ListBucketMultipartUploads",
                "s3:PutObject",
                "s3:PutBucketAcl",
                "s3:PutBucketCors",
                "s3:DeleteObject",
                "s3:AbortMultipartUpload",
                "s3:CreateBucket"
            ],
            "Resource": [
                "arn:aws:s3:::redshift-downloads",
                "arn:aws:s3:::redshift-downloads/*",
                "arn:aws:s3:::*redshift*",
                "arn:aws:s3:::*redshift*/*"
            ]
        },
        {
            "Effect": "Allow",
            "Action": [
                "s3:GetObject",
                "s3:GetBucketAcl",
                "s3:GetBucketCors",
                "s3:GetEncryptionConfiguration",
                "s3:GetBucketLocation",
                "s3:ListBucket",
                "s3:ListAllMyBuckets",
                "s3:ListMultipartUploadParts",
                "s3:ListBucketMultipartUploads",
                "s3:PutObject",
                "s3:PutBucketAcl",
                "s3:PutBucketCors",
                "s3:DeleteObject",
                "s3:AbortMultipartUpload",
                "s3:CreateBucket"
            ],
            "Resource": "*",
            "Condition": {
                "StringEqualsIgnoreCase": {
                    "s3:ExistingObjectTag/Redshift": "true"
                }
            }
        },
        {
            "Effect": "Allow",
            "Action": [
                "dynamodb:Scan",
                "dynamodb:DescribeTable",
                "dynamodb:Getitem"
            ],
            "Resource": [
                "arn:aws:dynamodb:*:*:table/*redshift*",
                "arn:aws:dynamodb:*:*:table/*redshift*/index/*"
            ]
        },
        {
            "Effect": "Allow",
            "Action": [
                "elasticmapreduce:ListInstances"
            ],
            "Resource": [
                "arn:aws:elasticmapreduce:*:*:cluster/*redshift*"
            ]
        },
        {
            "Effect": "Allow",
            "Action": [
                "elasticmapreduce:ListInstances"
            ],
            "Resource": "*",
            "Condition": {
                "StringEqualsIgnoreCase": {
                    "elasticmapreduce:ResourceTag/Redshift": "true"
                }
            }
        },
        {
            "Effect": "Allow",
            "Action": [
                "lambda:InvokeFunction"
            ],
            "Resource": "arn:aws:lambda:*:*:function:*redshift*"
        },
        {
            "Effect": "Allow",
            "Action": [
                "glue:CreateDatabase",
                "glue:DeleteDatabase",
                "glue:GetDatabase",
                "glue:GetDatabases",
                "glue:UpdateDatabase",
                "glue:CreateTable",
                "glue:DeleteTable",
                "glue:BatchDeleteTable",
                "glue:UpdateTable",
                "glue:GetTable",
                "glue:GetTables",
                "glue:BatchCreatePartition",
                "glue:CreatePartition",
                "glue:DeletePartition",
                "glue:BatchDeletePartition",
                "glue:UpdatePartition",
                "glue:GetPartition",
                "glue:GetPartitions",
                "glue:BatchGetPartition"
            ],
            "Resource": [
                "arn:aws:glue:*:*:table/*redshift*/*",
                "arn:aws:glue:*:*:catalog",
                "arn:aws:glue:*:*:database/*redshift*"
            ]
        },
        {
            "Effect": "Allow",
            "Action": [
                "secretsmanager:GetResourcePolicy",
                "secretsmanager:GetSecretValue",
                "secretsmanager:DescribeSecret",
                "secretsmanager:ListSecretVersionIds"
            ],
            "Resource": [
                "arn:aws:secretsmanager:*:*:secret:*redshift*"
            ]
        },
        {
            "Effect": "Allow",
            "Action": [
                "secretsmanager:GetRandomPassword",
                "secretsmanager:ListSecrets"
            ],
            "Resource": "*",
            "Condition": {
                "StringEquals": {
                    "secretsmanager:ResourceTag/Redshift": "true"
                }
            }
        },
        {
            "Effect": "Allow",
            "Action": [
                "iam:PassRole"
            ],
            "Resource": "arn:aws:iam::*:role/*",
            "Condition": {
                "StringEquals": {
                    "iam:PassedToService": [
                        "redshift.amazonaws.com",
                        "glue.amazonaws.com",
                        "sagemaker.amazonaws.com",
                        "athena.amazonaws.com"
                    ]
                }
            }
        }
    ]
}
```

------

或者，要使用 AWS KMS 密钥用于加密，将以下权限添加到策略中。

```
{
    "Effect": "Allow",
    "Action": [
        "kms:CreateGrant",
        "kms:Decrypt",
        "kms:DescribeKey",
        "kms:Encrypt",
        "kms:GenerateDataKey*"
    ],
    "Resource": [
        "arn:aws:kms:<your-region>:<your-account-id>:key/<your-kms-key>"
    ]
}
```

要支持 Amazon Redshift 和 SageMaker AI 代入先前的 IAM 角色以便与其它服务交互，请将以下信任策略添加到 IAM 角色中。

------
#### [ JSON ]

****  

```
{
  "Version":"2012-10-17",		 	 	 
  "Statement": [
    {
      "Effect": "Allow",
      "Principal": {
        "Service": [
          "redshift.amazonaws.com",
          "sagemaker.amazonaws.com",
          "forecast.amazonaws.com"
        ]
      },
      "Action": "sts:AssumeRole"
    }
  ]
}
```

------

先前的 Amazon S3 桶 `redshift-downloads/redshift-ml/`，是存储用于其他步骤和示例的示例数据的位置。如果您不需要从 Amazon S3 加载数据，您可以将桶删除。或者，将其替换为用于将数据加载到 Amazon Redshift 的其它 Amazon S3 桶。

**your-account-id**、**your-role** 和 **your-s3-bucket** 值是您在 CREATE MODEL（创建模型）命令中指定的账户 ID、角色和桶。

（可选）如果您为使用 Amazon Redshift ML 指定了一个 AWS KMS 密钥，请使用示例策略的 AWS KMS 密钥部分。**your-kms-key** 值是作为 CREATE MODEL 命令一部分使用的键。

如果您为超参数优化任务指定了一个私有的 Virtual Private Cloud (VPC)，请添加以下权限：

```
{
            "Effect": "Allow",
            "Action": [
            "ec2:CreateNetworkInterface",
            "ec2:CreateNetworkInterfacePermission",
            "ec2:DeleteNetworkInterface",
            "ec2:DeleteNetworkInterfacePermission",
            "ec2:DescribeNetworkInterfaces",
            "ec2:DescribeVpcs",
            "ec2:DescribeDhcpOptions",
            "ec2:DescribeSubnets",
            "ec2:DescribeSecurityGroups"
            ]
}
```

要使用模型解释，请确保您具备调用 SageMaker AI API 操作的权限。建议使用 `AmazonSageMakerFullAccess` 托管式策略。如果您要使用更具限制性的策略创建 IAM 角色，您可以使用以下策略。

------
#### [ JSON ]

****  

```
{
  "Version":"2012-10-17",		 	 	 
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "sagemaker:CreateEndpoint",
        "sagemaker:CreateEndpointConfig",
        "sagemaker:DeleteEndpoint",
        "sagemaker:DeleteEndpointConfig",
        "sagemaker:DescribeEndpoint",
        "sagemaker:DescribeEndpointConfig",
        "sagemaker:DescribeModel",
        "sagemaker:InvokeEndpoint",
        "sagemaker:ListTags"
      ],
      "Resource": "*"
    }
  ]
}
```

------

有关 `AmazonSageMakerFullAccess` 托管式策略的更多信息，请参阅《Amazon SageMaker AI 开发人员指南》**中的 [AmazonSageMakerFullAccess](https://docs.aws.amazon.com/sagemaker/latest/dg/security-iam-awsmanpol.html#security-iam-awsmanpol-AmazonSageMakerFullAccess)。

如果您想创建预测模型，我们建议您使用 `AmazonForecastFullAccess` 托管式策略。如果您要使用更具限制性的策略，请将以下策略添加到您的 IAM 角色中。

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "forecast:CreateAutoPredictor",
                "forecast:CreateDataset",
                "forecast:CreateDatasetGroup",
                "forecast:CreateDatasetImportJob",
                "forecast:CreateForecast",
                "forecast:CreateForecastExportJob",
                "forecast:DeleteResourceTree",
                "forecast:DescribeAutoPredictor",
                "forecast:DescribeDataset",
                "forecast:DescribeDatasetGroup",
                "forecast:DescribeDatasetImportJob",
                "forecast:DescribeForecast",
                "forecast:DescribeForecastExportJob",
                "forecast:StopResource",
                "forecast:TagResource",
                "forecast:UpdateDatasetGroup"
             ],
             "Resource": "*"
         }
    ]
}
```

------

如果您想创建 Amazon Bedrock 模型，我们建议您使用 `AmazonBedrockFullAccess` 托管式策略。如果您要使用更具限制性的策略，请将以下策略添加到您的 IAM 角色中。

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Effect": "Allow",
            "Action": "bedrock:InvokeModel",
            "Resource": [
                "*",
                "arn:aws:bedrock:us-east-1::foundation-model/*"
            ]
        }
    ]
}
```

------

有关 Amazon Redshift ML 的更多信息，请参阅[在 Amazon Redshift 中使用机器学习](https://docs.aws.amazon.com/redshift/latest/dg/machine_learning.html)、[CREATE MODEL](https://docs.aws.amazon.com/redshift/latest/dg/r_CREATE_MODEL.html) 或 [CREATE EXTERNAL MODEL](https://docs.aws.amazon.com/redshift/latest/dg/r_create_external_model.html)。

## 串流摄取的权限
<a name="iam-permission-streaming-ingestion"></a>

串流摄取适用于两项服务。这两项服务是 Kinesis Data Streams 和 Amazon MSK。

### 在 Kinesis Data Streams 中使用串流摄取所需的权限
<a name="iam-permission-streaming-ingestion-kinesis"></a>

有关托管式策略示例的过程，请参阅[开始使用 Amazon Kinesis Data Streams 串流摄取](https://docs.aws.amazon.com/redshift/latest/dg/materialized-view-streaming-ingestion-getting-started.html)。

### 在 Amazon MSK 中使用串流摄取所需的权限
<a name="iam-permission-streaming-ingestion-kafka"></a>

有关托管式策略示例的过程，请参阅[开始使用 Amazon Managed Streaming for Apache Kafka 串流摄取](https://docs.aws.amazon.com/redshift/latest/dg/materialized-view-streaming-ingestion-getting-started-MSK.html)。

## 使用数据共享 API 操作所需的权限
<a name="iam-permission-datasharing"></a>

要控制对数据共享 API 操作的访问，请使用基于 IAM 操作的策略。有关如何管理 IAM 策略的信息，请参阅《IAM 用户指南》**中的[管理 IAM 策略](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_manage.html)。

当创建者集群管理员需要使用 `AuthorizeDataShare` 调用来授权 AWS 账户 账户外数据共享出口的时候，更是如此。在这种情况下，您可以设置基于 IAM 操作的策略来授予此权限。使用 `DeauthorizeDataShare` 调用以撤消出口。

使用基于 IAM 操作的策略时，您还可以在策略中指定 IAM 资源，例如 `DataShareARN`。下面显示了 `DataShareARN` 的格式和示例。

```
arn:aws:redshift:region:account-id:datashare:namespace-guid/datashare-name
arn:aws:redshift:us-east-1:555555555555:datashare:86b5169f-01dc-4a6f-9fbb-e2e24359e9a8/SalesShare
```

您可以通过在 IAM 策略中指定数据更新名称来限制对特定数据共享的 `AuthorizeDataShare` 访问权限。

```
{
  "Statement": [
    {
      "Action": [
        "redshift:AuthorizeDataShare",
      ],
      "Resource": [
        "arn:aws:redshift:us-east-1:555555555555:datashare:86b5169f-01dc-4a6f-9fbb-e2e24359e9a8/SalesShare"
      ],
      "Effect": "Deny"
    }
  ]
}
```

您还可以将 IAM 策略限制为特定创建器集群拥有的所有数据共享。若要执行此操作，请将策略中的 **datashare-name** 值替换为通配符或星号。保留集群的 `namespace-guid` 值。

```
arn:aws:redshift:us-east-1:555555555555:datashare:86b5169f-01dc-4a6f-9fbb-e2e24359e9a8/*
```

以下 IAM 策略防止实体面向特定创建者集群拥有的数据共享调用 `AuthorizeDataShare`。

```
{
  "Statement": [
    {
      "Action": [
        "redshift:AuthorizeDataShare",
      ],
      "Resource": [
        "arn:aws:redshift:us-east-1:555555555555:datashare:86b5169f-01dc-4a6f-9fbb-e2e24359e9a8/*"
      ],
      "Effect": "Deny"
    }
  ]
}
```

`DataShareARN` 会根据数据共享名称和所拥有的全局唯一的集群命名空间 ID (GUID) 来限制访问。它通过将名称指定为星号来完成此操作。

## GetClusterCredentials 的资源策略
<a name="redshift-policy-resources.getclustercredentials-resources"></a>

要使用 IAM 数据库凭证通过 JDBC 或 ODBC 连接来连接到集群数据库，或以编程方式调用 `GetClusterCredentials` 操作，您需要拥有调用 `redshift:GetClusterCredentials` 操作的权限以及对 `dbuser` 资源的访问权限。

如果使用 JDBC 或 ODBC 连接，您可以指定 `server` 和 `port` 来代替 `cluster_id` 和 `region`，为此，您的策略必须允许能够访问 `redshift:DescribeClusters` 资源的 `cluster` 操作。

如果您使用可选参数 `Autocreate`、`DbGroups` 和 `DbName` 调用 `GetClusterCredentials` 操作，您还必须允许这些操作，并允许访问下表中列出的资源。

[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/redshift/latest/mgmt/redshift-iam-access-control-identity-based.html)

有关资源的更多信息，请参阅 [Amazon Redshift 资源和操作](redshift-iam-access-control-overview.md#redshift-iam-accesscontrol.actions-and-resources)。

您还可以在策略中包括以下条件：
+ `redshift:DurationSeconds`
+ `redshift:DbName`
+ `redshift:DbUser`

**重要**  
对于 SAML SSO 集成，您可能需要使用 `${redshift:DbUser}` 变量指定 IAM 策略。在此类情况下，我们强烈建议您使用条件语句，以确保调用方无法获取与其 AWS userid 不匹配的用户的凭证。例如，`"StringEquals": {"aws:userid":"AIDIODR4TAW7CSEXAMPLE:${redshift:DbUser}"}"`。请参阅[示例 8：使用 GetClusterCredentials 的 IAM 策略](#redshift-policy-examples-getclustercredentials)。有关条件的更多信息，请参阅[在策略中指定条件](redshift-iam-access-control-overview.md#redshift-policy-resources.specifying-conditions) 

## 客户管理型策略示例
<a name="redshift-iam-accesscontrol.examples"></a>

本节的用户策略示例介绍如何授予各 Amazon Redshift 操作的权限。当您使用 Amazon Redshift API、AWS 开发工具包或 AWS CLI 时，可以使用这些策略。

**注意**  
所有示例都使用美国西部（俄勒冈州）区域 (`us-west-2`) 并且包含虚构的账户 ID。

### 示例 1：为用户授予所有 Amazon Redshift 操作和资源的完全访问权限
<a name="redshift-policy-example-allow-full-access"></a>

以下策略允许访问所有资源上的所有 Amazon Redshift 操作。

------
#### [ JSON ]

****  

```
{
  "Version":"2012-10-17",		 	 	 
  "Statement": [
    {
      "Sid":"AllowRedshift",
      "Action": [
        "redshift:*"
      ],
      "Effect": "Allow",
      "Resource": "*"
    }
  ]
}
```

------

`Action` 元素中的 `redshift:*` 值指示 Amazon Redshift 中的所有操作。

### 示例 2：拒绝用户访问一组 Amazon Redshift 操作
<a name="redshift-policy-example-deny-specific-actions"></a>

默认情况下，所有权限都将被拒绝。不过，有时您需要明确拒绝对某个或某组操作的访问。以下策略允许访问所有 Amazon Redshift 操作，但明确拒绝对名称以 `Delete` 开头的任何 Amazon Redshift 操作的访问。该策略适用于 `us-west-2` 中的所有 Amazon Redshift 资源。

------
#### [ JSON ]

****  

```
{
  "Version":"2012-10-17",		 	 	 
  "Statement": [
    {
      "Sid":"AllowUSWest2Region",
      "Action": [
        "redshift:*"
      ],
      "Effect": "Allow",
      "Resource": "arn:aws:redshift:us-east-1:111122223333:*"
    },
   {
     "Sid":"DenyDeleteUSWest2Region",
     "Action": [
        "redshift:Delete*"
      ],
      "Effect": "Deny",
      "Resource": "arn:aws:redshift:us-east-1:111122223333:*"
   }
  ]
}
```

------

### 示例 3：允许用户管理集群
<a name="redshift-policy-example-allow-manage-clusters"></a>

以下策略允许用户创建、删除、修改和重启所有集群，但拒绝删除名称以 `protected` 开头的任何集群的权限。

------
#### [ JSON ]

****  

```
{
  "Version":"2012-10-17",		 	 	 
  "Statement": [
    {
      "Sid":"AllowClusterManagement",
      "Action": [
        "redshift:CreateCluster",
        "redshift:DeleteCluster",
        "redshift:ModifyCluster",
        "redshift:RebootCluster"
      ],
      "Resource": [
        "*"
      ],
      "Effect": "Allow"
    },
    {
      "Sid":"DenyDeleteProtected",
      "Action": [
        "redshift:DeleteCluster"
      ],
      "Resource": [
        "arn:aws:redshift:us-west-2:123456789012:cluster:protected*"
      ],
      "Effect": "Deny"
    }
  ]
}
```

------

### 示例 4：允许用户授予和撤销快照访问权限
<a name="redshift-policy-example-allow-authorize-revoke-snapshot"></a>

以下策略允许用户（如用户 A）执行以下操作：
+ 授予对从名为 `shared` 的集群中创建的任何快照的访问权限。
+ 撤消对从快照名称以 `shared` 开头的 `revokable` 集群中创建的任何快照的访问权限。

------
#### [ JSON ]

****  

```
{
  "Version":"2012-10-17",		 	 	 
  "Statement": [
    {
      "Sid":"AllowSharedSnapshots",
      "Action": [
        "redshift:AuthorizeSnapshotAccess"
      ],
      "Resource": [
        "arn:aws:redshift:us-west-2:123456789012:shared/*"
      ],
      "Effect": "Allow"
    },
    {
      "Sid":"AllowRevokableSnapshot",
      "Action": [
        "redshift:RevokeSnapshotAccess"
      ],
      "Resource": [
        "arn:aws:redshift:us-west-2:123456789012:snapshot:*/revokable*"
      ],
      "Effect": "Allow"
    }
  ]
}
```

------

如果用户 A 允许用户 B 访问快照，则用户 B 必须拥有以下某项策略才能从该快照还原集群。以下策略允许用户 B 描述集群、从快照还原集群以及创建集群。这些集群的名称必须以 `from-other-account` 开头。

------
#### [ JSON ]

****  

```
{
  "Version":"2012-10-17",		 	 	 
  "Statement": [
    {
      "Sid":"AllowDescribeSnapshots",
      "Action": [
        "redshift:DescribeClusterSnapshots"
      ],
      "Resource": [
        "*"
      ],
      "Effect": "Allow"
    },
    {
      "Sid":"AllowUserRestoreFromSnapshot",
      "Action": [
        "redshift:RestoreFromClusterSnapshot"
      ],
      "Resource": [
        "arn:aws:redshift:us-west-2:123456789012:snapshot:*/*",
        "arn:aws:redshift:us-west-2:444455556666:cluster:from-other-account*"
      ],
      "Effect": "Allow"
    }
  ]
}
```

------

### 示例 5：允许用户复制集群快照以及从快照中还原集群
<a name="redshift-policy-example-allow-copy-restore-snapshot"></a>

以下策略允许用户复制从名为 `big-cluster-1` 的集群中创建的任何快照，以及还原名称以 `snapshot-for-restore` 开头的任何快照。

------
#### [ JSON ]

****  

```
{
  "Version":"2012-10-17",		 	 	 
  "Statement": [
    {
      "Sid":"AllowCopyClusterSnapshot",
      "Action": [
        "redshift:CopyClusterSnapshot"
      ],
      "Resource": [
        "arn:aws:redshift:us-west-2:123456789012:snapshot:big-cluster-1/*"
      ],
      "Effect": "Allow"
    },
    {
      "Sid":"AllowRestoreFromClusterSnapshot",
      "Action": [
        "redshift:RestoreFromClusterSnapshot"
      ],
      "Resource": [
        "arn:aws:redshift:us-west-2:123456789012:snapshot:*/snapshot-for-restore*",
        "arn:aws:redshift:us-west-2:123456789012:cluster:*"
      ],
      "Effect": "Allow"
    }
  ]
}
```

------

### 示例 6：允许用户访问 Amazon Redshift 以及相关 AWS 服务的常见操作和资源
<a name="redshift-policy-example-allow-related-services"></a>

 以下示例策略允许访问 Amazon Redshift、Amazon Simple Notification Service (Amazon SNS) 和 Amazon CloudWatch 的所有操作和资源。它还允许对账户下的所有相关 Amazon EC2 资源执行指定的操作。

**注意**  
 此示例策略中指定的 Amazon EC2 操作不支持资源级权限。

------
#### [ JSON ]

****  

```
{
  "Version":"2012-10-17",		 	 	 
  "Statement": [
    {
      "Sid":"AllowRedshift",
      "Effect": "Allow",
      "Action": [
        "redshift:*"
      ],
      "Resource": [
        "*"
      ]
    },
    {
      "Sid":"AllowSNS",
      "Effect": "Allow",
        "Action": [
          "sns:*"
        ],
        "Resource": [
          "*"
        ]
      },
    {
      "Sid":"AllowCloudWatch",
      "Effect": "Allow",
      "Action": [
        "cloudwatch:*"
      ],
      "Resource": [
        "*"
      ]
    },
    {
      "Sid":"AllowEC2Actions",
      "Effect": "Allow",
      "Action": [
        "ec2:AllocateAddress",
        "ec2:AssociateAddress",
        "ec2:AttachNetworkInterface",
        "ec2:DescribeAccountAttributes",
        "ec2:DescribeAddresses",
        "ec2:DescribeAvailabilityZones",
        "ec2:DescribeInternetGateways",
        "ec2:DescribeSecurityGroups",
        "ec2:DescribeSubnets",
        "ec2:DescribeVpcs"
      ],
      "Resource": [
        "*"
      ]
    }
  ]
}
```

------

### 示例 7：允许用户使用 Amazon Redshift 控制台标记资源
<a name="redshift-policy-example-allow-tagging-with-console"></a>

以下示例策略允许用户使用 AWS Resource Groups 通过 Amazon Redshift 控制台对资源进行标记。此策略可附加到调用新的或原始 Amazon Redshift 控制台的用户角色。有关标记的更多信息，请参阅[在 Amazon Redshift 中为资源添加标签](amazon-redshift-tagging.md)。

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid":"TaggingPermissions",
            "Effect": "Allow",
            "Action": [
                "redshift:DeleteTags",
                "redshift:CreateTags",
                "redshift:DescribeTags",
                "tag:UntagResources",
                "tag:TagResources"
            ],
            "Resource": "*"
        }
    ]
}
```

------

## 示例 8：使用 GetClusterCredentials 的 IAM 策略
<a name="redshift-policy-examples-getclustercredentials"></a>

以下策略使用这些示例参数值：
+ 区域：`us-west-2`
+ AWS 账户：`123456789012`
+ 集群名称：`examplecluster`

以下策略启用 `GetCredentials`、`CreateClusterUser` 和 `JoinGroup` 操作。仅在 AWS 用户 ID 与 `"AIDIODR4TAW7CSEXAMPLE:${redshift:DbUser}@yourdomain.com"` 匹配时，该策略才使用条件键以允许 `GetClusterCredentials` 和 `CreateClusterUser` 操作。IAM 访问权限仅对 `"testdb"` 数据库是必需的。该策略还允许用户参与名为 `"common_group"` 的组。

------
#### [ JSON ]

****  

```
{
"Version":"2012-10-17",		 	 	 
  "Statement": [
    {
     "Sid":"GetClusterCredsStatement",
      "Effect": "Allow",
      "Action": [
        "redshift:GetClusterCredentials"
      ],
      "Resource": [
        "arn:aws:redshift:us-west-2:123456789012:dbuser:examplecluster/${redshift:DbUser}",
        "arn:aws:redshift:us-west-2:123456789012:dbname:examplecluster/testdb",
        "arn:aws:redshift:us-west-2:123456789012:dbgroup:examplecluster/common_group"
      ],
        "Condition": {
           "StringEquals": {
           "aws:userid":"AIDIODR4TAW7CSEXAMPLE:${redshift:DbUser}@yourdomain.com"
           }
        }
    },
    {
      "Sid":"CreateClusterUserStatement",
      "Effect": "Allow",
      "Action": [
        "redshift:CreateClusterUser"
      ],
      "Resource": [
        "arn:aws:redshift:us-west-2:123456789012:dbuser:examplecluster/${redshift:DbUser}"
      ],
      "Condition": {
        "StringEquals": {
          "aws:userid":"AIDIODR4TAW7CSEXAMPLE:${redshift:DbUser}@yourdomain.com"
        }
      }
    },
    {
      "Sid":"RedshiftJoinGroupStatement",
      "Effect": "Allow",
      "Action": [
        "redshift:JoinGroup"
      ],
      "Resource": [
        "arn:aws:redshift:us-west-2:123456789012:dbgroup:examplecluster/common_group"
      ]
    }
  ]
}
```

------

以下示例显示允许 IAM 角色调用 `GetClusterCredentials` 操作的策略。该策略指定，对于名为 ` examplecluster` 的集群上的名为 ` temp_creds_user` 的数据库用户，Amazon Redshift `dbuser` 资源为其授予角色访问权限。

------
#### [ JSON ]

****  

```
{
  "Version":"2012-10-17",		 	 	 
  "Statement": {
    "Effect": "Allow",
    "Action": "redshift:GetClusterCredentials",
    "Resource": "arn:aws:redshift:us-west-2:123456789012:dbuser:examplecluster/temp_creds_user"
  }
}
```

------

您可使用通配符 (\$1) 替换完整或部分集群名称、用户名和数据库组名称。以下示例允许指定账户中的任何集群上所有以 `temp_` 开头的用户名调用。

**重要**  
以下示例中的语句指定通配符 (\$1) 作为资源的值，以便策略允许以指定字符开头的任何资源。在 IAM 策略使用通配符可能过于宽松。作为最佳实践，我们建议对您的业务应用程序使用最严格的可行策略。

------
#### [ JSON ]

****  

```
{
  "Version":"2012-10-17",		 	 	 
  "Statement": {
    "Effect": "Allow",
    "Action": "redshift:GetClusterCredentials",
    "Resource": "arn:aws:redshift:us-west-2:123456789012:dbuser:*/temp_*"
  }
}
```

------

以下示例显示一个允许 IAM 角色调用 `GetClusterCredentials` 操作的策略，并提供了自动创建新用户和指定用户在登录时加入的组的选项。`"Resource": "*" `子句向角色授予对任何资源 (包括集群、数据库用户或用户组) 的访问权限。

**重要**  
以下示例中的语句指定通配符（\$1）作为给定操作的资源，使策略能够允许访问任何集群和数据库用户，并支持创建任何用户。在 IAM 策略使用通配符可能过于宽松。作为最佳实践，我们建议对您的业务应用程序使用最严格的可行策略。

------
#### [ JSON ]

****  

```
{
  "Version":"2012-10-17",		 	 	 
  "Statement": {
    "Effect": "Allow",
    "Action": [
             "redshift:GetClusterCredentials",
             "redshift:CreateClusterUser",
		"redshift:JoinGroup"
            ],
    "Resource": "*"
  }
}
```

------

有关更多信息，请参阅 [Amazon Redshift ARN 语法](https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html#arn-syntax-redshift)。