本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
為 Amazon Bedrock 知識庫建立服務角色
若要針對知識庫使用自訂角色,而非 Amazon Bedrock 自動建立的角色,請建立 IAM 角色,並依照建立角色以將許可委派給 AWS 服務中的步驟連接下列許可。僅包含您自身安全的必要許可。
-
信任關係
-
Amazon Bedrock 基本模型的存取
-
存取您存放資料的資料來源
-
(如果您在 Amazon OpenSearch Service 中建立向量資料庫) 存取您的 OpenSearch Service 集合
-
(如果您在 Amazon Aurora 中建立向量資料庫) 存取您的 Aurora 叢集
-
(如果您在 Pinecone或 中建立向量資料庫Redis Enterprise Cloud) AWS Secrets Manager 讓 驗證您的 Pinecone或 Redis Enterprise Cloud帳戶的許可
-
(選用) 如果您使用 KMS 金鑰加密下列任何資源,則需要解密金鑰的權限 (請參閱 知識庫資源的加密)。
信任關係
下列政策允許 Amazon Bedrock 擔任此角色,並建立和管理知識庫。以下顯示您可使用的範例政策。您可以使用一或多個全域條件內容索引鍵來限制權限範圍。如需詳細資訊,請參閱 AWS 全域條件內容索引鍵。將 aws:SourceAccount
值設定為您的帳戶 ID。使用 ArnEquals
或 ArnLike
條件將範圍限制為特定的知識庫。
作為安全目的的最佳實務,請在建立特定知識庫 ID 之後,將 *
取代為特定知識庫 ID。
- JSON
-
-
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": "bedrock.amazonaws.com"
},
"Action": "sts:AssumeRole",
"Condition": {
"StringEquals": {
"aws:SourceAccount": "123456789012
"
},
"ArnLike": {
"AWS:SourceArn": "arn:aws:bedrock:us-east-1
:123456789012
:knowledge-base/*
"
}
}
}
]
}
存取 Amazon Bedrock 模型的權限
附加以下政策,為角色提供使用 Amazon Bedrock 模型以嵌入來源資料的許可權。
- JSON
-
-
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"bedrock:ListFoundationModels",
"bedrock:ListCustomModels"
],
"Resource": "*"
},
{
"Effect": "Allow",
"Action": [
"bedrock:InvokeModel"
],
"Resource": [
"arn:aws:bedrock:us-east-1
::foundation-model/amazon.titan-embed-text-v1",
"arn:aws:bedrock:us-east-1
::foundation-model/cohere.embed-english-v3",
"arn:aws:bedrock:us-east-1
::foundation-model/cohere.embed-multilingual-v3"
]
}
]
}
存取資料來源的許可
從下列資料來源中選取 ,以連接角色的必要許可。
存取 Amazon S3 資料來源的許可
如果您的資料來源是 Amazon S3,請連接下列政策,以提供 角色存取您將做為資料來源連線之 S3 儲存貯體的許可。
如果您使用 AWS KMS 金鑰加密資料來源,請依照 中的步驟,將解密金鑰的許可連接到角色在 Amazon S3 中解密資料來源 AWS KMS 金鑰的許可。
- JSON
-
-
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "S3ListBucketStatement",
"Effect": "Allow",
"Action": [
"s3:ListBucket"
],
"Resource": [
"arn:aws:s3:::${Bucket}
"
],
"Condition": {
"StringEquals": {
"aws:ResourceAccount": [123456789012
]
}
}
},
{
"Sid": "S3GetObjectStatement",
"Effect": "Allow",
"Action": [
"s3:GetObject"
],
"Resource": [
"arn:aws:s3:::${BucketAndKeyPrefix}
"
],
"Condition": {
"StringEquals": {
"aws:ResourceAccount": [123456789012
]
}
}
}
]
}
存取 Confluence 資料來源的許可
Confluence 資料來源連接器處於預覽版本中,可能會有所變更。
連接下列政策,以提供 角色存取 Confluence 的許可。
secretsmanager:PutSecretValue
只有在您使用 OAuth 2.0 身分驗證搭配重新整理權杖時才需要。
Confluence OAuth2.0 存取權杖的預設到期時間為 60 分鐘。如果此權杖在資料來源同步時過期 (同步任務),Amazon Bedrock 將使用提供的重新整理權杖來重新產生此權杖。此重新產生會同時重新整理存取權杖和重新整理權杖。為了讓字符從目前同步任務更新到下一個同步任務,Amazon Bedrock 需要秘密登入資料的寫入/輸出許可。
- JSON
-
-
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"secretsmanager:GetSecretValue",
"secretsmanager:PutSecretValue"
],
"Resource": [
"arn:aws:secretsmanager:us-east-1
:123456789012
:secret:${secret-id}
"
]
},
{
"Effect": "Allow",
"Action": [
"kms:Decrypt"
],
"Resource": [
"arn:aws:kms:us-east-1
:123456789012
:key/${KeyId}
"
],
"Condition": {
"StringLike": {
"kms:ViaService": [
"secretsmanager.us-east-1
.amazonaws.com"
]
}
}
}
]
}
存取 Microsoft SharePoint 資料來源的許可
SharePoint 資料來源連接器處於預覽版本,可能會有所變更。
連接下列政策,以提供 角色存取 SharePoint 的許可。
- JSON
-
-
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"secretsmanager:GetSecretValue"
],
"Resource": [
"arn:aws:secretsmanager:us-east-1
:123456789012
:secret:${SecretId}
"
]
},
{
"Effect": "Allow",
"Action": [
"kms:Decrypt"
],
"Resource": [
"arn:aws:kms:us-east-1
:123456789012
:key/${KeyId}
"
],
"Condition": {
"StringLike": {
"kms:ViaService": [
"secretsmanager.us-east-1
.amazonaws.com"
]
}
}
}
]
}
存取 Salesforce 資料來源的許可
Salesforce 資料來源連接器處於預覽版本,可能會有所變更。
連接下列政策,以提供 角色存取 Salesforce 的許可。
- JSON
-
-
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"secretsmanager:GetSecretValue"
],
"Resource": [
"arn:aws:secretsmanager:us-east-1
:123456789012
:secret:${SecretId}
"
]
},
{
"Effect": "Allow",
"Action": [
"kms:Decrypt"
],
"Resource": [
"arn:aws:kms:us-east-1
:123456789012
:key/${KeyId}
"
],
"Condition": {
"StringLike": {
"kms:ViaService": [
"secretsmanager.us-east-1
.amazonaws.com"
]
}
}
}
]
}
與您的文件聊天的許可
連接下列政策,為角色提供使用 Amazon Bedrock 模型與您的文件聊天的許可:
- JSON
-
-
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"bedrock:RetrieveAndGenerate"
],
"Resource": "*"
}
]
}
如果您只想授予使用者與您的文件聊天的存取權 (而不是所有知識庫RetrieveAndGenerate
上的 ),請使用下列政策:
- JSON
-
-
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"bedrock:RetrieveAndGenerate"
],
"Resource": "*"
},
{
"Effect": "Deny",
"Action": [
"bedrock:Retrieve"
],
"Resource": "*"
}
]
}
如果您想要與文件聊天並在特定知識庫RetrieveAndGenerate
上使用 ,請提供 ${KnowledgeBaseArn}
,並使用下列政策:
- JSON
-
-
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"bedrock:RetrieveAndGenerate"
],
"Resource": "*"
},
{
"Effect": "Allow",
"Action": [
"bedrock:Retrieve"
],
"Resource": "${KnowledgeBaseArn}
"
}
]
}
存取 Amazon Kendra GenAI 索引的許可
如果您已為知識庫建立 Amazon Kendra GenAI 索引,請將下列政策連接至 Amazon Bedrock 知識庫服務角色,以允許存取索引。在政策中,將 ${Partition}
、${Region}
、${AccountId}
和 ${IndexId}
取代為您的索引值。您可以將多個索引新增至Resource
清單,以允許存取這些索引。若要允許存取 中的每個索引 AWS 帳戶,請以萬用字元 (*) 取代 ${IndexId}
。
- JSON
-
-
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"kendra:Retrieve", // To call their Retrieve API
"kendra:DescribeIndex" // For validation when creating the KB
],
"Resource": "arn:${${Partition}
}:kendra:${us-east-1
}:${123456789012
}:index/${${IndexId}
}"
}
]
}
在 Amazon OpenSearch Serverless 中存取向量資料庫的許可
如果您在 OpenSearch Serverless 中為知識庫建立向量資料庫,請將下列政策連接至 Amazon Bedrock 知識庫服務角色,以允許存取集合。將 ${Region}
和 ${AccountId}
取代為資料庫所屬的區域和帳戶 ID。在 ${CollectionId}
中輸入 Amazon OpenSearch Service 集合的 ID。將集合新增至 Resource
清單,即可允許存取多個集合。
- JSON
-
-
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"aoss:APIAccessAll"
],
"Resource": [
"arn:aws:aoss:us-east-1
:123456789012
:collection/${CollectionId}
"
]
}
]
}
在 OpenSearch 受管叢集中存取向量資料庫的許可
如果您在 OpenSearch 受管叢集中為知識庫建立向量資料庫,請將下列政策連接至 Amazon Bedrock 知識庫服務角色,以允許存取網域。將 <region>
和 <accountId>
取代為資料庫所屬的區域和帳戶 ID。您可以將多個網域新增至Resource
清單,以允許這些網域的存取。如需設定許可的詳細資訊,請參閱 搭配 Amazon Bedrock 知識庫使用 OpenSearch 受管叢集所需的先決條件和許可。
- JSON
-
-
{
"Version": "2012-10-17",
"Statement": [{
"Effect": "Allow",
"Action": [
"es:ESHttpGet",
"es:ESHttpPost",
"es:ESHttpPut",
"es:ESHttpDelete"
],
"Resource": [
"arn:<partition>
:es:<region>
:<123456789012>
:domain/<domainName>
/<indexName>
"
]
},
{
"Effect": "Allow"
},
"Action": [
"es:DescribeDomain"
],
"Resource": [
"arn:<partition>
:es:<region>
:<123456789012>
:domain/<domainName>
"
]
]
}
存取 Amazon Aurora 資料庫叢集的許可
Amazon Aurora 叢集必須與為 Amazon Bedrock 建立知識庫 AWS 帳戶 的叢集位於相同的 中。
如果您在 Amazon Aurora 中為知識庫建立資料庫 (資料庫) 叢集,請將下列政策連接至 Amazon Bedrock 知識庫服務角色,以允許存取資料庫叢集並提供讀取和寫入許可。將 ${Region}
和 ${AccountId}
取代為資料庫叢集所屬的區域和帳戶 ID。在 ${DbClusterId}
中輸入 Amazon Aurora 資料庫叢集的 ID。將資料庫叢集新增至 Resource
清單,即可允許存取多個資料庫叢集。
- JSON
-
-
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "RdsDescribeStatementID
",
"Effect": "Allow",
"Action": [
"rds:DescribeDBClusters"
],
"Resource": [
"arn:aws:rds:us-east-1
:123456789012
:cluster:${DbClusterId}
"
]
},
{
"Sid": "DataAPIStatementID",
"Effect": "Allow",
"Action": [
"rds-data:BatchExecuteStatement",
"rds-data:ExecuteStatement"
],
"Resource": [
"arn:aws:rds:us-east-1
:123456789012
:cluster:${DbClusterId}
"
]
}
]
}
在 Amazon Neptune Analytics 中存取向量資料庫的許可
如果您已為知識庫建立 Amazon Neptune Analytics 圖形,請將下列政策連接至 Amazon Bedrock 知識庫服務角色,以允許存取圖形。在政策中,將 ${Region}
和 ${AccountId}
取代為資料庫所屬的區域和帳戶 ID。將 ${GraphId}
取代為圖形資料庫的值。
- JSON
-
-
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "NeptuneAnalyticsAccess",
"Effect": "Allow",
"Action": [
"neptune-graph:GetGraph",
"neptune-graph:ReadDataViaQuery",
"neptune-graph:WriteDataViaQuery",
"neptune-graph:DeleteDataViaQuery"
],
"Resource": [
"arn:aws:neptune-graph:us-east-1
:123456789012
:graph/${GraphId}
"
]
}
]
}
在 Amazon S3 Vectors 中存取向量存放區的許可
如果您選擇使用 Amazon S3 Vectors 做為知識庫,請將下列政策連接至 Amazon Bedrock 知識庫服務角色,以允許存取向量索引。
Amazon S3 Vectors 與 Amazon Bedrock 知識庫的整合處於預覽版本中,可能會有所變更。
在政策中,將 ${Region}
和 ${AccountId}
取代為向量索引所屬的區域和帳戶 ID。以 S3 向量儲存貯體的名稱取代 ${BucketName}
,以向量索引的名稱取代 ${IndexName}
。如需 Amazon S3 向量的詳細資訊,請參閱設定 以使用 Amazon S3 向量。
- JSON
-
-
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "S3VectorBucketReadAndWritePermission",
"Effect": "Allow",
"Action": [
"s3vectors:PutVectors",
"s3vectors:GetVectors",
"s3vectors:DeleteVectors",
"s3vectors:QueryVectors",
"s3vectors:GetIndex"
],
"Resource": "arn:aws:s3vectors:us-east-1
:123456789012
:bucket/${BucketName}
/index/${IndexName}
"
}
]
}
存取使用 AWS Secrets Manager 秘密設定之向量資料庫的許可
如果您的向量資料庫已設定 AWS Secrets Manager 秘密,請將下列政策連接至 Amazon Bedrock 知識庫服務角色, AWS Secrets Manager 以允許 驗證您的帳戶存取資料庫。將 ${Region}
和 ${AccountId}
取代為資料庫所屬的區域和帳戶 ID。以秘密的 ID 取代 ${SecretId}
。
- JSON
-
-
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"secretsmanager:GetSecretValue"
],
"Resource": [
"arn:aws:secretsmanager:us-east-1
:123456789012
:secret:${SecretId}
"
]
}
]
}
如果您使用 AWS KMS 金鑰加密秘密,請依照 中的步驟,將解密金鑰的許可連接到角色解密包含知識庫之向量存放區的 AWS Secrets Manager 秘密的許可。
在資料擷取期間 AWS 管理暫時性資料儲存 AWS KMS 金鑰的 許可
若要允許在擷取資料來源的過程中建立暫時性資料儲存的 AWS KMS 金鑰,請將下列政策連接至您的 Amazon Bedrock 知識庫服務角色。以適當的值取代 ${Region}
、${AccountId}
和 ${KeyId}
。
- JSON
-
-
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"kms:GenerateDataKey",
"kms:Decrypt"
],
"Resource": [
"arn:aws:kms:us-east-1
:123456789012
:key/${KeyId}
"
]
}
]
}
AWS 管理來自其他使用者帳戶之資料來源的許可 AWS 。
若要允許存取另一個使用者帳戶 AWS ,您必須建立角色,允許跨帳戶存取另一個使用者帳戶中的 Amazon S3 儲存貯體。以適當的值取代 ${BucketName}
、${BucketOwnerAccountId}
和 ${BucketNameAndPrefix}
。
知識庫角色所需的許可
在建立知識庫期間提供的知識庫角色createKnowledgeBase
需要下列 Amazon S3 許可。
- JSON
-
-
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "S3ListBucketStatement",
"Effect": "Allow",
"Action": [
"s3:ListBucket"
],
"Resource": [
"arn:aws:s3:::${BucketName}
"
],
"Condition": {
"StringEquals": {
"aws:ResourceAccount": "${BucketOwnerAccountId}
"
}
}
},
{
"Sid": "S3GetObjectStatement",
"Effect": "Allow",
"Action": [
"s3:GetObject"
],
"Resource": [
"arn:aws:s3:::${BucketNameAndPrefix}
/*"
],
"Condition": {
"StringEquals": {
"aws:ResourceAccount": "${BucketOwnerAccountId}
"
}
}
}
]
}
如果 Amazon S3 儲存貯體使用 AWS KMS 金鑰加密,則還需要將下列項目新增至知識庫角色。以適當的值取代 ${BucketOwnerAccountId}
和 ${Region}
。
{
"Sid": "KmsDecryptStatement",
"Effect": "Allow",
"Action": [
"kms:Decrypt"
],
"Resource": [
"arn:aws:kms:${Region}
:${BucketOwnerAccountId}
:key/${KeyId}
"
],
"Condition": {
"StringEquals": {
"kms:ViaService": [
"s3.${Region}
.amazonaws.com"
]
}
}
}
跨帳戶 Amazon S3 儲存貯體政策所需的許可
其他帳戶中的 儲存貯體需要下列 Amazon S3 儲存貯體政策。以適當的值取代 ${KbRoleArn}
、${BucketName}
和 ${BucketNameAndPrefix}
。
- JSON
-
-
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "Example ListBucket permissions",
"Effect": "Allow",
"Principal": {
"AWS": "123456789012
"
},
"Action": [
"s3:ListBucket"
],
"Resource": [
"arn:aws:s3:::${BucketName}
"
]
},
{
"Sid": "Example GetObject permissions",
"Effect": "Allow",
"Principal": {
"AWS": "${KbRoleArn}
"
},
"Action": [
"s3:GetObject"
],
"Resource": [
"arn:aws:s3:::${BucketNameAndPrefix}
/*"
]
}
]
}
跨帳戶 AWS KMS 金鑰政策所需的許可
如果跨帳戶 Amazon S3 儲存貯體使用該帳戶中的 AWS KMS 金鑰加密,則 AWS KMS 金鑰的政策需要下列政策。以適當的值取代 ${KbRoleArn}
和 ${KmsKeyArn}
。
{
"Sid": "Example policy",
"Effect": "Allow",
"Principal": {
"AWS": [
"${KbRoleArn}
"
]
},
"Action": [
"kms:Decrypt"
],
"Resource": "${KmsKeyArn}
"
}