docwho2 / java-connect-lex-chatgpt

Amazon Connect Multi-Lingual ChatGPT Voice Bot via AWS Lex written in Java
MIT License
7 stars 3 forks source link

Failed Deployment. #1

Closed phi16180 closed 11 months ago

phi16180 commented 11 months ago

Deployment failed and returned the following error

ResourceStatus ResourceType LogicalResourceId ResourceStatusReason

CREATE_IN_PROGRESS AWS::DynamoDB::Table SessionTable -
CREATE_IN_PROGRESS AWS::IAM::ManagedPolicy ContactUpdatePolicy -
CREATE_IN_PROGRESS AWS::KMS::Key BucketKey -
CREATE_IN_PROGRESS AWS::SNS::Topic NewCallTopic -
CREATE_IN_PROGRESS AWS::IAM::Role BotRuntimeRole -
CREATE_IN_PROGRESS AWS::DynamoDB::Table CallTable -
CREATE_IN_PROGRESS AWS::IAM::Role BotRuntimeRole Resource creation Initiated
CREATE_FAILED AWS::KMS::Key BucketKey Resource handler returned message:
"Policy contains a statement with
one or more invalid principals.
(Service: Kms, Status Code: 400,
Request ID: 5d2ceba6-72c0-4e0f-9b4d -b5e41e144c45)" (RequestToken: 840c 1c0c-9a44-59e6-ae92-80effc0cc09e,
HandlerErrorCode: InvalidRequest)
CREATE_IN_PROGRESS AWS::IAM::ManagedPolicy ContactUpdatePolicy Resource creation Initiated
CREATE_IN_PROGRESS AWS::DynamoDB::Table SessionTable Resource creation Initiated
CREATE_IN_PROGRESS AWS::SNS::Topic NewCallTopic Resource creation Initiated
CREATE_FAILED AWS::IAM::Role BotRuntimeRole Resource creation cancelled
CREATE_FAILED AWS::SNS::Topic NewCallTopic Resource creation cancelled
CREATE_FAILED AWS::IAM::ManagedPolicy ContactUpdatePolicy Resource creation cancelled
CREATE_FAILED AWS::DynamoDB::Table CallTable Resource creation cancelled
CREATE_FAILED AWS::DynamoDB::Table SessionTable Resource creation cancelled
ROLLBACK_IN_PROGRESS AWS::CloudFormation::Stack connect-chatgpt The following resource(s) failed to create: [BotRuntimeRole, BucketKey, SessionTable, NewCallTopic,
CallTable, ContactUpdatePolicy].
Rollback requested by user.
DELETE_IN_PROGRESS AWS::DynamoDB::Table SessionTable -
DELETE_IN_PROGRESS AWS::IAM::Role BotRuntimeRole -
DELETE_IN_PROGRESS AWS::IAM::ManagedPolicy ContactUpdatePolicy -
DELETE_IN_PROGRESS AWS::SNS::Topic NewCallTopic -
DELETE_IN_PROGRESS AWS::DynamoDB::Table CallTable -
DELETE_COMPLETE AWS::IAM::ManagedPolicy ContactUpdatePolicy -
DELETE_COMPLETE AWS::IAM::Role BotRuntimeRole -
DELETE_COMPLETE AWS::DynamoDB::Table SessionTable -
DELETE_COMPLETE AWS::DynamoDB::Table CallTable -
DELETE_COMPLETE AWS::SNS::Topic NewCallTopic -
DELETE_COMPLETE AWS::KMS::Key BucketKey -
ROLLBACK_COMPLETE AWS::CloudFormation::Stack connect-chatgpt -

Error: Failed to create/update the stack: connect-chatgpt, Waiter StackCreateComplete failed: Waiter encountered a terminal failure state: For expression "Stacks[].StackStatus" we matched expected path: "ROLLBACK_COMPLETE" at least once

============================== Prior to the deployment, the "sam build" also failed (partially) "=============================="

Build Failed Error: JavaMavenWorkflow:MavenBuild - Maven Failed: [INFO] Scanning for projects... [INFO] [INFO] ---------< cloud.cleo.awsconnect-chatgpt:generate-poly-prompt >--------- [INFO] Building Polly Prompt Generator 1.0 [INFO] from pom.xml [INFO] --------------------------------[ jar ]--------------------------------- [WARNING] The POM for com.amazonaws:aws-lambda-java-events:jar:4.0.0 is missing, no dependency information available [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 2.662 s [INFO] Finished at: 2023-09-13T17:03:53-04:00 [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal on project generate-poly-prompt: Could not resolve dependencies for project cloud.cleo.awsconnect-chatgpt:generate-poly-prompt:jar:1.0: The following artifacts could not be resolved: com.amazonaws:aws-lambda-java-events:jar:4.0.0 (absent): com.amazonaws:aws-lambda-java-events:jar:4.0.0 was not found in https://repo.maven.apache.org/maven2 during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of central has elapsed or updates are forced -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException

======================== When I ran ./init.bash before sam build, it also failed : "========================"

[INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 6.024 s [INFO] Finished at: 2023-09-13T17:03:11-04:00 [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.apache.maven.plugins:maven-shade-plugin:3.2.1:shade (default) on project aws-lambda-java-serialization: Error creating shaded jar: duplicate entry: META-INF/services/com.amazonaws.lambda.thirdparty.com.fasterxml.jackson.core.JsonFactory -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

docwho2 commented 11 months ago

Can't see the whole execution for init.bash. but if that doesn't succeed then you really can't go any further with sam build. I made some adjustments and tested in a clean cloud shell. So just wipe everything and clone again. I verified it works as seen below. Fresh environment, installed maven via "sudo yum install maven", and then the below.

[cloudshell-user@ip-10-6-114-175 ~]$ git clone https://github.com/docwho2/java-connect-lex-chatgpt.git Cloning into 'java-connect-lex-chatgpt'... remote: Enumerating objects: 363, done. remote: Counting objects: 100% (363/363), done. remote: Compressing objects: 100% (197/197), done. remote: Total 363 (delta 161), reused 305 (delta 106), pack-reused 0 Receiving objects: 100% (363/363), 3.46 MiB | 16.71 MiB/s, done. Resolving deltas: 100% (161/161), done.

[cloudshell-user@ip-10-6-114-175 ~]$ cd java-connect-lex-chatgpt/

[cloudshell-user@ip-10-6-114-175 java-connect-lex-chatgpt]$ ./init.bash

Submodule 'LambdaEventsV4' (https://github.com/aws/aws-lambda-java-libs.git) registered for path 'LambdaEventsV4' Cloning into '/home/cloudshell-user/java-connect-lex-chatgpt/LambdaEventsV4'... Submodule path 'LambdaEventsV4': checked out '85837fa301a83f89bbb09683c35aa5df1077b7d4' [INFO] Scanning for projects... [INFO]
[INFO] ------------------------------------------------------------------------ [INFO] Building AWS Lambda Java Runtime Serialization 2.0.0 [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ aws-lambda-java-serialization --- [debug] execute contextualize [WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent! [INFO] Copying 1 resource [INFO] [INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ aws-lambda-java-serialization --- [WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent! [INFO] Compiling 3 source files to /home/cloudshell-user/java-connect-lex-chatgpt/LambdaEventsV4/aws-lambda-java-serialization/target/classes [INFO] [INFO] --- maven-resources-plugin:2.5:testResources (default-testResources) @ aws-lambda-java-serialization --- [debug] execute contextualize [WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent! [INFO] skip non existing resourceDirectory /home/cloudshell-user/java-connect-lex-chatgpt/LambdaEventsV4/aws-lambda-java-serialization/src/test/resources [INFO] [INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) @ aws-lambda-java-serialization --- [WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent! [INFO] Compiling 3 source files to /home/cloudshell-user/java-connect-lex-chatgpt/LambdaEventsV4/aws-lambda-java-serialization/target/test-classes [INFO] [INFO] --- maven-surefire-plugin:2.22.2:test (default-test) @ aws-lambda-java-serialization --- [INFO] Tests are skipped. [INFO] [INFO] --- maven-jar-plugin:2.3.2:jar (default-jar) @ aws-lambda-java-serialization --- [INFO] Building jar: /home/cloudshell-user/java-connect-lex-chatgpt/LambdaEventsV4/aws-lambda-java-serialization/target/aws-lambda-java-serialization-2.0.0.jar [INFO] [INFO] --- maven-install-plugin:2.3.1:install (default-install) @ aws-lambda-java-serialization --- [INFO] Installing /home/cloudshell-user/java-connect-lex-chatgpt/LambdaEventsV4/aws-lambda-java-serialization/target/aws-lambda-java-serialization-2.0.0.jar to /home/cloudshell-user/.m2/repository/com/amazonaws/aws-lambda-java-serialization/2.0.0/aws-lambda-java-serialization-2.0.0.jar [INFO] Installing /home/cloudshell-user/java-connect-lex-chatgpt/LambdaEventsV4/aws-lambda-java-serialization/pom.xml to /home/cloudshell-user/.m2/repository/com/amazonaws/aws-lambda-java-serialization/2.0.0/aws-lambda-java-serialization-2.0.0.pom [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 10.201s [INFO] Finished at: Thu Sep 14 10:27:13 UTC 2023 [INFO] Final Memory: 13M/54M [INFO] ------------------------------------------------------------------------ [INFO] Scanning for projects... [INFO]
[INFO] ------------------------------------------------------------------------ [INFO] Building AWS Lambda Java Events Library 4.0.0 [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ aws-lambda-java-events --- [debug] execute contextualize [WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent! [INFO] skip non existing resourceDirectory /home/cloudshell-user/java-connect-lex-chatgpt/LambdaEventsV4/aws-lambda-java-events/src/main/resources [INFO] [INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ aws-lambda-java-events --- [WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent! [INFO] Compiling 73 source files to /home/cloudshell-user/java-connect-lex-chatgpt/LambdaEventsV4/aws-lambda-java-events/target/classes [INFO] [INFO] --- maven-resources-plugin:2.5:testResources (default-testResources) @ aws-lambda-java-events --- [debug] execute contextualize [WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent! [INFO] Copying 66 resources [INFO] [INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) @ aws-lambda-java-events --- [WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent! [INFO] Compiling 4 source files to /home/cloudshell-user/java-connect-lex-chatgpt/LambdaEventsV4/aws-lambda-java-events/target/test-classes [INFO] [INFO] --- maven-surefire-plugin:2.10:test (default-test) @ aws-lambda-java-events --- [INFO] Tests are skipped. [INFO] [INFO] --- maven-jar-plugin:2.3.2:jar (default-jar) @ aws-lambda-java-events --- [INFO] Building jar: /home/cloudshell-user/java-connect-lex-chatgpt/LambdaEventsV4/aws-lambda-java-events/target/aws-lambda-java-events-4.0.0.jar [INFO] [INFO] --- maven-install-plugin:2.3.1:install (default-install) @ aws-lambda-java-events --- [INFO] Installing /home/cloudshell-user/java-connect-lex-chatgpt/LambdaEventsV4/aws-lambda-java-events/target/aws-lambda-java-events-4.0.0.jar to /home/cloudshell-user/.m2/repository/com/amazonaws/aws-lambda-java-events/4.0.0/aws-lambda-java-events-4.0.0.jar [INFO] Installing /home/cloudshell-user/java-connect-lex-chatgpt/LambdaEventsV4/aws-lambda-java-events/pom.xml to /home/cloudshell-user/.m2/repository/com/amazonaws/aws-lambda-java-events/4.0.0/aws-lambda-java-events-4.0.0.pom [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 42.510s [INFO] Finished at: Thu Sep 14 10:27:59 UTC 2023 [INFO] Final Memory: 17M/64M [INFO] ------------------------------------------------------------------------ [INFO] Scanning for projects... [INFO]
[INFO] ------------------------------------------------------------------------ [INFO] Building Connect GPT Parent POM 1.0 [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- maven-install-plugin:2.3.1:install (default-install) @ parent-pom --- [INFO] Installing /home/cloudshell-user/java-connect-lex-chatgpt/pom.xml to /home/cloudshell-user/.m2/repository/cloud/cleo/awsconnect-chatgpt/parent-pom/1.0/parent-pom-1.0.pom [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 1.365s [INFO] Finished at: Thu Sep 14 10:28:03 UTC 2023 [INFO] Final Memory: 6M/27M [INFO] ------------------------------------------------------------------------ [cloudshell-user@ip-10-6-114-175 java-connect-lex-chatgpt]$

phi16180 commented 11 months ago

Thank you for your prompt response! After restarting from a fresh environment, the build is successful. However, I'm still having the same error related to AWS KMS Bucket Key:

================= Resource handler returned message: "Policy contains a statement with one or more invalid principals. (Service: Kms, Status Code: 400, Request ID: d40946d5-37fa-4d3e-b1d1-46b10e78f53e)" (RequestToken: 6f59b1cc-5d7a-0f21-4f2b-f87b27066031, HandlerErrorCode: InvalidRequest)

========================

I started to use a traditional IAM Key (access_key_id + aws_secret_access_key) with administrator access instead of the recommended SSO from IAM Identity Center but that didn't solve the issue. I obtained the same error that I was experiencing when the build was failing.

Find below the deployment error message:

======================================

2023-09-14 17:55:19 - Waiting for stack create/update to complete

CloudFormation events from stack operations (refresh every 5.0 seconds)

ResourceStatus ResourceType LogicalResourceId ResourceStatusReason

CREATE_IN_PROGRESS AWS::DynamoDB::Table CallTable - CREATE_IN_PROGRESS AWS::IAM::ManagedPolicy ContactUpdatePolicy - CREATE_IN_PROGRESS AWS::DynamoDB::Table SessionTable - CREATE_IN_PROGRESS AWS::IAM::Role BotRuntimeRole - CREATE_IN_PROGRESS AWS::KMS::Key BucketKey - CREATE_IN_PROGRESS AWS::SNS::Topic NewCallTopic - CREATE_IN_PROGRESS AWS::IAM::Role BotRuntimeRole Resource creation Initiated CREATE_IN_PROGRESS AWS::IAM::ManagedPolicy ContactUpdatePolicy Resource creation Initiated CREATE_FAILED AWS::KMS::Key BucketKey Resource handler returned message: "Policy contains a statement with one or more invalid principals. (Service: Kms, Status Code: 400, Request ID: d40946d5-37fa-4d3e-b1d1-46b10e78f53e)" (RequestToken: 6f59b1cc-5d7a-0f21-4f2b-f87b27066031, HandlerErrorCode: InvalidRequest) CREATE_IN_PROGRESS AWS::DynamoDB::Table CallTable Resource creation Initiated CREATE_IN_PROGRESS AWS::DynamoDB::Table SessionTable Resource creation Initiated CREATE_FAILED AWS::IAM::Role BotRuntimeRole Resource creation cancelled CREATE_FAILED AWS::IAM::ManagedPolicy ContactUpdatePolicy Resource creation cancelled CREATE_FAILED AWS::DynamoDB::Table SessionTable Resource creation cancelled CREATE_FAILED AWS::DynamoDB::Table CallTable Resource creation cancelled CREATE_FAILED AWS::SNS::Topic NewCallTopic Resource creation cancelled ROLLBACK_IN_PROGRESS AWS::CloudFormation::Stack connect-chatgpt The following resource(s) failed to create: [BotRuntimeRole, BucketKey, SessionTable, NewCallTopic, CallTable, ContactUpdatePolicy]. Rollback requested by user. DELETE_IN_PROGRESS AWS::SNS::Topic NewCallTopic - DELETE_IN_PROGRESS AWS::DynamoDB::Table CallTable - DELETE_IN_PROGRESS AWS::IAM::ManagedPolicy ContactUpdatePolicy - DELETE_IN_PROGRESS AWS::DynamoDB::Table SessionTable - DELETE_IN_PROGRESS AWS::IAM::Role BotRuntimeRole - DELETE_COMPLETE AWS::IAM::ManagedPolicy ContactUpdatePolicy - DELETE_COMPLETE AWS::IAM::Role BotRuntimeRole - DELETE_COMPLETE AWS::DynamoDB::Table CallTable - DELETE_COMPLETE AWS::DynamoDB::Table SessionTable - DELETE_COMPLETE AWS::SNS::Topic NewCallTopic - DELETE_COMPLETE AWS::KMS::Key BucketKey - ROLLBACK_COMPLETE AWS::CloudFormation::Stack connect-chatgpt -

Error: Failed to create/update the stack: connect-chatgpt, Waiter StackCreateComplete failed: Waiter encountered a terminal failure state: For expression "Stacks[].StackStatus" we matched expected path: "ROLLBACK_COMPLETE" at least once


From: Steve Jensen @.> Sent: Thursday, September 14, 2023 6:36 AM To: docwho2/java-connect-lex-chatgpt @.> Cc: phi16180 @.>; Author @.> Subject: Re: [docwho2/java-connect-lex-chatgpt] Failed Deployment. (Issue #1)

Can't see the whole execution for init.bash. but if that doesn't succeed then you really can't go any further with sam build. I made some adjustments and tested in a clean cloud shell. So just wipe everything and clone again. I verified it works as seen below. Fresh environment, installed maven via sudo yum install maven, and then the below.

@.*** ~]$ git clone https://github.com/docwho2/java-connect-lex-chatgpt.git Cloning into 'java-connect-lex-chatgpt'... remote: Enumerating objects: 363, done. remote: Counting objects: 100% (363/363), done. remote: Compressing objects: 100% (197/197), done. remote: Total 363 (delta 161), reused 305 (delta 106), pack-reused 0 Receiving objects: 100% (363/363), 3.46 MiB | 16.71 MiB/s, done. Resolving deltas: 100% (161/161), done.

@.*** ~]$ cd java-connect-lex-chatgpt/

@.*** java-connect-lex-chatgpt]$ ./init.bash

Submodule 'LambdaEventsV4' (https://github.com/aws/aws-lambda-java-libs.git) registered for path 'LambdaEventsV4' Cloning into '/home/cloudshell-user/java-connect-lex-chatgpt/LambdaEventsV4'... Submodule path 'LambdaEventsV4': checked out '85837fa301a83f89bbb09683c35aa5df1077b7d4' [INFO] Scanning for projects... [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building AWS Lambda Java Runtime Serialization 2.0.0 [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ aws-lambda-java-serialization --- [debug] execute contextualize [WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent! [INFO] Copying 1 resource [INFO] [INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ aws-lambda-java-serialization --- [WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent! [INFO] Compiling 3 source files to /home/cloudshell-user/java-connect-lex-chatgpt/LambdaEventsV4/aws-lambda-java-serialization/target/classes [INFO] [INFO] --- maven-resources-plugin:2.5:testResources (default-testResources) @ aws-lambda-java-serialization --- [debug] execute contextualize [WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent! [INFO] skip non existing resourceDirectory /home/cloudshell-user/java-connect-lex-chatgpt/LambdaEventsV4/aws-lambda-java-serialization/src/test/resources [INFO] [INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) @ aws-lambda-java-serialization --- [WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent! [INFO] Compiling 3 source files to /home/cloudshell-user/java-connect-lex-chatgpt/LambdaEventsV4/aws-lambda-java-serialization/target/test-classes [INFO] [INFO] --- maven-surefire-plugin:2.22.2:test (default-test) @ aws-lambda-java-serialization --- [INFO] Tests are skipped. [INFO] [INFO] --- maven-jar-plugin:2.3.2:jar (default-jar) @ aws-lambda-java-serialization --- [INFO] Building jar: /home/cloudshell-user/java-connect-lex-chatgpt/LambdaEventsV4/aws-lambda-java-serialization/target/aws-lambda-java-serialization-2.0.0.jar [INFO] [INFO] --- maven-install-plugin:2.3.1:install (default-install) @ aws-lambda-java-serialization --- [INFO] Installing /home/cloudshell-user/java-connect-lex-chatgpt/LambdaEventsV4/aws-lambda-java-serialization/target/aws-lambda-java-serialization-2.0.0.jar to /home/cloudshell-user/.m2/repository/com/amazonaws/aws-lambda-java-serialization/2.0.0/aws-lambda-java-serialization-2.0.0.jar [INFO] Installing /home/cloudshell-user/java-connect-lex-chatgpt/LambdaEventsV4/aws-lambda-java-serialization/pom.xml to /home/cloudshell-user/.m2/repository/com/amazonaws/aws-lambda-java-serialization/2.0.0/aws-lambda-java-serialization-2.0.0.pom [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 10.201s [INFO] Finished at: Thu Sep 14 10:27:13 UTC 2023 [INFO] Final Memory: 13M/54M [INFO] ------------------------------------------------------------------------ [INFO] Scanning for projects... [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building AWS Lambda Java Events Library 4.0.0 [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ aws-lambda-java-events --- [debug] execute contextualize [WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent! [INFO] skip non existing resourceDirectory /home/cloudshell-user/java-connect-lex-chatgpt/LambdaEventsV4/aws-lambda-java-events/src/main/resources [INFO] [INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ aws-lambda-java-events --- [WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent! [INFO] Compiling 73 source files to /home/cloudshell-user/java-connect-lex-chatgpt/LambdaEventsV4/aws-lambda-java-events/target/classes [INFO] [INFO] --- maven-resources-plugin:2.5:testResources (default-testResources) @ aws-lambda-java-events --- [debug] execute contextualize [WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent! [INFO] Copying 66 resources [INFO] [INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) @ aws-lambda-java-events --- [WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent! [INFO] Compiling 4 source files to /home/cloudshell-user/java-connect-lex-chatgpt/LambdaEventsV4/aws-lambda-java-events/target/test-classes [INFO] [INFO] --- maven-surefire-plugin:2.10:test (default-test) @ aws-lambda-java-events --- [INFO] Tests are skipped. [INFO] [INFO] --- maven-jar-plugin:2.3.2:jar (default-jar) @ aws-lambda-java-events --- [INFO] Building jar: /home/cloudshell-user/java-connect-lex-chatgpt/LambdaEventsV4/aws-lambda-java-events/target/aws-lambda-java-events-4.0.0.jar [INFO] [INFO] --- maven-install-plugin:2.3.1:install (default-install) @ aws-lambda-java-events --- [INFO] Installing /home/cloudshell-user/java-connect-lex-chatgpt/LambdaEventsV4/aws-lambda-java-events/target/aws-lambda-java-events-4.0.0.jar to /home/cloudshell-user/.m2/repository/com/amazonaws/aws-lambda-java-events/4.0.0/aws-lambda-java-events-4.0.0.jar [INFO] Installing /home/cloudshell-user/java-connect-lex-chatgpt/LambdaEventsV4/aws-lambda-java-events/pom.xml to /home/cloudshell-user/.m2/repository/com/amazonaws/aws-lambda-java-events/4.0.0/aws-lambda-java-events-4.0.0.pom [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 42.510s [INFO] Finished at: Thu Sep 14 10:27:59 UTC 2023 [INFO] Final Memory: 17M/64M [INFO] ------------------------------------------------------------------------ [INFO] Scanning for projects... [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building Connect GPT Parent POM 1.0 [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- maven-install-plugin:2.3.1:install (default-install) @ parent-pom --- [INFO] Installing /home/cloudshell-user/java-connect-lex-chatgpt/pom.xml to /home/cloudshell-user/.m2/repository/cloud/cleo/awsconnect-chatgpt/parent-pom/1.0/parent-pom-1.0.pom [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 1.365s [INFO] Finished at: Thu Sep 14 10:28:03 UTC 2023 [INFO] Final Memory: 6M/27M [INFO] ------------------------------------------------------------------------ @.*** java-connect-lex-chatgpt]$

— Reply to this email directly, view it on GitHubhttps://github.com/docwho2/java-connect-lex-chatgpt/issues/1#issuecomment-1719201917, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AEFSALUNLCQ26FE5U6JTELLX2LM4LANCNFSM6AAAAAA4XD6UXE. You are receiving this because you authored the thread.Message ID: @.***>

phi16180 commented 11 months ago

After restarting from a fresh environment, the build was successful. However, I'm still having the same error related to AWS KMS Bucket Key:

================= Resource handler returned message: "Policy contains a statement with one or more invalid principals. (Service: Kms, Status Code: 400, Request ID: d40946d5-37fa-4d3e-b1d1-46b10e78f53e)" (RequestToken: 6f59b1cc-5d7a-0f21-4f2b-f87b27066031, HandlerErrorCode: InvalidRequest)

========================

I started to use a traditional IAM Key (access_key_id + aws_secret_access_key) with administrator access instead of the recommended SSO from IAM Identity Center but that didn't solve the issue. I obtained the same error that I was experiencing when the build was failing.

Find below the deployment error message:

======================================

2023-09-14 17:55:19 - Waiting for stack create/update to complete

CloudFormation events from stack operations (refresh every 5.0 seconds)

ResourceStatus ResourceType LogicalResourceId ResourceStatusReason

CREATE_IN_PROGRESS AWS::DynamoDB::Table CallTable -
CREATE_IN_PROGRESS AWS::IAM::ManagedPolicy ContactUpdatePolicy -
CREATE_IN_PROGRESS AWS::DynamoDB::Table SessionTable -
CREATE_IN_PROGRESS AWS::IAM::Role BotRuntimeRole -
CREATE_IN_PROGRESS AWS::KMS::Key BucketKey -
CREATE_IN_PROGRESS AWS::SNS::Topic NewCallTopic -
CREATE_IN_PROGRESS AWS::IAM::Role BotRuntimeRole Resource creation Initiated
CREATE_IN_PROGRESS AWS::IAM::ManagedPolicy ContactUpdatePolicy Resource creation Initiated
CREATE_FAILED AWS::KMS::Key BucketKey Resource handler returned message: "Policy
contains a statement with one or more
invalid principals. (Service: Kms, Status
Code: 400, Request ID:
d40946d5-37fa-4d3e-b1d1-46b10e78f53e)"
(RequestToken:
6f59b1cc-5d7a-0f21-4f2b-f87b27066031,
HandlerErrorCode: InvalidRequest)
CREATE_IN_PROGRESS AWS::DynamoDB::Table CallTable Resource creation Initiated
CREATE_IN_PROGRESS AWS::DynamoDB::Table SessionTable Resource creation Initiated
CREATE_FAILED AWS::IAM::Role BotRuntimeRole Resource creation cancelled
CREATE_FAILED AWS::IAM::ManagedPolicy ContactUpdatePolicy Resource creation cancelled
CREATE_FAILED AWS::DynamoDB::Table SessionTable Resource creation cancelled
CREATE_FAILED AWS::DynamoDB::Table CallTable Resource creation cancelled
CREATE_FAILED AWS::SNS::Topic NewCallTopic Resource creation cancelled
ROLLBACK_IN_PROGRESS AWS::CloudFormation::Stack connect-chatgpt The following resource(s) failed to create:
[BotRuntimeRole, BucketKey, SessionTable,
NewCallTopic, CallTable,
ContactUpdatePolicy]. Rollback requested by
user.
DELETE_IN_PROGRESS AWS::SNS::Topic NewCallTopic -
DELETE_IN_PROGRESS AWS::DynamoDB::Table CallTable -
DELETE_IN_PROGRESS AWS::IAM::ManagedPolicy ContactUpdatePolicy -
DELETE_IN_PROGRESS AWS::DynamoDB::Table SessionTable -
DELETE_IN_PROGRESS AWS::IAM::Role BotRuntimeRole -
DELETE_COMPLETE AWS::IAM::ManagedPolicy ContactUpdatePolicy -
DELETE_COMPLETE AWS::IAM::Role BotRuntimeRole -
DELETE_COMPLETE AWS::DynamoDB::Table CallTable -
DELETE_COMPLETE AWS::DynamoDB::Table SessionTable -
DELETE_COMPLETE AWS::SNS::Topic NewCallTopic -
DELETE_COMPLETE AWS::KMS::Key BucketKey -
ROLLBACK_COMPLETE AWS::CloudFormation::Stack connect-chatgpt -

Error: Failed to create/update the stack: connect-chatgpt, Waiter StackCreateComplete failed: Waiter encountered a terminal failure state: For expression "Stacks[].StackStatus" we matched expected path: "ROLLBACK_COMPLETE" at least once

docwho2 commented 11 months ago

I updated the template.yml and verified it works correctly. I had policy in there to allow an administrator role to be able to manage the key, but it's really not necessary and the deployment works fine to create and deleting the stack properly schedules the key for deletion. So all good. It's just depending on your role you might not be able to delete it in the UI. I had a role in there that's present only in my account pushed down from SSO. So if you just do a "git pull" you should get the updated template, or remove the this section:

phi16180 commented 11 months ago

Hello Steve,

Thanks for your help!

After deploying the stack successfully, I'm still not able to start a conversation with ChatGPT. When I call the number, I get the default prompt from Connect which offers me to talk to an agent and several other default options. After selecting the option to speak to an agent, I'm transferred to the queue and from the agent dashboard I'm able to pick up the call. How to initiate a conversation with ChatGPT? Are there any specific configurations I need to implement in Connect?

See below the success message after running sam deploy: Initiating deployment

    Uploading to connect-chatgpt/2b7d6a623b19bca5e06adff275cb793d.template  35744 / 35744  (100.00%)

Waiting for changeset to be created..

CloudFormation stack changeset

Operation LogicalResourceId ResourceType Replacement

Changeset created successfully. arn:aws:cloudformation:us-east-1:420557977378:changeSet/samcli-deploy1695179698/adf254c2-3bcc-4875-8df2-245adc23dd81

Previewing CloudFormation changeset before deployment

Deploy this changeset? [y/N]: y

2023-09-20 03:15:38 - Waiting for stack create/update to complete

CloudFormation events from stack operations (refresh every 5.0 seconds)

ResourceStatus ResourceType LogicalResourceId ResourceStatusReason

CREATE_IN_PROGRESS AWS::SNS::Topic NewCallTopic - CREATE_IN_PROGRESS AWS::DynamoDB::Table CallTable - CREATE_IN_PROGRESS AWS::KMS::Key BucketKey - CREATE_IN_PROGRESS AWS::DynamoDB::Table SessionTable - CREATE_IN_PROGRESS AWS::IAM::Role BotRuntimeRole - CREATE_IN_PROGRESS AWS::IAM::ManagedPolicy ContactUpdatePolicy - CREATE_IN_PROGRESS AWS::SNS::Topic NewCallTopic Resource creation Initiated CREATE_IN_PROGRESS AWS::KMS::Key BucketKey Resource creation Initiated CREATE_IN_PROGRESS AWS::IAM::ManagedPolicy ContactUpdatePolicy Resource creation Initiated CREATE_IN_PROGRESS AWS::IAM::Role BotRuntimeRole Resource creation Initiated CREATE_IN_PROGRESS AWS::DynamoDB::Table CallTable Resource creation Initiated CREATE_IN_PROGRESS AWS::DynamoDB::Table SessionTable Resource creation Initiated CREATE_COMPLETE AWS::SNS::Topic NewCallTopic - CREATE_IN_PROGRESS AWS::IAM::Role SendToSNSRole - CREATE_IN_PROGRESS AWS::IAM::Role SendToSNSRole Resource creation Initiated CREATE_COMPLETE AWS::DynamoDB::Table CallTable - CREATE_COMPLETE AWS::IAM::Role BotRuntimeRole - CREATE_COMPLETE AWS::DynamoDB::Table SessionTable - CREATE_IN_PROGRESS AWS::IAM::Role ChatGPTRole - CREATE_IN_PROGRESS AWS::Lex::Bot LexBot - CREATE_IN_PROGRESS AWS::IAM::Role ChatGPTRole Resource creation Initiated CREATE_COMPLETE AWS::IAM::Role SendToSNSRole - CREATE_IN_PROGRESS AWS::Lambda::Function SendToSNS - CREATE_IN_PROGRESS AWS::Lambda::Function SendToSNS Resource creation Initiated CREATE_COMPLETE AWS::IAM::ManagedPolicy ContactUpdatePolicy - CREATE_IN_PROGRESS AWS::IAM::Role NewCallLookupRole - CREATE_IN_PROGRESS AWS::Lex::Bot LexBot Resource creation Initiated CREATE_IN_PROGRESS AWS::IAM::Role NewCallLookupRole Resource creation Initiated CREATE_COMPLETE AWS::Lambda::Function SendToSNS - CREATE_IN_PROGRESS AWS::Connect::IntegrationAssociation SendToSNSConnectIntegration - CREATE_COMPLETE AWS::IAM::Role ChatGPTRole - CREATE_IN_PROGRESS AWS::Connect::IntegrationAssociation SendToSNSConnectIntegration Resource creation Initiated CREATE_COMPLETE AWS::Connect::IntegrationAssociation SendToSNSConnectIntegration - CREATE_IN_PROGRESS AWS::Lambda::Function ChatGPT - CREATE_IN_PROGRESS AWS::Lambda::Function ChatGPT Resource creation Initiated CREATE_COMPLETE AWS::IAM::Role NewCallLookupRole - CREATE_IN_PROGRESS AWS::Lambda::Function NewCallLookup - CREATE_IN_PROGRESS AWS::Lambda::Function NewCallLookup Resource creation Initiated CREATE_COMPLETE AWS::Lambda::Function ChatGPT - CREATE_IN_PROGRESS AWS::Lambda::Permission LexToChatGPTPerm - CREATE_IN_PROGRESS AWS::Lambda::Version ChatGPTVersion972031d1b7 - CREATE_IN_PROGRESS AWS::Lambda::Version ChatGPTVersion972031d1b7 Resource creation Initiated CREATE_IN_PROGRESS AWS::Lambda::Permission LexToChatGPTPerm Resource creation Initiated CREATE_COMPLETE AWS::Lex::Bot LexBot - CREATE_COMPLETE AWS::Lambda::Permission LexToChatGPTPerm - CREATE_IN_PROGRESS AWS::Lex::BotVersion BotVersion - CREATE_COMPLETE AWS::Lambda::Function NewCallLookup - CREATE_IN_PROGRESS AWS::Lex::BotVersion BotVersion Resource creation Initiated CREATE_IN_PROGRESS AWS::Lambda::Version NewCallLookupVersion2ddb8ebfdc - CREATE_IN_PROGRESS AWS::Lambda::Version NewCallLookupVersion2ddb8ebfdc Resource creation Initiated CREATE_COMPLETE AWS::KMS::Key BucketKey - CREATE_IN_PROGRESS AWS::S3::Bucket PromptBucket - CREATE_IN_PROGRESS AWS::S3::Bucket PromptBucket Resource creation Initiated CREATE_COMPLETE AWS::S3::Bucket PromptBucket - CREATE_IN_PROGRESS AWS::IAM::Role PromptCreatorRole - CREATE_IN_PROGRESS AWS::S3::BucketPolicy BucketPolicy - CREATE_IN_PROGRESS AWS::S3::BucketPolicy BucketPolicy Resource creation Initiated CREATE_COMPLETE AWS::S3::BucketPolicy BucketPolicy - CREATE_IN_PROGRESS AWS::IAM::Role PromptCreatorRole Resource creation Initiated CREATE_COMPLETE AWS::IAM::Role PromptCreatorRole - CREATE_IN_PROGRESS AWS::Lambda::Function PromptCreator - CREATE_IN_PROGRESS AWS::Lambda::Function PromptCreator Resource creation Initiated CREATE_COMPLETE AWS::Lambda::Function PromptCreator - CREATE_IN_PROGRESS Custom::PromptCreator LexPromptEnglish - CREATE_IN_PROGRESS Custom::PromptCreator LexPromptSpanish - CREATE_IN_PROGRESS Custom::PromptCreator HelpPromptEnglish - CREATE_IN_PROGRESS Custom::PromptCreator ErrorPromptSpanish - CREATE_IN_PROGRESS Custom::PromptCreator MainPrompt - CREATE_IN_PROGRESS Custom::PromptCreator ErrorPromptEnglish - CREATE_IN_PROGRESS Custom::PromptCreator TransferPromptSpanish - CREATE_IN_PROGRESS Custom::PromptCreator ClosingPromptSpanish - CREATE_IN_PROGRESS Custom::PromptCreator SpanishPrompt - CREATE_IN_PROGRESS Custom::PromptCreator ClosingPromptEnglish - CREATE_IN_PROGRESS Custom::PromptCreator HelpPromptSpanish - CREATE_IN_PROGRESS Custom::PromptCreator TransferPromptEnglish - CREATE_IN_PROGRESS Custom::PromptCreator SpanishPrompt Resource creation Initiated CREATE_IN_PROGRESS Custom::PromptCreator ClosingPromptSpanish Resource creation Initiated CREATE_COMPLETE Custom::PromptCreator SpanishPrompt - CREATE_COMPLETE Custom::PromptCreator ClosingPromptSpanish - CREATE_COMPLETE AWS::Lex::BotVersion BotVersion - CREATE_IN_PROGRESS Custom::PromptCreator ErrorPromptSpanish Resource creation Initiated CREATE_IN_PROGRESS Custom::PromptCreator TransferPromptSpanish Resource creation Initiated CREATE_IN_PROGRESS Custom::PromptCreator HelpPromptEnglish Resource creation Initiated CREATE_IN_PROGRESS Custom::PromptCreator MainPrompt Resource creation Initiated CREATE_IN_PROGRESS Custom::PromptCreator ClosingPromptEnglish Resource creation Initiated CREATE_IN_PROGRESS Custom::PromptCreator ErrorPromptEnglish Resource creation Initiated CREATE_IN_PROGRESS Custom::PromptCreator LexPromptSpanish Resource creation Initiated CREATE_COMPLETE Custom::PromptCreator ErrorPromptSpanish - CREATE_IN_PROGRESS Custom::PromptCreator LexPromptEnglish Resource creation Initiated CREATE_COMPLETE Custom::PromptCreator TransferPromptSpanish - CREATE_COMPLETE Custom::PromptCreator HelpPromptEnglish - CREATE_COMPLETE Custom::PromptCreator MainPrompt - CREATE_COMPLETE Custom::PromptCreator ClosingPromptEnglish - CREATE_COMPLETE Custom::PromptCreator ErrorPromptEnglish - CREATE_COMPLETE Custom::PromptCreator LexPromptSpanish - CREATE_COMPLETE Custom::PromptCreator LexPromptEnglish - CREATE_IN_PROGRESS Custom::PromptCreator TransferPromptEnglish Resource creation Initiated CREATE_COMPLETE Custom::PromptCreator TransferPromptEnglish - CREATE_IN_PROGRESS Custom::PromptCreator HelpPromptSpanish Resource creation Initiated CREATE_COMPLETE Custom::PromptCreator HelpPromptSpanish - CREATE_COMPLETE AWS::Lambda::Version ChatGPTVersion972031d1b7 - CREATE_IN_PROGRESS AWS::Lambda::Alias ChatGPTAliasSNAPSTART - CREATE_IN_PROGRESS AWS::Lambda::Alias ChatGPTAliasSNAPSTART Resource creation Initiated CREATE_COMPLETE AWS::Lambda::Alias ChatGPTAliasSNAPSTART - CREATE_IN_PROGRESS AWS::Lambda::Permission LexToChatGPTSnapPerm - CREATE_IN_PROGRESS AWS::Lex::BotAlias BotAlias - CREATE_IN_PROGRESS AWS::Lambda::Permission LexToChatGPTSnapPerm Resource creation Initiated CREATE_COMPLETE AWS::Lambda::Permission LexToChatGPTSnapPerm - CREATE_IN_PROGRESS AWS::Lex::BotAlias BotAlias Resource creation Initiated CREATE_COMPLETE AWS::Lex::BotAlias BotAlias - CREATE_IN_PROGRESS AWS::Connect::IntegrationAssociation LexV2ConnectIntegration - CREATE_COMPLETE AWS::Lambda::Version NewCallLookupVersion2ddb8ebfdc - CREATE_IN_PROGRESS AWS::Connect::ContactFlow ConnectFlow - CREATE_IN_PROGRESS AWS::Lambda::Alias NewCallLookupAliasSNAPSTART - CREATE_IN_PROGRESS AWS::Lambda::Alias NewCallLookupAliasSNAPSTART Resource creation Initiated CREATE_COMPLETE AWS::Lambda::Alias NewCallLookupAliasSNAPSTART - CREATE_IN_PROGRESS AWS::Connect::IntegrationAssociation LexV2ConnectIntegration Resource creation Initiated CREATE_COMPLETE AWS::Connect::IntegrationAssociation LexV2ConnectIntegration - CREATE_IN_PROGRESS AWS::Connect::ContactFlow ConnectFlow Resource creation Initiated CREATE_IN_PROGRESS AWS::Lambda::Permission NewCallLookupSNSTriggerPermission - CREATE_IN_PROGRESS AWS::SNS::Subscription NewCallLookupSNSTrigger - CREATE_COMPLETE AWS::Connect::ContactFlow ConnectFlow - CREATE_IN_PROGRESS AWS::SNS::Subscription NewCallLookupSNSTrigger Resource creation Initiated CREATE_IN_PROGRESS AWS::Lambda::Permission NewCallLookupSNSTriggerPermission Resource creation Initiated CREATE_COMPLETE AWS::SNS::Subscription NewCallLookupSNSTrigger - CREATE_COMPLETE AWS::Lambda::Permission NewCallLookupSNSTriggerPermission - CREATE_COMPLETE AWS::CloudFormation::Stack connect-chatgpt -

Successfully created/updated stack - connect-chatgpt in us-east-1


From: Steve Jensen @.> Sent: Saturday, September 16, 2023 7:33 AM To: docwho2/java-connect-lex-chatgpt @.> Cc: phi16180 @.>; Author @.> Subject: Re: [docwho2/java-connect-lex-chatgpt] Failed Deployment. (Issue #1)

Closed #1https://github.com/docwho2/java-connect-lex-chatgpt/issues/1 as completed.

— Reply to this email directly, view it on GitHubhttps://github.com/docwho2/java-connect-lex-chatgpt/issues/1#event-10389542947, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AEFSALVOAZISNXNWSHO3WUDX2WFBVANCNFSM6AAAAAA4XD6UXE. You are receiving this because you authored the thread.Message ID: @.***>

docwho2 commented 11 months ago

You have to associate a phone number to flow/script that was deployed per the instructions. You have to login to the connect instance, go to phone numbers and either associate some existing number or provision a new number and then associate to the "connect-chatgpt-gptflow" contact flow.

phi16180 commented 11 months ago

Thank you so much for your support. The project is awesome and it's working fine. You've done a great job!