

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

# 控制 Amazon Bedrock Marketplace 模型的访问
<a name="control-amazon-bedrock-marketplace"></a>

您可以使用 [Amazon Bedrock 完全访问权限策略](https://docs.aws.amazon.com/aws-managed-policy/latest/reference/AmazonBedrockFullAccess.html)为 SageMaker AI 提供权限。要阻止用户访问特定的 Bedrock Marketplace 模型，同时保持对所有其他模型的访问权限，请使用拒绝策略。以下策略演示如何拒绝访问特定模型。

拒绝访问特定模型：

```
{
    "Version": "2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "MarketplaceModelDeny",
            "Effect": "Deny",
            "Action": [
                "sagemaker:*",
                "bedrock:*"
            ],
            "Resource": [
                "arn:aws:sagemaker:*:*:endpoint/*",
                "arn:aws:sagemaker:*:*:endpoint-config/*",
                "arn:aws:sagemaker:*:*:model/*"
            ],
            "Condition": {
                "StringLike": {
                    "aws:ResourceTag/sagemaker-studio:hub-content-arn": "arn:aws:sagemaker:*:aws:hub-content/SageMakerPublicHub/Model/{{model-id-to-deny}}/*"
                }
            }
        }
    ]
}
```

**重要**  
此策略明确拒绝对指定模型的访问，同时允许访问所有其他 Bedrock Marketplace 模型（假设已具备所有其他必需权限）。

**仅允许访问特定模型**

要限制用户只能访问特定的 Bedrock Marketplace 模型，请使用允许策略并明确指定模型规格。以下策略演示如何仅允许访问特定模型：

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

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "MarketplaceModelAllow",
            "Effect": "Allow",
            "Action": [
                "sagemaker:CreateEndpoint",
                "sagemaker:CreateEndpointConfig",
                "sagemaker:CreateModel",
                "sagemaker:DeleteEndpoint",
                "sagemaker:UpdateEndpoint"
            ],
            "Resource": [
                "arn:aws:sagemaker:*:*:endpoint/*",
                "arn:aws:sagemaker:*:*:endpoint-config/*",
                "arn:aws:sagemaker:*:*:model/*"
            ],
            "Condition": {
                "StringEquals": {
                    "aws:CalledViaLast": "bedrock.amazonaws.com",
                    "aws:ResourceTag/sagemaker-sdk:bedrock": "compatible"
                },
                "StringLike": {
                    "aws:ResourceTag/sagemaker-studio:hub-content-arn": "arn:aws:sagemaker:*:aws:hub-content/SageMakerPublicHub/Model/<model-id-to-allow>/*"
                }
            }
        },
        {
            "Sid": "BedrockEndpointTaggingOperations",
            "Effect": "Allow",
            "Action": [
                "sagemaker:AddTags",
                "sagemaker:DeleteTags"
            ],
            "Resource": [
                "arn:aws:sagemaker:*:*:endpoint/*",
                "arn:aws:sagemaker:*:*:endpoint-config/*",
                "arn:aws:sagemaker:*:*:model/*"
            ],
            "Condition": {
                "StringLike": {
                    "aws:ResourceTag/sagemaker-studio:hub-content-arn": "arn:aws:sagemaker:*:aws:hub-content/SageMakerPublicHub/Model/<model-id-to-allow>/*"
                }
            }
        }
    ]
}
```

------

此策略仅允许访问指定的模型，并拒绝访问所有其他模型。如果您的策略基于 `AmazonBedrockFullAccess`，则此策略应该取代 `MarketplaceModelEndpointMutatingAPIs` 和 `BedrockEndpointTaggingOperations` 语句。