本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
控制对亚马逊 Bedrock Marketplace 模型的访问权限
您可以使用 Amazon Bedrock 完全访问权限策略为 SageMaker AI 提供权限。要防止用户访问特定的 Bedrock Marketplace 模型,同时保持对所有其他模型的访问权限,请使用拒绝政策。以下策略演示如何拒绝对特定模型的访问。
拒绝访问特定模型:
- JSON
-
-
{
"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
声明。