aws-cdk: bedrock: KnowledgeBaseConfigurationProperty is missing sqlKnowledgeBaseConfiguration property in latest CDK version 2.176.0

Describe the bug

KnowledgeBaseConfigurationProperty is missing the sqlKnowledgeBaseConfiguration property which is currently supported by CloudFormation AWS::Bedrock::KnowledgeBase KnowledgeBaseConfiguration

Regression Issue

  • Select this option if this issue appears to be a regression.

Last Known Working CDK Version

No response

Expected Behavior

sqlKnowledgeBaseConfiguration should not be missing in L1 construct.

Current Behavior

CDK gives the following error: Object literal may only specify known properties, and 'sqlKnowledgeBaseConfiguration' does not exist in type 'IResolvable | KnowledgeBaseConfigurationProperty'.

Reproduction Steps

Here’s a sample code to replicate the error:

      new bedrock.CfnKnowledgeBase(this, 'knowledgebase', {
          knowledgeBaseConfiguration: {
            type: 'type',
            vectorKnowledgeBaseConfiguration: {
              embeddingModelArn: 'embeddingModelArn'
          },
          kendraKnowledgeBaseConfiguration: {
            kendraIndexArn: 'kendraIndexArn'
          }
          sqlKnowledgeBaseConfiguration:{
            type: 'REDSHIFT'
          }
        },
        roleArn: 'roleName',
        name: 'Name'
      })

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.176.0

Framework Version

No response

Node.js Version

v18.20.5

OS

Linux

Language

TypeScript

Language Version

5.3.3

Other information

No response

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 2
  • Comments: 15 (6 by maintainers)

Most upvoted comments

kb = bedrock.CfnKnowledgeBase(
            self, 'SomeKb',
            name=financial_data_kb_name,
            role_arn=knowledge_base_role.role_arn,
            knowledge_base_configuration=bedrock.CfnKnowledgeBase.KnowledgeBaseConfigurationProperty(
                type="SQL",
                sql_knowledge_base_configuration=bedrock.CfnKnowledgeBase.SqlKnowledgeBaseConfigurationProperty(
                    type="REDSHIFT",
                    redshift_configuration=bedrock.CfnKnowledgeBase.RedshiftConfigurationProperty(
                        query_engine_configuration=bedrock.CfnKnowledgeBase.RedshiftQueryEngineConfigurationProperty(
                            type="SERVERLESS",
                            serverless_configuration=bedrock.CfnKnowledgeBase.RedshiftServerlessConfigurationProperty(
                                auth_configuration=bedrock.CfnKnowledgeBase.RedshiftServerlessAuthConfigurationProperty(
                                    type="IAM",
                                ),
                                workgroup_arn=redshift_workgroup.attr_workgroup_workgroup_arn
                            )
                        ),
                        storage_configurations=[bedrock.CfnKnowledgeBase.RedshiftQueryEngineStorageConfigurationProperty(
                            type="AWS_DATA_CATALOG",
                            aws_data_catalog_configuration=bedrock.CfnKnowledgeBase.RedshiftQueryEngineAwsDataCatalogStorageConfigurationProperty(
                                table_names=["financial_data_db.*"]
                            )
                        )],
                        query_generation_configuration=bedrock.CfnKnowledgeBase.QueryGenerationConfigurationProperty(
                            execution_timeout_seconds=200,
                            generation_context=bedrock.CfnKnowledgeBase.QueryGenerationContextProperty(
                                curated_queries=[
                                    bedrock.CfnKnowledgeBase.CuratedQueryProperty(
                                        natural_language=query["naturalLanguage"],
                                        sql=query["sqlQuery"]
                                    ) for query in curated_queries["queryPairs"]
                                ],
                                tables=[
                                    bedrock.CfnKnowledgeBase.QueryGenerationTableProperty(
                                        name=f"database.schema.{table_name}",
                                        columns=[
                                            bedrock.CfnKnowledgeBase.QueryGenerationColumnProperty(
                                                name=column_name,
                                                description=column_description
                                            ) for column_name, column_description in table_columns.items()
                                        ],
                                        description=f"Table containing {table_name} information"
                                    ) for table_name, table_columns in table_column_description.items()
                                ]
                            )
                        )
                    )
                )
            )
        )

The storage_configuration still does not work with type=AWS_DATA_CATALOG. Deploying this stack creates the knowledge base but does not connect the query engine. It works when I create the knowledge base with the same configuration using the console.

hi all,

i’ve also faced the same binding issue that @dave-moser mentioned.

I think you are correct. Other data sources require another CF construct to pass in more detail.

    new cdk.aws_bedrock.CfnDataSource(
      this,
      "BedrockKnowledgeBaseRedshiftDataSource",
      {
        name: `kb-ds`,
        knowledgeBaseId: kb.attrKnowledgeBaseId,
        dataSourceConfiguration: {
          type: "REDSHIFT_METADATA",
        },
      }
    );

This CF construct does not have parameters for Redshift. The above code throws an error.

Where do I report such an issue with CloudFormation?

FYI - I am able to successfully create the working KB with Redshift using the Boto3 API.

Thanks @dave-moser for raising this issue. I believe the issue of being unable to bind the knowledge base to redshift is a service side issue, since as I understood from your reply that the missing properties are now exist in the L1 construct which is actually one to one mapping with the CFN resources, and CDK do not add any logic.

Could you please check the synthesized CFN template and confirm if this is what you expect.

Thank you for that update. SqlKnowledgeBaseConfiguration is now available in cdk version 2.177.0

It does create the Bedrock KnowledgeBase, however, it does not successfully bind the KB to the Redshift serverless cluster.

CDK Code:

    const kb = new cdk.aws_bedrock.CfnKnowledgeBase(
      this,
      "BedrockKnowledgeBaseRedshift",
      {
        name: props.knowledgeBaseName,
        roleArn: bedrockRole.roleArn,
        knowledgeBaseConfiguration: {
          type: "SQL",
          sqlKnowledgeBaseConfiguration: {
            type: "REDSHIFT",
            redshiftConfiguration: {
              queryEngineConfiguration: {
                serverlessConfiguration: {
                  authConfiguration: {
                    type: "IAM",
                  },
                  workgroupArn: props.workGroupArn,
                },
                type: "SERVERLESS",
              },
              queryGenerationConfiguration: {
                executionTimeoutSeconds: props.executionTimeoutSeconds,
                generationContext: {
                  curatedQueries: props.curatedQueries,
                  tables: props.tables,
                },
              },
              storageConfigurations: [
                {
                  redshiftConfiguration: {
                    databaseName: props.databaseName,
                  },
                  type: "REDSHIFT",
                },
              ],
            },
          },
        },
      }
    );

Console screenshot (no Query Engine created):

Image