Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bedrock: L1 construct for KnowledgeBase is missing the StorageConfiguration parameter in python #30116

Closed
josebagar opened this issue May 8, 2024 · 1 comment
Labels
@aws-cdk/aws-s3 Related to Amazon S3 bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.

Comments

@josebagar
Copy link

josebagar commented May 8, 2024

Describe the bug

Required parameter StorageConfiguration for CfnKnowledgeBase appears to have been added to CDK with 2.140.0 (closing #29966 with PR #30037). The python bindings, however, appear to have not been updated, as the parameter is not recognized in the CfnKnowledgeBase L1 construct for Python, defined as below:

    def __init__(
        self,
        scope: _constructs_77d1e7e8.Construct,
        id: builtins.str,
        *,
        knowledge_base_configuration: typing.Union[_IResolvable_da3f097b, typing.Union["CfnKnowledgeBase.KnowledgeBaseConfigurationProperty", typing.Dict[builtins.str, typing.Any]]],
        name: builtins.str,
        role_arn: builtins.str,
        description: typing.Optional[builtins.str] = None,
        tags: typing.Optional[typing.Mapping[builtins.str, builtins.str]] = None,
    ) -> None:

Expected Behavior

The constructor should include the parameter and should create the knowledge base.

Current Behavior

The constructor does not include the parameter. Trying cdk deploy without the parameter results in the following error:

╰─ cdk deploy               

✨  Synthesis time: 3.66s

HotelAssistantStack: deploying... [1/1]
HotelAssistantStack: creating CloudFormation changeset...
[████████████▉·············································] (4/18)

1:05:28 AM | CREATE_IN_PROGRESS   | AWS::CloudFormation::Stack    | HotelAssistantStack
1:05:32 AM | CREATE_FAILED        | AWS::Bedrock::KnowledgeBase   | AgentKB
Properties validation failed for resource AgentKB with message:
#: required key [StorageConfiguration] not found

Reproduction Steps

The stack is as follows:

from aws_cdk import (RemovalPolicy,
                     Stack,
                     aws_bedrock as bedrock,aws_s3 as s3,
                     aws_s3_deployment as s3_deployment)
from constructs import Construct

class HotelAssistantStack(Stack):
    def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:
        super().__init__(scope, construct_id, **kwargs)

        # Bedrock Agents-related resources
        # S3 bucket that will be used for our storage needs
        bucket = s3.Bucket(scope=self,
                           id='AgentKBDocsBucket',
                           versioned=False,
                           encryption=s3.BucketEncryption.S3_MANAGED,
                           event_bridge_enabled=True,
                           removal_policy=RemovalPolicy.DESTROY,
                           enforce_ssl=True,
                           auto_delete_objects=True)
        s3_deployment.BucketDeployment(scope=self,
                                       id='AgentKBDocsDeployment',
                                       sources=[s3_deployment.Source.asset('docs',
                                                                           exclude=['*.pptx', '*.docx'])],
                                       destination_bucket=bucket)
        model_arn = bedrock.FoundationModel.from_foundation_model_id(
            scope=self,
            _id='EmbeddingsModel',
            foundation_model_id=bedrock.FoundationModelIdentifier('cohere.embed-english-v3')).model_arn
        knowledge_base = bedrock.CfnKnowledgeBase(scope=self,
                                                  id='AgentKB',
                                                  name='HotelDataKB',
                                                  role_arn='arn:aws:iam::123456789012:role/service-role/'
                                                           'AmazonBedrockExecutionRoleForKnowledgeBase_vz9pm',
                                                  knowledge_base_configuration={'type': 'VECTOR',
                                                                                'vectorKnowledgeBaseConfiguration': {
                                                                                    'embeddingModelArn': model_arn}})
        # Create the data source; we could also define the chunking strategy, but let's leave its default values
        bedrock.CfnDataSource(scope=self,
                              id='AgentKBDataSource',
                              name='HotelDataS3Source',
                              knowledge_base_id=knowledge_base.attr_knowledge_base_id,
                              data_source_configuration={'s3Configuration': {'bucketArn': bucket.bucket_arn},
                                                         'type': 'S3'})

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.140.0 (build 46168aa)

Framework Version

No response

Node.js Version

v22.1.0

OS

macOS 14.4.1

Language

Python

Language Version

Python 3.12.3

Other information

No response

@josebagar josebagar added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels May 8, 2024
@github-actions github-actions bot added the @aws-cdk/aws-s3 Related to Amazon S3 label May 8, 2024
Copy link

github-actions bot commented May 8, 2024

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-s3 Related to Amazon S3 bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.
Projects
None yet
Development

No branches or pull requests

1 participant