aws-amplify / amplify-cli

The AWS Amplify CLI is a toolchain for simplifying serverless web and mobile development.
Apache License 2.0
2.82k stars 820 forks source link

Interactions hang while replicating settings per environment #6347

Closed patweb99 closed 3 years ago

patweb99 commented 3 years ago

Describe the bug After setting up an interaction category within an environment (eg dev) successfully, it will fail through cloudformation when attempting to configure within another environment (eg test). After digging deeper, I found this is because Amplify attempts to create a pre-existing intent that was already created through the dev environment.

Since amplify creates resources with the environment prefix (eg dev, test) would it make sense to also build out the intent resources in a similar manner?

To Reproduce

  1. Create Interactions category in dev environment
  2. Checkout test environment
  3. Runamplify push -y in the test environment
  4. Cloudformation hangs

See error { "errorType": "Runtime.UnhandledPromiseRejection", "errorMessage": "ResourceConflictException: The statement id (Lex-words1a103c15) provided already exists. Please provide a new statement id, or remove the existing statement.", "reason": { "errorType": "ResourceConflictException", "errorMessage": "The statement id (Lex-words1a103c15) provided already exists. Please provide a new statement id, or remove the existing statement.", "code": "ResourceConflictException", "message": "The statement id (Lex-words1a103c15) provided already exists. Please provide a new statement id, or remove the existing statement.", "time": "2021-01-08T19:50:53.967Z", "requestId": "1a4e8e6b-3b28-4b7c-8f4a-f90f884b9197", "statusCode": 409, "retryable": false, "retryDelay": 25.416709266030146, "stack": [ "ResourceConflictException: The statement id (Lex-words1a103c15) provided already exists. Please provide a new statement id, or remove the existing statement.", " at Object.extractError (/var/runtime/node_modules/aws-sdk/lib/protocol/json.js:52:27)", " at Request.extractError (/var/runtime/node_modules/aws-sdk/lib/protocol/rest_json.js:55:8)", " at Request.callListeners (/var/runtime/node_modules/aws-sdk/lib/sequential_executor.js:106:20)", " at Request.emit (/var/runtime/node_modules/aws-sdk/lib/sequential_executor.js:78:10)", " at Request.emit (/var/runtime/node_modules/aws-sdk/lib/request.js:688:14)", " at Request.transition (/var/runtime/node_modules/aws-sdk/lib/request.js:22:10)", " at AcceptorStateMachine.runTo (/var/runtime/node_modules/aws-sdk/lib/state_machine.js:14:12)", " at /var/runtime/node_modules/aws-sdk/lib/state_machine.js:26:10", " at Request. (/var/runtime/node_modules/aws-sdk/lib/request.js:38:9)", " at Request. (/var/runtime/node_modules/aws-sdk/lib/request.js:690:12)" ] }, "promise": {}, "stack": [ "Runtime.UnhandledPromiseRejection: ResourceConflictException: The statement id (Lex-words1a103c15) provided already exists. Please provide a new statement id, or remove the existing statement.", " at process.on (/var/runtime/index.js:37:15)", " at process.emit (events.js:198:13)", " at process.EventEmitter.emit (domain.js:448:20)", " at emitPromiseRejectionWarnings (internal/process/promises.js:140:18)", " at process._tickCallback (internal/process/next_tick.js:69:34)" ] }

edwardfoyle commented 3 years ago

@patweb99 I wan't able to repro this in a new project (I used the "BookTrip" sample chatbot when adding the interactions category). Did you modify the lex resource at all? Also what version of the CLI are you using?

patweb99 commented 3 years ago

Hi @edwardfoyle, gotcha. That's good to know. I've only tried with my own project and have not changed any of the lex resources. I will try from scratch with the BookTrip example to see if that works for me.

I'm currently on version 4.41.0.

Can you share the Q&A's that you answered while setting up your Amplify environment? This way I can mirror exactly what you did.

Thank you

edwardfoyle commented 3 years ago

I ran:

$ yes '' | amplify init
$ yes '' | amplify add interactions
$ amplify push --yes
$ amplify env add // named test using default profile
$ amplify push --yes
patweb99 commented 3 years ago

@edwardfoyle I noticed that you are apply "yes" to add interactions to bypass questions. Can you try adding a Lambda to the Fulfillment Lex option? I have that in place within my app and may be the issue.

Here is the questions and answers I went through

? Provide a friendly resource name that will be used to label this category in the 
project: SightWords
? Would you like to start with a sample chatbot or start from scratch? Start from s
cratch
? Enter a name for your bot: SightWords
? Choose an output voice: Female
? After how long should the session timeout (in minutes)? 5
? Please indicate if your use of this bot is subject to the Children's Online Priva
cy Protection Act (COPPA).
Learn more: https://www.ftc.gov/tips-advice/business-center/guidance/complying-copp
a-frequently-asked-questions Yes
You must obtain any required verifiable parental consent under COPPA.
First create an intent for your new chatbot. An intent represents an action that the user wants to perform.
? Give a unique name for the new intent: NewApp
? Enter a sample utterance (spoken or typed phrase that invokes your intent. e.g. B
ook a hotel) Start
? Would you like to add another utterance? No
Now, add a slot to your intent. A slot is data the user must provide to fulfill the intent.
? Enter a name for your slot (e.g. Location) word
? Would you like to choose an Amazon built-in slot type, a slot type you've already
 made, or create a new slot type? Create a new slot type
? What would you like to name your slot type? YesNo
? Give a description of your slot type: YesNo
? Add a possible value for your slot: yes
? Add another slot value? Yes
? Add a possible value for your slot: no
? Add another slot value? No
? Enter a prompt for your slot (e.g. What city?) Ready?
? Should this slot be required? Yes
? Would you like to add another slot? No
? Would you like to add a confirmation prompt to your intent? No
? How would you like the intent to be fulfilled? AWS Lambda Function
? Select a Lambda function amplifycloudfrontc7f79966-test (my own function i uploaded through amplify function)
? Would you like to create another intent? No
edwardfoyle commented 3 years ago

Hey @patweb99 thanks for the detailed repro steps! I was able to repro the bug.

As a workaround, you can modify the custom CFN labmda that spins up the Lex resource as follows: In index.js around line 30 modify it to:

let intentParams = [

        {
            "name": `NewApp_${process.env.ENV}`,
github-actions[bot] commented 3 years ago

This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs.

Looking for a help forum? We recommend joining the Amplify Community Discord server *-help channels for those types of questions.