

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# S3 Vectors 中的身分和存取管理
<a name="s3-vectors-access-management"></a>

S3 Vectors 中的存取管理遵循 AWS 安全最佳實務，提供多層控制，以確保只有授權的使用者和應用程式才能存取您的向量資料。此服務與 IAM 整合，並支援身分型政策和資源型政策，讓您靈活地建構和管理整個組織的許可權。

## 驗證和授權請求
<a name="s3-vectors-authenticating-authorizing"></a>

S3 Vectors 使用 AWS 標準身分驗證和授權機制來保護對向量儲存貯體及其內容的存取。對 S3 Vectors 的每個請求都必須使用有效的 AWS 登入資料進行驗證，而且服務會根據身分型政策、資源型政策以及任何適用服務控制政策的組合來評估許可。

當用戶端使用 AWS 登入資料 （存取金鑰、來自 的臨時登入資料或 IAM 角色） 向 S3 Vectors 提出請求時 AWS STS，身分驗證程序就會開始。服務會驗證這些憑證，然後針對請求的動作和目標資源，評估與已驗證身分相關聯的許可權。此評估程序會考慮多種政策類型，並套用最低權限原則來決定是否應允許或拒絕請求。

S3 Vectors 中的授權會以多個精細程度運作。您可以在向量儲存貯體層級、個別向量索引層級，甚至是索引中的特定操作上控制存取。此階層式許可模型可讓您實作符合您組織結構和資料治理要求的複雜存取控制機制。

## 為向量儲存貯體定義的資源類型
<a name="s3-vectors-resource-types"></a>

S3 Vectors 定義了可在 IAM 政策和資源型政策中參考的特定資源類型。了解這些資源類型對於建立有效的存取控制政策至關重要，因為這些政策可為適當的使用者和應用程式提供適當的存取層級。

下表說明 S3 Vectors 中的可用資源類型。


**S3 Vectors 中的可用資源類型**  

| Resource Type (資源類型) | ARN 格式 | Description | 
| --- | --- | --- | 
| VectorBucket | arn:aws:s3vectors:region:123456789012:bucket/bucket-name | 代表向量儲存貯體，並用於儲存貯體層級的操作，例如建立、刪除或設定儲存貯體 | 
| 索引 | arn:aws:s3vectors:region:123456789012:bucket/bucket-name/index/index-name | 代表儲存貯體中的向量索引，並用於特定索引操作，例如查詢向量或管理索引中容 | 

## 向量儲存貯體的政策動作
<a name="s3-vectors-policy-actions"></a>

S3 Vectors 提供一組完整的政策動作，對應於您可以在向量儲存貯體和索引上執行的各種操作。這些動作旨在提供可以全面執行特定操作的精細控制，以讓您有效地實作最低權限原則。

下表列出 S3 Vectors 資源的所有可用政策動作。


**S3 Vectors 資源的政策動作**  

| Resource Type (資源類型) | API 操作 | 政策動作 | 政策動作的描述 | 存取層級 | 條件索引鍵 | 
| --- | --- | --- | --- | --- | --- | 
| 帳戶 | [ListVectorBuckets](https://docs.aws.amazon.com/AmazonS3/latest/API/API_S3VectorBuckets_ListVectorBuckets.html) | s3vectors:ListVectorBuckets | 授予列出帳戶和區域中的所有向量儲存貯體 | 清單 |  | 
| VectorBucket | [CreateVectorBucket](https://docs.aws.amazon.com/AmazonS3/latest/API/API_S3VectorBuckets_CreateVectorBucket.html) | s3vectors:CreateVectorBucket | 授予使用指定的組態建立新向量儲存貯體的許可權 | 寫入 | s3vectors:sseType, s3vectors:kmsKeyArn | 
| VectorBucket | [GetVectorBucket](https://docs.aws.amazon.com/AmazonS3/latest/API/API_S3VectorBuckets_GetVectorBucket.html) | s3vectors:GetVectorBucket | 授予擷取向量儲存貯體屬性和組態 | 讀取 |  | 
| VectorBucket | [DeleteVectorBucket](https://docs.aws.amazon.com/AmazonS3/latest/API/API_S3VectorBuckets_DeleteVectorBucket.html) | s3vectors:DeleteVectorBucket | 授予刪除空白向量儲存貯體的許可權 | 寫入 |  | 
| VectorBucket | [ListIndexes](https://docs.aws.amazon.com/AmazonS3/latest/API/API_S3VectorBuckets_ListIndexes.html) | s3vectors:ListIndexes | 授予列出向量儲存貯體中的所有索引的許可權 | 清單 |  | 
| VectorBucket | [PutVectorBucketPolicy](https://docs.aws.amazon.com/AmazonS3/latest/API/API_S3VectorBuckets_PutVectorBucketPolicy.html) | s3vectors:PutVectorBucketPolicy | 授予在向量儲存貯體上套用或更新資源型政策的許可權 | 許可管理 |  | 
| VectorBucket | [GetVectorBucketPolicy](https://docs.aws.amazon.com/AmazonS3/latest/API/API_S3VectorBuckets_GetVectorBucketPolicy.html) | s3vectors:GetVectorBucketPolicy | 授予擷取連接至向量儲存貯體的資源類型政策的許可權 | 讀取 |  | 
| VectorBucket | [DeleteVectorBucketPolicy](https://docs.aws.amazon.com/AmazonS3/latest/API/API_S3VectorBuckets_DeleteVectorBucketPolicy.html) | s3vectors:DeleteVectorBucketPolicy | 授予從向量儲存貯體中移除資源型政策的許可權 | 許可管理 |  | 
| 索引 | [CreateIndex](https://docs.aws.amazon.com/AmazonS3/latest/API/API_S3VectorBuckets_CreateIndex.html) | s3vectors:CreateIndex | 授予使用指定的維度和中繼資料組態建立新的向量索引的許可權 | 寫入 |  | 
| 索引 | [GetIndex](https://docs.aws.amazon.com/AmazonS3/latest/API/API_S3VectorBuckets_GetIndex.html) | s3vectors:GetIndex | 授予擷取向量索引屬性和組態的許可權 | 讀取 |  | 
| 索引 | [DeleteIndex](https://docs.aws.amazon.com/AmazonS3/latest/API/API_S3VectorBuckets_DeleteIndex.html) | s3vectors:DeleteIndex | 授予刪除向量索引及其所有內容的許可權 | 寫入 |  | 
| 索引 | [QueryVectors](https://docs.aws.amazon.com/AmazonS3/latest/API/API_S3VectorBuckets_QueryVectors.html) | (必要) s3vectors:QueryVectors | 授予對索引中的向量執行相似度查詢的許可權。  **僅使用 `s3vectors:QueryVectors` 時**，您可以擷取近似最近鄰的向量索引鍵及其與查詢向量的計算距離。只有在您未設定任何中繼資料篩選條件且未請求中繼資料時 （將 `returnMetadata` 參數保持為 false 或未指定），此許可才足夠。 | 讀取 |  | 
|  |  | (附帶條件的需要)：s3vectors:GetVectors | 如果您設定中繼資料篩選條件，在請求中將 `returnMetadata` 設定為 true 時，則為必要。  **使用 `s3vectors:QueryVectors` 和 `s3vectors:GetVectors` 時**，您可以使用中繼資料條件來篩選結果，並擷取向量索引鍵及其與查詢向量的相關資料、中繼資料和計算距離。 | 讀取 |  | 
| 索引 | [PutVectors](https://docs.aws.amazon.com/AmazonS3/latest/API/API_S3VectorBuckets_PutVectors.html) | s3vectors:PutVectors | 授予在索引中新增或更新向量的許可權 | 寫入 |  | 
| 索引 | [GetVectors](https://docs.aws.amazon.com/AmazonS3/latest/API/API_S3VectorBuckets_GetVectors.html) | s3vectors:GetVectors | 授予依向量索引鍵擷取特定向量及其中繼資料的許可權 | 讀取 |  | 
| 索引 | [ListVectors](https://docs.aws.amazon.com/AmazonS3/latest/API/API_S3VectorBuckets_ListVectors.html) | (必要) s3vectors:ListVectors | 授予列出索引中的向量索引鍵的許可權。 **僅使用 `s3vectors:ListVectors` 時**，當 `returnData` 和 `returnMetadata` 參數皆為 false 或未指定，您才能列出向量索引鍵。 | 讀取 |  | 
|  |  | (附帶條件的需要)：s3vectors:GetVectors | 如果您在請求中將 `returnData` 或 `returnMetadata` 參數設定為 true，則為必要。  **使用 `s3vectors:ListVectors` 和 `s3vectors:GetVectors` 時**，您可以透過將 `returnData` 和 `returnMetadata` 設定為 true 來擷取向量索引鍵及其相關聯的資料和中繼資料。 | 讀取 |  | 
| 索引 | [DeleteVectors](https://docs.aws.amazon.com/AmazonS3/latest/API/API_S3VectorBuckets_DeleteVectors.html) | s3vectors:DeleteVectors | 授予從索引刪除特定向量的許可權 | 寫入 |  | 

這些動作可以透過各種方式組合，以建立符合您特定存取要求的政策。例如，您可以建立包含 `s3vectors:GetVectorBucket`、`s3vectors:ListIndexes`、`s3vectors:QueryVectors` 和 `s3vectors:GetVectors` 動作的唯讀政策，或包含查詢和向量檢索許可權的政策，但不包括建立或刪除索引等管理動作。

## 向量儲存貯體的條件索引鍵
<a name="s3-vectors-condition-keys"></a>


**向量儲存貯體的條件索引鍵**  

|  | 條件索引鍵 | 描述 | Type | 
| --- | --- | --- | --- | 
| 1 | s3vectors:sseType | 依伺服器端加密類型篩選存取權，有效值：AES256 \$1 aws:kms | String | 
| 2 | s3vectors:kmsKeyArn | 針對用於加密向量儲存貯體的 AWS AWS KMS 金鑰，依金鑰 ARN 篩選存取權 | ARN | 

# S3 Vectors 身分型政策範例
<a name="s3-vectors-iam-policies"></a>

IAM 身分型政策，是您連接到 IAM 使用者、群組或角色的 JSON 文件，可用於定義可以在 S3 Vectors 資源上執行的動作。這些政策會在提出請求的身分內容中進行評估，並提供集中方式來管理整個 AWS 環境的許可。身分型政策提供清楚的稽核軌跡，說明誰擁有哪些許可權，而且可以隨著您的存取要求演變而輕鬆修改。

為 S3 Vectors 設計身分型政策時，請考慮將與您的向量資料互動的不同類型的使用者和應用程式。常見模式包括需要查詢向量的資料科學家、需要載入和管理向量資料的資料工程師、需要完全控制儲存貯體組態的管理員，以及需要特定讀取或寫入權限以存取特定向量索引的應用程式。

## 政策範例
<a name="s3-vectors-iam-policies-examples"></a>

### 管理存取政策
<a name="s3-vectors-iam-policies-admin"></a>

此政策提供 S3 Vectors 資源的完整管理存取權，適用於平台管理員或 DevOps 團隊：

```
{
    "Version": "2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "AllowAdministrativeAccess",
            "Effect": "Allow",
            "Action": [
                "s3vectors:CreateVectorBucket",
                "s3vectors:PutVectorBucketPolicy",
                "s3vectors:DeleteVectorBucket",
                "s3vectors:DeleteVectorBucketPolicy",
                "s3vectors:GetVectorBucket",
                "s3vectors:GetVectorBucketPolicy",
                "s3vectors:ListVectorBuckets",
                "s3vectors:CreateIndex",
                "s3vectors:DeleteIndex",
                "s3vectors:GetIndex",
                "s3vectors:ListIndexes",
                "s3vectors:DeleteVectors",
                "s3vectors:GetVectors",
                "s3vectors:ListVectors",
                "s3vectors:PutVectors",
                "s3vectors:QueryVectors"
            ],
            "Resource": "*"
        }
    ]
}
```

### 特定應用程式存取政策
<a name="s3-vectors-iam-policies-app"></a>

此政策專為需要對指定向量索引執行特定操作的應用程式而設計：

```
{
    "Version": "2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "AllowApplicationVectorAccess",
            "Effect": "Allow",
            "Action": [
                "s3vectors:QueryVectors",
                "s3vectors:GetVectors",
                "s3vectors:PutVectors",
                "s3vectors:ListVectors"
            ],
            "Resource": [
                "arn:aws:s3vectors:aws-region:123456789012:bucket/amzn-s3-demo-vector-bucket/index/product-recommendations",
                "arn:aws:s3vectors:aws-region:123456789012:bucket/amzn-s3-demo-vector-bucket/index/content-similarity"
            ]
        },
        {
            "Sid": "AllowGetIndex",
            "Effect": "Allow",
            "Action": "s3vectors:GetIndex",
            "Resource": "arn:aws:s3vectors:aws-region:123456789012:bucket/amzn-s3-demo-vector-bucket/index/*"
        },
        {
            "Sid": "AllowIndexInspection",
            "Effect": "Allow",
            "Action": "s3vectors:ListIndexes",
            "Resource": "arn:aws:s3vectors:aws-region:123456789012:bucket/amzn-s3-demo-vector-bucket"
        }  
    ]
}
```

# S3 Vectors 資源型政策範例
<a name="s3-vectors-resource-based-policies"></a>

以資源為基礎的政策會連接至資源。您可以為向量儲存貯體建立資源型政策。S3 Vectors 的資源型政策使用您直接連接到向量儲存貯體的 JSON 標準 AWS 政策格式，以控制對儲存貯體及其內容的存取。

與連接到使用者、群組或角色的身分型政策不同，資源型政策會連接到資源本身 （向量儲存貯體），並可將許可授予其他 AWS 帳戶的主體。這使得這類型政策成為當您需要跨組織邊界共用向量資料，或根據要存取的特定資源實作精細存取控制的情況的理想選擇。

資源型政策會與身分型政策結合評估，而有效許可權則是由所有適用政策的聯集決定。這表示主體需要身分型政策 (連接至其使用者/角色) 和資源型政策 (連接至儲存貯體) 的許可權，才能執行動作，除非資源型政策明確授予許可權。

## 範例 1：跨帳戶存取權政策
<a name="s3-vectors-resource-based-policies-example1"></a>

此政策示範如何將特定許可權授予來自不同 AWS 帳戶的使用者：

```
{
    "Version": "2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "CrossAccountBucketAccess",
            "Effect": "Allow",
            "Principal": {
                "AWS": "arn:aws:iam:123456789012:role/Admin"
            },
            "Action": [
                "s3vectors:CreateIndex",
                "s3vectors:ListIndexes",
                "s3vectors:QueryVectors",
                "s3vectors:PutVectors",
                "s3vectors:DeleteIndex"
            ],
            "Resource": [
                "arn:aws:s3vectors:aws-region:111122223333:bucket/amzn-s3-demo-vector-bucket/*",
                "arn:aws:s3vectors:aws-region:111122223333:bucket/amzn-s3-demo-vector-bucket"
            ]
        }
    ]
}
```

## 範例 2：拒絕向量索引層級動作
<a name="s3-vectors-resource-based-policies-example2"></a>

此政策展示如何拒絕 IAM 角色的特定向量索引層級動作：

```
{
    "Version": "2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "DenyIndexLevelActions",
            "Effect": "Deny",
            "Principal": {
                "AWS": "arn:aws:iam:123456789012:role/External-Role-Name"
            },
            "Action": [
                "s3vectors:QueryVectors",
                "s3vectors:PutVectors",
                "s3vectors:DeleteIndex",
                "s3vectors:GetVectors",
                "s3vectors:GetIndex",
                "s3vectors:DeleteVectors",
                "s3vectors:CreateIndex",
                "s3vectors:ListVectors"
            ],
            "Resource": "arn:aws:s3vectors:aws-region:111122223333:bucket/amzn-s3-demo-vector-bucket/*"
        }
    ]
}
```

## 範例 3：拒絕向量索引和儲存貯體層級的修改操作
<a name="s3-vectors-resource-based-policies-example3"></a>

此政策展示如何透過指定多個資源，拒絕向量索引和儲存貯體層級動作的修改請求：

```
{
    "Version": "2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "DenyModificationActionsAtBucketandIndexLevels",
            "Effect": "Deny",
            "Principal": {
                "AWS": "arn:aws:iam:123456789012:role/External-Role-Name"
            },
            "Action": [
                "s3vectors:CreateVectorBucket",
                "s3vectors:DeleteVectorBucket",
                "s3vectors:PutVectorBucketPolicy",
                "s3vectors:DeleteVectorBucketPolicy",                
                "s3vectors:CreateIndex",
                "s3vectors:DeleteIndex",
                "s3vectors:PutVectors",
                "s3vectors:DeleteVectors"
            ],
            "Resource": [
                "arn:aws:s3vectors:aws-region:111122223333:bucket/amzn-s3-demo-vector-bucket/*",
                "arn:aws:s3vectors:aws-region:111122223333:bucket/amzn-s3-demo-vector-bucket"
            ]
        }
    ]
}
```