Experimental
@aws-cdk/aws-bedrock-alpha is an experimental (alpha) package: its API may change in any release, without a major version bump.
KnowledgeBaseGrants Facade
Collection of grant methods for a IKnowledgeBaseRef.
| Stability | Experimental |
|---|---|
| Source | |
| Type last changed |
Example
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import * as bedrock_alpha from '@aws-cdk/aws-bedrock-alpha';
import { aws_bedrock as interfaces_bedrock } from 'aws-cdk-lib/interfaces';
declare const knowledgeBaseRef: interfaces_bedrock.IKnowledgeBaseRef;
const knowledgeBaseGrants = bedrock_alpha.KnowledgeBaseGrants.fromKnowledgeBase(knowledgeBaseRef);
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
import aws_cdk.aws_bedrock_alpha as bedrock_alpha
from aws_cdk.interfaces import aws_bedrock as interfaces_bedrock
# knowledge_base_ref: interfaces_bedrock.IKnowledgeBaseRef
knowledge_base_grants = bedrock_alpha.KnowledgeBaseGrants.from_knowledge_base(knowledge_base_ref)
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.services.bedrock.alpha.*;
import software.amazon.awscdk.interfaces.bedrock.*;
IKnowledgeBaseRef knowledgeBaseRef;
KnowledgeBaseGrants knowledgeBaseGrants = KnowledgeBaseGrants.fromKnowledgeBase(knowledgeBaseRef);
// Install: dotnet add package Amazon.CDK.AWS.Bedrock.Alpha
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
using Amazon.CDK.AWS.Bedrock.Alpha;
using Amazon.CDK.Interfaces.Bedrock;
IKnowledgeBaseRef knowledgeBaseRef;
var knowledgeBaseGrants = KnowledgeBaseGrants.FromKnowledgeBase(knowledgeBaseRef);
// Install: go get github.com/aws/aws-cdk-go/awsbedrockalpha/v2
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import bedrock_alpha "github.com/aws/aws-cdk-go/awsbedrockalpha"
import "github.com/aws/aws-cdk-go/awscdk"
var knowledgeBaseRef IKnowledgeBaseRef
knowledgeBaseGrants := bedrock_alpha.KnowledgeBaseGrants_FromKnowledgeBase(knowledgeBaseRef)
Methods
actions(grantee: IGrantable, actions: string[], options?: PermissionsOptions): Grantdef actions(self, grantee: IGrantable, actions: typing.List[str], options: typing.Optional[PermissionsOptions] = None) -> Grantpublic Grant actions(IGrantable grantee, List<String> actions, PermissionsOptions options)public Grant Actions(IGrantable grantee, string[] actions, PermissionsOptions? options = null)func Actions(Grantee IGrantable, Actions *[]*string, Options PermissionsOptions) Grant #fromKnowledgeBase(resource: IKnowledgeBaseRef): KnowledgeBaseGrants // chainable@staticmethod def from_knowledge_base(resource: IKnowledgeBaseRef) -> KnowledgeBaseGrantspublic static KnowledgeBaseGrants fromKnowledgeBase(IKnowledgeBaseRef resource)public static KnowledgeBaseGrants FromKnowledgeBase(IKnowledgeBaseRef resource)func FromKnowledgeBase(Resource IKnowledgeBaseRef) KnowledgeBaseGrants static #getDocumentContent(grantee: IGrantable): Grantdef get_document_content(self, grantee: IGrantable) -> Grantpublic Grant getDocumentContent(IGrantable grantee)public Grant GetDocumentContent(IGrantable grantee)func GetDocumentContent(Grantee IGrantable) Grant #bedrock:GetDocumentContent requires bedrock:Retrieve on the same knowledge base, so both are granted.
This will grant the following permissions on the knowledge base:
- bedrock:Retrieve
- bedrock:GetDocumentContent
retrieve(grantee: IGrantable): Grantdef retrieve(self, grantee: IGrantable) -> Grantpublic Grant retrieve(IGrantable grantee)public Grant Retrieve(IGrantable grantee)func Retrieve(Grantee IGrantable) Grant #This will grant the following permissions on the knowledge base:
- bedrock:Retrieve
retrieveAndGenerate(grantee: IGrantable): Grantdef retrieve_and_generate(self, grantee: IGrantable) -> Grantpublic Grant retrieveAndGenerate(IGrantable grantee)public Grant RetrieveAndGenerate(IGrantable grantee)func RetrieveAndGenerate(Grantee IGrantable) Grant #notes
bedrock:RetrieveAndGenerate does not support resource-level permissions, so it is granted on all resources (*). Access to a specific knowledge base is controlled by bedrock:Retrieve, so also call retrieve() on this knowledge base, and grant bedrock:InvokeModel on the generation model with BedrockFoundationModel.grantInvoke().
This will grant the following permissions:
- bedrock:RetrieveAndGenerate