

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

# AWS 全域條件內容索引鍵
<a name="reference_policies_condition-keys"></a>

當[委託人](https://docs.aws.amazon.com/glossary/latest/reference/glos-chap.html?icmpid=docs_homepage_addtlrcs#principal)向 提出[請求](intro-structure.md#intro-structure-request)時 AWS， 會將請求資訊 AWS 收集到[請求內容](intro-structure.md#intro-structure-request)中。您可以使用 JSON 政策的 `Condition` 元素，來比較請求內容中的鍵和您在政策中指定的鍵值。請求資訊由不同的來源提供，包括提出請求的主體、提出請求的資源，以及請求本身的中繼資料。

**全域條件索引鍵**可用於所有 AWS 服務。雖然這些條件索引鍵可用於所有政策，但不是每個請求內容都提供該索引鍵。例如，只有在 [AWS 服務主體](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_principal.html#principal-services)直接呼叫您的資源時，`aws:SourceAccount` 條件索引鍵才可用。若要進一步了解全域金鑰包含在請求內容中的情況，請參閱每個金鑰的**可用性**資訊。

有些個別服務會建立其自己的條件索引鍵，可在其他服務的請求內容中使用。**跨服務條件索引鍵**是一種全域條件索引鍵類型，其中包含符合服務名稱的字首，例如 `ec2:` 或 `lambda:`，但可在其他服務中使用。

**定義服務特定的條件金鑰**，以搭配個別 AWS 服務使用。例如，Amazon S3 可讓您使用 `s3:VersionId` 條件索引鍵撰寫政策，以限制對特定 Amazon S3 物件版本的存取。此條件索引鍵對服務是唯一的，這表示它僅適用於對 Amazon S3 服務的請求。如需服務特定的條件金鑰，請參閱 [AWS 服務的動作、資源和條件金鑰](https://docs.aws.amazon.com/service-authorization/latest/reference/reference_policies_actions-resources-contextkeys.html)，然後選擇您要檢視其金鑰的服務。

**注意**  
如果您使用只能在一些情況下可用的條件鍵，則可以使用條件運算子的 [IfExists](reference_policies_elements_condition_operators.md#Conditions_IfExists) 版本。如果請求內容中缺少條件鍵，則政策可能會讓評估失敗。例如，搭配使用以下條件區塊與 `...IfExists` 運算子，以在請求來自特定 IP 範圍或特定 VPC 時進行比對。若其中一個鍵，或兩者都不包含在請求內容中，條件仍會傳回 `true`。只有在請求內容中包含指定鍵時，才會檢查值。如需有關在運算子不存在金鑰時如何評估政策的詳細資訊，請參閱[條件運算子](reference_policies_elements_condition_operators.md)。  

```
"Condition": {
    "IpAddressIfExists": {"aws:SourceIp" : ["xxx"] },
    "StringEqualsIfExists" : {"aws:SourceVpc" : ["yyy"]} 
}
```

**重要**  
若要將您的條件與具有多個鍵值的請求內容進行比較，您必須使用 `ForAllValues` 或 `ForAnyValue` 設定運算子。只能將集合運算子與多值條件鍵搭配使用。請勿將集合運算子與單一值條件鍵搭配使用。如需詳細資訊，請參閱[用於多值內容索引鍵的集運算子](reference_policies_condition-single-vs-multi-valued-context-keys.md#reference_policies_condition-multi-valued-context-keys)。


| 主體的屬性 | 角色工作階段的屬性 | 網路的屬性 | 資源的屬性 | 請求的屬性 | 
| --- | --- | --- | --- | --- | 
|  `aws:PrincipalArn` `aws:PrincipalAccount` `aws:PrincipalOrgPaths` `aws:PrincipalOrgID` `aws:PrincipalTag/*tag-key*` `aws:PrincipalIsAWSService` `aws:PrincipalServiceName` `aws:PrincipalServiceNamesList` `aws:PrincipalType` `aws:userid` `aws:username`  |  `aws:AssumedRoot` `aws:FederatedProvider` `aws:TokenIssueTime` `aws:MultiFactorAuthAge` `aws:MultiFactorAuthPresent` `aws:ChatbotSourceArn` `aws:Ec2InstanceSourceVpc` `aws:Ec2InstanceSourcePrivateIPv4` `aws:SourceIdentity` `ec2:RoleDelivery` `ec2:SourceInstanceArn` `glue:RoleAssumedBy` `glue:CredentialIssuingService` `codebuild:BuildArn` `codebuild:ProjectArn` `lambda:SourceFunctionArn` `ssm:SourceInstanceArn` `identitystore:UserId`  |  `aws:SourceIp` `aws:SourceVpc` `aws:SourceVpcArn` `aws:SourceVpce` `aws:VpceAccount` `aws:VpceOrgID` `aws:VpceOrgPaths` `aws:VpcSourceIp`  |  `aws:ResourceAccount` `aws:ResourceOrgID` `aws:ResourceOrgPaths` `aws:ResourceTag/*tag-key*`  |  `aws:CalledVia` `aws:CalledViaFirst` `aws:CalledViaLast` `aws:CalledViaAWSMCP` `aws:ViaAWSService` `aws:ViaAWSMCPService` `aws:CurrentTime` `aws:EpochTime` `aws:referer` `aws:RequestedRegion` `aws:RequestTag/*tag-key*` `aws:TagKeys` `aws:SecureTransport` `aws:SourceAccount` `aws:SourceArn` `aws:SourceOrgID` `aws:SourceOrgPaths` `aws:UserAgent` `aws:IsMcpServiceAction`  | 

## 敏感條件索引鍵
<a name="condition-keys-sensitive"></a>

下列條件索引鍵視為敏感資訊。在這些條件索引鍵中使用萬用字元沒有任何有效的使用案例，即使具有萬用字元的索引鍵值子字串也一樣。這是因為萬用字元可能會將條件索引鍵與任何值比對，這可能會構成安全風險。
+ `aws:PrincipalAccount`
+ `aws:PrincipalOrgID`
+ `aws:ResourceAccount`
+ `aws:ResourceOrgID`
+ `aws:SourceAccount`
+ `aws:SourceOrgID`
+ `aws:SourceVpc`
+ `aws:SourceVpce`
+ `aws:VpceAccount`
+ `aws:VpceOrgID`

## 主體的屬性
<a name="condition-keys-principal-properties"></a>

使用下列條件索引鍵，將提出請求的主體詳細資訊與您在政策中指定的主體屬性進行比較。如需可以提出請求的主體清單，請參閱 [如何指定主體](reference_policies_elements_principal.md#Principal_specifying)。

### aws:PrincipalArn
<a name="condition-keys-principalarn"></a>

使用此鍵來將提出請求主體的 [Amazon Resource Name (ARN)](reference_identifiers.md#identifiers-arns) 與您在政策中所指定的 ARN 進行比較。針對 IAM 角色，請求內容會傳回角色的 ARN，而非取得角色使用者的 ARN。
+ **可用性** – 此鍵會包含在所有簽章請求的請求內容中。匿名請求不包含此鍵。您可以在此條件鍵中指定以下類型的主體：
  + IAM 角色
  + IAM 使用者
  + AWS STS 聯合身分使用者主體
  + AWS 帳戶 根使用者
+ **資料類型** – ARN

  AWS 建議您在比較 [ARN 時使用 ARN 運算子](reference_policies_elements_condition_operators.md#Conditions_ARN)，而非[字串運算子](reference_policies_elements_condition_operators.md#Conditions_String)。 ARNs
+ **值類型** - 單一值
+ **範例值**以下清單顯示您可以在 `aws:PrincipalArn` 條件索引鍵中指定的不同類型主體傳回的請求內容值：
  + **IAM 角色** – 請求內容包含條件鍵 `aws:PrincipalArn` 的下列值。請勿將擔任角色工作階段 ARN 指定為此條件鍵的值。如需有關擔任角色工作階段主體的詳細資訊，請參閱 [角色工作階段主體](reference_policies_elements_principal.md#principal-role-session)。

    ```
    arn:aws:iam::123456789012:role/role-name
    ```
  + **IAM 使用者** – 請求內容包含條件鍵 `aws:PrincipalArn` 的下列值。

    ```
    arn:aws:iam::123456789012:user/user-name
    ```
  + **AWS STS 聯合身分使用者主體** – 請求內容包含條件索引鍵 的下列值`aws:PrincipalArn`。

    ```
    arn:aws:sts::123456789012:federated-user/user-name
    ```
  + **AWS 帳戶 根使用者** – 請求內容包含條件索引鍵 的下列值`aws:PrincipalArn`。將根使用者 ARN 指定為 `aws:PrincipalArn` 條件鍵的值時，僅會限制 AWS 帳戶根使用者的許可。這不同於在資源型政策的主體元素中指定根使用者 ARN，後者將授權委派給 AWS 帳戶。如需在資源型政策的主體元素中指定根使用者 ARN 的相關資訊，請參閱 [AWS 帳戶 主體](reference_policies_elements_principal.md#principal-accounts)。

    ```
    arn:aws:iam::123456789012:root
    ```

您可以在 AWS Organizations 服務控制政策 (SCPs) `aws:PrincipalArn`中將根使用者 ARN 指定為條件索引鍵的值。SCP 是一種組織政策，用於管理您組織中的許可，並且僅會影響組織中的成員帳戶。SCP 會限制 IAM 使用者和成員帳戶中 IAM 使用者和角色的許可，包括成員帳戶的根使用者。如需有關 SCP 對許可之影響的詳細資訊，請參閱 *AWS Organizations User Guide* 中的 [SCP effects on permissions](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_policies_scps.html#scp-effects-on-permissions)。

### aws:PrincipalAccount
<a name="condition-keys-principalaccount"></a>

使用此鍵來將請求主體所屬的帳戶與您在政策中指定的帳戶識別碼進行比較。對於匿名請求，請求內容會返回 `anonymous`。
+ **可用性** – 此金鑰會包含在所有請求的請求內容中，包括匿名請求。
+ **資料類型** – [字串](reference_policies_elements_condition_operators.md#Conditions_String)
+ **值類型** - 單一值

以下範例中，除了帳號為 `123456789012` 的主體之外，一律拒絕存取。

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

****  

```
{
  "Version":"2012-10-17",		 	 	 
  "Statement": [
    {
      "Sid": "DenyAccessFromPrincipalNotInSpecificAccount",
      "Action": "service:*",
      "Effect": "Deny",
      "Resource": [
        "arn:aws:service:us-east-1:111122223333:resource"
      ],
      "Condition": {
        "StringNotEquals": {
          "aws:PrincipalAccount": [
            "123456789012"
          ]
        }
      }
    }
  ]
}
```

------

### aws:PrincipalOrgPaths
<a name="condition-keys-principalorgpaths"></a>

使用此金鑰來比較提出請求之委託人的 AWS Organizations 路徑與政策中的路徑。該主體可以是 IAM 使用者、IAM 角色、 AWS STS 聯合身分使用者主體或 AWS 帳戶根使用者。在政策中，這項條件鍵會確保申請者是在指定組織根或 AWS Organizations中組織單位 (OU) 內的帳戶成員。 AWS Organizations 路徑是 AWS Organizations 實體結構的文字表示法。如需有關使用和了解路徑的詳細資訊，請參閱 [了解 AWS Organizations 實體路徑](access_policies_last-accessed-view-data-orgs.md#access_policies_last-accessed-viewing-orgs-entity-path)。
+ **可用性** – 只有在主體是組織的成員時，請求內容中才會包含此鍵。匿名請求不包含此鍵。
+ **資料類型** – [字串](reference_policies_elements_condition_operators.md#Conditions_String) (清單)
+ **值類型** - 多重值

**注意**  
組織 ID 是全域唯一，但 OU ID 和根 ID 只有在組織內是唯一。這表示沒有兩個組織共用相同的組織 ID。不過，另一個組織的 OU 或根可能與您的 ID 相同。我們建議您在指定 OU 或根時，一律包含組織 ID。

例如，以下條件會針對帳戶中的主體傳回 `true`。這些帳戶是直接連接到 `ou-ab12-22222222` OU，但並非其子 OU。

```
"Condition" : { "ForAnyValue:StringEquals" : {
     "aws:PrincipalOrgPaths":["o-a1b2c3d4e5/r-ab12/ou-ab12-11111111/ou-ab12-22222222/"]
}}
```

以下條件會針對帳戶中的主體傳回 `true`。該帳戶是直接連接到 OU 或其任何的子 OU。當您包含萬用字元時，您必須使用 `StringLike` 條件運算子。

```
"Condition" : { "ForAnyValue:StringLike" : {
     "aws:PrincipalOrgPaths":["o-a1b2c3d4e5/r-ab12/ou-ab12-11111111/ou-ab12-22222222/*"]
}}
```

對於直接連接到任何子 OU 但不直接連接到父 OU 的帳戶中的主體，以下條件將傳回 `true`。先前的條件適用於 OU 或任何子系。以下條件僅適用於子系 (以及這些子系的任何子系)。

```
"Condition" : { "ForAnyValue:StringLike" : {
     "aws:PrincipalOrgPaths":["o-a1b2c3d4e5/r-ab12/ou-ab12-11111111/ou-ab12-22222222/ou-*"]
}}
```

以下條件會允許存取 `o-a1b2c3d4e5` 組織中的任何主體，無論其父 OU 為何。

```
"Condition" : { "ForAnyValue:StringLike" : {
     "aws:PrincipalOrgPaths":["o-a1b2c3d4e5/*"]
}}
```

`aws:PrincipalOrgPaths` 是多重值條件鍵。多重值金鑰在請求內容中可以擁有多個值。當您搭配 `ForAnyValue` 條件運算子使用多個值時，主體的路徑必須符合政策列出的其中一個路徑。如需有關多重值條件鍵的詳細資訊，請參閱 [用於多值內容索引鍵的集運算子](reference_policies_condition-single-vs-multi-valued-context-keys.md#reference_policies_condition-multi-valued-context-keys)。

```
    "Condition": {
        "ForAnyValue:StringLike": {
            "aws:PrincipalOrgPaths": [
                "o-a1b2c3d4e5/r-ab12/ou-ab12-33333333/*",
                "o-a1b2c3d4e5/r-ab12/ou-ab12-22222222/*"
            ]
        }
    }
```

### aws:PrincipalOrgID
<a name="condition-keys-principalorgid"></a>

使用此金鑰來比較 AWS Organizations 請求主體所屬組織的識別符與政策中指定的識別符。
+ **可用性** – 只有在主體是組織的成員時，請求內容中才會包含此鍵。匿名請求不包含此鍵。
+ **資料類型** – [字串](reference_policies_elements_condition_operators.md#Conditions_String)
+ **值類型** - 單一值

此全域鍵提供了列出組織中所有 AWS 帳戶的所有帳戶 ID 的替代方法。您可以使用此條件鍵來簡化在[資源型政策](access_policies_identity-vs-resource.md)中指定 `Principal` 元素。您可以在條件元素中指定[組織 ID](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_org_details.html)。當您新增和移除帳戶時，包含 `aws:PrincipalOrgID` 鍵的政策會自動包含正確的帳戶，不需要手動更新。

例如，下列 Amazon S3 儲存貯體政策允許 `o-xxxxxxxxxxx` 組織中任何帳戶的成員將物件新增至 `amzn-s3-demo-bucket` 儲存貯體。

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

****  

```
 {
  "Version":"2012-10-17",		 	 	 
  "Statement": {
    "Sid": "AllowPutObject",
    "Effect": "Allow",
    "Principal": "*",
    "Action": "s3:PutObject",
    "Resource": "arn:aws:s3:::amzn-s3-demo-bucket/*",
    "Condition": {"StringEquals":
      {"aws:PrincipalOrgID":"o-xxxxxxxxxxx"}
    }
  }
}
```

------

**注意**  
此全域條件也適用於 AWS 組織的管理帳戶。此政策可防止指定組織以外的所有主體存取 Amazon S3 儲存貯體。這包括與您的內部資源互動的任何 AWS 服務，例如 AWS CloudTrail 將日誌資料傳送到 Amazon S3 儲存貯體。若要了解如何安全地授予 AWS 服務的存取權，請參閱 [aws:PrincipalIsAWSService](#condition-keys-principalisawsservice)。

如需 的詳細資訊 AWS Organizations，請參閱[什麼是 AWS Organizations？](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_introduction.html) *AWS Organizations 《 使用者指南*》中的 。

### aws:PrincipalTag/*tag-key*
<a name="condition-keys-principaltag"></a>

使用此鍵來將連接至提出請求主體的標籤，與您在政策中所指定的標籤進行比較。若主體連接的標籤超過一個，請求內容會針對每個連接的標籤鍵包含一個 `aws:PrincipalTag` 鍵。
+ **可用性** – 若主體搭配連接標籤使用 IAM 使用者，此鍵會包含在請求內容中。其會針對主體，使用具備連接標籤或[工作階段標籤](id_session-tags.md)的 IAM 角色包含在其中。匿名請求不包含此鍵。
+ **資料類型** – [字串](reference_policies_elements_condition_operators.md#Conditions_String)
+ **值類型** - 單一值

您可以將自訂屬性以鍵值對的形式新增至使用者或角色。如需有關 IAM 標籤的詳細資訊，請參閱 [AWS Identity and Access Management 資源的標籤](id_tags.md)。您可以使用 `aws:PrincipalTag` 對 AWS 主體進行[控制存取](access_iam-tags.md#access_iam-tags_control-principals)。

此範例會示範如何建立身分型政策，允許具有 **department=hr** 標籤的使用者管理 IAM 使用者、群組或角色。若要使用此政策，請將範例政策中的*斜體預留位置文字*取代為您自己的資訊。然後，遵循[建立政策](access_policies_create.md)或[編輯政策](access_policies_manage-edit.md)中的指示進行操作。

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

****  

```
{
  "Version":"2012-10-17",		 	 	 
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "iam:Get*",
        "iam:List*",
        "iam:Generate*"
      ],
      "Resource": "*",
      "Condition": {
        "StringEquals": {
          "aws:PrincipalTag/department": "hr"
        }
      }
    }
  ]
}
```

------

### aws:PrincipalIsAWSService
<a name="condition-keys-principalisawsservice"></a>

使用此金鑰來檢查 AWS [服務主體](reference_policies_elements_principal.md#principal-services)是否直接呼叫您的資源。例如： AWS CloudTrail 使用服務主體 `cloudtrail.amazonaws.com` 將日誌寫入至 Amazon S3 儲存貯體。當服務使用服務主體對您的資源執行直接動作時，請求內容鍵會設定為 true (真)。服務代表 IAM 主體使用主體的憑證來提出請求時，內容鍵設定為 false。若服務使用[服務角色或服務連結角色](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles.html#id_roles_terms-and-concepts)來代表主體進行呼叫，則也會設定為 false。
+ **可用性** – 對於所有使用 AWS 憑證的已簽署 API 請求，此鍵會出現在請求內容中。匿名請求不包含此鍵。
+ **資料類型** – [布林值](reference_policies_elements_condition_operators.md#Conditions_Boolean)
+ **值類型** - 單一值

您可以使用此條件金鑰來限制對信任身分和預期網路位置的存取，同時安全地授予對 AWS 服務的存取。

在下列 Amazon S3 儲存貯體政策範例中，存取儲存貯體會受到限制，除非請求來自 `vpc-111bbb22` 或來自服務主體，例如 CloudTrail。

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

****  

```
{
  "Version":"2012-10-17",		 	 	 
  "Statement": [
    {
      "Sid": "ExpectedNetworkServicePrincipal",
      "Effect": "Deny",
      "Principal": "*",
      "Action": "s3:PutObject",
      "Resource": "arn:aws:s3:::amzn-s3-demo-bucket1/AWS Logs/AccountNumber/*",
      "Condition": {
        "StringNotEqualsIfExists": {
          "aws:SourceVpc": "vpc-111bbb22"
        },
        "BoolIfExists": {
          "aws:PrincipalIsAWSService": "false"
        }
      }
    }
  ]
}
```

------

在下列影片中，進一步了解如何在政策中使用 `aws:PrincipalIsAWSService` 條件鍵。

[![AWS Videos](http://img.youtube.com/vi/https://www.youtube.com/embed/gv-_H8a42G4/0.jpg)](http://www.youtube.com/watch?v=https://www.youtube.com/embed/gv-_H8a42G4)


### aws:PrincipalServiceName
<a name="condition-keys-principalservicename"></a>

使用此鍵將政策中的[服務主體](reference_policies_elements_principal.md#principal-services)名稱，以及向您的資源提出請求的服務主體進行比較。您可以使用這個鍵來檢查這個呼叫是否由特定的服務主體進行比較。當服務主體直接向您的資源要求時，`aws:PrincipalServiceName` 鍵會包含服務主體的名稱。例如， AWS CloudTrail 服務主體名稱為 `cloudtrail.amazonaws.com`。
+ **可用性** – 當 AWS 服務委託人進行呼叫時，此金鑰會出現在請求中。此鍵在任何其他情況下都不存在，包括以下情況：
  + 若服務使用[服務角色或服務連結角色](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles.html#id_roles_terms-and-concepts)來代表主體進行呼叫。
  + 服務使用 IAM 主體的憑證代表主體提出請求。
  + 如果呼叫是由 IAM 主體直接進行。
  + 如果呼叫由匿名請求者發出。
+ **資料類型** – [字串](reference_policies_elements_condition_operators.md#Conditions_String)
+ **值類型** - 單一值

您可以使用此條件金鑰來限制對信任身分和預期網路位置的存取，同時安全地授予對 AWS 服務的存取。

在下列 Amazon S3 儲存貯體政策範例中，存取儲存貯體會受到限制，除非請求來自 `vpc-111bbb22` 或來自服務主體，例如 CloudTrail。

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

****  

```
{
  "Version":"2012-10-17",		 	 	 
  "Statement": [
    {
      "Sid": "ExpectedNetworkServicePrincipal",
      "Effect": "Deny",
      "Principal": "*",
      "Action": "s3:PutObject",
      "Resource": "arn:aws:s3:::amzn-s3-demo-bucket1/AWS Logs/AccountNumber/*",
      "Condition": {
        "StringNotEqualsIfExists": {
          "aws:SourceVpc": "vpc-111bbb22",
          "aws:PrincipalServiceName": "cloudtrail.amazonaws.com"
        }
      }
    }
  ]
}
```

------

### aws:PrincipalServiceNamesList
<a name="condition-keys-principalservicenameslist"></a>

此鍵提供屬於該服務的所有[服務主體](reference_policies_elements_principal.md#principal-services)名稱清單。這是進階條件鍵。您可以用其來限制服務僅從特定區域存取您的資源。某些服務可能會建立區域服務主體，以指示特定區域內服務的特定執行個體。您可以將資源的存取限制為服務的特定執行個體。當服務主體直接向您的資源要求時，`aws:PrincipalServiceNamesList` 包含與服務區域執行個體相關聯的所有服務主體名稱的無序清單。
+ **可用性** – 當 AWS 服務委託人進行呼叫時，此金鑰會出現在請求中。此鍵在任何其他情況下都不存在，包括以下情況：
  + 若服務使用[服務角色或服務連結角色](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles.html#id_roles_terms-and-concepts)來代表主體進行呼叫。
  + 服務使用 IAM 主體的憑證代表主體提出請求。
  + 如果呼叫是由 IAM 主體直接進行。
  + 如果呼叫由匿名請求者發出。
+ **資料類型** – [字串](reference_policies_elements_condition_operators.md#Conditions_String) (清單)
+ **值類型** - 多重值

`aws:PrincipalServiceNamesList` 是多重值條件鍵。多值鍵在請求內容中可以擁有多個值。使用此鍵時，您必須使用 `ForAnyValue` 或 `ForAllValues` 設定運算子搭配[字串條件運算子](reference_policies_elements_condition_operators.md#Conditions_String)。如需有關多重值條件鍵的詳細資訊，請參閱 [用於多值內容索引鍵的集運算子](reference_policies_condition-single-vs-multi-valued-context-keys.md#reference_policies_condition-multi-valued-context-keys)。

### aws:PrincipalType
<a name="condition-keys-principaltype"></a>

使用此鍵來將發出請求的主體類型與您在政策中所指定的主體類型進行比較。如需詳細資訊，請參閱 [如何指定主體](reference_policies_elements_principal.md#Principal_specifying)。如需 `principal` 鍵值的具體範例，請參閱 [主體索引鍵值](reference_policies_variables.md#principaltable)。
+ **可用性** – 此鍵會包含在所有請求的請求內容中，包括匿名請求。
+ **資料類型** – [字串](reference_policies_elements_condition_operators.md#Conditions_String)
+ **值類型** - 單一值

### aws:userid
<a name="condition-keys-userid"></a>

使用此鍵來將申請者的主體識別碼與您在政策中所指定的 ID 進行比較。針對 IAM 使用者，請求內容值是使用者 ID。針對 IAM 角色，此值的格式可能會不同。如需針對不同主體資訊顯示方式的詳細資訊，請參閱 [如何指定主體](reference_policies_elements_principal.md#Principal_specifying)。如需 `principal` 鍵值的具體範例，請參閱 [主體索引鍵值](reference_policies_variables.md#principaltable)。
+ **可用性** – 此鍵會包含在所有請求的請求內容中，包括匿名請求。
+ **資料類型** – [字串](reference_policies_elements_condition_operators.md#Conditions_String)
+ **值類型** - 單一值

### aws:username
<a name="condition-keys-username"></a>

使用此鍵將申請者的使用者名稱與您在政策中所指定的使用者名稱進行比較。如需針對不同主體資訊顯示方式的詳細資訊，請參閱 [如何指定主體](reference_policies_elements_principal.md#Principal_specifying)。如需 `principal` 鍵值的具體範例，請參閱 [主體索引鍵值](reference_policies_variables.md#principaltable)。
+ **可用性** – 此鍵一律會包含在 IAM 使用者的請求內容中。使用 AWS 帳戶根使用者 或 IAM 角色提出的匿名請求和請求不包含此金鑰。使用 IAM Identity Center 憑證提出的請求不會在內容中包含此鍵。
+ **資料類型** – [字串](reference_policies_elements_condition_operators.md#Conditions_String)
+ **值類型** - 單一值

## 角色工作階段的屬性
<a name="condition-keys-role-session-properties"></a>

使用下列條件索引鍵來比較產生工作階段時角色工作階段的屬性。只有在主體使用角色工作階段或聯合身分使用者主體憑證發出請求時，這些條件索引鍵方才可用。這些條件索引鍵的值會內嵌在角色的工作階段權杖中。

[角色](reference_policies_elements_principal.md#principal-roles)是一種主體。您也可以使用 [主體的屬性](#condition-keys-principal-properties) 區段中的條件索引鍵，在角色提出請求時評估角色的屬性。

### aws:AssumedRoot
<a name="condition-keys-assumedroot"></a>

使用此金鑰來檢查是否使用 [AssumeRoot](https://docs.aws.amazon.com/STS/latest/APIReference/API_AssumeRoot.html) 提出請求。`AssumeRoot` 會傳回特權根使用者工作階段的短期憑證，可以用來對組織中的成員帳戶採取特權動作。如需詳細資訊，請參閱[集中管理成員帳戶的根存取權](id_root-user.md#id_root-user-access-management)。
+ **可用性**：只有在主體使用 [AssumeRoot](https://docs.aws.amazon.com/STS/latest/APIReference/API_AssumeRoot.html) 的憑證發出請求時，請求內容中才會包含此金鑰。
+ **資料類型** – [布林值](reference_policies_elements_condition_operators.md#Conditions_Boolean)
+ **值類型** - 單一值

在下列範例中，當用作服務控制政策時， 拒絕使用 AWS Organizations 成員帳戶中根使用者的長期登入資料。不過，該政策不會拒絕 `AssumeRoot` 工作階段執行 `AssumeRoot` 工作階段允許的動作。

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

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement":[
       {
          "Effect":"Deny",
          "Action":"*",
          "Resource": "*",
          "Condition":{
             "ArnLike":{
                "aws:PrincipalArn":[
                   "arn:aws:iam::*:root"
                ]
             },
             "Null":{
                "aws:AssumedRoot":"true"
             }
          }
       }
    ]
 }
```

------

### aws:FederatedProvider
<a name="condition-keys-federatedprovider"></a>

使用此鍵來將主體的發行身分提供者 (IdP) 與您在政策中所指定的 IdP 進行比較。這表示使用 [https://docs.aws.amazon.com//STS/latest/APIReference/API_AssumeRoleWithWebIdentity](https://docs.aws.amazon.com//STS/latest/APIReference/API_AssumeRoleWithWebIdentity) AWS STS 操作擔任的 IAM 角色。使用產生角色工作階段的暫時憑證提出要求時，要求內容會識別驗證原始聯合身分的 IdP。
+ **可用性** – 此金鑰存在於使用 OpenID Connect (OIDC) 提供者擔任的角色工作階段中，以及使用 OIDC 提供者呼叫 `AssumeRoleWithWebIdentity` 時的角色信任政策中。
+ **資料類型** – [字串](reference_policies_elements_condition_operators.md#Conditions_String)\$1
+ **值類型** - 單一值

\$1 資料類型取決於 IdP：
+ 如果您使用的是內建 AWS IdP，例如 [Amazon Cognito](https://docs.aws.amazon.com/cognito/latest/developerguide/iam-roles.html)，則金鑰值將為**字串**。鍵值可能類似：`cognito-identity.amazonaws.com`。
+ 如果您使用的 IdP 不是內建的 AWS，例如 [https://docs.github.com/en/actions/security-for-github-actions/security-hardening-your-deployments/configuring-openid-connect-in-amazon-web-services](https://docs.github.com/en/actions/security-for-github-actions/security-hardening-your-deployments/configuring-openid-connect-in-amazon-web-services)或 [Amazon EKS](https://docs.aws.amazon.com//eks/latest/userguide/associate-service-account-role.html)，則金鑰值將為 **ARN**。鍵值可能類似：`arn:aws:iam::111122223333:oidc-provider/oidc.eks.region.amazonaws.com/id/OIDC_Provider_ID`。

如需有關外部 IdP 和 `AssumeRoleWithWebIdentity` 的詳細資訊，請參閱[常用案例](id_federation_common_scenarios.md)。如需詳細資訊，請參閱[角色工作階段主體](reference_policies_elements_principal.md#principal-role-session)。

### aws:TokenIssueTime
<a name="condition-keys-tokenissuetime"></a>

使用此鍵來將發行暫時性安全憑證的日期和時間與您在政策中所指定的日期和時間進行比較。
+ **可用性** – 只有在主體使用暫時憑證發出請求時，請求內容中才會包含此鍵。金鑰不存在於使用存取金鑰提出的 AWS CLI API AWS 或 AWS SDK 請求中。
+ **資料類型** – [日期](reference_policies_elements_condition_operators.md#Conditions_Date)
+ **值類型** - 單一值

若要了解哪些服務支援使用暫時憑證，請參閱[AWS 使用 IAM 的 服務](reference_aws-services-that-work-with-iam.md)。

### aws:MultiFactorAuthAge
<a name="condition-keys-multifactorauthage"></a>

使用此鍵來將請求主體獲得授權使用 MFA 以來的秒數，與您在政策中所指定的數字進行比較。如需有關 MFA 的詳細資訊，請參閱 [AWS IAM 中的多重要素驗證](id_credentials_mfa.md)。

**重要**  
此條件金鑰不適用於使用存取金鑰簽署 CLI、 AWS API 或 AWS SDK AWS 請求的聯合身分或請求。若要進一步了解如何使用臨時安全憑證將 MFA 保護新增至 API 操作，請參閱 [透過 MFA 實現安全的 API 存取](id_credentials_mfa_configure-api-require.md)。  
若要檢查是否使用 MFA 來驗證 IAM 聯合身分，您可以將身分提供者的身分驗證方法 AWS 作為工作階段標籤傳遞至 。如需詳細資訊，請參閱[在 中傳遞工作階段標籤 AWS STS](id_session-tags.md)。若要針對 IAM Identity Center 身分強制執行 MFA，您可以[啟用存取控制的屬性](https://docs.aws.amazon.com/singlesignon/latest/userguide/configure-abac.html)，以使用身分提供者的身分驗證方法將 SAML 聲明宣告傳遞至 IAM Identity Center。
+ **可用性**：只有在主體使用[臨時安全憑證](id_credentials_temp.md)發出請求時，請求內容中才會包含此金鑰。含有 MFA 條件的政策可連接到：
  + IAM 使用者或群組
  + 資源，例如 Amazon S3 儲存貯體、Amazon SQS 佇列或者 Amazon SNS 主題
  + 可由使用者擔任的 IAM 角色的信任政策
+ **資料類型** – [數值](reference_policies_elements_condition_operators.md#Conditions_Numeric)
+ **值類型** - 單一值

### aws:MultiFactorAuthPresent
<a name="condition-keys-multifactorauthpresent"></a>

使用此金鑰來檢查是否使用了多重要素驗證 (MFA) 來驗證發出請求的[臨時安全憑證](id_credentials_temp.md)。

**重要**  
此條件金鑰不適用於使用存取金鑰簽署 CLI、 AWS API 或 AWS SDK AWS 請求的聯合身分或請求。若要進一步了解如何使用臨時安全憑證將 MFA 保護新增至 API 操作，請參閱 [透過 MFA 實現安全的 API 存取](id_credentials_mfa_configure-api-require.md)。  
若要檢查是否使用 MFA 來驗證 IAM 聯合身分，您可以將身分提供者的身分驗證方法 AWS 作為工作階段標籤傳遞至 。如需詳細資訊，請參閱[在 中傳遞工作階段標籤 AWS STS](id_session-tags.md)。若要針對 IAM Identity Center 身分強制執行 MFA，您可以[啟用存取控制的屬性](https://docs.aws.amazon.com/singlesignon/latest/userguide/configure-abac.html)，以使用身分提供者的身分驗證方法將 SAML 聲明宣告傳遞至 IAM Identity Center。
+ **可用性** – 只有在主體使用暫時憑證發出請求時，請求內容中才會包含此鍵。含有 MFA 條件的政策可連接到：
  + IAM 使用者或群組
  + 資源，例如 Amazon S3 儲存貯體、Amazon SQS 佇列或者 Amazon SNS 主題
  + 可由使用者擔任的 IAM 角色的信任政策
+ **資料類型** – [布林值](reference_policies_elements_condition_operators.md#Conditions_Boolean)
+ **值類型** - 單一值

臨時憑證可用來驗證擁有 [AssumeRole](https://docs.aws.amazon.com/STS/latest/APIReference/API_AssumeRole.html) 或 [GetSessionToken](https://docs.aws.amazon.com/STS/latest/APIReference/API_GetSessionToken.html) 臨時權杖的 IAM 角色和 IAM 使用者，以及 AWS 管理主控台使用者。

IAM 使用者存取金鑰是長期憑證，但在某些情況下， 會代表 IAM 使用者 AWS 建立臨時憑證以執行操作。在這些情況下，`aws:MultiFactorAuthPresent` 鍵會出現在請求中，並設為 `false` 值。在兩種常見的情況下可能會發生此情況：
+ 中的 IAM 使用者 AWS 管理主控台 在不知情的情況下使用臨時登入資料。使用者會使用他們的使用者名稱和密碼 (長期憑證) 登入主控台。不過，主控台會在背景中代表使用者產生臨時憑證。
+ 如果 IAM 使用者呼叫 AWS 服務，服務會重複使用使用者的登入資料，對不同的服務提出另一個請求。例如，呼叫 Athena 存取 Amazon S3 儲存貯體時，或使用 CloudFormation 建立 Amazon EC2 執行個體時。對於後續請求， AWS 會使用臨時登入資料。

若要了解哪些服務支援使用暫時憑證，請參閱[AWS 使用 IAM 的 服務](reference_aws-services-that-work-with-iam.md)。

`aws:MultiFactorAuthPresent` 鍵在使用長期憑證 (例如使用者存取金鑰對) 呼叫 API 或 CLI 命令時，便不會出現。因此，我們建議您在檢查此鍵時使用條件運算子的 `...IfExists` 版本。

請務必了解，下列 `Condition` 元素***不是***檢查是否使用 MFA 針對請求進行身分驗證的可靠方法。

```
#####   WARNING: NOT RECOMMENDED   #####
"Effect" : "Deny",
"Condition" : { "Bool" : { "aws:MultiFactorAuthPresent" : "false" } }
```

這個 `Deny` 效果、`Bool` 元素與 `false` 值的組合會拒絕可使用 MFA 驗證但卻未驗證的請求。這僅適用於支援使用 MFA 的暫時憑證。此陳述式不會拒絕存取使用長期憑證所提出的請求，或是使用 MFA 進行身分驗證的請求。請小心使用本範例，因為其邏輯十分複雜，而且未測試是否實際使用 MFA 身分驗證。

此外，請不要使用 `Deny` 效果、`Null` 元素與 `true` 的組合，因為其行為相同，而邏輯更為複雜。

**建議的組合**  
我們建議您使用 [`BoolIfExists`](reference_policies_elements_condition_operators.md#Conditions_IfExists) 運算子來檢查是否使用 MFA 驗證請求。

```
"Effect" : "Deny",
"Condition" : { "BoolIfExists" : { "aws:MultiFactorAuthPresent" : "false" } }
```

這個 `Deny`、`BoolIfExists` 與 `false` 的組合會拒絕未使用 MFA 驗證的請求。特別地是，它會拒絕來自未包含 MFA 之暫時憑證的請求。它也會拒絕使用長期登入資料提出的請求，例如使用存取金鑰進行的 AWS CLI 或 AWS API 操作。`*IfExists` 運算子會檢查 `aws:MultiFactorAuthPresent` 鍵是否存在以及它是否可能存在，如其存在所指出。當您想要拒絕任何未使用 MFA 驗證的請求時，請使用此項目。這更安全，但可能會破壞任何使用存取金鑰來存取 或 API 的程式碼 AWS CLI 或 AWS 指令碼。

**替代組合**  
您也可以使用 [`BoolIfExists`](reference_policies_elements_condition_operators.md#Conditions_IfExists)運算子來允許使用長期憑證提出的 MFA 驗證請求和 AWS CLI 或 AWS API 請求。

```
"Effect" : "Allow",
"Condition" : { "BoolIfExists" : { "aws:MultiFactorAuthPresent" : "true" } }
```

此條件會比對鍵是否存在，**或者**鍵是否不存在。這個 `Allow`、`BoolIfExists` 與 `true` 的組合允許使用 MFA 驗證的請求，或允許無法使用 MFA 驗證的請求。這表示請求者使用其長期存取金鑰時，允許 AWS CLI AWS API 和 AWS SDK 操作。此組合不允許來自暫時憑證，且能夠包含 MFA 的請求但未這麼做的請求。

當您使用 IAM 主控台視覺化編輯器建立政策並選擇 **MFA required** (需要 MFA) 時，即會套用此組合。此設定需要 MFA 來存取主控台，但允許不使用 MFA 進行程式設計存取。

或者，您可以使用 `Bool` 運算子，僅在使用 MFA 驗證時允許程式設計和主控台請求。

```
"Effect" : "Allow",
"Condition" : { "Bool" : { "aws:MultiFactorAuthPresent" : "true" } }
```

這個 `Allow`、`Bool` 與 `true` 的組合只允許 MFA 驗證的請求。這僅適用於支援使用 MFA 的暫時憑證。此陳述式不允許存取使用長期存取鍵所提出的請求，或是使用暫時憑證但未使用 MFA 所提出的請求。

***請不要***使用與下列內容類似的政策建構來檢查是否存在 MFA 鍵：

```
#####   WARNING: USE WITH CAUTION   #####

"Effect" : "Allow",
"Condition" : { "Null" : { "aws:MultiFactorAuthPresent" : "false" } }
```

這個 `Allow` 效果、`Null` 元素與 `false` 值的組合只允許可使用 MFA 驗證的請求，不論是否實際驗證請求都一樣。這會允許所有使用暫時憑證所提出的請求，並拒絕長期憑證的存取。請小心使用本範例，因為未測試是否實際使用 MFA 身分驗證。

### aws:ChatbotSourceArn
<a name="condition-keys-chatbotsourcearn"></a>

使用此金鑰，將主體設定的來源聊天組態 ARN 與您在頻道組態相關聯之 IAM 角色政策中指定的聊天組態 ARN 進行比較。可以根據 Amazon Q Developer 在聊天應用程式中啟動的擔任角色工作階段來授權請求。
+ **可用性** – 每當擔任角色工作階段時，聊天應用程式中的 Amazon Q Developer 都會在請求內容中包含此索引鍵。金鑰值是聊天組態 ARN，例如當您[從聊天頻道執行 AWS CLI 命令](https://docs.aws.amazon.com/chatbot/latest/adminguide/chatbot-cli-commands.html)時。
+ **資料類型** – [ARN](reference_policies_elements_condition_operators.md#Conditions_ARN)
+ **值類型** - 單一值
+ **範例值** – `arn:aws::chatbot::123456789021:chat-configuration/slack-channel/private_channel`

以下政策拒絕 Amazon S3 對來自 Slack 頻道的所有請求的指定儲存貯體提出請求。

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

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "ExampleS3Deny",
            "Effect": "Deny",
            "Action": "s3:PutObject",
            "Resource": "arn:aws:s3:::amzn-s3-demo-bucket/*",
            "Condition": {
                "ArnLike": {
                      "aws:ChatbotSourceArn": "arn:aws:chatbot::*:chat-configuration/slack-channel/*"
                }
            }
        }
    ]
}
```

------

### aws:Ec2InstanceSourceVpc
<a name="condition-keys-ec2instancesourcevpc"></a>

此鍵可識別要接收 Amazon EC2 IAM 角色憑證的 VPC。您可以在具有 [`aws:SourceVPC`](#condition-keys-sourcevpc) 全域鍵的政策中使用此鍵，以檢查是否從與接收憑證之 VPC (`aws:Ec2InstanceSourceVpc`) 相符的 VPC (`aws:SourceVPC`) 進行呼叫。
+ **可用性** – 每當請求者使用 Amazon EC2 角色憑證簽署請求時，請求內容中會包含此鍵。它可用於 IAM 政策、服務控制政策、VPC 端點政策和資源政策。
+ **資料類型** – [字串](reference_policies_elements_condition_operators.md#Conditions_String)
+ **值類型** - 單一值

此鍵可與 VPC 識別符值搭配使用，但是當與 `aws:SourceVpc` 內容鍵一起用作變數時最有用。只有在請求者使用 VPC 端點提出請求時，請求內容中才會包含 `aws:SourceVpc` 內容鍵。搭配使用 `aws:Ec2InstanceSourceVpc` 與 `aws:SourceVpc` 可讓您更廣泛地使用 `aws:Ec2InstanceSourceVpc`，因為其會比較通常一起變更的值。

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

****  

```
{
  "Version":"2012-10-17",		 	 	 
  "Statement": [
    {
      "Sid": "RequireSameVPC",
      "Effect": "Deny",
      "Action": "*",
      "Resource": "*",
      "Condition": {
        "StringNotEquals": {
            "aws:SourceVpc": "${aws:Ec2InstanceSourceVpc}"
        },
        "Null": {
          "ec2:SourceInstanceARN": "false"
        },
        "BoolIfExists": {
          "aws:ViaAWSService": "false"
        }
      }
    }
  ]
}
```

------

在上面的範例中，如果 `aws:SourceVpc` 值不等於 `aws:Ec2InstanceSourceVpc` 值，則會拒絕存取。政策聲明僅限於透過測試 `ec2:SourceInstanceARN` 條件鍵是否存在，作為 Amazon EC2 執行個體角色使用的角色。

此政策使用 `aws:ViaAWSService` AWS 允許 在代表 Amazon EC2 執行個體角色提出請求時授權請求。例如，當您從 Amazon EC2 執行個體向加密的 Amazon S3 儲存貯體提出請求時，Amazon S3 AWS KMS 會代表您呼叫 。提出請求時，某些金鑰不存在 AWS KMS。

### aws:Ec2InstanceSourcePrivateIPv4
<a name="condition-keys-ec2instancesourceprivateip4"></a>

此鍵可識別接收 Amazon EC2 IAM 角色憑證之主要彈性網路介面的私有 IPv4 地址。您必須搭配使用此條件鍵與其配套鍵 `aws:Ec2InstanceSourceVpc`，以確保您擁有 VPC ID 和來源私有 IP 的全域唯一組合。搭配使用此鍵與 `aws:Ec2InstanceSourceVpc`，來確保從接收憑證的相同私有 IP 地址提出請求。
+ **可用性** – 每當請求者使用 Amazon EC2 角色憑證簽署請求時，請求內容中會包含此鍵。它可用於 IAM 政策、服務控制政策、VPC 端點政策和資源政策。
+ **資料類型** – [IP 位址](reference_policies_elements_condition_operators.md#Conditions_IPAddress)
+ **值類型** - 單一值

**重要**  
此鍵不應該單獨在 `Allow` 陳述式中使用。私有 IP 地址根據定義不是全域唯一的。每次使用 `aws:Ec2InstanceSourcePrivateIPv4` 鍵指定可從中使用 Amazon EC2 執行個體憑證的 VPC 時，都應該使用 `aws:Ec2InstanceSourceVpc` 鍵。

下列範例是服務控制政策 (SCP)，拒絕存取所有資源，除非請求透過與 角色登入資料相同的 VPC 中的 VPC 端點抵達。在此範例中，`aws:Ec2InstanceSourcePrivateIPv4` 會根據來源 IP 將憑證來源限制為特定執行個體。

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

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Effect": "Deny",
            "Action":  "*",
            "Resource": "*",
            "Condition": {
                "StringNotEquals": {
                    "aws:Ec2InstanceSourceVpc": "${aws:SourceVpc}"
                },                
                "Null": {
                    "ec2:SourceInstanceARN": "false"
                },
                "BoolIfExists": {
                    "aws:ViaAWSService": "false"
                }
            }
        },
        {
            "Effect": "Deny",
            "Action":  "*",
            "Resource": "*",
            "Condition": {
                "StringNotEquals": {
                    "aws:Ec2InstanceSourcePrivateIPv4": "${aws:VpcSourceIp}"
                },                               
                "Null": {
                    "ec2:SourceInstanceARN": "false"
                },
                "BoolIfExists": {
                    "aws:ViaAWSService": "false"
                }
            }
        }
    ]
}
```

------

### aws:SourceIdentity
<a name="condition-keys-sourceidentity"></a>

使用此鍵來將主體所設定的來源身分與您在政策中所指定的來源身分進行比較。
+ **可用性** – 當使用任何 AWS STS 擔任角色 CLI 命令或 AWS STS `AssumeRole` API 操作擔任角色時，設定來源身分後，此金鑰會包含在請求內容中。
+ **資料類型** – [字串](reference_policies_elements_condition_operators.md#Conditions_String)
+ **值類型** - 單一值

您可以在政策中使用此金鑰，允許 AWS 在擔任角色時設定來源身分的委託人在 中執行動作。[AWS CloudTrail](cloudtrail-integration.md#cloudtrail-integration_signin-tempcreds) 中會顯示角色指定來源身分的活動。這可讓管理員更輕鬆地判斷角色在其中執行動作的對象或對象 AWS。

與 [`sts:RoleSessionName`](reference_policies_iam-condition-keys.md#ck_rolesessionname) 不同，在設定來源身分之後，就無法變更值。這會出現在由角色所採取的所有動作的請求內容中。當您使用工作階段憑證來擔任另一個角色時，此值仍然存在於後續角色工作階段。從另一個角色取得及擔任角色稱為[角色鏈結](id_roles.md#iam-term-role-chaining)。

當委託人最初設定來源身分，同時使用任何 AWS STS 擔任角色 CLI 命令或 AWS STS `AssumeRole` API 操作來擔任角色時， [`sts:SourceIdentity`](reference_policies_iam-condition-keys.md#ck_sourceidentity)金鑰會出現在請求中。針對具有來源身分集的角色工作階段所採取的任何動作，`aws:SourceIdentity` 鍵會出現在請求中。

下列在帳戶 `111122223333` 中的 `CriticalRole` 角色信任政策包含針對 `aws:SourceIdentity` 的條件，可防止沒有設定為 Saanvi 或 Diego 的來源身分的主體擔任角色。

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

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "AssumeRoleIfSourceIdentity",
            "Effect": "Allow",
            "Principal": {"AWS": "arn:aws:iam::123456789012:role/CriticalRole"},
            "Action": [
                "sts:AssumeRole",
                "sts:SetSourceIdentity"
            ],
            "Condition": {
                "StringLike": {
                    "aws:SourceIdentity": ["Saanvi","Diego"]
                }
            }
        }
    ]
}
```

------

若要進一步了解有關使用來源身分的詳細資訊，請參閱 [監控並控制使用擔任角色所採取的動作](id_credentials_temp_control-access_monitor.md)。

### ec2:RoleDelivery
<a name="condition-keys-ec2-role-delivery"></a>

使用此金鑰來比較已簽署請求中的執行個體中繼資料服務版本與 Amazon EC2 的 IAM 角色憑證。執行個體中繼資料服務會依據任何指定請求 (`PUT` 或 `GET` 標頭) 來區分 IMDSv1 及 IMDSv2 請求，這些對 IMDSv2 而言是唯一的內容，會出現在該請求中。
+ **可用性**：每當 Amazon EC2 執行個體建立角色工作階段時，請求內容中會包含此鍵。
+ **資料類型** – [數值](reference_policies_elements_condition_operators.md#Conditions_Numeric)
+ **值類型** - 單一值
+ **範例值** – 1.0、2.0

您可以在每個執行個體上設定執行個體中繼資料服務 (IMDS)，此類本機程式碼或使用者必須使用 IMDSv2。當您指定必須使用該 IMDSv2 時，IMDSv1 則無法繼續運作。
+ 執行個體中繼資料服務第 1 版 (IMDSv1) – 請求/回應方法 
+ 執行個體中繼資料服務第 2 版 (IMDSv2) – 工作階段導向方法

如需如何設定執行個體以使用 IMDSv2 的資訊，請參閱[設定執行個體中繼資料選項](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/configuring-instance-metadata-options.html)。

在下列範例中，如果請求內容中的 ec2:RoleDelivery 值為 1.0 (IMDSv1)，則會拒絕存取。一般情況下，可套用此政策陳述式，如果 Amazon EC2 角色憑證未簽署該請求，則不具任何作用。

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

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
               {
            "Sid": "RequireAllEc2RolesToUseV2",
            "Effect": "Deny",
            "Action": "*",
            "Resource": "*",
            "Condition": {
                "NumericLessThan": {
                    "ec2:RoleDelivery": "2.0"
                }
            }
        }
    ]
}
```

------

如需詳細資訊，請參閱[使用執行個體中繼資料的範例政策](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ExamplePolicies_EC2.html#iam-example-instance-metadata)。

### ec2:SourceInstanceArn
<a name="condition-keys-ec2-source-instance-arn"></a>

使用此金鑰來比較產生角色工作階段之執行個體的 ARN。
+ **可用性**：每當 Amazon EC2 執行個體建立角色工作階段時，請求內容中會包含此鍵。
+ **資料類型** – [ARN](reference_policies_elements_condition_operators.md#Conditions_ARN)
+ **值類型** - 單一值
+ **範例值** – arn：aws：ec2：us-west-2：111111111111：instance/instance-id

如需政策範例，請參閱[允許特定執行個體檢視其他 AWS 服務中的資源](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ExamplePolicies_EC2.html#iam-example-source-instance)。

### glue:RoleAssumedBy
<a name="condition-keys-glue-role-assumed-by"></a>

 AWS Glue 服務會為每個 AWS API 請求設定此條件金鑰，其中 AWS Glue 代表客戶使用服務角色提出請求 （不是透過任務或開發人員端點，而是直接透過 AWS Glue 服務）。使用此金鑰來驗證對 AWS 資源的呼叫是否來自 AWS Glue 服務。
+ **可用性** – 當 代表客戶使用服務角色 AWS Glue 提出請求時，此金鑰會包含在請求內容中。
+ **資料類型** – [字串](reference_policies_elements_condition_operators.md#Conditions_String)
+ **值類型** - 單一值
+ **範例值** – 此金鑰始終設定為 `glue.amazonaws.com`。

下列範例新增條件，以允許 AWS Glue 服務從 Amazon S3 儲存貯體取得物件。

```
{
    "Effect": "Allow",
    "Action": "s3:GetObject",
    "Resource": "arn:aws:s3:::amzn-s3-demo-bucket/*",
    "Condition": {
        "StringEquals": {
            "glue:RoleAssumedBy": "glue.amazonaws.com"
        }
    }
}
```

### glue:CredentialIssuingService
<a name="condition-keys-glue-credential-issuing"></a>

 AWS Glue 服務會使用來自任務或開發人員端點的服務角色，為每個 AWS API 請求設定此金鑰。使用此金鑰來驗證對 AWS 資源的呼叫是否來自 AWS Glue 任務或開發人員端點。
+ **可用性** – 當 從任務或開發人員端點 AWS Glue 發出請求時，此金鑰會包含在請求內容中。
+ **資料類型** – [字串](reference_policies_elements_condition_operators.md#Conditions_String)
+ **值類型** - 單一值
+ **範例值** – 此金鑰始終設定為 `glue.amazonaws.com`。

下列範例會新增條件，此條件會連接至 AWS Glue 任務所使用的 IAM 角色。這可確保根據角色工作階段是否用於 AWS Glue 任務執行期環境，允許/拒絕特定動作。

```
{
    "Effect": "Allow",
    "Action": "s3:GetObject",
    "Resource": "arn:aws:s3:::amzn-s3-demo-bucket/*",
    "Condition": {
        "StringEquals": {
            "glue:CredentialIssuingService": "glue.amazonaws.com"
        }
    }
}
```

### codebuild:BuildArn
<a name="condition-keys-codebuild-build-arn"></a>

此金鑰可識別已交付 IAM 角色登入資料的 CodeBuild 組建 ARN。使用此金鑰來驗證對 AWS 資源的呼叫是否來自特定的 CodeBuild 組建。

**注意**  
的完整值`codebuild:BuildArn`無法事先得知，因為它包含動態產生的組建 ID。
+ **可用性** – 每當請求是由 CodeBuild 擔任的角色提出時，請求內容中就會包含此金鑰。
+ **資料類型** – [ARN](reference_policies_elements_condition_operators.md#Conditions_ARN)
+ **值類型** - 單一值
+ **範例值** – arn：aws：codebuild：us-east-1：123456789012：build/MyBuildProject：12345678-1234-1234-1234-123456789012

下列範例允許特定 CodeBuild 組建`s3:GetObject`存取指定的儲存貯體。

```
{
    "Effect": "Allow",
    "Action": "s3:GetObject",
    "Resource": "arn:aws:s3:::amzn-s3-demo-bucket/*",
    "Condition": {
        "ArnLike": {
            "codebuild:BuildArn": "arn:aws:codebuild:us-east-1:123456789012:build/MyBuildProject:*"
        }
    }
}
```

### codebuild:ProjectArn
<a name="condition-keys-codebuild-project-arn"></a>

此金鑰可識別已將 IAM 角色登入資料交付至 CodeBuild 組建的 CodeBuild 專案 ARN。使用此金鑰來驗證對 AWS 資源的呼叫是否來自特定的 CodeBuild 專案。
+ **可用性** – 每當請求是由 CodeBuild 擔任的角色提出時，請求內容中都會包含此金鑰。
+ **資料類型** – [ARN](reference_policies_elements_condition_operators.md#Conditions_ARN)
+ **值類型** - 單一值
+ **範例值** – arn：aws：codebuild：us-east-1：123456789012：project/MyBuildProject

下列範例允許來自特定 CodeBuild 專案的任何組建`s3:GetObject`存取指定的儲存貯體。

```
{
    "Effect": "Allow",
    "Action": "s3:GetObject",
    "Resource": "arn:aws:s3:::amzn-s3-demo-bucket/*",
    "Condition": {
        "ArnEquals": {
            "codebuild:ProjectArn": "arn:aws:codebuild:us-east-1:123456789012:project/MyBuildProject"
        }
    }
}
```

### lambda:SourceFunctionArn
<a name="condition-keys-lambda-source-function-arn"></a>

使用此金鑰來識別接收 IAM 角色憑證的 Lambda 函數 ARN。Lambda 服務會為來自函數執行環境的每個 AWS API 請求設定此金鑰。使用此金鑰來驗證對 AWS 資源的呼叫是否來自特定 Lambda 函數的程式碼。Lambda 也會為來自執行環境外部的某些請求設定此金鑰，例如將日誌寫入到 CloudWatch 並將追蹤傳送至 X-Ray。
+ **可用性** – 每當叫用 Lambda 函數程式碼時，此金鑰會包含在請求內容中。
+ **資料類型** – [ARN](reference_policies_elements_condition_operators.md#Conditions_ARN)
+ **值類型** - 單一值
+ **範例值** – arn:aws:lambda:us-east-1:123456789012:function:TestFunction

下列範例允許一個特定 Lambda 函數對指定的儲存貯體進行 `s3:PutObject` 存取。

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

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "ExampleSourceFunctionArn",
            "Effect": "Allow",
            "Action": "s3:PutObject",
            "Resource": "arn:aws:s3:::amzn-s3-demo-bucket/*",
            "Condition": {
                "ArnEquals": {
                    "lambda:SourceFunctionArn": "arn:aws:lambda:us-east-1:123456789012:function:source_lambda"
                }
            }
        }
    ]
}
```

------

如需詳細資訊，請參閱 *AWS Lambda Developer Guide* 中的 [Working with Lambda execution environment credentials](https://docs.aws.amazon.com/lambda/latest/dg/lambda-intro-execution-role.html#permissions-executionrole-source-function-arn)。

### ssm:SourceInstanceArn
<a name="condition-keys-ssm-source-instance-arn"></a>

使用此金鑰來識別交付 IAM 角色登入資料的 AWS Systems Manager 受管執行個體 ARN。當請求來自具有與 Amazon EC2 執行個體設定檔關聯之 IAM 角色的受管執行個體時，則此條件索引鍵不存在。
+ **可用性**：每當角色憑證交付至 AWS Systems Manager 受管執行個體時，此金鑰會包含在請求內容中。
+ **資料類型** – [ARN](reference_policies_elements_condition_operators.md#Conditions_ARN)
+ **值類型** - 單一值
+ **範例值** – arn：aws：ec2：us-west-2：111111111111：instance/instance-id

### identitystore:UserId
<a name="condition-keys-identity-store-user-id"></a>

使用此金鑰來比較已簽署請求中的 IAM Identity Center 人力資源身分與政策中指定的身分。
+ **可用性**：當請求的發起人是 IAM Identity Center 中的使用者時，會包含此金鑰。
+ **資料類型** – [字串](reference_policies_elements_condition_operators.md#Conditions_String)
+ **值類型** - 單一值
+ **範例值** – 94482488-3041-7026-18f3-be45837cd0e4

您可以使用、UserId AWS 或 AWS SDK 向 [GetUserId](https://docs.aws.amazon.com//singlesignon/latest/IdentityStoreAPIReference/API_GetUserId.html) API 提出請求，在 IAM Identity Center 中找到使用者的 UserId。 AWS CLI

## 網路的屬性
<a name="condition-keys-network-properties"></a>

使用下列條件索引鍵，將請求來源或傳遞通過的網路詳細資訊與您在政策中指定的網路屬性進行比較。

### aws:SourceIp
<a name="condition-keys-sourceip"></a>

使用此鍵來將申請者的 IP 地址和您在政策中所指定的 IP 地址進行比較。`aws:SourceIp` 條件鍵僅可用於公有 IP 地址範圍。
+ **可用性** – 此鍵會包含在請求內容中，但當申請者使用 VPC 端點提出請求時則除外。
+ **資料類型** – [IP 位址](reference_policies_elements_condition_operators.md#Conditions_IPAddress)
+ **值類型** - 單一值

`aws:SourceIp` 條件鍵可用在政策中，只允許主體在指定的 IP 範圍內提出請求。

**注意**  
`aws:SourceIp` 同時支援 IPv4 和 IPv6 IP 地址或者 IP 地址範圍。如需支援 IPv6 AWS 服務 的清單，請參閱《*Amazon VPC 使用者指南*》中的[AWS 服務 支援 IPv6](https://docs.aws.amazon.com/vpc/latest/userguide/aws-ipv6-support.html) 的 。

例如，您可以將以下身分型政策連接至 IAM 角色。如果使用者從指定的 IPv4 地址範圍進行呼叫，則此政策允許使用者將物件放入 `amzn-s3-demo-bucket3` Amazon S3 儲存貯體。此政策也允許 AWS 服務使用 [轉送存取工作階段](access_forward_access_sessions.md) 代表您執行此操作。

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

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "PrincipalPutObjectIfIpAddress",
            "Effect": "Allow",
            "Action": "s3:PutObject",
            "Resource": "arn:aws:s3:::amzn-s3-demo-bucket3/*",
            "Condition": {
                "IpAddress": {
                    "aws:SourceIp": "203.0.113.0/24"
                }
            }
        }
    ]
}
```

------

如果您需要限制來自同時支援 IPv4 和 IPv6 定址的網路存取，您可以在 IAM 政策條件中包含 IPv4 和 IPv6 地址或 IP 地址範圍。如果使用者從指定的 IPv4 或 IPv6 地址範圍進行呼叫，則以下身分型政策允許使用者將物件放入 `amzn-s3-demo-bucket3` Amazon S3 儲存貯體。在 IAM 政策中包含 IPv6 地址範圍之前，請確認 AWS 服務 您正在使用的 支援 IPv6。如需支援 IPv6 AWS 服務 的清單，請參閱《*Amazon VPC 使用者指南*》中的[AWS 服務 支援 IPv6](https://docs.aws.amazon.com/vpc/latest/userguide/aws-ipv6-support.html) 的 。

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

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "PrincipalPutObjectIfIpAddress",
            "Effect": "Allow",
            "Action": "s3:PutObject",
            "Resource": "arn:aws:s3:::amzn-s3-demo-bucket3/*",
            "Condition": {
                "IpAddress": {
                    "aws:SourceIp": [
                        "203.0.113.0/24",
                        "2001:DB8:1234:5678::/64"
                    ]
                }
            }
        }
    ]
}
```

------

如果請求來自使用 Amazon VPC 端點的主機，則 `aws:SourceIp` 鍵不可用。建議您改為使用 VPC 專屬鍵，例如 [aws:VpcSourceIp](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_condition-keys.html#condition-keys-vpcsourceip)。如需有關使用 VPC 端點的詳細資訊，請參閱 *AWS PrivateLink 指南*中的 [VPC 端點和 VPC 端點服務的身分與存取管理](https://docs.aws.amazon.com/vpc/latest/privatelink/vpc-endpoints-iam.html)。

**注意**  
 AWS 服務 代表您 AWS 服務 呼叫其他 (service-to-service呼叫） 時，會修訂特定網路的授權內容。如果您的政策搭配 `Deny`陳述式使用此條件金鑰， AWS 服務 原則可能會意外遭到封鎖。為在滿足安全需求的同時讓 AWS 服務 可以正常運作，請透過新增值為 `false` 的 `aws:PrincipalIsAWSService` 條件索引鍵，將服務主體從 `Deny` 陳述式中排除。

### aws:SourceVpc
<a name="condition-keys-sourcevpc"></a>

使用此金鑰來檢查請求是否通過 VPC 端點所連接的 VPC。在政策中，您可以使用此鍵，只允許存取特定 VPC。如需詳細資訊，請參閱 *Amazon Simple Storage Service 使用者指南*中的[限制特定 VPC 的存取](https://docs.aws.amazon.com/AmazonS3/latest/userguide/example-bucket-policies-vpc-endpoint.html#example-bucket-policies-restrict-access-vpc)。
+ **可用性** – 只有在申請者使用 VPC 端點提出請求時，請求內容中才會包含此鍵。
+ **資料類型** – [字串](reference_policies_elements_condition_operators.md#Conditions_String)
+ **值類型** - 單一值

在政策中，您可以使用此金鑰來允許或限制對特定 VPC 端點的存取。

例如，您可以將下列身分型政策連接至 IAM 角色以拒絕 `PutObject` Amazon S3 `amzn-s3-demo-bucket3` 儲存貯體，除非請求是從指定的 VPC ID 提出 AWS 服務 ，或使用[轉送存取工作階段 (FAS)](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_forward_access_sessions.html) 代表該角色提出請求。與 [aws:SourceIp](#condition-keys-sourceip) 不同，您必須使用 [aws:ViaAWSService](#condition-keys-viaawsservice) 或 [aws:CalledVia](#condition-keys-calledvia) 來允許 FAS 請求，因為不會保留初始請求的來源 VPC。

**注意**  
此政策不允許任何動作。將此政策與允許特定動作的其他政策結合使用。

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

****  

```
{
  "Version":"2012-10-17",		 	 	 
  "Statement": [
    {
      "Sid": "PutObjectIfNotVPCID",
      "Effect": "Deny",
      "Action": "s3:PutObject",
      "Resource": "arn:aws:s3:::amzn-s3-demo-bucket3/*",
      "Condition": {
        "StringNotEqualsIfExists": {
          "aws:SourceVpc": "vpc-1234567890abcdef0"
        },
        "Bool": {
          "aws:ViaAWSService": "false"
        }
      }
    }
  ]
}
```

------

**注意**  
AWS 建議您使用 `aws:SourceVpc` `aws:SourceVpcArn`，而不是您要鎖定的服務`aws:SourceVpcArn`是否支援 。如需支援的 服務清單，請參閱 [aws：SourceVpcArn](#condition-keys-sourcevpcarn)。

### aws:SourceVpcArn
<a name="condition-keys-sourcevpcarn"></a>

使用此金鑰來驗證透過 VPC 端點提出請求的 VPC ARN。此金鑰會傳回 VPC 端點所連接之 VPC 的 ARN。
+ **可用性** – 透過 VPC 端點提出請求時，此金鑰會包含在受支援服務的請求內容中。若請求透過公有服務端點發出，則不會包含此鍵。下列服務支援此鍵：
  + AWS App Runner （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsapprunner.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsapprunner.html))
  + AWS Application Discovery Service （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsapplicationdiscoveryservice.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsapplicationdiscoveryservice.html))
  + Amazon Athena (字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonathena.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonathena.html))
  + AWS Cloud Map （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_awscloudmap.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awscloudmap.html))
  + Amazon CloudWatch Application Insights (字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazoncloudwatchapplicationinsights.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazoncloudwatchapplicationinsights.html))
  + AWS CloudFormation （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_awscloudformation.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awscloudformation.html))
  + Amazon Comprehend Medical (字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazoncomprehendmedical.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazoncomprehendmedical.html))
  + AWS Compute Optimizer （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_awscomputeoptimizer.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awscomputeoptimizer.html))
  + Amazon； Elastic Container Registry （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonelasticcontainerregistry.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonelasticcontainerregistry.html))
  + Amazon Elastic Container Service （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonelasticcontainerservice.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonelasticcontainerservice.html))
  + Amazon Kinesis Analytics （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonkinesisanalytics.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonkinesisanalytics.html))
  + Amazon Route 53 （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonroute53.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonroute53.html))
  + AWS DataSync （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsdatasync.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsdatasync.html))
  + Amazon Elastic Block Store (字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonelasticblockstore.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonelasticblockstore.html))
  + Amazon EventBridge 排程器 (字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazoneventbridgescheduler.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazoneventbridgescheduler.html))
  + Amazon Data Firehose (字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonkinesisfirehose.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonkinesisfirehose.html))
  + AWS HealthImaging （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_awshealthimaging.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awshealthimaging.html))
  + AWS HealthLake （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_awshealthlake.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awshealthlake.html))
  + AWS HealthOmics （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_awshealthomics.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awshealthomics.html))
  + AWS Identity and Access Management (`iam:PassRole`動作除外） （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsidentityandaccessmanagementiam.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsidentityandaccessmanagementiam.html))
  + AWS IoT FleetWise （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsiotfleetwise.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsiotfleetwise.html))
  + AWS IoT Wireless （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsiotwireless.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsiotwireless.html))
  + AWS Key Management Service （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_awskeymanagementservice.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awskeymanagementservice.html))
  + AWS Lambda （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_awslambda.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awslambda.html))
  + AWS Payment Cryptography （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_awspaymentcryptography.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awspaymentcryptography.html))
  + Amazon Polly (字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonpolly.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonpolly.html))
  + AWS 私有憑證授權單位 （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsprivatecertificateauthority.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsprivatecertificateauthority.html))
  + AWS 資源回收筒 （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsrecyclebin.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsrecyclebin.html))
  + Amazon Rekognition (字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonrekognition.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonrekognition.html))
  + Service Quotas (字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_servicequotas.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_servicequotas.html))
  + Amazon Simple Storage Service (字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazons3.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazons3.html))
  + AWS Storage Gateway （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsstoragegateway.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsstoragegateway.html))
  + AWS Systems Manager Incident Manager 聯絡人 （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_awssystemsmanagerincidentmanagercontacts.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awssystemsmanagerincidentmanagercontacts.html))
  + Amazon Textract (字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazontextract.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazontextract.html))
  + Amazon Transcribe (字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazontranscribe.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazontranscribe.html))
  + AWS Transfer Family （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_awstransferfamily.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awstransferfamily.html))
+ **資料類型** – ARN

  AWS 建議您在比較 [ARN 時使用 ARN 運算子](reference_policies_elements_condition_operators.md#Conditions_ARN)，而非[字串運算子](reference_policies_elements_condition_operators.md#Conditions_String)。 ARNs
+ **值類型** - 單一值
+ **範例值** – `arn:aws:ec2:us-east-1:123456789012:vpc/vpc-0e9801d129EXAMPLE`

以下是拒絕從 VPC 外部任何位置存取 `amzn-s3-demo-bucket`及其物件的儲存貯體政策範例`vpc-1a2b3c4d`。

```
{
   "Version":"2012-10-17",		 	 	 
   "Statement": [
     {
       "Sid": "Access-to-specific-VPC-only",
       "Principal": "*",
       "Action": "s3:*",
       "Effect": "Deny",
       "Resource": ["arn:aws:s3:::amzn-s3-demo-bucket",
                    "arn:aws:s3:::amzn-s3-demo-bucket/*"],
       "Condition": {
         "ArnNotEquals": {
           "aws:SourceVpcArn": "arn:aws:ec2:us-east-1:*:vpc/vpc-1a2b3c4d"
         }
       }
     }
   ]
}
```

### aws:SourceVpce
<a name="condition-keys-sourcevpce"></a>

使用此鍵來將請求的 VPC 端點識別碼與您在政策中所指定的端點 ID 進行比較。
+ **可用性** – 只有在申請者使用 VPC 端點提出請求時，請求內容中才會包含此鍵。
+ **資料類型** – [字串](reference_policies_elements_condition_operators.md#Conditions_String)
+ **值類型** - 單一值

在政策中，您可以使用此鍵來將存取限制在特定 VPC 端點。如需詳細資訊，請參閱 *Amazon Simple Storage Service 使用者指南*中的[限制特定 VPC 的存取](https://docs.aws.amazon.com/AmazonS3/latest/userguide/example-bucket-policies-vpc-endpoint.html#example-bucket-policies-restrict-access-vpc)。與使用 類似[aws:SourceVpc](#condition-keys-sourcevpc)，您必須使用 [aws:ViaAWSService](#condition-keys-viaawsservice)或 [aws:CalledVia](#condition-keys-calledvia) 來允許 AWS 服務 使用[轉送存取工作階段 (FAS)](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_forward_access_sessions.html) 提出的請求。這是因為不會保留初始請求的來源 VPC 端點。

### aws:VpceAccount
<a name="condition-keys-vpceaccount"></a>

使用此金鑰將擁有 VPC 端點 AWS 的帳戶 ID 與您在政策中指定的帳戶 ID 進行比較。此條件索引鍵可確保請求來自特定帳戶擁有的 VPC 端點，協助您建立網路周邊控制。
+ **可用性** – 若請求透過 VPC 端點發出，請求內容中會包含此鍵。若請求透過公有服務端點發出，則不會包含此鍵。

  下列服務支援此鍵：
  + AWS App Runner （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsapprunner.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsapprunner.html))
  + AWS Application Discovery Service （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsapplicationdiscoveryservice.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsapplicationdiscoveryservice.html))
  + Amazon Athena (字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonathena.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonathena.html))
  + AWS Cloud Map （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_awscloudmap.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awscloudmap.html))
  + Amazon CloudWatch Application Insights (字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazoncloudwatchapplicationinsights.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazoncloudwatchapplicationinsights.html))
  + AWS CloudFormation （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_awscloudformation.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awscloudformation.html))
  + Amazon Comprehend Medical (字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazoncomprehendmedical.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazoncomprehendmedical.html))
  + AWS Compute Optimizer （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_awscomputeoptimizer.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awscomputeoptimizer.html))
  + Amazon； Elastic Container Registry （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonelasticcontainerregistry.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonelasticcontainerregistry.html))
  + Amazon Elastic Container Service （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonelasticcontainerservice.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonelasticcontainerservice.html))
  + Amazon Kinesis Analytics （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonkinesisanalytics.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonkinesisanalytics.html))
  + Amazon Route 53 （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonroute53.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonroute53.html))
  + AWS DataSync （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsdatasync.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsdatasync.html))
  + Amazon Elastic Block Store (字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonelasticblockstore.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonelasticblockstore.html))
  + Amazon EventBridge 排程器 (字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazoneventbridgescheduler.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazoneventbridgescheduler.html))
  + Amazon Data Firehose (字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonkinesisfirehose.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonkinesisfirehose.html))
  + AWS HealthImaging （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_awshealthimaging.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awshealthimaging.html))
  + AWS HealthLake （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_awshealthlake.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awshealthlake.html))
  + AWS HealthOmics （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_awshealthomics.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awshealthomics.html))
  + AWS Identity and Access Management (`iam:PassRole`動作除外） （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsidentityandaccessmanagementiam.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsidentityandaccessmanagementiam.html))
  + AWS IoT FleetWise （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsiotfleetwise.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsiotfleetwise.html))
  + AWS IoT Wireless （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsiotwireless.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsiotwireless.html))
  + AWS Key Management Service （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_awskeymanagementservice.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awskeymanagementservice.html))
  + AWS Lambda （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_awslambda.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awslambda.html))
  + AWS Payment Cryptography （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_awspaymentcryptography.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awspaymentcryptography.html))
  + Amazon Polly (字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonpolly.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonpolly.html))
  + AWS 私有憑證授權單位 （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsprivatecertificateauthority.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsprivatecertificateauthority.html))
  + AWS 資源回收筒 （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsrecyclebin.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsrecyclebin.html))
  + Amazon Rekognition (字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonrekognition.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonrekognition.html))
  + Service Quotas (字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_servicequotas.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_servicequotas.html))
  + Amazon Simple Storage Service (字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazons3.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazons3.html))
  + AWS Storage Gateway （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsstoragegateway.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsstoragegateway.html))
  + AWS Systems Manager Incident Manager 聯絡人 （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_awssystemsmanagerincidentmanagercontacts.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awssystemsmanagerincidentmanagercontacts.html))
  + Amazon Textract (字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazontextract.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazontextract.html))
  + Amazon Transcribe (字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazontranscribe.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazontranscribe.html))
  + AWS Transfer Family （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_awstransferfamily.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awstransferfamily.html))
+ **資料類型** – [字串](reference_policies_elements_condition_operators.md#Conditions_String)
+ **值類型** - 單一值
+ **範例值** – `123456789012`

您可以使用此條件索引鍵來限制存取資源，使得請求必須透過帳戶擁有的 VPC 端點送達。下列 Amazon S3 儲存貯體政策範例允許在請求來自指定帳戶擁有的 VPC 端點時存取：

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

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "AccessToSpecificVpceAccountOnly",
            "Principal": {
                "AWS": "arn:aws:iam::111122223333:role/RoleName"
            },
            "Action": "s3:GetObject",
            "Effect": "Allow",
            "Resource": "arn:aws:s3:::amzn-s3-demo-bucket1/*",
            "Condition": {
                "StringEquals": {
                    "aws:VpceAccount": "111122223333"
                }
            }
        }
    ]
}
```

------

**注意**  
選取的服務集目前支援此條件金鑰 AWS 。將此鍵與不受支援的服務搭配使用，可能會導致意外的授權結果。請務必將條件索引鍵的範圍限定為政策中受支援的服務。

有些 AWS 服務會在代表您時，從其網路存取您的資源。如果您使用這類服務，則需要編輯上述政策範例，以允許 AWS 服務從網路外部存取您的資源。如需有關根據請求來源強制執行存取控制時需要考量之存取模式的詳細資訊，請參閱[使用資料周邊建立許可防護機制](access_policies_data-perimeters.md)。

### aws:VpceOrgID
<a name="condition-keys-vpceorgid"></a>

使用此金鑰來比較 中 AWS Organizations 擁有 VPC 端點之組織的識別符，而該 VPC 端點具有您在政策中指定的識別符。此條件索引鍵提供了最具可擴展性的網路周邊控制方法，可自動包含組織內帳戶擁有的所有 VPC 端點。
+ **可用性** – 當透過 VPC 端點提出請求，且 VPC 端點擁有者帳戶是 AWS 組織的成員時，此金鑰會包含在請求內容中。如果透過其他網路路徑發出請求，或 VPC 端點擁有者帳戶不屬於組織，則不會包含此索引鍵。

  下列服務支援此鍵：
  + AWS App Runner （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsapprunner.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsapprunner.html))
  + AWS Application Discovery Service （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsapplicationdiscoveryservice.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsapplicationdiscoveryservice.html))
  + Amazon Athena (字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonathena.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonathena.html))
  + AWS B2B 資料交換 （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsb2bdatainterchange.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsb2bdatainterchange.html))
  + AWS Cloud Map （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_awscloudmap.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awscloudmap.html))
  + Amazon CloudWatch Application Insights (字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazoncloudwatchapplicationinsights.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazoncloudwatchapplicationinsights.html))
  + AWS CloudFormation （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_awscloudformation.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awscloudformation.html))
  + Amazon Cognito （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazoncognitoidentity.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazoncognitoidentity.html))
  + Amazon Comprehend Medical (字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazoncomprehendmedical.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazoncomprehendmedical.html))
  + AWS Compute Optimizer （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_awscomputeoptimizer.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awscomputeoptimizer.html))
  + AWS Database Migration Service （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsdatabasemigrationservice.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsdatabasemigrationservice.html))
  + AWS Directory Service Data （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsdirectoryservicedata.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsdirectoryservicedata.html))
  + Amazon； Elastic Container Registry （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonelasticcontainerregistry.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonelasticcontainerregistry.html))
  + Amazon Elastic Container Service （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonelasticcontainerservice.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonelasticcontainerservice.html))
  + Amazon Kinesis Analytics （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonkinesisanalytics.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonkinesisanalytics.html))
  + Amazon Route 53 （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonroute53.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonroute53.html))
  + AWS DataSync （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsdatasync.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsdatasync.html))
  + Amazon Elastic Block Store (字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonelasticblockstore.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonelasticblockstore.html))
  + Amazon EventBridge 排程器 (字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazoneventbridgescheduler.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazoneventbridgescheduler.html))
  + Amazon Data Firehose (字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonkinesisfirehose.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonkinesisfirehose.html))
  + AWS HealthImaging （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_awshealthimaging.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awshealthimaging.html))
  + AWS HealthLake （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_awshealthlake.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awshealthlake.html))
  + AWS HealthOmics （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_awshealthomics.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awshealthomics.html))
  + AWS Identity and Access Management (`iam:PassRole`動作除外） （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsidentityandaccessmanagementiam.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsidentityandaccessmanagementiam.html))
  + AWS Identity Store （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsidentitystore.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsidentitystore.html))
  + AWS IoT FleetWise （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsiotfleetwise.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsiotfleetwise.html))
  + AWS IoT TwinMaker （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsiottwinmaker.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsiottwinmaker.html))
  + AWS IoT Wireless （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsiotwireless.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsiotwireless.html))
  + Amazon Keyspaces （適用於 Apache Cassandra) （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonkeyspacesforapachecassandra.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonkeyspacesforapachecassandra.html))
  + AWS Key Management Service （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_awskeymanagementservice.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awskeymanagementservice.html))
  + AWS Lambda （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_awslambda.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awslambda.html))
  + AWS Network Firewall （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsnetworkfirewall.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsnetworkfirewall.html))
  + AWS Payment Cryptography （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_awspaymentcryptography.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awspaymentcryptography.html))
  + Amazon Pinpoint SMS 和語音服務 （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonpinpointsmsandvoiceservice.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonpinpointsmsandvoiceservice.html))
  + Amazon Polly (字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonpolly.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonpolly.html))
  + AWS 價格表 （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_awspricelist.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awspricelist.html))
  + AWS 私有憑證授權單位 （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsprivatecertificateauthority.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsprivatecertificateauthority.html))
  + AWS 資源回收筒 （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsrecyclebin.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsrecyclebin.html))
  + Amazon Rekognition (字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonrekognition.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonrekognition.html))
  + Service Quotas (字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_servicequotas.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_servicequotas.html))
  + Amazon Simple Email Service （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonses.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonses.html))
  + Amazon Simple Storage Service (字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazons3.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazons3.html))
  + Amazon Simple Queue Service （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonsqs.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonsqs.html))
  + AWS Storage Gateway （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsstoragegateway.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsstoragegateway.html))
  + AWS Systems Manager Incident Manager 聯絡人 （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_awssystemsmanagerincidentmanagercontacts.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awssystemsmanagerincidentmanagercontacts.html))
  + Amazon Textract (字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazontextract.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazontextract.html))
  + Amazon Transcribe (字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazontranscribe.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazontranscribe.html))
  + AWS Transfer Family （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_awstransferfamily.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awstransferfamily.html))
  + Amazon WorkMail （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonworkmail.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonworkmail.html))
+ **資料類型** – [字串](reference_policies_elements_condition_operators.md#Conditions_String)
+ **值類型** - 單一值
+ **範例值** – `o-a1b2c3d4e5`

下列資源控制政策範例會拒絕存取您的 Amazon S3 和資源， AWS Key Management Service 除非請求是透過指定組織擁有的 VPC 端點，或來自代表您行事 AWS 的服務網路。某些組織可能需要進一步編輯此政策以滿足其組織需求，例如允許第三方合作夥伴存取。如需有關根據請求來源強制執行存取控制時需要考量之存取模式的詳細資訊，請參閱[使用資料周邊建立許可防護機制](access_policies_data-perimeters.md)。

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

****  

```
{
  "Version":"2012-10-17",		 	 	 
  "Statement": [
    {
      "Sid": "EnforceNetworkPerimeterVpceOrgID",
      "Effect": "Deny",
      "Principal": "*",
      "Action": [
        "s3:*",
        "kms:*"
      ],
      "Resource": "*",
      "Condition": {
        "BoolIfExists": {
          "aws:PrincipalIsAWSService": "false",
          "aws:ViaAWSService": "false"
        },
        "StringNotEqualsIfExists": {
            "aws:VpceOrgID": "o-abcdef0123",
            "aws:PrincipalTag/network-perimeter-exception": "true"
        }
      }
    }
  ]
}
```

------

**注意**  
選取的服務集目前支援此條件金鑰 AWS 。將此鍵與不受支援的服務搭配使用，可能會導致意外的授權結果。請務必將條件索引鍵的範圍限定為政策中受支援的服務。

### aws:VpceOrgPaths
<a name="condition-keys-vpceorgpaths"></a>

使用此金鑰，將發出請求的 VPC 端點 AWS Organizations 路徑與您在政策中指定的路徑進行比較。借助此條件索引鍵，您可以在組織單位層級實作網路周邊控制，當您在指定的組織單位內新增端點時，系統會隨 VPC 端點用量自動擴展。
+ **可用性** – 如果透過 VPC 端點發出請求，且 VPC 端點擁有者帳戶是組織成員，請求內容中會包含此索引鍵。如果透過其他網路路徑發出請求，或 VPC 端點擁有者帳戶不屬於組織，則不會包含此索引鍵。

  下列服務支援此鍵：
  + AWS App Runner （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsapprunner.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsapprunner.html))
  + AWS Application Discovery Service （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsapplicationdiscoveryservice.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsapplicationdiscoveryservice.html))
  + Amazon Athena (字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonathena.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonathena.html))
  + AWS Cloud Map （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_awscloudmap.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awscloudmap.html))
  + Amazon CloudWatch Application Insights (字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazoncloudwatchapplicationinsights.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazoncloudwatchapplicationinsights.html))
  + AWS CloudFormation （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_awscloudformation.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awscloudformation.html))
  + Amazon Comprehend Medical (字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazoncomprehendmedical.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazoncomprehendmedical.html))
  + AWS Compute Optimizer （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_awscomputeoptimizer.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awscomputeoptimizer.html))
  + Amazon； Elastic Container Registry （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonelasticcontainerregistry.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonelasticcontainerregistry.html))
  + Amazon Elastic Container Service （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonelasticcontainerservice.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonelasticcontainerservice.html))
  + Amazon Kinesis Analytics （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonkinesisanalytics.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonkinesisanalytics.html))
  + Amazon Route 53 （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonroute53.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonroute53.html))
  + AWS DataSync （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsdatasync.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsdatasync.html))
  + Amazon Elastic Block Store (字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonelasticblockstore.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonelasticblockstore.html))
  + Amazon EventBridge 排程器 (字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazoneventbridgescheduler.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazoneventbridgescheduler.html))
  + Amazon Data Firehose (字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonkinesisfirehose.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonkinesisfirehose.html))
  + AWS HealthImaging （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_awshealthimaging.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awshealthimaging.html))
  + AWS HealthLake （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_awshealthlake.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awshealthlake.html))
  + AWS HealthOmics （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_awshealthomics.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awshealthomics.html))
  + AWS Identity and Access Management (`iam:PassRole`動作除外） （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsidentityandaccessmanagementiam.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsidentityandaccessmanagementiam.html))
  + AWS IoT FleetWise （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsiotfleetwise.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsiotfleetwise.html))
  + AWS IoT Wireless （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsiotwireless.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsiotwireless.html))
  + AWS Key Management Service （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_awskeymanagementservice.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awskeymanagementservice.html))
  + AWS Lambda （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_awslambda.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awslambda.html))
  + AWS Payment Cryptography （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_awspaymentcryptography.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awspaymentcryptography.html))
  + Amazon Polly (字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonpolly.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonpolly.html))
  + AWS 私有憑證授權單位 （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsprivatecertificateauthority.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsprivatecertificateauthority.html))
  + AWS 資源回收筒 （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsrecyclebin.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsrecyclebin.html))
  + Amazon Rekognition (字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonrekognition.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonrekognition.html))
  + Service Quotas (字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_servicequotas.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_servicequotas.html))
  + Amazon Simple Storage Service (字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazons3.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazons3.html))
  + AWS Storage Gateway （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsstoragegateway.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsstoragegateway.html))
  + AWS Systems Manager Incident Manager 聯絡人 （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_awssystemsmanagerincidentmanagercontacts.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awssystemsmanagerincidentmanagercontacts.html))
  + Amazon Textract (字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazontextract.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazontextract.html))
  + Amazon Transcribe (字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazontranscribe.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazontranscribe.html))
  + AWS Transfer Family （字首：[https://docs.aws.amazon.com/service-authorization/latest/reference/list_awstransferfamily.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awstransferfamily.html))
+ **資料類型** – [字串](reference_policies_elements_condition_operators.md#Conditions_String) (清單)
+ **值類型** - 多重值
+ **範例值** – `o-a1b2c3d4e5/r-ab12/ou-ab12-11111111/ou-ab12-22222222/`

由於 `aws:VpceOrgPaths` 是多值條件索引鍵，因此使用此鍵時，您必須搭配[字串條件運算子](reference_policies_elements_condition_operators.md#Conditions_String)使用 `ForAnyValue` 或 `ForAllValues` 集運算子。下列 Amazon S3 儲存貯體政策範例僅在請求透過特定組織單位中帳戶擁有的 VPC 端點送達時允許存取：

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

****  

```
{
  "Version":"2012-10-17",		 	 	 
  "Statement": [
    {
      "Sid": "AllowAccessFromSpecificOrgPaths",
      "Effect": "Allow",
      "Principal": {
        "AWS": "arn:aws:iam::111122223333:role/RoleName"
      },
      "Action": "s3:GetObject",
      "Resource": "arn:aws:s3:::amzn-s3-demo-bucket1/*",
      "Condition": {
        "ForAnyValue:StringLike": {
          "aws:VpceOrgPaths": [
            "o-a1b2c3d4e5/r-ab12/ou-ab12-11111111/ou-ab12-22222222/*",
            "o-a1b2c3d4e5/r-ab12/ou-ab12-11111111/ou-ab12-33333333/*"
          ]
        }
      }
    }
  ]
}
```

------

**注意**  
選取的服務集目前支援此條件金鑰 AWS 。將此鍵與不受支援的服務搭配使用，可能會導致意外的授權結果。請務必將條件索引鍵的範圍限定為政策中受支援的服務。

有些 AWS 服務會在代表您時，從其網路存取您的資源。如果您使用這類服務，則需要編輯上述政策範例，以允許 AWS 服務從網路外部存取您的資源。如需有關根據請求來源強制執行存取控制時需要考量之存取模式的詳細資訊，請參閱[使用資料周邊建立許可防護機制](access_policies_data-perimeters.md)。

### aws:VpcSourceIp
<a name="condition-keys-vpcsourceip"></a>

使用此鍵來將提出請求的 IP 地址與您在政策中所指定的 IP 地址進行比較。在政策中，只有在請求來自指定 IP 地址並且透過 VPC 端點時，此鍵才會相符。
+ **可用性** – 只有在請求是使用 VPC 端點提出時，請求內容中才會包含此鍵。
+ **資料類型** – [IP 位址](reference_policies_elements_condition_operators.md#Conditions_IPAddress)
+ **值類型** - 單一值

如需詳細資訊，請參閱《Amazon VPC 使用者指南》**中的[使用端點政策控制 VPC 端點的存取](https://docs.aws.amazon.com/vpc/latest/userguide/vpc-endpoints-access.html)。與使用 類似[aws:SourceVpc](#condition-keys-sourcevpc)，您必須使用 [aws:ViaAWSService](#condition-keys-viaawsservice)或 [aws:CalledVia](#condition-keys-calledvia) 來允許 AWS 服務 使用[轉送存取工作階段 (FAS)](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_forward_access_sessions.html) 提出的請求。這是因為使用 VPC 端點提出的初始請求的來源 IP 並不會保留在 FAS 請求中。

**注意**  
`aws:VpcSourceIp` 同時支援 IPv4 和 IPv6 IP 地址或者 IP 地址範圍。如需支援 IPv6 AWS 服務 的清單，請參閱《*Amazon VPC 使用者指南*》中的[AWS 服務 支援 IPv6](https://docs.aws.amazon.com/vpc/latest/userguide/aws-ipv6-support.html) 的 。  
一律使用 `aws:VpcSourceIp`條件金鑰搭配 `aws:SourceVpc`、 `aws:SourceVpce`或 `aws:SourceVpcArn`條件金鑰。如果您不這樣做，政策可能會允許來自使用相同或重疊 IP CIDR 之非預期 VPC 的 API 呼叫。這可能是因為來自兩個不相關 VPCs IP CIDRs 可能相同或重疊。

**注意**  
 AWS 服務 代表您 AWS 服務 呼叫其他 (service-to-service呼叫） 時，會修訂特定網路的授權內容。如果您的政策搭配 `Deny`陳述式使用此條件金鑰， AWS 服務 原則可能會意外遭到封鎖。為在滿足安全需求的同時讓 AWS 服務 可以正常運作，請透過新增值為 `false` 的 `aws:PrincipalIsAWSService` 條件索引鍵，將服務主體從 `Deny` 陳述式中排除。

## 資源的屬性
<a name="condition-keys-resource-properties"></a>

使用下列條件索引鍵，將請求目標的資源詳細資訊與您在政策中指定的資源屬性進行比較。

### aws:ResourceAccount
<a name="condition-keys-resourceaccount"></a>

使用此鍵來比較請求的資源所有者的 [AWS 帳戶 ID](https://docs.aws.amazon.com/general/latest/gr/acct-identifiers.html) 與政策中的資源帳戶。然後，根據擁有該資源的帳戶來允許或拒絕對該資源的存取。
+ **可用性** – 此鍵一律會包含在大部分服務動作的請求內容中。下列動作不支援此鍵：
  + AWS Audit Manager
    + `auditmanager:UpdateAssessmentFrameworkShare`
  + Amazon Detective
    + `detective:AcceptInvitation`
  + AWS Directory Service
    + `ds:AcceptSharedDirectory`
  + Amazon Elastic Block Store – 所有動作
  + Amazon EC2
    + `ec2:AcceptTransitGatewayPeeringAttachment`
    + `ec2:AcceptVpcEndpointConnections`
    + `ec2:AcceptVpcPeeringConnection`
    + `ec2:CreateTransitGatewayPeeringAttachment`
    + `ec2:CreateVpcEndpoint`
    + `ec2:CreateVpcPeeringConnection`
  + Amazon EventBridge
    + `events:PutEvents` – 如果該事件匯流排在 2023 年 3 月 2 日之前設定為跨帳戶 EventBridge 目標，則 EventBridge `PutEvents` 會呼叫另一個帳戶中的事件匯流排。如需詳細資訊，請參閱 *Amazon EventBridge 使用者指南*中的[授予許可以便允許來自其他  AWS  帳戶的事件](https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-cross-account.html#eb-receiving-events-from-another-account)。
  + Amazon GuardDuty
    + `guardduty:AcceptAdministratorInvitation`
  + Amazon Macie
    + `macie2:AcceptInvitation`
  + Amazon OpenSearch Service
    + `es:AcceptInboundConnection`
  + Amazon Route 53
    + `route53:AssociateVpcWithHostedZone`
    + `route53:CreateVPCAssociationAuthorization`
  + AWS Security Hub CSPM
    + `securityhub:AcceptAdministratorInvitation`
+ **資料類型** – [字串](reference_policies_elements_condition_operators.md#Conditions_String)
+ **值類型** - 單一值

**注意**  
如需上述不受支援動作的其他考量事項，請參閱[資料周邊政策範例](https://github.com/aws-samples/data-perimeter-policy-examples)儲存庫。

此金鑰等於具有請求中評估之資源的帳戶 AWS 帳戶 ID。

對於您帳戶中的大部分資源，[ARN](reference_policies_elements_condition_operators.md#Conditions_ARN) 包含該資源的擁有者帳戶 ID。對於某些資源 (例如 Amazon S3 儲存貯體)，資源 ARN 不包含帳戶 ID。以下兩個範例顯示在 ARN 中具有帳戶 ID 的資源與沒有帳戶 ID 的 Amazon S3 ARN 之間的差異：
+ `arn:aws:iam::123456789012:role/AWSExampleRole` – 在帳戶 123456789012 中建立和擁有的 IAM 角色。
+ `arn:aws:s3:::amzn-s3-demo-bucket2` – 在帳戶 `111122223333` 中建立和擁有 Amazon S3 儲存貯體，不會顯示在 ARN 中。

使用 AWS 主控台、API 或 CLI 來尋找您的所有資源和對應的 ARNs。

您撰寫的政策會根據資源擁有者的帳戶 ID 拒絕資源許可。例如，如果*指定資源*不屬於*指定帳戶*，下列身分型政策會拒絕存取這些資源。

若要使用此政策，請將*斜體預留位置文字*取代為您的帳戶資訊。

**重要**  
此政策不允許任何動作。相反，它使用 `Deny` 效果，明確拒絕存取陳述式中列出的不屬於所列帳戶的所有資源。將此政策與允許存取特定資源的其他政策結合使用。

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

****  

```
{
  "Version":"2012-10-17",		 	 	 
  "Statement": [
    {
      "Sid": "DenyInteractionWithResourcesNotInSpecificAccount",
      "Action": "service:*",
      "Effect": "Deny",
      "Resource": [
        "arn:aws:service:us-east-1:111122223333:*"
      ],
      "Condition": {
        "StringNotEquals": {
          "aws:ResourceAccount": [
            "111122223333"
          ]
        }
      }
    }
  ]
}
```

------

除非指定的 AWS 帳戶 擁有資源，否則此政策會拒絕存取特定 AWS 服務的所有資源。

**注意**  
有些 AWS 服務 需要存取在另一個 中託管的 AWS 擁有資源 AWS 帳戶。在身分型政策中使用 `aws:ResourceAccount`，可能會影響您的身分存取這些資源。

某些 AWS 服務，例如 AWS Data Exchange，依賴存取 外部的資源 AWS 帳戶 進行正常操作。如果在政策中使用元素 `aws:ResourceAccount`，請包含其他陳述式來建立這些服務的豁免。範例政策 [AWS：拒絕存取您帳戶外部的 Amazon S3 資源，但 AWS Data Exchange](reference_policies_examples_resource_account_data_exch.md) 示範如何在定義服務所擁有資源的例外狀況時，根據資源帳戶拒絕存取。

使用此政策範例作為建立您自己的自訂政策的範本。如需詳細資訊，請參閱您的服務[文件](https://docs.aws.amazon.com/index.html)。

### aws:ResourceOrgPaths
<a name="condition-keys-resourceorgpaths"></a>

使用此金鑰將存取資源的 AWS Organizations 路徑與政策中的路徑進行比較。在政策中，此條件索引鍵會確保資源屬於指定組織根帳戶或 AWS Organizations中組織單位內的帳戶成員。 AWS Organizations 路徑是 Organizations 實體結構的文字表示法。如需有關使用和了解路徑的詳細資訊，請參閱 [了解 AWS Organizations 實體路徑](access_policies_last-accessed-view-data-orgs.md#access_policies_last-accessed-viewing-orgs-entity-path)。
+ **可用性** – 只有在擁有資源的帳戶是組織成員時，請求內容中才會包含此鍵。此全域條件鍵不支援下列動作：
  + AWS Audit Manager
    + `auditmanager:UpdateAssessmentFrameworkShare`
  + Amazon Detective
    + `detective:AcceptInvitation`
  + AWS Directory Service
    + `ds:AcceptSharedDirectory`
  + Amazon Elastic Block Store – 所有動作
  + Amazon EC2
    + `ec2:AcceptTransitGatewayPeeringAttachment`
    + `ec2:AcceptVpcEndpointConnections`
    + `ec2:AcceptVpcPeeringConnection`
    + `ec2:CreateTransitGatewayPeeringAttachment`
    + `ec2:CreateVpcEndpoint`
    + `ec2:CreateVpcPeeringConnection`
  + Amazon EventBridge
    + `events:PutEvents` – 如果該事件匯流排在 2023 年 3 月 2 日之前設定為跨帳戶 EventBridge 目標，則 EventBridge `PutEvents` 會呼叫另一個帳戶中的事件匯流排。如需詳細資訊，請參閱 *Amazon EventBridge 使用者指南*中的[授予許可以便允許來自其他  AWS  帳戶的事件](https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-cross-account.html#eb-receiving-events-from-another-account)。
  + Amazon GuardDuty
    + `guardduty:AcceptAdministratorInvitation`
  + Amazon Macie
    + `macie2:AcceptInvitation`
  + Amazon OpenSearch Service
    + `es:AcceptInboundConnection`
  + Amazon Route 53
    + `route53:AssociateVpcWithHostedZone`
    + `route53:CreateVPCAssociationAuthorization`
  + AWS Security Hub CSPM
    + `securityhub:AcceptAdministratorInvitation`
+ **資料類型** – [字串](reference_policies_elements_condition_operators.md#Conditions_String) (清單)
+ **值類型** - 多重值

**注意**  
如需上述不受支援動作的其他考量事項，請參閱[資料周邊政策範例](https://github.com/aws-samples/data-perimeter-policy-examples)儲存庫。

`aws:ResourceOrgPaths` 是多重值條件鍵。多值鍵在請求內容中可以擁有多個值。使用此鍵時，您必須使用 `ForAnyValue` 或 `ForAllValues` 設定運算子搭配[字串條件運算子](reference_policies_elements_condition_operators.md#Conditions_String)。如需有關多重值條件鍵的詳細資訊，請參閱 [用於多值內容索引鍵的集運算子](reference_policies_condition-single-vs-multi-valued-context-keys.md#reference_policies_condition-multi-valued-context-keys)。

例如，下列條件會對屬於組織 `o-a1b2c3d4e5` 的資源傳回 `True`。當您包含萬用字元時，您必須使用 [StringLike](reference_policies_elements_condition_operators.md) 條件運算子。

```
"Condition": { 
      "ForAnyValue:StringLike": {
             "aws:ResourceOrgPaths":["o-a1b2c3d4e5/*"]
   }
}
```

針對具有 OU ID `ou-ab12-11111111` 的資源，下列條件會傳回 `True`。該條件會比對連接至 OU ou-ab12-11111111 或任何子 OU 的帳戶所擁有的資源。

```
"Condition": { "ForAnyValue:StringLike" : {
     "aws:ResourceOrgPaths":["o-a1b2c3d4e5/r-ab12/ou-ab12-11111111/*"]
}}
```

下列條件會對直接連接至 OU ID `ou-ab12-22222222` 但未連接至子 OU 的帳戶所擁有的資源傳回 `True`。下列範例會使用 [StringEquals](reference_policies_elements_condition_operators.md) 條件運算子來指定 OU ID 的精確比對要求，而非萬用字元比對。

```
"Condition": { "ForAnyValue:StringEquals" : {
     "aws:ResourceOrgPaths":["o-a1b2c3d4e5/r-ab12/ou-ab12-11111111/ou-ab12-22222222/"]
}}
```

**注意**  
有些 AWS 服務 需要存取在另一個 中託管的 AWS 擁有資源 AWS 帳戶。在身分型政策中使用 `aws:ResourceOrgPaths`，可能會影響您的身分存取這些資源。

某些 AWS 服務，例如 AWS Data Exchange，依賴存取 外部的資源 AWS 帳戶 進行正常操作。如果在政策中使用 `aws:ResourceOrgPaths` 鍵，請包含其他陳述式來建立這些服務的豁免。範例政策 [AWS：拒絕存取您帳戶外部的 Amazon S3 資源，但 AWS Data Exchange](reference_policies_examples_resource_account_data_exch.md) 示範如何在定義服務所擁有資源的例外狀況時，根據資源帳戶拒絕存取。您可以建立類似的政策，使用 `aws:ResourceOrgPaths` 鍵來限制組織單位 (OU) 內資源的存取，同時考量服務擁有的資源。

使用此政策範例作為建立您自己的自訂政策的範本。如需詳細資訊，請參閱您的服務[文件](https://docs.aws.amazon.com/index.html)。

### aws:ResourceOrgID
<a name="condition-keys-resourceorgid"></a>

使用此金鑰，將 AWS Organizations 請求資源所屬組織的識別符與政策中指定的識別符進行比較。
+ **可用性** – 只有在擁有資源的帳戶是組織成員時，請求內容中才會包含此鍵。此全域條件鍵不支援下列動作：
  + AWS Audit Manager
    + `auditmanager:UpdateAssessmentFrameworkShare`
  + Amazon Detective
    + `detective:AcceptInvitation`
  + AWS Directory Service
    + `ds:AcceptSharedDirectory`
  + Amazon Elastic Block Store – 所有動作
  + Amazon EC2
    + `ec2:AcceptTransitGatewayPeeringAttachment`
    + `ec2:AcceptVpcEndpointConnections`
    + `ec2:AcceptVpcPeeringConnection`
    + `ec2:CreateTransitGatewayPeeringAttachment`
    + `ec2:CreateVpcEndpoint`
    + `ec2:CreateVpcPeeringConnection`
  + Amazon EventBridge
    + `events:PutEvents` – 如果該事件匯流排在 2023 年 3 月 2 日之前設定為跨帳戶 EventBridge 目標，則 EventBridge `PutEvents` 會呼叫另一個帳戶中的事件匯流排。如需詳細資訊，請參閱 *Amazon EventBridge 使用者指南*中的[授予許可以便允許來自其他  AWS  帳戶的事件](https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-cross-account.html#eb-receiving-events-from-another-account)。
  + Amazon GuardDuty
    + `guardduty:AcceptAdministratorInvitation`
  + Amazon Macie
    + `macie2:AcceptInvitation`
  + Amazon OpenSearch Service
    + `es:AcceptInboundConnection`
  + Amazon Route 53
    + `route53:AssociateVpcWithHostedZone`
    + `route53:CreateVPCAssociationAuthorization`
  + AWS Security Hub CSPM
    + `securityhub:AcceptAdministratorInvitation`
+ **資料類型** – [字串](reference_policies_elements_condition_operators.md#Conditions_String)
+ **值類型** - 單一值

**注意**  
如需上述不受支援動作的其他考量事項，請參閱[資料周邊政策範例](https://github.com/aws-samples/data-perimeter-policy-examples)儲存庫。

此全域鍵會傳回指定請求的資源組織 ID。它可讓您建立規則，這些規則適用於[身分型政策](access_policies_identity-vs-resource.md)的 `Resource` 元素中指定的組織中的所有資源。您可以在條件元素中指定[組織 ID](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_org_details.html)。當您新增和移除帳戶時，包含 `aws:ResourceOrgID` 鍵的政策會自動包含正確的帳戶，您無需手動更新它。

例如，下列政策可避免主體將物件新增至 `policy-genius-dev` 資源，除非 Amazon S3 資源屬於與提出請求的主體相同的組織。

**重要**  
此政策不允許任何動作。相反，它使用 `Deny` 效果，明確拒絕存取陳述式中列出的不屬於所列帳戶的所有資源。將此政策與允許存取特定資源的其他政策結合使用。

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

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": {
        "Sid": "DenyPutObjectToS3ResourcesOutsideMyOrganization",
        "Effect": "Deny",
        "Action": "s3:PutObject",
        "Resource": "arn:aws:s3:::policy-genius-dev/*",
        "Condition": {
            "StringNotEquals": {
                "aws:ResourceOrgID": "${aws:PrincipalOrgID}"
            }
        }
    }
}
```

------

**注意**  
有些 AWS 服務 需要存取在另一個 中託管的 AWS 擁有資源 AWS 帳戶。在身分型政策中使用 `aws:ResourceOrgID`，可能會影響您的身分存取這些資源。

某些 AWS 服務，例如 AWS Data Exchange，依賴存取 外部的資源 AWS 帳戶 進行正常操作。如果在政策中使用 `aws:ResourceOrgID` 鍵，請包含其他陳述式來建立這些服務的豁免。範例政策 [AWS：拒絕存取您帳戶外部的 Amazon S3 資源，但 AWS Data Exchange](reference_policies_examples_resource_account_data_exch.md) 示範如何在定義服務所擁有資源的例外狀況時，根據資源帳戶拒絕存取。您可以建立類似的政策，使用 `aws:ResourceOrgID` 鍵來限制組織內資源的存取，同時考量服務擁有的資源。

使用此政策範例作為建立您自己的自訂政策的範本。如需詳細資訊，請參閱您的服務[文件](https://docs.aws.amazon.com/index.html)。

在下列影片中，進一步了解如何在政策中使用 `aws:ResourceOrgID` 條件鍵。

[![AWS Videos](http://img.youtube.com/vi/https://www.youtube.com/embed/cWVW0xAiWwc/0.jpg)](http://www.youtube.com/watch?v=https://www.youtube.com/embed/cWVW0xAiWwc)


### aws:ResourceTag/*tag-key*
<a name="condition-keys-resourcetag"></a>

使用此鍵來將您在政策中所指定的標籤鍵值對與連接到資源的鍵值對進行比較。例如，您可以要求只在資源擁有連接標籤鍵 `"Dept"` 和值 `"Marketing"` 時才允許資源的存取。如需詳細資訊，請參閱[控制對 AWS 資源的存取](access_tags.md#access_tags_control-resources)。
+ **可用性** – 當所請求資源已連接標籤時，此鍵包含在請求內容中，或者包含在使用所連接標籤建立資源的請求中。只有在資源[支援以標籤為基礎的授權](reference_aws-services-that-work-with-iam.md)時，才會傳回此鍵。每個標籤鍵值對都會有一個內容鍵。
+ **資料類型** – [字串](reference_policies_elements_condition_operators.md#Conditions_String)
+ **值類型** - 單一值

此內容鍵的格式為 `"aws:ResourceTag/tag-key":"tag-value"`，其中 *tag-key* 和 *tag-value* 是標籤鍵值組。標籤索引鍵不區分大小寫。這表示如果您在政策的條件元素中指定 `"aws:ResourceTag/TagKey1": "Value1"`，則該條件會符合名為 `TagKey1` 或 `tagkey1` 的資源標籤鍵 (但不會同時符合兩者)。這些標籤索引鍵值對中的值需區分大小寫。這表示如果您在政策的條件元素中指定 `"aws:ResourceTag/TagKey1": "Production"`，該條件會符合名為 `Production` 的資源標籤值 (但不會符合 `production` 或 `PRODUCTION`)。

如需使用 `aws:ResourceTag` 鍵來控制 IAM 資源存取的範例，請參閱 [控制對 AWS 資源的存取](access_tags.md#access_tags_control-resources)。

如需使用 `aws:ResourceTag`金鑰控制對其他 AWS 資源之存取的範例，請參閱 [使用標籤控制對 AWS 資源的存取](access_tags.md)。

如需有關使用屬性型存取控制 (ABAC) 之 `aws:ResourceTag` 條件鍵的教程，請參閱 [IAM 教學課程：定義根據標籤存取 AWS 資源的許可](tutorial_attribute-based-access-control.md)。

## 請求的屬性
<a name="condition-keys-request-properties"></a>

使用下列條件索引鍵，將請求本身和請求內容的詳細資訊與您在政策中指定的請求屬性進行比較。

### aws:CalledVia
<a name="condition-keys-calledvia"></a>

使用此鍵可將政策中的服務與代表 IAM 主體 (使用者或角色) 提出請求的服務進行比較。當委託人向 AWS 服務提出請求時，該服務可能會使用委託人的登入資料向其他 服務提出後續請求。如果使用轉寄存取工作階段 (FAS) 發出請求，此索引鍵的值會設定為服務主體的值。`aws:CalledVia` 鍵包含代表主體提出請求的鏈結中，每個服務的排序清單。

如需詳細資訊，請參閱[轉送存取工作階段](access_forward_access_sessions.md)。
+ **可用性** – 支援 `aws:CalledVia` 的服務使用 IAM 主體的憑證向其他服務提出請求時，此鍵即出現在請求中。若服務使用[服務角色或服務連結角色](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles.html#id_roles_terms-and-concepts)來代表主體進行呼叫，則此金鑰不存在。若主體直接進行呼叫，此鍵亦不存在。
+ **資料類型** – [字串](reference_policies_elements_condition_operators.md#Conditions_String) (清單)
+ **值類型** - 多重值

若要在政策中使用 `aws:CalledVia` 條件金鑰，您必須提供服務委託人，以允許或拒絕 AWS 服務請求。例如，您可以使用 從 Amazon DynamoDB 資料表 AWS CloudFormation 讀取和寫入。DynamoDB 接著會使用由 AWS Key Management Service (AWS KMS) 提供的加密。

若要在*任何*服務使用主體憑證提出請求時，允許或拒絕存取，請使用 `aws:ViaAWSService` 條件鍵。該條件索引鍵支援 AWS 服務。

`aws:CalledVia` 鍵是[多值鍵](reference_policies_condition-single-vs-multi-valued-context-keys.md)。但是，您無法在條件中使用此鍵強制排序。使用上面的例子，**使用者 1** 向 CloudFormation發出請求，其中 CloudFormation會呼叫 DynamoDB，而 DynamoDB 呼叫 AWS KMS。這是三個獨立的請求。使用者 1 *透過* CloudFormation 和 DynamoDB 對 AWS KMS 執行最終呼叫。

![\[使用 aws:CalledVia 的範例\]](http://docs.aws.amazon.com/zh_tw/IAM/latest/UserGuide/images/condition-key-calledvia-example-diagram.png)


在此情況下，請求環境中的 `aws:CalledVia` 鍵會依該排序包括 `cloudformation.amazonaws.com` 和 `dynamodb.amazonaws.com`。如果您只在意呼叫是透過請求鏈結中的某處的 DynamoDB 進行，則可以在政策中使用此條件鍵。

例如，下列政策允許管理名為 的 AWS KMS 金鑰`my-example-key`，但前提是 DynamoDB 是其中一個請求服務。`ForAnyValue:StringEquals` 條件運算子確保 DynamoDB 為呼叫服務之一。若主體直接呼叫 AWS KMS ，則條件會傳回 `false`，且此政策不允許該請求。

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

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "KmsActionsIfCalledViaDynamodb",
            "Effect": "Allow",
            "Action": [
                "kms:Encrypt",
                "kms:Decrypt",
                "kms:ReEncrypt*",
                "kms:GenerateDataKey",
                "kms:DescribeKey"
            ],
            "Resource": "arn:aws:kms:us-east-1:111122223333:key/my-example-key",
            "Condition": {
                "ForAnyValue:StringEquals": {
                    "aws:CalledVia": [
                        "dynamodb.amazonaws.com"
                    ]
                }
            }
        }
    ]
}
```

------

如果您想強制執行鏈結中進行第一個或最後一個呼叫的服務，可以使用 `aws:CalledViaFirst` 和 `aws:CalledViaLast` 鍵。例如，下列政策允許管理`my-example-key`名為 的金鑰 AWS KMS。只有在鏈結中包含多個請求時，才允許這些 AWS KMS 操作。第一個請求必須透過 CloudFormation 執行，而最後一個須透過 DynamoDB 進行。如果其他服務在鏈結中間發出請求，則仍允許該操作。

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

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "KmsActionsIfCalledViaChain",
            "Effect": "Allow",
            "Action": [
                "kms:Encrypt",
                "kms:Decrypt",
                "kms:ReEncrypt*",
                "kms:GenerateDataKey",
                "kms:DescribeKey"
            ],
            "Resource": "arn:aws:kms:us-east-1:111122223333:key/my-example-key",
            "Condition": {
                "StringEquals": {
                    "aws:CalledViaFirst": "cloudformation.amazonaws.com",
                    "aws:CalledViaLast": "dynamodb.amazonaws.com"
                }
            }
        }
    ]
}
```

------

當服務使用 IAM 主體憑證來呼叫另一個服務時，`aws:CalledViaFirst` 和 `aws:CalledViaLast` 鍵即會出現在請求中。它們會指出在請求鏈中進行呼叫的第一個和最後一個服務。例如，假設 CloudFormation 呼叫另一個名為 的服務`X Service`，它會呼叫 DynamoDB，然後呼叫 AWS KMS。對 的最終呼叫是由 `User 1` ** CloudFormation執行，然後 AWS KMS 是 `X Service`，然後是 DynamoDB。它首先透過 呼叫 CloudFormation ，最後透過 DynamoDB 呼叫。

![\[使用 aws:CalledViaFirst 和 aws:CalledViaLast 的範例\]](http://docs.aws.amazon.com/zh_tw/IAM/latest/UserGuide/images/condition-key-calledviafirstlast-example-diagram.png)


### aws:CalledViaFirst
<a name="condition-keys-calledviafirst"></a>

使用此鍵可將政策中的服務與代表 IAM 主體 (使用者或角色) 提出請求的***第一個服務***進行比較。如需詳細資訊，請參閱 `aws:CalledVia`。
+ **可用性** – 服務使用 IAM 主體的憑證向不同服務提出至少一個其他請求時，此鍵即出現在請求中。若服務使用[服務角色或服務連結角色](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles.html#id_roles_terms-and-concepts)來代表主體進行呼叫，則此金鑰不存在。若主體直接進行呼叫，此鍵亦不存在。
+ **資料類型** – [字串](reference_policies_elements_condition_operators.md#Conditions_String)
+ **值類型** - 單一值

### aws:CalledViaLast
<a name="condition-keys-calledvialast"></a>

使用此鍵可將政策中的服務與代表 IAM 主體 (使用者或角色) 提出請求的*最後一個服務*進行比較。如需詳細資訊，請參閱 `aws:CalledVia`。
+ **可用性** – 服務使用 IAM 主體的憑證向不同服務提出至少一個其他請求時，此鍵即出現在請求中。若服務使用[服務角色或服務連結角色](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles.html#id_roles_terms-and-concepts)來代表主體進行呼叫，則此金鑰不存在。若主體直接進行呼叫，此鍵亦不存在。
+ **資料類型** – [字串](reference_policies_elements_condition_operators.md#Conditions_String)
+ **值類型** - 單一值

### aws:ViaAWSService
<a name="condition-keys-viaawsservice"></a>

使用此金鑰來檢查 是否使用[轉送存取工作階段 (FAS)](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_forward_access_sessions.html) 代表您向其他 服務 AWS 服務 提出請求。

當服務使用轉寄存取工作階段代表原始 IAM 主體發出請求時，請求內容索引鍵會傳回 `true`。主體直接進行呼叫時，請求環境鍵也會傳回 `false`。
+ **可用性** – 此金鑰一律會包含在請求內容中。
+ **資料類型** – [布林值](reference_policies_elements_condition_operators.md#Conditions_Boolean)
+ **值類型** - 單一值

### aws:CalledViaAWSMCP
<a name="condition-keys-calledviaawasmcp"></a>

使用此金鑰來比較政策中的服務與代表 IAM 主體 （使用者或角色） 提出請求的 AWS MCP 服務。當委託人向 AWS MCP 服務提出請求時，該服務會使用委託人的登入資料向其他服務提出後續請求。使用 AWS MCP 服務提出請求時，會以服務主體的值設定此金鑰。`aws:CalledViaAWSMCP` 金鑰包含代表委託人提出請求的 MCP 服務的服務委託人名稱。
+ **可用性** – 當 AWS MCP 服務使用 IAM 主體的登入資料向 AWS 服務提出請求時，此金鑰會出現在請求中。若主體直接進行呼叫，此鍵亦不存在。
+ **資料類型** – [字串](reference_policies_elements_condition_operators.md#Conditions_String)
+ **值類型** - 單一值

您可以使用此條件金鑰，根據啟動請求的特定 MCP 伺服器來允許或拒絕存取。例如，以下政策拒絕透過特定 MCP 伺服器啟動敏感刪除操作：

```
{
    "Version": "2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "DenySensitiveActionsViaSpecificMCP",
            "Effect": "Deny",
            "Action": [
                "s3:DeleteBucket",
                "s3:DeleteObject",
                "dynamodb:DeleteTable"
            ],
            "Resource": "*",
            "Condition": {
                "StringEquals": {
                    "aws:CalledViaAWSMCP": "aws-mcp.amazonaws.com"
                }
            }
        }
    ]
}
```

### aws:ViaAWSMCPService
<a name="condition-keys-viaawsmcpservice"></a>

使用此金鑰來檢查 AWS MCP 服務是否使用轉送存取工作階段 (FAS) AWS 代表您向其他服務提出請求。當 AWS MCP 服務代表原始 IAM 主體將請求轉送至 AWS 服務`true`時，請求內容金鑰會傳回。主體直接進行呼叫時，請求環境鍵也會傳回 `false`。
+ **可用性** – 當 AWS MCP 伺服器代表 IAM 主體向下游 AWS 服務提出請求時，此金鑰會包含在請求內容中。
+ **資料類型** – [布林值](reference_policies_elements_condition_operators.md#Conditions_Boolean)
+ **值類型** - 單一值

您可以使用此金鑰在特定動作透過 MCP 伺服器時加以限制。例如，當透過任何 AWS MCP 伺服器啟動時，下列政策會拒絕敏感的刪除操作：

```
{
    "Version": "2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "DenySensitiveActionsViaMCP",
            "Effect": "Deny",
            "Action": [
                "s3:DeleteBucket",
                "s3:DeleteObject",
                "dynamodb:DeleteTable"
            ],
            "Resource": "*",
            "Condition": {
                "Bool": {
                    "aws:ViaAWSMCPService": "true"
                }
            }
        }
    ]
}
```

### aws:CurrentTime
<a name="condition-keys-currenttime"></a>

使用此鍵來將請求的日期和時間及您在政策中所指定的日期與時間進行比較。如要檢視使用此條件鍵的範例政策，請參閱 [AWS：允許根據日期和時間進行存取](reference_policies_examples_aws-dates.md)。
+ **可用性** – 此金鑰一律會包含在請求內容中。
+ **資料類型** – [日期](reference_policies_elements_condition_operators.md#Conditions_Date)
+ **值類型** - 單一值

### aws:EpochTime
<a name="condition-keys-epochtime"></a>

使用此鍵來將請求的日期和時間 (epoch 或 Unix 時間) 與您在政策中所指定的日期與時間進行比較。此鍵也接受自 1970 年 1 月 1 日以來的秒數。
+ **可用性** – 此金鑰一律會包含在請求內容中。
+ **資料類型** – [日期](reference_policies_elements_condition_operators.md#Conditions_Date)、[數字](reference_policies_elements_condition_operators.md#Conditions_Numeric)
+ **值類型** - 單一值

### aws:referer
<a name="condition-keys-referer"></a>

使用此鍵來將在用戶端瀏覽器中推薦請求的人員，與您在政策中所指定的推薦者進行比較。`aws:referer` 請求內容的值會由呼叫者在 HTTP 標頭中提供。當您選取網頁上的連結時，`Referer` 標頭會包含在 Web 瀏覽器請求中。`Referer` 標頭包含選取連結的網頁 URL。
+ **可用性** – 只有在透過從瀏覽器中的網頁 URL 連結來調用對 AWS 資源的請求時，請求內容才會包含此金鑰。程式設計請求不會包含此鍵，因為它不會使用瀏覽器連結來存取 AWS 資源。
+ **資料類型** – [字串](reference_policies_elements_condition_operators.md#Conditions_String)
+ **值類型** - 單一值

例如，您可以直接使用 URL 或使用直接 API 呼叫來存取 Amazon S3 物件。如需詳細資訊，請參閱[直接使用 Web 瀏覽器的 Amazon S3 API 操作](https://docs.aws.amazon.com/AmazonS3/latest/userguide/example-bucket-policies.html#example-bucket-policies-use-case-4)。當您從存在於網頁中的 URL 存取 Amazon S3 物件時，會在 `aws:referer` 中使用來源網頁的 URL。當您在瀏覽器中輸入 URL 來存取 Amazon S3 物件時，`aws:referer` 不存在。當您直接呼叫 API 時，`aws:referer` 也不存在。您可以使用政策中的 `aws:referer` 條件鍵來允許特定參照者提出的請求，例如公司網域中網頁上的連結。

**警告**  
應該小心使用此鍵。包含公開已知推薦者標頭值相當危險。未授權方可以使用修改的或自訂瀏覽器來提供他們選擇的任何 `aws:referer` 值。因此， `aws:referer` 不應用於防止未經授權方提出直接 AWS 請求。它僅用於允許客戶保護其數位內容 (例如存放在 Amazon S3 中的內容)，使其不被未經授權的第三方網站參考。

### aws:RequestedRegion
<a name="condition-keys-requestedregion"></a>

使用此金鑰來比較請求中呼叫 AWS 的區域與您在政策中指定的區域。您可以使用此全域條件鍵來控制可接受請求的區域。若要檢視每個服務的 AWS 區域，請參閱 中的[服務端點和配額](https://docs.aws.amazon.com/general/latest/gr/aws-service-information.html)*Amazon Web Services 一般參考*。
+ **可用性** – 此鍵一律會包含在請求內容中。
+ **資料類型** – [字串](reference_policies_elements_condition_operators.md#Conditions_String)
+ **值類型** - 單一值

有些全域服務 (例如 IAM) 只會有單一端點。因為此端點實際位於美國東部 (維吉尼亞北部) 區域，所以一律會對 us-east-1 區域提出 IAM 呼叫。例如，如果您建立的政策拒絕存取所有服務 (如果請求的區域不是 us-west-2)，則 IAM 呼叫一律會失敗。若要檢視如何解決此問題的範例，請參閱[帶拒絕的 NotAction](reference_policies_elements_notaction.md)。

**注意**  
`aws:RequestedRegion` 條件鍵可讓您控制哪個端點叫用的服務，但不控制操作的影響。有些服務具有跨區域影響。  
例如，Amazon S3 具有延及其他區域的 API 操作。  
您可以在一個區域 (受 `s3:PutBucketReplication` 條件鍵影響) 中叫用`aws:RequestedRegion`，但其他區域會根據複寫組態設定而受到影響。
您可以調用 `s3:CreateBucket` 以在其他區域建立儲存貯體，並使用 `s3:LocationConstraint` 條件鍵控制適用的區域。

您可以使用此內容金鑰來限制存取指定區域集中 AWS 的服務。例如，下列政策可讓使用者在 AWS 管理主控台中檢視所有 Amazon EC2 執行個體。不過，只允許他們對愛爾蘭 (eu-west-1)、倫敦 (eu-west-2) 或巴黎 (eu-west-3) 的執行個體進行變更。

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

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "InstanceConsoleReadOnly",
            "Effect": "Allow",
            "Action": [
                "ec2:Describe*",
                "ec2:Export*",
                "ec2:Get*",
                "ec2:Search*"
            ],
            "Resource": "*"
        },
        {
            "Sid": "InstanceWriteRegionRestricted",
            "Effect": "Allow",
            "Action": [
                "ec2:Associate*",
                "ec2:Import*",
                "ec2:Modify*",
                "ec2:Monitor*",
                "ec2:Reset*",
                "ec2:Run*",
                "ec2:Start*",
                "ec2:Stop*",
                "ec2:Terminate*"
            ],
            "Resource": "*",
            "Condition": {
                "StringEquals": {
                    "aws:RequestedRegion": [
                        "eu-west-1",
                        "eu-west-2",
                        "eu-west-3"
                    ]
                }
            }
        }
    ]
}
```

------

### aws:RequestTag/*tag-key*
<a name="condition-keys-requesttag"></a>

使用此鍵來將請求中傳遞的標籤鍵/值對與您在政策中所指定的標籤對進行比較。例如，您可以檢查請求是否包含標籤鍵 `"Dept"` 並且其具有值 `"Accounting"`。如需詳細資訊，請參閱[在 AWS 請求期間控制存取](access_tags.md#access_tags_control-requests)。
+ **可用性** – 在請求中傳遞標籤鍵/值對時，鍵會包含在請求內容中。在請求中傳遞多個標籤時，每個標籤鍵值對都會有一個內容鍵。
+ **資料類型** – [字串](reference_policies_elements_condition_operators.md#Conditions_String)
+ **值類型** - 單一值

此內容鍵的格式為 `"aws:RequestTag/tag-key":"tag-value"`，其中 *tag-key* 和 *tag-value* 是標籤鍵值組。標籤索引鍵不區分大小寫。這表示如果您在政策的條件元素中指定 `"aws:RequestTag/TagKey1": "Value1"`，則該條件會符合名為 `TagKey1` 或 `tagkey1` 的要求標籤鍵 (但不會同時符合兩者)。這些標籤索引鍵值對中的值需區分大小寫。這表示如果您在政策的條件元素中指定 `"aws:RequestTag/TagKey1": "Production"`，該條件會符合名為 `Production` 的請求標籤值 (但不會符合 `production` 或 `PRODUCTION`)。

此範例顯示雖然鍵為單一值，但如果鍵不同，您仍然可以在請求中使用多個鍵/值對。

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

****  

```
{
  "Version":"2012-10-17",		 	 	 
  "Statement": {
    "Effect": "Allow",
    "Action": "ec2:CreateTags",
    "Resource": "arn:aws:ec2::111122223333:instance/*",
    "Condition": {
      "StringEquals": {
        "aws:RequestTag/environment": [
          "preprod",
          "production"
        ],
        "aws:RequestTag/team": [
          "engineering"
        ]
      }
    }
  }
}
```

------

### aws:TagKeys
<a name="condition-keys-tagkeys"></a>

使用此鍵來將請求中的標籤鍵與您在政策中所指定的鍵進行比較。當使用政策來控制使用標籤的存取時，建議您使用 `aws:TagKeys` 條件鍵來定義允許的標籤鍵。如需範例政策和詳細資訊，請參閱 [根據標籤索引鍵控制存取權限](access_tags.md#access_tags_control-tag-keys)。
+ **可用性** – 如果操作支援在請求中傳遞標籤，則此鍵會包含在請求內容中。
+ **資料類型** – [字串](reference_policies_elements_condition_operators.md#Conditions_String) (清單)
+ **值類型** - 多重值

此內容鍵的格式為 `"aws:TagKeys":"tag-key"`，其中 *tag-key* 是沒有值的標籤鍵清單 (例如，`["Dept","Cost-Center"]`)。

由於您可以在請求中包含多個標籤鍵值對，因此請求內容可能會是[多值](reference_policies_condition-single-vs-multi-valued-context-keys.md)請求。在這種情況下，您必須使用 `ForAllValues` 或 `ForAnyValue` 設定運算子。如需詳細資訊，請參閱[用於多值內容索引鍵的集運算子](reference_policies_condition-single-vs-multi-valued-context-keys.md#reference_policies_condition-multi-valued-context-keys)。

有些服務支援標記搭配資源操作，如建立、修改或刪除資源。若要允許標記和操作作為單一呼叫，您必須建立一個政策，同時包括標記動作和資源修改動作。然後，您可以使用 `aws:TagKeys` 條件鍵以強制執行在請求中使用特定的標籤鍵。例如，若要在某人建立 Amazon EC2 快照時限制標籤，您必須在政策中包含 `ec2:CreateSnapshot` 建立動作***和*** `ec2:CreateTags` 標記動作。若要檢視適用於此案例 (使用 `aws:TagKeys`) 的政策，請參閱《Amazon EC2 使用者指南》**中的[使用標籤建立快照](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ExamplePolicies_EC2.html#iam-creating-snapshot-with-tags)。

### aws:SecureTransport
<a name="condition-keys-securetransport"></a>

使用此金鑰來檢查請求是否使用 TLS 進行傳送。請求內容會傳回 `true` 或 `false`。在政策中，您可以允許只有在使用 TLS 傳送請求時，才能進行特定動作。
+ **可用性** – 此鍵一律會包含在請求內容中。
+ **資料類型** – [布林值](reference_policies_elements_condition_operators.md#Conditions_Boolean)
+ **值類型** - 單一值

**注意**  
 AWS 服務 代表您 AWS 服務 呼叫其他 (service-to-service呼叫） 時，會修訂特定網路的授權內容。如果您的政策搭配 `Deny`陳述式使用此條件金鑰， AWS 服務 原則可能會意外遭到封鎖。為在滿足安全需求的同時讓 AWS 服務 可以正常運作，請透過新增值為 `false` 的 `aws:PrincipalIsAWSService` 條件索引鍵，將服務主體從 `Deny` 陳述式中排除。例如：  

```
{
  "Effect": "Deny",
  "Action": "s3:*",
  "Resource": "*",
  "Condition": {
    "Bool": {
      "aws:SecureTransport": "false",
      "aws:PrincipalIsAWSService": "false"
    }
  }
}
```
當不使用 HTTPS (`aws:SecureTransport` 為 false) 時，此政策拒絕存取 Amazon S3 操作，但僅適用於非AWS 服務主體。這可確保您的條件限制適用於委託人以外的所有 AWS 服務 委託人。

### aws:SourceAccount
<a name="condition-keys-sourceaccount"></a>

使用此金鑰來比較提出service-to-service請求之資源的帳戶 ID 與您在政策中指定的帳戶 ID，但僅限於服務 AWS 委託人提出請求時。
+ **可用性** – 只有當 [AWS 服務主體](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_principal.html#principal-services)代表組態觸發服務對服務要求的資源直接呼叫您的資源時，才會將此鍵包含在請求內容中。發出呼叫服務會將原始資源的帳戶 ID 傳遞給被呼叫的服務。
**注意**  
此金鑰提供統一機制，以跨 AWS 服務強制執行跨服務混淆代理控制。不過，並非所有服務整合都需要使用此全域條件索引鍵。如需緩解跨服務混淆代理人風險之服務特定機制的詳細資訊，請參閱 AWS 服務 您使用的 文件。  
![\[aws:SourceAccount\]](http://docs.aws.amazon.com/zh_tw/IAM/latest/UserGuide/images/sourceAccount.png)
+ **資料類型** – [字串](reference_policies_elements_condition_operators.md#Conditions_String)
+ **值類型** - 單一值

您可以使用此條件索引鍵，以協助確保呼叫服務只有在請求來自特定帳戶時，才能存取您的資源。例如，您可以連接下列資源控制政策 (RCP)，以拒絕服務主體對 Amazon S3 儲存貯體的請求，除非它們由指定帳戶中的資源所觸發。此政策只會對具有 `aws:SourceAccount` 金鑰 (`"Null": {"aws:SourceAccount": "false"}`) 的服務主體 (`"Bool": {"aws:PrincipalIsAWSService": "true"}`) 提出的請求套用控制項，因此不需要使用此金鑰和主體呼叫的服務整合不會受到影響。如果請求內容中存在 `aws:SourceAccount` 金鑰，則 `Null` 條件將評估為 `true`，導致強制執行 `aws:SourceAccount` 金鑰。

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

****  

```
{
  "Version":"2012-10-17",		 	 	 
  "Statement": [
    {
      "Sid": "RCPEnforceConfusedDeputyProtection",
      "Effect": "Deny",
      "Principal": "*",
      "Action": [
        "s3:*"
      ],
      "Resource": "*",
      "Condition": {
        "StringNotEqualsIfExists": {
          "aws:SourceAccount": "111122223333"
        },
        "Null": {
          "aws:SourceAccount": "false"
        },
        "Bool": {
          "aws:PrincipalIsAWSService": "true"
        }
      }
    }
  ]
}
```

------

在以資源為基礎的政策中，其中委託人是 AWS 服務 委託人，請使用 金鑰來限制授予服務的許可。例如，當 Amazon S3 儲存貯體設定為傳送通知至 Amazon SNS 主題時，Amazon S3 服務會叫用所有已設定事件的 `sns:Publish` API 操作。在允許 `sns:Publish` 操作的主題政策中，將條件鍵的值設定為 Amazon S3 儲存貯體的帳戶 ID。

### aws:SourceArn
<a name="condition-keys-sourcearn"></a>

使用此鍵，可將提出服務對服務請求之資源的 [Amazon Resource Name (ARN)](reference_identifiers.md#identifiers-arns) 與您在政策中所指定的 ARN 進行比較，但僅限於請求是由 AWS 服務主體提出的情況。如果來源的 ARN 包括帳戶 ID 時，則不需要搭配 `aws:SourceAccount` 使用 `aws:SourceArn`。

此鍵不適用提出請求的主體 ARN。請改用 `aws:PrincipalArn`。
+ **可用性** – 只有當 [AWS 服務主體](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_principal.html#principal-services)代表組態觸發服務對服務要求的資源直接呼叫您的資源時，才會將此鍵包含在請求內容中。發出呼叫的服務會將原始資源的 ARN 傳遞給被呼叫的服務。
**注意**  
此金鑰提供統一機制，以跨 AWS 服務強制執行跨服務混淆代理控制。不過，並非所有服務整合都需要使用此全域條件索引鍵。如需緩解跨服務混淆代理人風險之服務特定機制的詳細資訊，請參閱 AWS 服務 您使用的 文件。  
![\[aws:SourceArn\]](http://docs.aws.amazon.com/zh_tw/IAM/latest/UserGuide/images/sourceArn.png)
+ **資料類型** – ARN

  AWS 建議您在比較 [ARN 時使用 ARN 運算子](reference_policies_elements_condition_operators.md#Conditions_ARN)，而非[字串運算子](reference_policies_elements_condition_operators.md#Conditions_String)。 ARNs
+ **值類型** - 單一值

您可以使用此條件索引鍵，以協助確保呼叫服務只有在請求來自特定資源時，才能存取您的資源。使用以資源為基礎的政策搭配 AWS 服務 委託人做為 時`Principal`，請將此條件索引鍵的值設定為您要限制存取之資源的 ARN。例如，當 Amazon S3 儲存貯體設定為傳送通知至 Amazon SNS 主題時，Amazon S3 服務會叫用所有已設定事件的 `sns:Publish` API 操作。在允許 `sns:Publish` 操作的主題政策中，將條件鍵的值設定為 Amazon S3 儲存貯體的 ARN。如需有關何時在資源型政策中使用此條件索引鍵的建議，請參閱您正在使用的 AWS 服務 文件。

### aws:SourceOrgID
<a name="condition-keys-sourceorgid"></a>

使用此金鑰來比較提出service-to-service請求之資源[的組織 ID](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_org_details.html) 與您在政策中指定的組織 ID，但僅限於服務 AWS 委託人提出請求時。當您對 AWS Organizations中的組織新增和移除帳戶時，包含 `aws:SourceOrgID` 鍵的政策會自動包含正確的帳戶，您無需手動更新政策。
+ **可用性** – 只有當 [AWS 服務主體](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_principal.html#principal-services)代表組織成員帳戶所擁有的資源直接呼叫您的資源時，此鍵才會包含在請求內容中。發出呼叫的服務會將原始資源的組織 ID 傳遞給被呼叫的服務。
**注意**  
此金鑰提供統一機制，以跨 AWS 服務強制執行跨服務混淆代理控制。不過，並非所有服務整合都需要使用此全域條件索引鍵。如需緩解跨服務混淆代理人風險之服務特定機制的詳細資訊，請參閱 AWS 服務 您使用的 文件。  
![\[aws:SourceOrgID\]](http://docs.aws.amazon.com/zh_tw/IAM/latest/UserGuide/images/sourceOrgID.png)
+ **資料類型** – [字串](reference_policies_elements_condition_operators.md#Conditions_String)
+ **值類型** - 單一值

您可以使用此條件索引鍵，以協助確保呼叫服務只有在請求來自特定組織時，才能存取您的資源。例如，您可以連接下列資源控制政策 (RCP) 來拒絕服務主體對 Amazon S3 儲存貯體的請求，除非它們是由指定 AWS 組織中的資源觸發。此政策只會對具有 `aws:SourceAccount` 金鑰 (`"Null": {"aws:SourceAccount": "false"}`) 的服務主體 (`"Bool": {"aws:PrincipalIsAWSService": "true"}`) 提出的請求套用控制項，因此不需要使用該金鑰和主體呼叫的服務整合不會受到影響。如果請求內容中存在 `aws:SourceAccount` 金鑰，則 `Null` 條件將評估為 `true`，導致強制執行 `aws:SourceOrgID` 金鑰。我們在 `Null` 條件運算子中使用 `aws:SourceAccount` 而非 `aws:SourceOrgID`，因此如果請求來自不屬於組織的帳戶，則控制仍然適用。

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

****  

```
{
  "Version":"2012-10-17",		 	 	 
  "Statement": [
    {
      "Sid": "RCPEnforceConfusedDeputyProtection",
      "Effect": "Deny",
      "Principal": "*",
      "Action": [
        "s3:*"
      ],
      "Resource": "*",
      "Condition": {
        "StringNotEqualsIfExists": {
          "aws:SourceOrgID": "o-xxxxxxxxxx"
        },
        "Null": {
          "aws:SourceAccount": "false"
        },
        "Bool": {
          "aws:PrincipalIsAWSService": "true"
        }
      }
    }
  ]
}
```

------

### aws:SourceOrgPaths
<a name="condition-keys-sourceorgpaths"></a>

使用此金鑰來比較提出service-to-service請求的資源 AWS Organizations 路徑與您在政策中指定的組織路徑，但僅限於服務 AWS 委託人提出請求時。 AWS Organizations 路徑是 AWS Organizations 實體結構的文字表示法。如需有關使用和了解路徑的詳細資訊，請參閱[了解 AWS Organizations 實體路徑](access_policies_last-accessed-view-data-orgs.md#access_policies_last-accessed-viewing-orgs-entity-path)。
+ **可用性** – 只有當 [AWS 服務主體](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_principal.html#principal-services)代表組織成員帳戶所擁有的資源直接呼叫您的資源時，此鍵才會包含在請求內容中。發出呼叫的服務會將原始資源的組織路徑傳遞給被呼叫的服務。
**注意**  
此金鑰提供統一機制，以跨 AWS 服務強制執行跨服務混淆代理控制。不過，並非所有服務整合都需要使用此全域條件索引鍵。如需緩解跨服務混淆代理人風險之服務特定機制的詳細資訊，請參閱 AWS 服務 您使用的 文件。  
![\[aws:SourceOrgPaths\]](http://docs.aws.amazon.com/zh_tw/IAM/latest/UserGuide/images/sourceOrgPaths.png)
+ **資料類型** – [字串](reference_policies_elements_condition_operators.md#Conditions_String) (清單)
+ **值類型** - 多重值

使用此條件索引鍵，以協助確保呼叫服務只有在請求來自 AWS Organizations中的特定組織單位 (OU) 時，才能存取您的資源。

與 `aws:SourceOrgID` 類似，為了協助防止對不需要使用此索引鍵的服務整合造成影響，請使用 `Null` 條件運算子與 `aws:SourceAccount` 條件索引鍵，以便在請求來自不屬於組織的帳戶時仍可套用控制項。

```
{
      "Condition": {
        "ForAllValues:StringNotLikeIfExists": {
            "aws:SourceOrgPaths": "o-a1b2c3d4e5/r-ab12/ou-ab12-11111111/ou-ab12-22222222/"
        },
        "Null": {
          "aws:SourceAccount": "false"
        },
        "Bool": {
          "aws:PrincipalIsAWSService": "true"
        }
      }
}
```

`aws:SourceOrgPaths` 是多重值條件鍵。多值鍵在請求內容中可以擁有多個值。使用此鍵時，您必須使用 `ForAnyValue` 或 `ForAllValues` 設定運算子搭配[字串條件運算子](reference_policies_elements_condition_operators.md#Conditions_String)。如需有關多重值條件鍵的詳細資訊，請參閱 [用於多值內容索引鍵的集運算子](reference_policies_condition-single-vs-multi-valued-context-keys.md#reference_policies_condition-multi-valued-context-keys)。

### aws:UserAgent
<a name="condition-keys-useragent"></a>

使用此鍵來將申請者的用戶端應用程式與您在政策中指定的應用程式進行比較。
+ **可用性** – 此鍵一律會包含在請求內容中。
+ **資料類型** – [字串](reference_policies_elements_condition_operators.md#Conditions_String)
+ **值類型** - 單一值

**警告**  
應該小心使用此鍵。由於`aws:UserAgent` 值由 HTTP 標頭中的呼叫者提供，未授權方可以使用修改的或自訂瀏覽器來提供他們選擇的任何 `aws:UserAgent` 值。因此， `aws:UserAgent` 不應用於防止未經授權方提出直接 AWS 請求。您可以使用它僅允許特定用戶端應用程式，而且只在測試政策之後才能使用。

### aws:IsMcpServiceAction
<a name="condition-keys-ismcpserviceaction"></a>

使用此金鑰來驗證正在授權的動作是否為 MCP 服務動作。此金鑰不是指 MCP 服務對其他服務 AWS 採取的動作。
+ **可用性** – 此金鑰包含在請求內容中，且只有在 MCP 服務授權 MCP 服務動作時，才會設為 True。
+ **資料類型** – [布林值](reference_policies_elements_condition_operators.md#Conditions_Boolean)
+ **值類型** - 單一值

## 其他跨服務條件鍵
<a name="condition-keys-other"></a>

AWS STS 支援 [OIDC](reference_policies_iam-condition-keys.md#condition-keys-wif) [聯合的 SAML 型聯合條件金鑰](reference_policies_iam-condition-keys.md#condition-keys-saml)和跨服務條件金鑰。當使用 OIDC 或 SAML 聯合身分的使用者在其他 服務中執行 AWS 操作時，即可使用這些金鑰。