agent-squad icon indicating copy to clipboard operation
agent-squad copied to clipboard

Bug: ERROR WHILE DEPLOYING THE CHAT DEMO APP USING AWS CDK

Open sauravesr opened this issue 1 year ago • 4 comments

Expected Behaviour

The example chat demo app should be deployed by using the aws cdk.

Current Behaviour

cdk bootstrap command is giving the following error:

Error: Stack "edge-lambda-stack-c857392ef2fe634217fd187925a80bc5b43ea2d9da" cannot reference {ChatDemoStack/MultiAgentLambda/FunctionUrl/Resource[FunctionArn]} in stack "ChatDemoStack". Cross stack references are only supported for stacks deployed to the same environment or between nested stacks and their parent stack. Set crossRegionReferences=true to enable cross region references at resolveValue (/home/saurav/multi-agent-orchestrator/examples/chat-demo-app/node_modules/aws-cdk-lib/core/lib/private/refs.js:1:2612) at resolveReferences (/home/saurav/multi-agent-orchestrator/examples/chat-demo-app/node_modules/aws-cdk-lib/core/lib/private/refs.js:1:1414) at prepareApp (/home/saurav/multi-agent-orchestrator/examples/chat-demo-app/node_modules/aws-cdk-lib/core/lib/private/prepare-app.js:1:802) at synthesize (/home/saurav/multi-agent-orchestrator/examples/chat-demo-app/node_modules/aws-cdk-lib/core/lib/private/synthesis.js:1:1530) at App.synth (/home/saurav/multi-agent-orchestrator/examples/chat-demo-app/node_modules/aws-cdk-lib/core/lib/stage.js:1:2263) at process.<anonymous> (/home/saurav/multi-agent-orchestrator/examples/chat-demo-app/node_modules/aws-cdk-lib/core/lib/app.js:1:1745) at Object.onceWrapper (node:events:633:26) at process.emit (node:events:518:28) at process.emit (node:domain:489:12) at process.emit.sharedData.processEmitHook.installedValue [as emit] (/home/saurav/multi-agent-orchestrator/examples/chat-demo-app/node_modules/@cspotcode/source-map-support/source-map-support.js:745:40) Subprocess exited with error 1

Code snippet

cd multi-agent-orchestrator/examples/chat-demo-app
npm install
cdk bootstrap

Possible Solution

No response

Steps to Reproduce

cd multi-agent-orchestrator/examples/chat-demo-app npm install cdk bootstrap

sauravesr avatar Dec 04 '24 04:12 sauravesr

Hi @sauravesr Thanks for your interest in the multi-agent orchestrator!

We have updated our doc since we haven't mentioned the whole cdk bootstrap command. You should run: cdk bootstrap aws://123456789012/us-east-1

in addition, you need to set the AWS_DEFAULT_REGION=your-region

for example: export AWS_DEFAULT_REGION=us-east-1

Replace the account number with yours. Also, make sure that the region is having Claude Sonnet 3.5 v1 as it is the default classifier used in this demo). See the updated doc here: https://awslabs.github.io/multi-agent-orchestrator/cookbook/examples/chat-demo-app/#-deployment-steps

Let us know if you still have some issues.

brnaba-aws avatar Dec 04 '24 09:12 brnaba-aws

Hi @brnaba-aws, Thanks for responding, I followed the steps in the updated doc and set my default region: export AWS_DEFAULT_REGION=us-west-2

Then tried the cdk bootstrap command but I am getting the same issue:

saurav@saurav-Aspire-A715-71G:~/multi-agent-orchestrator/examples/chat-demo-app$ export AWS_DEFAULT_REGION=us-west-2

saurav@saurav-Aspire-A715-71G:~/multi-agent-orchestrator/examples/chat-demo-app$ cdk bootstrap aws://328178554247/us-west-2

[WARNING] aws-cdk-lib.aws_cloudfront_origins.S3Origin is deprecated. Use S3BucketOrigin or S3StaticWebsiteOrigin instead. This API will be removed in the next major release. [WARNING] aws-cdk-lib.aws_cloudfront_origins.S3Origin#bind is deprecated. Use S3BucketOrigin or S3StaticWebsiteOrigin instead. This API will be removed in the next major release. /home/saurav/multi-agent-orchestrator/examples/chat-demo-app/node_modules/aws-cdk-lib/core/lib/private/refs.js:1 "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.referenceNestedStackValueInParent=exports.getExportable=exports.resolveReferences=void 0;var cfn_reference_1=()=>{var tmp=require("./cfn-reference");return cfn_reference_1=()=>tmp,tmp},resolve_1=()=>{var tmp=require("./resolve");return resolve_1=()=>tmp,tmp},uniqueid_1=()=>{var tmp=require("./uniqueid");return uniqueid_1=()=>tmp,tmp},cxapi=()=>{var tmp=require("../../../cx-api");return cxapi=()=>tmp,tmp},cfn_element_1=()=>{var tmp=require("../cfn-element");return cfn_element_1=()=>tmp,tmp},cfn_output_1=()=>{var tmp=require("../cfn-output");return cfn_output_1=()=>tmp,tmp},cfn_parameter_1=()=>{var tmp=require("../cfn-parameter");return cfn_parameter_1=()=>tmp,tmp},export_writer_provider_1=()=>{var tmp=require("../custom-resource-provider/cross-region-export-providers/export-writer-provider");return export_writer_provider_1=()=>tmp,tmp},names_1=()=>{var tmp=require("../names");return names_1=()=>tmp,tmp},stack_1=()=>{var tmp=require("../stack");return stack_1=()=>tmp,tmp},token_1=()=>{var tmp=require("../token");return token_1=()=>tmp,tmp},type_hints_1=()=>{var tmp=require("../type-hints");return type_hints_1=()=>tmp,tmp};function resolveReferences(scope){const edges=findAllReferences(scope);for(const{source,value}of edges){const consumer=stack_1().Stack.of(source);if(!value.hasValueForStack(consumer)){const resolved=resolveValue(consumer,value);value.assignValueForStack(consumer,resolved)}}}exports.resolveReferences=resolveReferences;function resolveValue(consumer,reference){const producer=stack_1().Stack.of(reference.target),producerAccount=token_1().Token.isUnresolved(producer.account)?cxapi().UNKNOWN_ACCOUNT:producer.account,producerRegion=token_1().Token.isUnresolved(producer.region)?cxapi().UNKNOWN_REGION:producer.region,consumerAccount=token_1().Token.isUnresolved(consumer.account)?cxapi().UNKNOWN_ACCOUNT:consumer.account,consumerRegion=token_1().Token.isUnresolved(consumer.region)?cxapi().UNKNOWN_REGION:consumer.region;if(producer===consumer)return reference;if(producer.node.root!==consumer.node.root)throw new Error("Cannot reference across apps. Consuming and producing stacks must be defined within the same CDK app.");if(producerAccount!==consumerAccount)throw new Error(Stack "${consumer.node.path}" cannot reference ${renderReference(reference)} in stack "${producer.node.path}". Cross stack references are only supported for stacks deployed to the same account or between nested stacks and their parent stack);if(producerRegion!==consumerRegion&&!consumer._crossRegionReferences)throw new Error(Stack "${consumer.node.path}" cannot reference ${renderReference(reference)} in stack "${producer.node.path}". Cross stack references are only supported for stacks deployed to the same environment or between nested stacks and their parent stack. Set crossRegionReferences=true to enable cross region references);if(consumer.nestedStackParent&&isNested(consumer,producer)){const parameterValue=resolveValue(consumer.nestedStackParent,reference);return createNestedStackParameter(consumer,reference,parameterValue)}if(producer.nested){const outputValue=createNestedStackOutput(producer,reference);return resolveValue(consumer,outputValue)}if(producerRegion!==consumerRegion&&consumer._crossRegionReferences){if(producerRegion===cxapi().UNKNOWN_REGION||consumerRegion===cxapi().UNKNOWN_REGION)throw new Error(Stack "${consumer.node.path}" cannot reference ${renderReference(reference)} in stack "${producer.node.path}". Cross stack/region references are only supported for stacks with an explicit region defined. );return consumer.addDependency(producer,${consumer.node.path} -> ${reference.target.node.path}.${reference.displayName}),createCrossRegionImportValue(reference,consumer)}return consumer.addDependency(producer,${consumer.node.path} -> ${reference.target.node.path}.${reference.displayName}),createImportValue(reference)}function renderReference(ref){return{${ref.target.node.path}[${ref.displayName}]}}function findAllReferences(root){const result=new Array;for(const consumer of root.node.findAll())if(cfn_element_1().CfnElement.isCfnElement(consumer))try{const tokens=(0,resolve_1().findTokens)(consumer,()=>consumer._toCloudFormation());for(const token of tokens)cfn_reference_1().CfnReference.isCfnReference(token)&&result.push({source:consumer,value:token})}catch(e){if(e.type==="CfnSynthesisError")continue;throw e}return result}function createImportValue(reference){const exportingStack=stack_1().Stack.of(reference.target);let importExpr;return reference.typeHint===type_hints_1().ResolutionTypeHint.STRING_LIST?(importExpr=exportingStack.exportStringListValue(reference),token_1().Tokenization.reverseList(importExpr)):(importExpr=exportingStack.exportValue(reference),token_1().Tokenization.reverseCompleteString(importExpr))}function createCrossRegionImportValue(reference,importStack){const referenceStack=stack_1().Stack.of(reference.target),exportingStack=referenceStack.nestedStackParent??referenceStack,exportable=getExportable(exportingStack,reference),id=JSON.stringify(exportingStack.resolve(exportable)),exportName=generateExportName(importStack,reference,id);if(token_1().Token.isUnresolved(exportName))throw new Error(unresolved token in generated export name: ${JSON.stringify(exportingStack.resolve(exportName))});const writerConstructName=(0,uniqueid_1().makeUniqueId)(["ExportsWriter",importStack.region]),exported=export_writer_provider_1().ExportWriter.getOrCreate(exportingStack,writerConstructName,{region:importStack.region}).exportValue(exportName,reference,importStack);return importStack.nestedStackParent?createNestedStackParameter(importStack,exported,exported):exported}function generateExportName(importStack,reference,id){const referenceStack=stack_1().Stack.of(reference.target),components=[referenceStack.stackName??"",referenceStack.region,id],prefix=${importStack.nestedStackParent?.stackName??importStack.stackName}/,localPart=(0,uniqueid_1().makeUniqueId)(components);return prefix+localPart.slice(Math.max(0,localPart.length-900+prefix.length))}function getExportable(stack,reference){return cfn_element_1().CfnElement.isCfnElement(reference.target)&&reference.target._lockLogicalId(),referenceNestedStackValueInParent(reference,stack)}exports.getExportable=getExportable;function createNestedStackParameter(nested,reference,value){const paramId=generateUniqueId(nested,reference,"reference-to-");let param=nested.node.tryFindChild(paramId);if(!param){if(param=new(cfn_parameter_1()).CfnParameter(nested,paramId,{type:"String"}),!("setParameter"in nested))throw new Error('assertion failed: nested stack should have a "setParameter" method');nested.setParameter(param.logicalId,token_1().Token.asString(value))}return param.value}function createNestedStackOutput(producer,reference){const outputId=generateUniqueId(producer,reference);let output=producer.node.tryFindChild(outputId);if(output||(output=new(cfn_output_1()).CfnOutput(producer,outputId,{value:token_1().Token.asString(reference)})),!producer.nestedStackResource)throw new Error("assertion failed");return producer.nestedStackResource.getAtt(Outputs.${output.logicalId})}function referenceNestedStackValueInParent(reference,targetStack){let currentStack=stack_1().Stack.of(reference.target);if(currentStack!==targetStack&&!isNested(currentStack,targetStack))throw new Error(Referenced resource must be in stack '${targetStack.node.path}', got '${reference.target.node.path}');for(;currentStack!==targetStack;)reference=createNestedStackOutput(stack_1().Stack.of(reference.target),reference),currentStack=stack_1().Stack.of(reference.target);return reference}exports.referenceNestedStackValueInParent=referenceNestedStackValueInParent;function isNested(nested,parent){return nested.nestedStackParent===parent?!0:nested.nestedStackParent?isNested(nested.nestedStackParent,parent):!1}function generateUniqueId(stack,ref,prefix=""){return stack.resolve(${prefix}${names_1().Names.nodeUniqueId(ref.target.node)}${ref.displayName})} ^ Error: Stack "edge-lambda-stack-c857392ef2fe634217fd187925a80bc5b43ea2d9da" cannot reference {ChatDemoStack/MultiAgentLambda/FunctionUrl/Resource[FunctionArn]} in stack "ChatDemoStack". Cross stack references are only supported for stacks deployed to the same environment or between nested stacks and their parent stack. Set crossRegionReferences=true to enable cross region references at resolveValue (/home/saurav/multi-agent-orchestrator/examples/chat-demo-app/node_modules/aws-cdk-lib/core/lib/private/refs.js:1:2612) at resolveReferences (/home/saurav/multi-agent-orchestrator/examples/chat-demo-app/node_modules/aws-cdk-lib/core/lib/private/refs.js:1:1414) at prepareApp (/home/saurav/multi-agent-orchestrator/examples/chat-demo-app/node_modules/aws-cdk-lib/core/lib/private/prepare-app.js:1:802) at synthesize (/home/saurav/multi-agent-orchestrator/examples/chat-demo-app/node_modules/aws-cdk-lib/core/lib/private/synthesis.js:1:1530) at App.synth (/home/saurav/multi-agent-orchestrator/examples/chat-demo-app/node_modules/aws-cdk-lib/core/lib/stage.js:1:2263) at process. (/home/saurav/multi-agent-orchestrator/examples/chat-demo-app/node_modules/aws-cdk-lib/core/lib/app.js:1:1745) at Object.onceWrapper (node:events:633:26) at process.emit (node:events:518:28) at process.emit (node:domain:489:12) at process.emit.sharedData.processEmitHook.installedValue [as emit] (/home/saurav/multi-agent-orchestrator/examples/chat-demo-app/node_modules/@cspotcode/source-map-support/source-map-support.js:745:40) Subprocess exited with error 1

sauravesr avatar Dec 04 '24 10:12 sauravesr

thanks @sauravesr I can reproduce, we will fix that.

brnaba-aws avatar Dec 04 '24 11:12 brnaba-aws

@sauravesr , this should be fixed now. Please pull the repo again, delete your current stack and deploy again. Let us know how it goes.

brnaba-aws avatar Dec 04 '24 13:12 brnaba-aws

@brnaba-aws

cdk bootstrap aws://328178554247/us-west-2 is working now but

cdk deploy --all is giving the following error:

saurav@saurav-Aspire-A715-71G:~/multi-agent-orchestrator/examples/chat-demo-app$ cdk deploy --all Bundling asset ChatDemoStack/MutiAgentOrchestratorDocKb/AOSSCollectionForKB/CustomResourceHandler/Code/Stage...

cdk.out/bundling-temp-4600bc25c54e76a2e7014e9d2c64fb9b9395a42d135de9562d6e98701647aee5/index.js 23.8mb ⚠️

⚡ Done in 390ms Bundling asset ChatDemoStack/MutiAgentOrchestratorDocKb/PermissionCustomResourceHandler/Code/Stage...

cdk.out/bundling-temp-5fdd136e63487fe8109253bbdece80499974e086097f37d8c16f27f830aa3d86/index.js 23.8mb ⚠️

⚡ Done in 400ms Bundling asset ChatDemoStack/MutiAgentOrchestratorDocKb/DataSyncCustomResourceHandler/Code/Stage...

cdk.out/bundling-temp-f26017ece44b513e3fb31e1b8c41d65b4a51f4e67a684ca2e64f72472da5322a/index.js 994.7kb

⚡ Done in 72ms Bundling asset ChatDemoStack/MultiAgentLambda/Code/Stage...

cdk.out/bundling-temp-be555a54d977b653b52c5bcacfbc65506d1968c6dfc25e2c3f54f6619d2cbe62/index.js 21.8mb ⚠️

⚡ Done in 552ms [WARNING] aws-cdk-lib.aws_cloudfront_origins.S3Origin is deprecated. Use S3BucketOrigin or S3StaticWebsiteOrigin instead. This API will be removed in the next major release. [WARNING] aws-cdk-lib.aws_cloudfront_origins.S3Origin#bind is deprecated. Use S3BucketOrigin or S3StaticWebsiteOrigin instead. This API will be removed in the next major release. [Info at /ChatDemoStack/LexAgent/template/$Mappings/BucketName] Consider making this CfnMapping a lazy mapping by providing lazy: true: either no findInMap was called or every findInMap could be immediately resolved without using Fn::FindInMap [Info at /ChatDemoStack/LexAgent/template/$Mappings/S3Path] Consider making this CfnMapping a lazy mapping by providing lazy: true: either no findInMap was called or every findInMap could be immediately resolved without using Fn::FindInMap

✨ Synthesis time: 12.36s

ChatDemoStack: start: Building 3322b7049fb0ed2b7cbb644a2ada8d1116ff80c32dca89e6ada846b5de26f961:328178554247-us-west-2 ChatDemoStack: success: Built 3322b7049fb0ed2b7cbb644a2ada8d1116ff80c32dca89e6ada846b5de26f961:328178554247-us-west-2 ChatDemoStack: start: Building 0158f40002a8c211635388a87874fd4dcc3d68f525fe08a0fe0f014069ae539c:328178554247-us-west-2 ChatDemoStack: success: Built 0158f40002a8c211635388a87874fd4dcc3d68f525fe08a0fe0f014069ae539c:328178554247-us-west-2 ChatDemoStack: start: Building 47487b5abc0b963e96310f403d0951e5f38ac6a8f87d29be052293bd5324831f:328178554247-us-west-2 ChatDemoStack: success: Built 47487b5abc0b963e96310f403d0951e5f38ac6a8f87d29be052293bd5324831f:328178554247-us-west-2 ChatDemoStack: start: Building 58e25da5585fb2ff5b16417c333c93fc4d38fb9f58f9ed7a4c08054a8a94c8ef:328178554247-us-west-2 ChatDemoStack: success: Built 58e25da5585fb2ff5b16417c333c93fc4d38fb9f58f9ed7a4c08054a8a94c8ef:328178554247-us-west-2 ChatDemoStack: start: Building 0c09a598d4dd9810b6f902000a464324ec3126129e2aabbbdb2c4d7f126ce487:328178554247-us-west-2 ChatDemoStack: success: Built 0c09a598d4dd9810b6f902000a464324ec3126129e2aabbbdb2c4d7f126ce487:328178554247-us-west-2 ChatDemoStack: start: Building 246cb27aa0cb552c81fdca061092d0905aa4d2529e8b52b5598c069f18be51d7:328178554247-us-west-2 ChatDemoStack: success: Built 246cb27aa0cb552c81fdca061092d0905aa4d2529e8b52b5598c069f18be51d7:328178554247-us-west-2 ChatDemoStack: start: Building a25acdc73419b3fc2e869f19e47106872e719a5becced645808dd871d4184297:328178554247-us-west-2 ChatDemoStack: success: Built a25acdc73419b3fc2e869f19e47106872e719a5becced645808dd871d4184297:328178554247-us-west-2 ChatDemoStack: start: Publishing 58e25da5585fb2ff5b16417c333c93fc4d38fb9f58f9ed7a4c08054a8a94c8ef:328178554247-us-west-2 ChatDemoStack: start: Publishing 0c09a598d4dd9810b6f902000a464324ec3126129e2aabbbdb2c4d7f126ce487:328178554247-us-west-2 ChatDemoStack: start: Publishing 47487b5abc0b963e96310f403d0951e5f38ac6a8f87d29be052293bd5324831f:328178554247-us-west-2 ChatDemoStack: start: Publishing 246cb27aa0cb552c81fdca061092d0905aa4d2529e8b52b5598c069f18be51d7:328178554247-us-west-2 ChatDemoStack: start: Publishing a25acdc73419b3fc2e869f19e47106872e719a5becced645808dd871d4184297:328178554247-us-west-2 current credentials could not be used to assume 'arn:aws:iam::328178554247:role/cdk-hnb659fds-deploy-role-328178554247-us-east-1', but are for the right account. Proceeding anyway. ChatDemoStack: success: Published 58e25da5585fb2ff5b16417c333c93fc4d38fb9f58f9ed7a4c08054a8a94c8ef:328178554247-us-west-2 ChatDemoStack: success: Published 246cb27aa0cb552c81fdca061092d0905aa4d2529e8b52b5598c069f18be51d7:328178554247-us-west-2 ChatDemoStack: success: Published a25acdc73419b3fc2e869f19e47106872e719a5becced645808dd871d4184297:328178554247-us-west-2 ChatDemoStack: success: Published 47487b5abc0b963e96310f403d0951e5f38ac6a8f87d29be052293bd5324831f:328178554247-us-west-2 ChatDemoStack: success: Published 0c09a598d4dd9810b6f902000a464324ec3126129e2aabbbdb2c4d7f126ce487:328178554247-us-west-2 UserInterfaceStack: SSM parameter /cdk-bootstrap/hnb659fds/version not found. Has the environment been bootstrapped? Please run 'cdk bootstrap' (see https://docs.aws.amazon.com/cdk/latest/guide/bootstrapping.html) saurav@saurav-Aspire-A715-71G:~/multi-agent-orchestrator/examples/chat-demo-app$

sauravesr avatar Dec 04 '24 14:12 sauravesr

oh, you also need to run cdk bootstrap in us-east-1 as the lambda@edge function is deployed there. Forgot about that. I'll make an update to the doc. thanks for your patience.

brnaba-aws avatar Dec 04 '24 14:12 brnaba-aws

Thanks @brnaba-aws, cdk bootstrap in us-east-1 region worked.

sauravesr avatar Dec 05 '24 04:12 sauravesr