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

feat(typescript/bedrock-kb-agent) #1111

Merged

Conversation

mihaws
Copy link
Contributor

@mihaws mihaws commented Dec 20, 2024

Fixes #


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@kaiz-io kaiz-io changed the title very frist try feat(typescript/bedrock-kb-agent) Dec 27, 2024
);
this.siteBucket.grantRead(originAccessIdentity);

const s3origin = new cdk.aws_cloudfront_origins.S3Origin(this.siteBucket, {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

S3Origin has been deprecated can you update to S3OriginBucket.

Also your tests are failing please fix.

@kaiz-io kaiz-io added the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Dec 27, 2024
@mihaws
Copy link
Contributor Author

mihaws commented Dec 31, 2024

The deprecated api was removed.
About the tests, I can run the test using
npm run test

in the top level of the project, all the test are running

Test Suites: 1 passed, 1 total Tests: 9 passed, 9 total Snapshots: 0 total Time: 252.097 s
do you have any specific way to start the tests, like a cicd pipeline, do I need to follow some name conventions ?

@kaiz-io
Copy link
Contributor

kaiz-io commented Dec 31, 2024

We run the following as defined in /scripts/build-typescript.sh

Looks like you are missing you web-app directory.

    yarn install --mutex network
    yarn build
    npm run --if-present test
+ npm run --if-present test
FAIL test/bedrock-kb-agent-stack.test.ts (8.458 s)
  BedrockKbAgentStack
    ✕ Cognito User Pool is created with correct name (275 ms)
    ✕ API Gateway HTTP API is created (36 ms)
    ✕ Lambda function is created with correct configuration (42 ms)
    ✕ At least one IAM policy includes required Bedrock permissions (39 ms)
    ✕ S3 bucket for knowledge base is created (38 ms)
    ✕ Bedrock Knowledge Base is created (39 ms)
    ✕ Bedrock Agent is created (46 ms)
    ✕ API Gateway routes are created (40 ms)
    ✕ Stack has the expected number of resources (41 ms)
  ● BedrockKbAgentStack › Cognito User Pool is created with correct name
    Cannot find asset at /home/runner/work/aws-cdk-examples/aws-cdk-examples/typescript/bedrock-kb-agent/web-app/dist
      192 |     }
      193 |
    > 194 |     new cdk.aws_s3_deployment.BucketDeployment(this, "DeployWithInvalidation", {
          |     ^
      195 |       sources: [
      196 |         cdk.aws_s3_deployment.Source.asset(props.webSiteBuildPath), // Main webapp from root directory
      197 |         cdk.aws_s3_deployment.Source.jsonData("config.json", amplifyConfig), // Amplify config file
      at new AssetStaging (node_modules/aws-cdk-lib/core/lib/asset-staging.js:1:2221)
      at new Asset (node_modules/aws-cdk-lib/aws-s3-assets/lib/asset.js:1:1243)
      at Object.bind (node_modules/aws-cdk-lib/aws-s3-deployment/lib/source.js:1:1562)
      at node_modules/aws-cdk-lib/aws-s3-deployment/lib/bucket-deployment.js:1:3870
          at Array.map (<anonymous>)
      at new BucketDeployment (node_modules/aws-cdk-lib/aws-s3-deployment/lib/bucket-deployment.js:1:3851)
      at new CloudFrontS3WebSiteConstruct (lib/constructs/cloudfront-s3-website-construct.ts:194:5)
      at new BedrockKbAgentStack (lib/bedrock-kb-agent-stack.ts:35:21)
      at Object.<anonymous> (test/bedrock-kb-agent-stack.test.ts:12:13)
  ● BedrockKbAgentStack › API Gateway HTTP API is created
    Cannot find asset at /home/runner/work/aws-cdk-examples/aws-cdk-examples/typescript/bedrock-kb-agent/web-app/dist
      192 |     }
      193 |
    > 194 |     new cdk.aws_s3_deployment.BucketDeployment(this, "DeployWithInvalidation", {
          |     ^
      195 |       sources: [
      196 |         cdk.aws_s3_deployment.Source.asset(props.webSiteBuildPath), // Main webapp from root directory
      197 |         cdk.aws_s3_deployment.Source.jsonData("config.json", amplifyConfig), // Amplify config file
      at new AssetStaging (node_modules/aws-cdk-lib/core/lib/asset-staging.js:1:2221)
      at new Asset (node_modules/aws-cdk-lib/aws-s3-assets/lib/asset.js:1:1243)
      at Object.bind (node_modules/aws-cdk-lib/aws-s3-deployment/lib/source.js:1:1562)
      at node_modules/aws-cdk-lib/aws-s3-deployment/lib/bucket-deployment.js:1:3870
          at Array.map (<anonymous>)
      at new BucketDeployment (node_modules/aws-cdk-lib/aws-s3-deployment/lib/bucket-deployment.js:1:3851)
      at new CloudFrontS3WebSiteConstruct (lib/constructs/cloudfront-s3-website-construct.ts:194:5)
      at new BedrockKbAgentStack (lib/bedrock-kb-agent-stack.ts:35:21)
      at Object.<anonymous> (test/bedrock-kb-agent-stack.test.ts:12:13)
  ● BedrockKbAgentStack › Lambda function is created with correct configuration
    Cannot find asset at /home/runner/work/aws-cdk-examples/aws-cdk-examples/typescript/bedrock-kb-agent/web-app/dist
      192 |     }
      193 |
    > 194 |     new cdk.aws_s3_deployment.BucketDeployment(this, "DeployWithInvalidation", {
          |     ^
      195 |       sources: [
      196 |         cdk.aws_s3_deployment.Source.asset(props.webSiteBuildPath), // Main webapp from root directory
      197 |         cdk.aws_s3_deployment.Source.jsonData("config.json", amplifyConfig), // Amplify config file
      at new AssetStaging (node_modules/aws-cdk-lib/core/lib/asset-staging.js:1:2221)
      at new Asset (node_modules/aws-cdk-lib/aws-s3-assets/lib/asset.js:1:1243)
      at Object.bind (node_modules/aws-cdk-lib/aws-s3-deployment/lib/source.js:1:1562)
      at node_modules/aws-cdk-lib/aws-s3-deployment/lib/bucket-deployment.js:1:3870
          at Array.map (<anonymous>)
      at new BucketDeployment (node_modules/aws-cdk-lib/aws-s3-deployment/lib/bucket-deployment.js:1:3851)
      at new CloudFrontS3WebSiteConstruct (lib/constructs/cloudfront-s3-website-construct.ts:194:5)
      at new BedrockKbAgentStack (lib/bedrock-kb-agent-stack.ts:35:21)
      at Object.<anonymous> (test/bedrock-kb-agent-stack.test.ts:12:13)
  ● BedrockKbAgentStack › At least one IAM policy includes required Bedrock permissions
    Cannot find asset at /home/runner/work/aws-cdk-examples/aws-cdk-examples/typescript/bedrock-kb-agent/web-app/dist
      192 |     }
      193 |
    > 194 |     new cdk.aws_s3_deployment.BucketDeployment(this, "DeployWithInvalidation", {
          |     ^
      195 |       sources: [
      196 |         cdk.aws_s3_deployment.Source.asset(props.webSiteBuildPath), // Main webapp from root directory
      197 |         cdk.aws_s3_deployment.Source.jsonData("config.json", amplifyConfig), // Amplify config file
      at new AssetStaging (node_modules/aws-cdk-lib/core/lib/asset-staging.js:1:2221)
      at new Asset (node_modules/aws-cdk-lib/aws-s3-assets/lib/asset.js:1:1243)
      at Object.bind (node_modules/aws-cdk-lib/aws-s3-deployment/lib/source.js:1:1562)
      at node_modules/aws-cdk-lib/aws-s3-deployment/lib/bucket-deployment.js:1:3870
          at Array.map (<anonymous>)
      at new BucketDeployment (node_modules/aws-cdk-lib/aws-s3-deployment/lib/bucket-deployment.js:1:3851)
      at new CloudFrontS3WebSiteConstruct (lib/constructs/cloudfront-s3-website-construct.ts:194:5)
      at new BedrockKbAgentStack (lib/bedrock-kb-agent-stack.ts:35:21)
      at Object.<anonymous> (test/bedrock-kb-agent-stack.test.ts:12:13)
  ● BedrockKbAgentStack › S3 bucket for knowledge base is created
    Cannot find asset at /home/runner/work/aws-cdk-examples/aws-cdk-examples/typescript/bedrock-kb-agent/web-app/dist
      192 |     }
      193 |
    > 194 |     new cdk.aws_s3_deployment.BucketDeployment(this, "DeployWithInvalidation", {
          |     ^
      195 |       sources: [
      196 |         cdk.aws_s3_deployment.Source.asset(props.webSiteBuildPath), // Main webapp from root directory
      197 |         cdk.aws_s3_deployment.Source.jsonData("config.json", amplifyConfig), // Amplify config file
      at new AssetStaging (node_modules/aws-cdk-lib/core/lib/asset-staging.js:1:2221)
      at new Asset (node_modules/aws-cdk-lib/aws-s3-assets/lib/asset.js:1:1243)
      at Object.bind (node_modules/aws-cdk-lib/aws-s3-deployment/lib/source.js:1:1562)
      at node_modules/aws-cdk-lib/aws-s3-deployment/lib/bucket-deployment.js:1:3870
          at Array.map (<anonymous>)
      at new BucketDeployment (node_modules/aws-cdk-lib/aws-s3-deployment/lib/bucket-deployment.js:1:3851)
      at new CloudFrontS3WebSiteConstruct (lib/constructs/cloudfront-s3-website-construct.ts:194:5)
      at new BedrockKbAgentStack (lib/bedrock-kb-agent-stack.ts:35:21)
      at Object.<anonymous> (test/bedrock-kb-agent-stack.test.ts:12:13)
  ● BedrockKbAgentStack › Bedrock Knowledge Base is created
    Cannot find asset at /home/runner/work/aws-cdk-examples/aws-cdk-examples/typescript/bedrock-kb-agent/web-app/dist
      192 |     }
      193 |
    > 194 |     new cdk.aws_s3_deployment.BucketDeployment(this, "DeployWithInvalidation", {
          |     ^
      195 |       sources: [
      196 |         cdk.aws_s3_deployment.Source.asset(props.webSiteBuildPath), // Main webapp from root directory
      197 |         cdk.aws_s3_deployment.Source.jsonData("config.json", amplifyConfig), // Amplify config file
      at new AssetStaging (node_modules/aws-cdk-lib/core/lib/asset-staging.js:1:2221)
      at new Asset (node_modules/aws-cdk-lib/aws-s3-assets/lib/asset.js:1:1243)
      at Object.bind (node_modules/aws-cdk-lib/aws-s3-deployment/lib/source.js:1:1562)
      at node_modules/aws-cdk-lib/aws-s3-deployment/lib/bucket-deployment.js:1:3870
          at Array.map (<anonymous>)
      at new BucketDeployment (node_modules/aws-cdk-lib/aws-s3-deployment/lib/bucket-deployment.js:1:3851)
      at new CloudFrontS3WebSiteConstruct (lib/constructs/cloudfront-s3-website-construct.ts:194:5)
      at new BedrockKbAgentStack (lib/bedrock-kb-agent-stack.ts:35:21)
      at Object.<anonymous> (test/bedrock-kb-agent-stack.test.ts:12:13)
  ● BedrockKbAgentStack › Bedrock Agent is created
    Cannot find asset at /home/runner/work/aws-cdk-examples/aws-cdk-examples/typescript/bedrock-kb-agent/web-app/dist
      192 |     }
      193 |
    > 194 |     new cdk.aws_s3_deployment.BucketDeployment(this, "DeployWithInvalidation", {
          |     ^
      195 |       sources: [
      196 |         cdk.aws_s3_deployment.Source.asset(props.webSiteBuildPath), // Main webapp from root directory
      197 |         cdk.aws_s3_deployment.Source.jsonData("config.json", amplifyConfig), // Amplify config file
      at new AssetStaging (node_modules/aws-cdk-lib/core/lib/asset-staging.js:1:2221)
      at new Asset (node_modules/aws-cdk-lib/aws-s3-assets/lib/asset.js:1:1243)
      at Object.bind (node_modules/aws-cdk-lib/aws-s3-deployment/lib/source.js:1:1562)
      at node_modules/aws-cdk-lib/aws-s3-deployment/lib/bucket-deployment.js:1:3870
          at Array.map (<anonymous>)
      at new BucketDeployment (node_modules/aws-cdk-lib/aws-s3-deployment/lib/bucket-deployment.js:1:3851)
      at new CloudFrontS3WebSiteConstruct (lib/constructs/cloudfront-s3-website-construct.ts:194:5)
      at new BedrockKbAgentStack (lib/bedrock-kb-agent-stack.ts:35:21)
      at Object.<anonymous> (test/bedrock-kb-agent-stack.test.ts:12:13)
  ● BedrockKbAgentStack › API Gateway routes are created
    Cannot find asset at /home/runner/work/aws-cdk-examples/aws-cdk-examples/typescript/bedrock-kb-agent/web-app/dist
      192 |     }
      193 |
    > 194 |     new cdk.aws_s3_deployment.BucketDeployment(this, "DeployWithInvalidation", {
          |     ^
      195 |       sources: [
      196 |         cdk.aws_s3_deployment.Source.asset(props.webSiteBuildPath), // Main webapp from root directory
      197 |         cdk.aws_s3_deployment.Source.jsonData("config.json", amplifyConfig), // Amplify config file
      at new AssetStaging (node_modules/aws-cdk-lib/core/lib/asset-staging.js:1:2221)
      at new Asset (node_modules/aws-cdk-lib/aws-s3-assets/lib/asset.js:1:1243)
      at Object.bind (node_modules/aws-cdk-lib/aws-s3-deployment/lib/source.js:1:1562)
      at node_modules/aws-cdk-lib/aws-s3-deployment/lib/bucket-deployment.js:1:3870
          at Array.map (<anonymous>)
      at new BucketDeployment (node_modules/aws-cdk-lib/aws-s3-deployment/lib/bucket-deployment.js:1:3851)
      at new CloudFrontS3WebSiteConstruct (lib/constructs/cloudfront-s3-website-construct.ts:194:5)
      at new BedrockKbAgentStack (lib/bedrock-kb-agent-stack.ts:35:21)
      at Object.<anonymous> (test/bedrock-kb-agent-stack.test.ts:12:13)
  ● BedrockKbAgentStack › Stack has the expected number of resources
    Cannot find asset at /home/runner/work/aws-cdk-examples/aws-cdk-examples/typescript/bedrock-kb-agent/web-app/dist
      192 |     }
      193 |
    > 194 |     new cdk.aws_s3_deployment.BucketDeployment(this, "DeployWithInvalidation", {
          |     ^
      195 |       sources: [
      196 |         cdk.aws_s3_deployment.Source.asset(props.webSiteBuildPath), // Main webapp from root directory
      197 |         cdk.aws_s3_deployment.Source.jsonData("config.json", amplifyConfig), // Amplify config file
      at new AssetStaging (node_modules/aws-cdk-lib/core/lib/asset-staging.js:1:2221)
      at new Asset (node_modules/aws-cdk-lib/aws-s3-assets/lib/asset.js:1:1243)
      at Object.bind (node_modules/aws-cdk-lib/aws-s3-deployment/lib/source.js:1:1562)
      at node_modules/aws-cdk-lib/aws-s3-deployment/lib/bucket-deployment.js:1:3870
          at Array.map (<anonymous>)
      at new BucketDeployment (node_modules/aws-cdk-lib/aws-s3-deployment/lib/bucket-deployment.js:1:3851)
      at new CloudFrontS3WebSiteConstruct (lib/constructs/cloudfront-s3-website-construct.ts:194:5)
      at new BedrockKbAgentStack (lib/bedrock-kb-agent-stack.ts:35:21)
      at Object.<anonymous> (test/bedrock-kb-agent-stack.test.ts:12:13)
Test Suites: 1 failed, 1 total
Tests:       9 failed, 9 total
Snapshots:   0 total
Time:        8.508 s
Ran all test suites.

@github-actions github-actions bot removed the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Jan 1, 2025
@kaiz-io kaiz-io added the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Jan 2, 2025
@mihaws
Copy link
Contributor Author

mihaws commented Jan 3, 2025

Thx answer Michael,
It was my bad i forgot to check the .gitignore, and there were a dist right at the top.
I will fix this in the next mins and I will run the test as you suggested

@mihaws
Copy link
Contributor Author

mihaws commented Jan 3, 2025

I add the missing dirs and run a test locally with a fresh checked branch, all tests are running

....
npm run --if-present test
....

PASS test/bedrock-kb-agent-stack.test.ts (272.977 s)a-powertools-3.4.0 aws_xray_sdk-2.14.0 botocore-1.35.91 jmespath-1.0.1 jsonpath_ng-1.7.0 ply-3.11 pydantic-2.10.4 pydantic-core-2.27.2 python-dateutil-2.9.0.post0 six-1.17.0 typing-extensions-4.12.2 ur
BedrockKbAgentStack
✓ Cognito User Pool is created with correct name (41952 ms)
✓ API Gateway HTTP API is created (25198 ms)
✓ Lambda function is created with correct configuration (26406 ms)
✓ At least one IAM policy includes required Bedrock permissions (27259 ms)
✓ S3 bucket for knowledge base is created (25676 ms)
✓ Bedrock Knowledge Base is created (26277 ms)
✓ Bedrock Agent is created (44441 ms)
✓ API Gateway routes are created (26414 ms)
✓ Stack has the expected number of resources (25973 ms)

Test Suites: 1 passed, 1 total
Tests: 9 passed, 9 total
Snapshots: 0 total
Time: 273.034 s

Copy link
Contributor

@kaiz-io kaiz-io left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀


const cognito = new CognitoWebNativeConstruct(this, "Cognito", props);

const webAppBuildPath = "./web-app/dist";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is missing.

@kaiz-io kaiz-io merged commit c332324 into aws-samples:main Jan 3, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants