

 Amazon Redshift 將不再支援從修補程式 198 開始建立新的 Python UDFs。現有 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 帳戶 `production`中以 開頭的任何叢集的許可`123456789012`。

------
#### [ 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) 的 `Resource` 值指定叢集 Amazon Resource Name (ARN)。因此，此陳述式適用於叢集識別符開頭為 的根 AWS 帳戶擁有的所有 Amazon Redshift 叢集`production`。

## AWS Amazon Redshift 的 受管政策
<a name="redshift-policy-resources.managed-policies"></a>

AWS 提供由 建立和管理的獨立 IAM 政策，以解決許多常見的使用案例 AWS。受管政策授與常見使用案例中必要的許可，讓您免於查詢需要哪些許可。如需詳細資訊，請參閱 *IAM 使用者指南*中的 [AWS 受管政策](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_managed-vs-inline.html#aws-managed-policies)。

您也能建立專屬的自訂 IAM 政策，以允許 Amazon Redshift API 操作與資源的相關許可。您可以將這些自訂政策附加至需要這些許可的 IAM 角色或群組。

下列各節說明 AWS 受管政策，您可以將這些政策連接到您帳戶中的使用者，並且專屬於 Amazon Redshift。

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



檢視自此服務開始追蹤 Amazon Redshift AWS 受管政策更新以來的詳細資訊。如需有關此頁面變更的自動提醒，請訂閱 Amazon Redshift 文件歷史記錄頁面上的 RSS 摘要。




| 變更 | 描述 | Date | 
| --- | --- | --- | 
|  [AmazonRedshiftFederatedAuthorization](#redshift-policy-managed-policies-federated-authorization) – 新政策  |   Amazon Redshift 新增了使用 Amazon Redshift 聯合授權執行查詢的新ease-of-use政策。  | 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_tw/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_tw/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_tw/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_tw/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_tw/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 角色，並將其設定為叢集的預設值，以便執行 COPY (從 Amazon S3)、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 Data 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 角色，並將其設定為叢集的預設值，以便執行 COPY (從 Amazon S3)、UNLOAD、CREATE EXTERNAL SCHEMA、CREATE EXTERNAL FUNCTION 和 CREATE MODEL 命令。此政策還會授予許可，以便為相關服務 (例如 Amazon S3、CloudWatch Logs、Amazon SageMaker AI 或 AWS Glue) 執行 SELECT 陳述式。

您可以在 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，因此需要取得目錄物件的動作來探索物件，以及建立、更新、重新命名和刪除動作來修改物件。請注意，資源是由 Amazon Redshift 管理，因此委託人還需要 Redshift 許可才能完成查詢。 `glue:FederateAuthorization`動作可讓 AWS Glue 將目錄物件的授權決策委派給 Amazon Redshift。

 此政策允許主體使用 Amazon Redshift 聯合許可對目錄執行查詢，但不允許向 Glue 註冊和取消註冊 Amazon Redshift AWS 命名空間。請參閱 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` 受管政策附加至使用者。若要了解如何執行這項操作，請參閱 [AWS Amazon Redshift 的 受管政策](#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 中會位於相同團隊。您一次只能與一個團隊相關聯。具有管理許可的使用者可以透過為所有團隊成員提供相同的 `sqlworkbench-team` 標籤值，以在 IAM 主控台中設定團隊。如果 IAM 使用者或 IAM 角色的 `sqlworkbench-team` 標籤值發生變更，則可能要等一段時間，共用資源才會反映此變更。如果資源 (例如查詢) 的標籤值發生變更，則一樣可能要等一段時間才會反映此變更。團隊成員還必須擁有 `tag:GetResources` 許可才能共用。

**範例：新增 IAM 角色的 `accounting-team` 標籤**

1. 登入 AWS 管理主控台 並開啟位於 https：//[https://console.aws.amazon.com/iam/](https://console.aws.amazon.com/iam/) 的 IAM 主控台。

1. 在主控台導覽窗格中，選擇 **Roles** (角色)，然後選擇您要編輯的角色名稱。

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 主控台中建立角色時，選擇以下項目：
+ 針對 **Choose the service that will use this role (選擇將使用此角色的服務)**：選擇 **Redshift**。
+ 針對 **Select your use case (選取您的使用案例)**：選擇 **Redshift - Scheduler (Redshift - 排程器)**。
+ 建立政策，或將政策附加到允許排程 Amazon Redshift 操作的角色。選擇 **Create policy (建立政策)** 或修改角色以連接政策。輸入要排程之操作的 JSON 政策。
+ 建立角色之後，編輯 IAM 角色的 **Trust Relationship (信任關係)** 以納入服務 `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 事件**。
+ 針對**選取您的使用案例**：選擇 **CloudWatch 事件**。
+ 附加以下許可政策：`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 角色，請將下列信任政策新增至該角色。

------
#### [ 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 命令一部分的金鑰。

當您為 hyperparameter 調校任務指定私有虛擬私有雲端 (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)。

如果您想要建立 Forecast 模型，建議您使用 `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/*
```

以下是可防止實體呼叫特定生產者叢集所擁有資料共用上 `AuthorizeDataShare` 的 IAM 政策。

```
{
  "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`動作，您需要許可來呼叫可存取 `dbuser` 資源`redshift:GetClusterCredentials`的動作。

如果您使用 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_tw/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 使用者 ID 不相符的使用者登入資料。例如 `"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 SDKs或 時，這些政策即可運作 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 從快照還原叢集。下列政策允許使用者 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 Notiﬁcation 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 符合 時，才允許 `GetClusterCredentials`和 `CreateClusterUser`動作`"AIDIODR4TAW7CSEXAMPLE:${redshift:DbUser}@yourdomain.com"`。僅會對 `"testdb"` 資料庫請求 IAM 存取權。此政策也允許使用者加入名為 `"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` 操作的政策。指定 Amazon Redshift `dbuser` 資源會將角色存取授予名為 ` examplecluster` 的叢集上的資料庫使用者名稱 ` temp_creds_user`。

------
#### [ 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)。