Skip to content

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

Closed
@josebagar

Description

@josebagar

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    @aws-cdk/aws-s3Related to Amazon S3bugThis issue is a bug.needs-triageThis issue or PR still needs to be triaged.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions