terraform-provider-awscc icon indicating copy to clipboard operation
terraform-provider-awscc copied to clipboard

Long deploy time for Lex bot and validation errors

Open joelzhuang opened this issue 2 years ago • 5 comments

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment
  • The resources and data sources in this provider are generated from the CloudFormation schema, so they can only support the actions that the underlying schema supports. For this reason submitted bugs should be limited to defects in the generation and runtime code of the provider. Customizing behavior of the resource, or noting a gap in behavior are not valid bugs and should be submitted as enhancements to AWS via the CloudFormation Open Coverage Roadmap.

Terraform CLI and Terraform AWS Cloud Control Provider Version

Terraform v1.2.2 on linux_amd64

  • provider registry.terraform.io/hashicorp/aws v4.18.0
  • provider registry.terraform.io/hashicorp/awscc v0.24.0

Affected Resource(s)

  • awscc_lex_bot

Terraform Configuration Files

Please include all Terraform configurations required to reproduce the bug. Bug reports without a functional reproduction may be closed without investigation.

terraform {
  required_providers {
    #
    awscc = {
      source  = "hashicorp/awscc"
      version = "0.24.0"
    }
    aws = {
      source  = "hashicorp/aws"
      version = "~> 4.17"
    }
  }
}

# Configure the AWS Provider
provider "awscc" {
  region = "ap-southeast-2"
}
provider "aws" {
  region = "ap-southeast-2"
}

# Lex variables
variable "nlu_confidence_threshold" {
  description = "nlu_confidence_threshold"
  type        = number
  default     = 0.5
}

# Create my first bot (empty)
resource "awscc_lex_bot" "demo_lexv2_bot" {
  name     = "testBot"
  # role_arn = aws_iam_service_linked_role.lex_service_role.arn
  role_arn = "arn:aws:iam::<account-id>:role/aws-service-role/lexv2.amazonaws.com/AWSServiceRoleForLexV2Bots"
  data_privacy = {
    child_directed = false
  }
  idle_session_ttl_in_seconds = 300
  bot_locales = [
    {
      locale_id                = "en_AU"
      nlu_confidence_threshold = var.nlu_confidence_threshold
      slot_types = [
        {
          name = "Slot1"
          slot_type_values = [
            {
              sample_value = {
                value="test"
              }
            }
          ],
          value_selection_setting = {
            resolution_strategy = "ORIGINAL_VALUE"
          }
        }
      ],
      intents = [
        {
          name        = "testIntent"
          description = "test description"
          sample_utterances = [
            {
              utterance = "hello"
            },
            {
              utterance = "hi"
            }
          ]
          slots = [
            {
              name           = "SlotIntent1"
              slot_type_name = "Slot1"
              value_elicitation_setting = {
                slot_constraint = "Required"
                prompt_specification = {
                  max_retries = 1
                  message_groups_list = [
                    {
                      message = {
                        plain_text_message = {
                          value = "I need a slot thanks"
                        }
                      }
                    }
                  ]
                }
              }
            }
          ]
        },
        {
          name                    = "FallbackIntent"
          description             = "test description"
          parent_intent_signature = "AMAZON.FallbackIntent"
          # sample_utterances = [
          #   {
          #     utterance = "test"
          #   }
          # ]
          slots = [
            {
              name           = "fallbackSlot"
              slot_type_name = "Slot1"
              value_elicitation_setting = {
                slot_constraint = "Required"
                prompt_specification = {
                  max_retries = 1
                  message_groups_list = [
                    {
                      message = {
                        plain_text_message = {
                          value = "I need a slot thanks"
                        }
                      }
                    }
                  ]
                }
              }
            }
          ]
        }
      ]
    },
  ]


}

Debug Output

│ Error: AWS SDK Go Service Operation Incomplete
│ 
│   with awscc_lex_bot.demo_lexv2_bot,
│   on main.tf line 39, in resource "awscc_lex_bot" "demo_lexv2_bot":
│   39: resource "awscc_lex_bot" "demo_lexv2_bot" {
│ 
│ Waiting for Cloud Control API service CreateResource operation completion
│ returned: waiter state transitioned to FAILED. StatusMessage: Importing
│ 3bottest3 failed due to [Unable to create or update Slot that extends a
│ builtin intent of type AMAZON.FallbackIntent.]. The import could not be
│ completed.. ErrorCode: InvalidRequest
╵

Note: I've created another issue regarding why I added slots to the fallback intent https://github.com/hashicorp/terraform-provider-awscc/issues/547

Expected Behavior

Deploy the LexV2 bot within a reasonable timeframe (minutes)

Actual Behavior

LexV2 bot with 2 intents, one custom slot type and one slot takes more than an hour to deploy, often resulting in an error at the end, either because the credentials expire, or the error mentioned above.

It seems the deployment takes a long time after the slots attribute is added to the intent. (I've also done tests with slot_types without slots, and it deploys fine)

Steps to Reproduce

  1. terraform apply
  • #0000

joelzhuang avatar Jun 14 '22 07:06 joelzhuang

Have the same issue, we're urgent in our project to implement this, could someone please help? Thanks

When creating a bot without slots, it's fast, less than 30 seconds. Then after adding 1 slot, terraform validate turns to very slow, took several minutes, terraform apply is only showing this after ~10 minutes

awscc_lex_bot.demo_lexv2_bot: Refreshing state... [id=4H7KKR8QAY]

hs79hs avatar Jun 16 '22 00:06 hs79hs

Is there an update on this ticket. No assignees to this ticket still

ronilp1 avatar Jul 12 '22 01:07 ronilp1

I had something similar, the deploy time was not hour but still 5 minutes for a simple change or so, and during Refreshing state CPU usage of terraform-awscc-provider went up to 140%... macOS 12.5

gevial avatar Aug 10 '22 10:08 gevial

Having very similar issues. Deploy terraform a lot with no issues. Started using the AWSCC provider to deploy a Lex bot. Facing very long state refresh times and sporadically long deploy times. Any update on this issue? Would love to know if I should just stop using it for now?

Trying to decide whether the project should start using the AWSCC provider for other resource deployments.

phill0555 avatar Feb 07 '23 16:02 phill0555

Same thing here.

I decided to just replace awscc with a regular aws_cloudformation_stack resource and write it all inside a jsonencode() since LexV2 can be deployed that way too, and it's a lot faster at determining the differences.

hnryjms avatar Nov 02 '23 00:11 hnryjms