

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# 设置使用 Amazon Bedrock 护栏的权限
<a name="guardrails-permissions"></a>

要设置具有护栏权限的角色，请创建一个 IAM 角色并按照创建[角色中的步骤为服务委派权限来附加 AWS 以下权限](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_create_for-service.html)。

如果您在代理中使用护栏，请将权限附加到有权创建和管理代理的服务角色。您可以在控制台中设置该角色，也可以按照[为 Amazon Bedrock 代理创建服务角色](agents-permissions.md)中的步骤创建自定义角色。

## 为策略角色创建和管理护栏的权限
<a name="guardrails-permissions-use"></a>

将以下语句附加到策略中的 `Statement` 字段，以便您的角色使用护栏。

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

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "CreateAndManageGuardrails",
            "Effect": "Allow",
            "Action": [  
                "bedrock:CreateGuardrail",
                "bedrock:CreateGuardrailVersion",
                "bedrock:DeleteGuardrail", 
                "bedrock:GetGuardrail", 
                "bedrock:ListGuardrails", 
                "bedrock:UpdateGuardrail"
            ],
            "Resource": "*"
        }
    ]   
}
```

------

## 调用护栏以筛选内容的权限
<a name="guardrails-permissions-invoke"></a>

将以下语句附加到角色的策略中的 `Statement` 字段，以便允许进行模型推理并调用护栏。

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

****  

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

------

# 自动推理策略的权限 ApplyGuardrail
<a name="guardrail-automated-reasoning-permissions"></a>

将自动推理策略与 `ApplyGuardrail` API 结合使用时，您需要允许您调用自动推理策略的 IAM 策略。

```
{
    "Sid": "AutomatedReasoningChecks",
    "Effect": "Allow",
    "Action": [
        "bedrock:InvokeAutomatedReasoningPolicy"
    ],
    "Resource": [
        "arn:aws:bedrock:region:account-id:automated-reasoning-policy/policy-id:policy-version"
    ]
}
```

此策略允许您在账户中调用指定的自动推理策略。

# 代理使用自动推理策略的权限
<a name="guardrail-automated-reasoning-agent-permissions"></a>

当您在 Amazon Bedrock 中创建代理时，代理的服务角色会自动包括调用护栏 (`bedrock:ApplyGuardrail`) 和基础模型的策略。要将包含自动推理策略的护栏附加到您的代理，请手动为代理的服务角色添加权限。

更新有关您的代理服务角色的`AmazonBedrockAgentBedrockApplyGuardrailPolicy`政策，以包括`bedrock:GetGuardrail`操作和对护栏配置文件的访问权限。然后，添加一条单独的语句，授予对自动推理策略资源的`bedrock:InvokeAutomatedReasoningPolicy`操作。

以下示例显示了完整的语句列表：

```
    "Statement": [
        {
            "Sid": "AmazonBedrockAgentBedrockApplyGuardrailPolicyProd",
            "Effect": "Allow",
            "Action": [
                "bedrock:ApplyGuardrail",
                "bedrock:GetGuardrail"
            ],
            "Resource": [
                "arn:aws:bedrock:region:account-id:guardrail/guardrail-id",
                "arn:aws:bedrock:*:account-id:guardrail-profile/*"
            ]
        },
        {
            "Sid": "InvokeAutomatedReasoningPolicyProd",
            "Effect": "Allow",
            "Action": "bedrock:InvokeAutomatedReasoningPolicy",
            "Resource": [
                "arn:aws:bedrock:region:account-id:automated-reasoning-policy/policy-id:policy-version"
            ]
        }
    ]
```

**注意**  
无需修改您的代理服务角色中现有的`AmazonBedrockAgentBedrockFoundationModelPolicy`角色。只有`AmazonBedrockAgentBedrockApplyGuardrailPolicy`需要进行上述更改。

# （可选）为护栏创建客户管理的密钥以提高安全性
<a name="guardrails-permissions-kms"></a>

您可以通过客户管理来加密您的护栏。 AWS KMS keys任何具有`CreateKey`权限的用户都可以使用 AWS Key Management Service (AWS KMS) 控制台或[CreateKey](https://docs.aws.amazon.com/kms/latest/APIReference/API_CreateKey.html)操作创建客户托管密钥。在这些情况下，应确保创建对称加密密钥。

创建密钥后，请配置以下权限策略。

1. 执行以下操作以创建基于资源的密钥策略。

   1. [创建密钥策略](https://docs.aws.amazon.com/kms/latest/developerguide/key-policy-overview.html)，为您的 KMS 密钥创建基于资源的策略。

   1. 添加以下策略语句，向护栏用户和护栏创建者授予权限。将每个 `role` 替换为您希望允许其执行指定操作的角色。

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

****  

      ```
      {
          "Version":"2012-10-17",		 	 	 
          "Id": "KMS key policy",
          "Statement": [
              {
                  "Sid": "PermissionsForGuardrailsCreators",
                  "Effect": "Allow",
                  "Principal": {
                      "AWS": "arn:aws:iam::111122223333:user/role"
                  },
                  "Action": [
                      "kms:Decrypt",
                      "kms:GenerateDataKey",
                      "kms:DescribeKey",
                      "kms:CreateGrant"
                  ],
                  "Resource": "*"
              },
              {
                  "Sid": "PermissionsForGuardrailsUsers",
                  "Effect": "Allow",
                  "Principal": {
                      "AWS": "arn:aws:iam::111122223333:user/role"
                  },
                  "Action": "kms:Decrypt",
                  "Resource": "*"
              }
          ]
      }
      ```

------

1. 将以下基于身份的策略附加到角色，以便该角色能够创建和管理护栏。将 `key-id` 替换为您创建的 KMS 密钥的 ID。

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

****  

   ```
   {
       "Version":"2012-10-17",		 	 	 
       "Statement": [
           {
               "Sid": "AllowRoleToCreateAndManageGuardrails",
               "Effect": "Allow",
               "Action": [
                   "kms:Decrypt",
                   "kms:DescribeKey",
                   "kms:GenerateDataKey",
                   "kms:CreateGrant"
               ],
               "Resource": "arn:aws:kms:us-east-1:123456789012:key/key-id"
           }
       ]
   }
   ```

------

1. 将以下基于身份的策略附加到角色，以便该角色能够在模型推理过程中或调用代理时使用您加密的护栏。将 `key-id` 替换为您创建的 KMS 密钥的 ID。

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

****  

   ```
   {
       "Version":"2012-10-17",		 	 	 
       "Statement": [
           {
               "Sid": "AllowRoleToUseEncryptedGuardrailDuringInference",
               "Effect": "Allow",
               "Action": [
                   "kms:Decrypt"
               ],
               "Resource": "arn:aws:kms:us-east-1:123456789012:key/key-id"
           }
       ]
   }
   ```

------

# 在模型推理请求中强制使用特定护栏
<a name="guardrails-permissions-id"></a>

您可以通过在 IAM 策略中添加 `bedrock:GuardrailIdentifier` 条件键，来强制为模型推理使用特定护栏。这样，您就可以拒绝任何未包含您的 IAM 策略中配置的护栏的推理 API 请求。

您可以将此强制应用于以下推断 APIs：
+ [Converse](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_Converse.html)
+ [ConverseStream](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_ConverseStream.html)
+ [InvokeModel](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_InvokeModel.html)
+ [InvokeModelWithResponseStream](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_InvokeModelWithResponseStream.html)

以下示例展示了使用 `bedrock:GuardrailIdentifier` 条件键的一些方式。

**示例 1：强制使用特定护栏及其数字版本**  
在模型推理期间，使用以下策略强制使用特定护栏（`guardrail-id`）及其数字版本 1。  
显式拒绝会阻止用户调用具有任何其他 `GuardrailIdentifier` 和护栏版本的所列操作，无论该用户可能具有哪些其他权限。    
****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "InvokeFoundationModelStatement1",
            "Effect": "Allow",
            "Action": [
                "bedrock:InvokeModel",
                "bedrock:InvokeModelWithResponseStream"
            ],
            "Resource": [
                "arn:aws:bedrock:us-east-1::foundation-model/*"
            ],
            "Condition": {
                "StringEquals": {
                    "bedrock:GuardrailIdentifier": "arn:aws:bedrock:us-east-1:123456789012:guardrail/guardrail-id:1"
                }
            }
        },
        {
            "Sid": "InvokeFoundationModelStatement2",
            "Effect": "Deny",
            "Action": [
                "bedrock:InvokeModel",
                "bedrock:InvokeModelWithResponseStream"
            ],
            "Resource": [
                "arn:aws:bedrock:us-east-1::foundation-model/*"
            ],
            "Condition": {
                "StringNotEquals": {
                    "bedrock:GuardrailIdentifier": "arn:aws:bedrock:us-east-1:123456789012:guardrail/guardrail-id:1"
                }
            }
        },
        {
            "Sid": "ApplyGuardrail",
            "Effect": "Allow",
            "Action": [
                "bedrock:ApplyGuardrail"
            ],
            "Resource": [
                "arn:aws:bedrock:us-east-1:123456789012:guardrail/guardrail-id"
            ]
        }
    ]
}
```

**示例 2：强制使用特定护栏及其草稿版本**  
在模型推理期间，借助以下策略强制使用特定护栏（`guardrail-id`）及其草稿版本。    
****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "InvokeFoundationModelStatement1",
            "Effect": "Allow",
            "Action": [
                "bedrock:InvokeModel",
                "bedrock:InvokeModelWithResponseStream"
            ],
            "Resource": [
                "arn:aws:bedrock:us-east-1::foundation-model/*"
            ],
            "Condition": {
                "StringEquals": {
                    "bedrock:GuardrailIdentifier": "arn:aws:bedrock:us-east-1:123456789012:guardrail/guardrail-id"
                }
            }
        },
        {
            "Sid": "InvokeFoundationModelStatement2",
            "Effect": "Deny",
            "Action": [
                "bedrock:InvokeModel",
                "bedrock:InvokeModelWithResponseStream"
            ],
            "Resource": [
                "arn:aws:bedrock:us-east-1::foundation-model/*"
            ],
            "Condition": {
                "StringNotEquals": {
                    "bedrock:GuardrailIdentifier": "arn:aws:bedrock:us-east-1:123456789012:guardrail/guardrail-id"
                }
            }
        },
        {
            "Sid": "ApplyGuardrail",
            "Effect": "Allow",
            "Action": [
                "bedrock:ApplyGuardrail"
            ],
            "Resource": [
                "arn:aws:bedrock:us-east-1:123456789012:guardrail/guardrail-id"
            ]
        }
    ]
}
```

**示例 3：强制使用特定护栏及其任一数字版本**  
在模型推理期间，借助以下策略强制使用特定护栏（`guardrail-id`）及其任一数字版本。    
****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "InvokeFoundationModelStatement1",
            "Effect": "Allow",
            "Action": [
                "bedrock:InvokeModel",
                "bedrock:InvokeModelWithResponseStream"
            ],
            "Resource": [
                "arn:aws:bedrock:us-east-1::foundation-model/*"
            ],
            "Condition": {
                "ArnLike": {
                    "bedrock:GuardrailIdentifier": "arn:aws:bedrock:us-east-1:123456789012:guardrail/guardrail-id:*"
                }
            }
        },
        {
            "Sid": "InvokeFoundationModelStatement2",
            "Effect": "Deny",
            "Action": [
                "bedrock:InvokeModel",
                "bedrock:InvokeModelWithResponseStream"
            ],
            "Resource": [
                "arn:aws:bedrock:us-east-1::foundation-model/*"
            ],
            "Condition": {
                "ArnNotLike": {
                    "bedrock:GuardrailIdentifier": "arn:aws:bedrock:us-east-1:123456789012:guardrail/guardrail-id:*"
                }
            }
        },
        {
            "Sid": "ApplyGuardrail",
            "Effect": "Allow",
            "Action": [
                "bedrock:ApplyGuardrail"
            ],
            "Resource": [
                "arn:aws:bedrock:us-east-1:123456789012:guardrail/guardrail-id"
            ]
        }
    ]
}
```

**示例 4：强制使用特定护栏及其任一版本**  
在模型推理期间，借助以下策略强制使用特定护栏（`guardrail-id`）及其任一数字版本（包括草稿版本）。    
****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "InvokeFoundationModelStatement1",
            "Effect": "Allow",
            "Action": [
                "bedrock:InvokeModel",
                "bedrock:InvokeModelWithResponseStream"
            ],
            "Resource": [
                "arn:aws:bedrock:us-east-1::foundation-model/*"
            ],
            "Condition": {
                "ArnLike": {
                    "bedrock:GuardrailIdentifier": "arn:aws:bedrock:us-east-1:123456789012:guardrail/guardrail-id*"
                }
            }
        },
        {
            "Sid": "InvokeFoundationModelStatement2",
            "Effect": "Deny",
            "Action": [
                "bedrock:InvokeModel",
                "bedrock:InvokeModelWithResponseStream"
            ],
            "Resource": [
                "arn:aws:bedrock:us-east-1::foundation-model/*"
            ],
            "Condition": {
                "ArnNotLike": {
                    "bedrock:GuardrailIdentifier": "arn:aws:bedrock:us-east-1:123456789012:guardrail/guardrail-id*"
                }
            }
        },
        {
            "Sid": "ApplyGuardrail",
            "Effect": "Allow",
            "Action": [
                "bedrock:ApplyGuardrail"
            ],
            "Resource": [
                "arn:aws:bedrock:us-east-1:123456789012:guardrail/guardrail-id"
            ]
        }
    ]
}
```

**示例 5：强制使用特定护栏和版本组合**  
通过以下策略，仅允许模型推理使用一组护栏及其相应版本。    
****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "InvokeFoundationModelStatement1",
            "Effect": "Allow",
            "Action": [
                "bedrock:InvokeModel",
                "bedrock:InvokeModelWithResponseStream"
            ],
            "Resource": [
                "arn:aws:bedrock:us-east-1::foundation-model/*"
            ],
            "Condition": {
                "StringEquals": {
                    "bedrock:GuardrailIdentifier": [
                        "arn:aws:bedrock:us-east-1:123456789012:guardrail/guardrail-1-id:1",
                        "arn:aws:bedrock:us-east-1:123456789012:guardrail/guardrail-2-id:2",
                        "arn:aws:bedrock:us-east-1:123456789012:guardrail/guardrail-3-id"
                    ]
                }
            }
        },
        {
            "Sid": "InvokeFoundationModelStatement2",
            "Effect": "Deny",
            "Action": [
                "bedrock:InvokeModel",
                "bedrock:InvokeModelWithResponseStream"
            ],
            "Resource": [
                "arn:aws:bedrock:us-east-1::foundation-model/*"
            ],
            "Condition": {
                "StringNotEquals": {
                    "bedrock:GuardrailIdentifier": [
                        "arn:aws:bedrock:us-east-1:123456789012:guardrail/guardrail-1-id:1",
                        "arn:aws:bedrock:us-east-1:123456789012:guardrail/guardrail-2-id:2",
                        "arn:aws:bedrock:us-east-1:123456789012:guardrail/guardrail-3-id"
                    ]
                }
            }
        },
        {
            "Sid": "ApplyGuardrail",
            "Effect": "Allow",
            "Action": [
                "bedrock:ApplyGuardrail"
            ],
            "Resource": [
                "arn:aws:bedrock:us-east-1:123456789012:guardrail/guardrail-1-id",
                "arn:aws:bedrock:us-east-1:123456789012:guardrail/guardrail-2-id",
                "arn:aws:bedrock:us-east-1:123456789012:guardrail/guardrail-3-id"
            ]
        }
    ]
}
```

**限制**  
如果用户代入拥有使用 `bedrock:GuardrailIdentifier` 条件键配置的特定护栏的 IAM 角色：  
+ 用户不应使用具有额外权限的相同角色来调用 Bedroc APIs k `RetrieveAndGenerate` 和`InvokeAgent`代表用户`InvokeModel`拨打电话。即使在请求中指定了护栏，这也可能导致访问被拒绝错误，因为 `RetrieveAndGenerate` 和 `InvokeAgent` 进行了多次 `InvokeModel` 调用，其中一些调用未包含护栏。
+ 用户可以通过使用[护栏输入标签](guardrails-tagging.md)来绕过在提示中应用护栏。但是，护栏始终应用于响应。
+ 由于 Amazon Bedrock 护栏目前不支持基于资源的跨账户访问策略，因此您的护栏必须与发出请求的 IAM 角色位于同一 AWS 账户 。

# 将跨区域推理与 Amazon Bedrock 护栏结合使用的权限
<a name="guardrail-profiles-permissions"></a>

要将[跨区域推理](guardrails-cross-region.md)与 Amazon Bedrock 护栏结合使用，需要向您的 IAM 角色添加特定权限，包括允许访问其他区域中的护栏配置文件。

## 为跨区域推理创建和管理护栏机制的权限
<a name="guardrail-profiles-permissions-create-modify"></a>

使用以下 IAM 策略[创建](guardrails-components.md)、[查看](guardrails-view.md)、[修改](guardrails-edit.md)和[删除](guardrails-delete.md)使用特定护栏配置文件的护栏。您只需要这些权限来调用 [Amazon Bedrock 控制面板端点](https://docs.aws.amazon.com/general/latest/gr/bedrock.html#br-cp)。

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

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "CreateAndManageGuardrails",
            "Effect": "Allow",
            "Action": [
                "bedrock:CreateGuardrail",
                "bedrock:UpdateGuardrail",
                "bedrock:DeleteGuardrail",
                "bedrock:GetGuardrail",
                "bedrock:ListGuardrails"
            ],
            "Resource": [
                "arn:aws:bedrock:us-east-1:123456789012:guardrail/*",
                "arn:aws:bedrock:us-east-1:123456789012:guardrail-profile/guardrail-profile-id"
            ]
        }
    ]
}
```

------

## 使用跨区域推理调用护栏的权限
<a name="guardrail-profiles-permissions-invoking"></a>

使用跨区域推理调用护栏时，您的 IAM 策略中需要指定护栏配置文件中定义的目标区域。

```
{
    "Effect": "Allow",
    "Action": ["bedrock:ApplyGuardrail"],
    "Resource": [
        "arn:aws:bedrock:us-east-1:account-id:guardrail/guardrail-id",
        "arn:aws:bedrock:us-east-1:account-id:guardrail-profile/us.guardrail.v1:0",
        "arn:aws:bedrock:us-east-2:account-id:guardrail-profile/us.guardrail.v1:0",
        "arn:aws:bedrock:us-west-2:account-id:guardrail-profile/us.guardrail.v1:0"
    ]
}
```

此示例策略指定以下资源：
+ 您在源区域（本例中为 `us-east-1`）中调用的护栏。
+ 在您使用的护栏配置文件中定义的目标区域（本例中为 `us.guardrail.v1:0`）。有关在策略中指定哪些目标区域的信息，请参阅[可用护栏配置文件](https://docs.aws.amazon.com/bedrock/latest/userguide/guardrails-cross-region-support.html#available-guardrail-profiles)。

# 使用基于资源的策略进行护栏
<a name="guardrails-resource-based-policies"></a>

**注意**  
对 Amazon Bedrock Guardrails 使用基于资源的政策尚处于预览阶段，可能会发生变化。

Guardrails 支持基于资源的护栏和护栏推理配置文件策略。基于资源的策略允许您指定谁有权访问每个资源，以及允许他们对每个资源执行哪些操作，以此来定义访问权限。

您可以将基于资源的策略 (RBP) 附加到 Guardrails 资源（护栏或护栏推理配置文件）。[在此策略中，您可以为身份和访问管理 (IAM) 委托人指定权限，这些委托人可以对这些资源执行特定操作。](https://docs.aws.amazon.com/IAM/latest/UserGuide/intro-structure.html#intro-structure-principal)例如，附加到护栏的策略将包含应用护栏或读取护栏配置的权限。

建议将基于资源的策略与账户级别的强制护栏一起使用，使用组织级别的强制护栏也是必需的，因为对于组织强制护栏，成员账户必须使用组织管理员账户中存在的护栏。要在其他账户中使用护栏，来电者身份必须有权在护栏上调用 `bedrock:ApplyGuardrail` API，并且护栏必须附加基于资源的策略，该策略向该呼叫者授予权限。有关更多信息，请参阅[跨账户策略评估逻辑](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_evaluation-logic-cross-account.html)和[基于身份的策略和基于资源的策略。](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_identity-vs-resource.html)

RBPs 附在护栏详情页面上。如果护栏启用了跨区域推理 (CRIS)，则呼叫者还必须拥有与该配置文件关联的所有目标区域 guardrail-owner-account配置文件对象的`ApplyGuardrail`权限，并且 RBPs 必须依次附加到配置文件中。有关更多信息，请参阅 [将跨区域推理与 Amazon Bedrock 护栏结合使用的权限](guardrail-profiles-permissions.md)。可以从护栏仪表板上的 “系统定义的护栏配置文件” 部分访问配置文件详细信息页面，并从那里进行附加。 RBPs 

对于强制性护栏（组织级别或账户级别），所有无权呼叫该护栏的 Bedrock Invoke 或 Converse APIs 呼叫者都将开始看到他们的通话失败，但有例外。`AccessDenied`出于这个原因，强烈建议您在创建组织或账户强制的护栏配置之前，检查您是否能够从将要使用的身份、要强制使用的账户中调用护栏上的 [ApplyGuardrail](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent_ApplyGuardrail.html)API。

基于资源的护栏和护栏配置文件策略所允许的策略语言目前受到限制，仅支持有限的政策声明。

## 支持的策略声明模式
<a name="supported-policy-statement-patterns"></a>

### 在自己的账户中共享护栏
<a name="share-guardrail-within-account"></a>

`account-id`必须是包含护栏的账号。

**护栏政策：**  


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

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [{
        "Effect": "Allow",
        "Principal": {
            "AWS": "arn:aws:iam::111122223333:root"
        },
        "Action": [
            "bedrock:ApplyGuardrail",
            "bedrock:GetGuardrail"
        ],
	    "Resource": "arn:aws:bedrock:us-east-1:111122223333:guardrail/guardrail-id"
    }]
}
```

------

**护栏型材政策：**  


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

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [{
        "Effect": "Allow",
        "Principal": {
            "AWS": "arn:aws:iam::111122223333:root"
        },
        "Action": [
            "bedrock:ApplyGuardrail"
        ],
        "Resource": "arn:aws:bedrock:us-east-1:111122223333:guardrail-profile/profile-id"
    }]
}
```

------

### 与您的组织共享护栏
<a name="share-guardrail-with-organization"></a>

`account-id`必须与您附加 RBP 的账户相匹配，并且该账户必须位于。`org-id`

**护栏政策：**  
 

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

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [{
        "Effect": "Allow",
        "Principal": "*",
        "Action": [
            "bedrock:GetGuardrail",
            "bedrock:ApplyGuardrail"
        ],
        "Resource": "arn:aws:bedrock:us-east-1:111122223333:guardrail/guardrail-id",
        "Condition": {
            "StringEquals": { 
                "aws:PrincipalOrgID": "org-id"
            }
        }
    }]
}
```

------

**护栏型材政策：**  
 

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

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [{
        "Effect": "Allow",
        "Principal": "*",
        "Action": [
            "bedrock:ApplyGuardrail"
        ],
        "Resource": "arn:aws:bedrock:us-east-1:111122223333:guardrail-profile/profile-id",
        "Condition": {
            "StringEquals": { 
                "aws:PrincipalOrgID": "org-id"
            }
        }
    }]
}
```

------

### 与特定人员共享护栏 OUs
<a name="share-guardrail-with-specific-ous"></a>

`account-id`必须与您附加 RBP 的账户相匹配，并且该账户必须位于。`org-id`

**护栏政策：**  
 

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

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [{
        "Effect": "Allow",
        "Principal": "*",
        "Action": [
            "bedrock:ApplyGuardrail",
            "bedrock:GetGuardrail"
        ],
        "Resource": "arn:aws:bedrock:us-east-1:111122223333:guardrail/guardrail-id",
        "Condition": {
            "ForAnyValue:StringLike": {
                "aws:PrincipalOrgPaths": [
                    "org-id/*/org-unit-id/*"
                ]
            }
        }
    }]
}
```

------

**护栏型材政策：**  
 

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

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [{
        "Effect": "Allow",
        "Principal": "*",
        "Action": [
            "bedrock:ApplyGuardrail"
        ],
        "Resource": "arn:aws:bedrock:us-east-1:111122223333:guardrail-profile/profile-id",
        "Condition": {
            "ForAnyValue:StringLike": {
                "aws:PrincipalOrgPaths": [
                    "org-id/*/org-unit-id/*"
                ]
            }
        }
    }]
}
```

------

## 不支持的功能
<a name="unsupported-features"></a>

Guardrails 不支持在组织外部共享。

除上述或上面列出的条件外，护栏不支持 RBPs 。`PrincipalOrgId` `PrincipalOrgPaths`

Guardrails 不支持在没有组织或组织单位条件的情况下使用`*`校长。

Guardrails 仅支持中的`bedrock:ApplyGuardrail`和`bedrock:GetGuardrail`操作。 RBPs仅`ApplyGuardrail`支持护栏配置文件资源。