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

Terraform requires all Lex intents to follow the same structure

Open joelzhuang opened this issue 2 years ago • 4 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     = "botTestNoSlots"
  # 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"
        }
      ]
    },
  ]


}

Debug Output

From debug log: [ERROR] vertex "awscc_lex_bot.demo_lexv2_bot" error: Incorrect attribute value type

From command output: Inappropriate value for attribute "bot_locales": element types must all match for conversion to set.

Expected Behavior

Deploys both intents

Actual Behavior

Errors when the structure is different, if I copy the slots attribute from the testIntent back into the fallback intent, it does not produce the error. However fallback intents should not have any slots.

Steps to Reproduce

  1. terraform apply
  • #0000

joelzhuang avatar Jun 14 '22 06:06 joelzhuang

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

ronilp1 avatar Jul 12 '22 01:07 ronilp1

Have the same issue with provider version 0.29.0. Makes the provider unusable for me.

gevial avatar Aug 10 '22 12:08 gevial

Ok, the workaround is to use aws_cloudcontrolapi_resource resource with type_name = "AWS::Lex::Bot".

There's a caveat though, if you have an error in slot types for example, the language is not created, but the bot itself does. And Terraform won't know about that, still trying to create the bot on the next run.

gevial avatar Aug 10 '22 13:08 gevial

😢 I am getting issues with some things in the API that are not implemented. Example, the initialResponseSetting is important to move from one intent to another with a condition InitialResponseSetting - Amazon Lex API Reference

victor-teran-rs-old avatar Apr 05 '23 13:04 victor-teran-rs-old