

# 搭配 Amazon Bedrock AgentCore Gateway 使用 IAM 條件金鑰
<a name="security-gateway-condition-keys"></a>

使用 Amazon Bedrock AgentCore 特定條件金鑰來控制如何在組織中建立和設定閘道和閘道目標。這些條件索引鍵適用於控制平面操作。它們在服務控制政策 (SCPs中特別有用，以強制執行組織安全要求。

例如，您可以：
+ 要求所有閘道使用特定的身分提供者進行身分驗證。
+ 限制可以建立的目標類型。
+ 強制執行目標使用特定的登入資料提供者類型。
+ 要求閘道目標透過核准的子網路和安全群組進行連線。

## 閘道條件索引鍵
<a name="gateway-condition-keys"></a>

下列條件索引鍵適用於 `CreateGateway`和 `UpdateGateway`操作。


| 條件鍵 | Type | API 操作 | Description | 
| --- | --- | --- | --- | 
|  `bedrock-agentcore:DiscoveryUrl`  | String |  `CreateGateway`, `UpdateGateway`  | 依閘道上設定的探索 URL 篩選存取權。使用此項目可確保閘道使用特定的身分提供者。 | 
|  `bedrock-agentcore:KmsKeyArn`  | String |  `CreateGateway`, `UpdateGateway`  | 依用來加密閘道資源的 KMS 金鑰 ARN 篩選存取權。 | 
|  `bedrock-agentcore:PolicyEngineArn`  | String |  `CreateGateway`, `UpdateGateway`  | 依與閘道相關聯之政策引擎組態的 ARN 篩選存取權。 | 
|  `bedrock-agentcore:PolicyEngineMode`  | String |  `CreateGateway`, `UpdateGateway`  | 依與閘道相關聯的政策引擎組態模式篩選存取權。 | 
|  `bedrock-agentcore:ProtocolType`  | String |  `CreateGateway`, `UpdateGateway`  | 依閘道的通訊協定類型篩選存取權。 | 
|  `bedrock-agentcore:GatewayAuthorizerType`  | String |  `CreateGateway`, `UpdateGateway`  | 依閘道上設定的授權方類型篩選存取權。有效值為 `AWS_IAM`、`CUSTOM_JWT` 和 `NONE`。 | 

## 閘道目標條件索引鍵
<a name="gateway-target-condition-keys"></a>

下列條件索引鍵適用於 `CreateGatewayTarget`和 `UpdateGatewayTarget`操作。


| 條件鍵 | Type | API 操作 | Description | 
| --- | --- | --- | --- | 
|  `bedrock-agentcore:McpTargetConfigurationType`  | String |  `CreateGatewayTarget`, `UpdateGatewayTarget`  | 依 MCP 目標的類型篩選存取權。有效值包括 `apiGateway`、`lambda`、`mcpServer`、`openApiSchema`、`smithyModel` 及 `connector`。 | 
|  `bedrock-agentcore:HttpTargetConfigurationType`  | String |  `CreateGatewayTarget`, `UpdateGatewayTarget`  | 依 HTTP 目標的類型篩選存取權。有效值包括 `agentcoreRuntime` 與 `passthrough`。 | 
|  `bedrock-agentcore:InferenceTargetConfigurationType`  | String |  `CreateGatewayTarget`, `UpdateGatewayTarget`  | 依推論目標的類型篩選存取權。有效值包括 `connector` 與 `provider`。 | 
|  `bedrock-agentcore:CredentialProviderType`  | String |  `CreateGatewayTarget`, `UpdateGatewayTarget`  | 依目標上設定的登入資料提供者類型篩選存取權。有效值包括 `GATEWAY_IAM_ROLE`、`OAUTH`、`API_KEY`、`CALLER_IAM_CREDENTIALS` 及 `JWT_PASSTHROUGH`。 | 
|  `bedrock-agentcore:PrivateEndpointType`  | String |  `CreateGatewayTarget`, `UpdateGatewayTarget`  | 依目標的私有端點類型篩選存取權。有效值包括 `managedVpcResource` 與 `selfManagedLatticeResource`。 | 
|  `bedrock-agentcore:ResourceConfigurationIdentifier`  | String |  `CreateGatewayTarget`, `UpdateGatewayTarget`  | 依目標私有端點的資源組態識別符篩選存取權。 | 
|  `bedrock-agentcore:subnets`  | ArrayOfString |  `CreateGatewayTarget`, `UpdateGatewayTarget`  | 依為目標的受管 VPC 資源設定的子網路篩選存取權。請參閱[搭配 AgentCore VPC 設定使用 IAM 條件金鑰](security-vpc-condition.md)。 | 
|  `bedrock-agentcore:securityGroups`  | ArrayOfString |  `CreateGatewayTarget`, `UpdateGatewayTarget`  | 依針對目標的受管 VPC 資源設定的安全群組篩選存取權。 | 
|  `bedrock-agentcore:AllowedQueryParameters`  | ArrayOfString |  `CreateGatewayTarget`, `UpdateGatewayTarget`  | 依目標中繼資料組態中允許的查詢參數篩選存取權。 | 
|  `bedrock-agentcore:AllowedRequestHeaders`  | ArrayOfString |  `CreateGatewayTarget`, `UpdateGatewayTarget`  | 依目標中繼資料組態中允許的請求標頭篩選存取權。 | 
|  `bedrock-agentcore:AllowedResponseHeaders`  | ArrayOfString |  `CreateGatewayTarget`, `UpdateGatewayTarget`  | 依目標中繼資料組態中允許的回應標頭篩選存取權。 | 
|  `bedrock-agentcore:CredentialProviderScope`  | ArrayOfString |  `CreateGatewayTarget`, `UpdateGatewayTarget`  | 依目標的 OAuth 登入資料提供者上設定的範圍篩選存取權。 | 

## 政策範例
<a name="gateway-condition-key-examples"></a>

下列範例示範如何在 IAM 政策和 SCPs 中使用條件金鑰，對閘道組態強制執行組織控制。

### 要求閘道使用特定的身分提供者
<a name="example-require-specific-idp"></a>

當閘道不使用您組織的核准身分提供者探索 URL 時，請使用下列 SCP 來拒絕閘道建立或更新。

```
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "EnforceGatewayIdP",
            "Effect": "Deny",
            "Action": [
                "bedrock-agentcore:CreateGateway",
                "bedrock-agentcore:UpdateGateway"
            ],
            "Resource": "*",
            "Condition": {
                "StringNotEquals": {
                    "bedrock-agentcore:DiscoveryUrl": "https://login.example.com/.well-known/openid-configuration"
                }
            }
        }
    ]
}
```

### 限制目標的登入資料提供者類型
<a name="example-restrict-target-credential-types"></a>

使用下列 SCP 將閘道目標限制為核准的憑證提供者類型。在此範例中，您將閘道目標限制為僅使用閘道的 IAM 角色或呼叫者 IAM 憑證。目標無法使用外部受管 API 金鑰或 OAuth 權杖。

```
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "RestrictTargetCredentialTypes",
            "Effect": "Deny",
            "Action": [
                "bedrock-agentcore:CreateGatewayTarget",
                "bedrock-agentcore:UpdateGatewayTarget"
            ],
            "Resource": "*",
            "Condition": {
                "StringNotEquals": {
                    "bedrock-agentcore:CredentialProviderType": [
                        "GATEWAY_IAM_ROLE",
                        "CALLER_IAM_CREDENTIALS"
                    ]
                }
            }
        }
    ]
}
```

### 限制可建立的 MCP 目標類型
<a name="example-restrict-target-types"></a>

使用下列政策來拒絕建立使用特定組態類型的 MCP 目標。此範例可防止目標使用直接 MCP 伺服器 URLs。

```
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "DenyDirectMcpServerTargets",
            "Effect": "Deny",
            "Action": [
                "bedrock-agentcore:CreateGatewayTarget",
                "bedrock-agentcore:UpdateGatewayTarget"
            ],
            "Resource": "*",
            "Condition": {
                "StringEquals": {
                    "bedrock-agentcore:McpTargetConfigurationType": "mcpServer"
                }
            }
        }
    ]
}
```

### 要求目標使用私有端點
<a name="example-enforce-private-endpoints"></a>

使用下列 SCP 來拒絕建立未指定私有端點類型的目標。這可確保所有目標流量都保留在私有網路中。

```
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "EnforcePrivateEndpoints",
            "Effect": "Deny",
            "Action": [
                "bedrock-agentcore:CreateGatewayTarget",
                "bedrock-agentcore:UpdateGatewayTarget"
            ],
            "Resource": "*",
            "Condition": {
                "Null": {
                    "bedrock-agentcore:PrivateEndpointType": "true"
                }
            }
        }
    ]
}
```

### 要求閘道使用客戶受管 KMS 金鑰
<a name="example-require-encryption"></a>

使用此 SCP 要求所有閘道使用客戶受管 KMS 金鑰進行加密，而不是使用服務預設值。

```
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "EnforceCustomerManagedKey",
            "Effect": "Deny",
            "Action": [
                "bedrock-agentcore:CreateGateway",
                "bedrock-agentcore:UpdateGateway"
            ],
            "Resource": "*",
            "Condition": {
                "Null": {
                    "bedrock-agentcore:KmsKeyArn": "true"
                }
            }
        }
    ]
}
```

### 強制閘道目標的已核准子網路
<a name="example-enforce-approved-subnets-for-targets"></a>

使用下列政策將閘道目標限制為核准的子網路。如需詳細資訊，請參閱[搭配 AgentCore VPC 設定使用 IAM 條件金鑰](security-vpc-condition.md)。

```
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "EnforceApprovedSubnets",
            "Effect": "Deny",
            "Action": [
                "bedrock-agentcore:CreateGatewayTarget",
                "bedrock-agentcore:UpdateGatewayTarget"
            ],
            "Resource": "*",
            "Condition": {
                "ForAnyValue:StringNotEquals": {
                    "bedrock-agentcore:subnets": [
                        "subnet-0123456789abcdef0",
                        "subnet-0123456789abcdef1"
                    ]
                }
            }
        }
    ]
}
```