Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Lex Bot Resource Creation/Update Fails with Provider State Inconsistency Error #2091

Open
fakhtar opened this issue Nov 7, 2024 · 0 comments

Comments

@fakhtar
Copy link

fakhtar commented Nov 7, 2024

Issue: Lex Bot Resource Creation/Update Fails with Provider State Inconsistency Error

Description

When creating or updating an awscc_lex_bot resource, the provider fails during terraform apply with a state inconsistency error related to the bot_locales attribute. The error occurs both during initial creation and subsequent updates of the bot but the bot is created successfully.

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 AWSCC Provider Version: 1.19.0 (also reproduced in 1.17.0)
  • Terraform Version: hashicorp/terraform:1.9.6 running docker contains in GitLab CI CD pipeline.
  • AWS Region: us-east-1

terraform -v
Terraform v1.9.6
on linux_amd64

Affected Resource(s)

  • awscc_lex_bot

Terraform Configuration Files

terraform {
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "~> 5.0"
    }
    awscc = {
      source  = "hashicorp/awscc"
      version = "~> 1.19.0"
    }
  }
  backend "s3" {}
}


provider "awscc" {
  region = var.region
  assume_role = {
    role_arn = var.resource_role_arn
  }
}

provider "aws" {
  region = var.region
  assume_role {
    role_arn = var.resource_role_arn
  }
}

resource "awscc_lex_bot" "demo_lexv2_bot" {
  name     = "botTest"
  role_arn = aws_iam_role.lex_role.arn
  data_privacy = {
    child_directed = false
  }
  idle_session_ttl_in_seconds = 300
  auto_build_bot_locales      = true
  bot_locales = [
    {
      locale_id                = "en_US",
      nlu_confidence_threshold = 0.7,
      voice_settings = {
        engine   = "standard"
        voice_id = "Kevin"
      },
      intents = [
        {
          name = "Sales",
          sample_utterances = [
            {
              utterance = "sales"
            }
          ],
          dialog_code_hook = {
            enabled = false
          },
          fulfillment_code_hook = {
            enabled = false
          }
        },
        {
          name = "Finance",
          sampleUtterances = [
            {
              utterance = "finance"
            }
          ],
          dialogCodeHook = {
            enabled = false
          },
          fulfillment_codeHook = {
            enabled = false
          }
        },
        {
          name        = "FallbackIntent",
          description = "Default intent when no other intent matches",
          dialog_code_hook = {
            enabled = false
          },
          fulfillment_code_hook = {
            enabled = false
          },
          parent_intent_signature = "AMAZON.FallbackIntent"
        }
      ]
    }
  ]
}

resource "aws_iam_role" "lex_role" {
  name = "lex_bot_role"

  assume_role_policy = jsonencode({
    Version = "2012-10-17"
    Statement = [
      {
        Action = "sts:AssumeRole"
        Effect = "Allow"
        Principal = {
          Service = "lexv2.amazonaws.com"
        }
      }
    ]
  })
}

Debug Output

Including 2 Gist
Default
https://gist.github.com/fakhtar/aeefd167a90c0a7396e8f0dafc426cc2
Log Level TRACE
https://gist.github.com/fakhtar/deb7880618ddc2285050e8d46c6aead8

Panic Output

Expected Behavior

  1. Configure the AWSCC provider:
provider "awscc" {
  region = var.region
  assume_role = {
    role_arn = var.resource_role_arn
  }
}
  1. Create a minimal Lex bot configuration:
resource "awscc_lex_bot" "demo_lexv2_bot" {
  name     = "botTest"
  role_arn = aws_iam_role.lex_role.arn
  data_privacy = {
    child_directed = false
  }
  idle_session_ttl_in_seconds = 300
  auto_build_bot_locales      = true
  bot_locales = [
    {
      locale_id                = "en_US"
      nlu_confidence_threshold = 0.7
      voice_settings = {
        engine   = "standard"
        voice_id = "Kevin"
      }
      intents = [
        {
          name = "Sales"
          sample_utterances = [
            {
              utterance = "sales"
            }
          ]
          dialog_code_hook = {
            enabled = false
          }
          fulfillment_code_hook = {
            enabled = false
          }
        },
        {
          name        = "FallbackIntent"
          description = "Default intent when no other intent matches"
          dialog_code_hook = {
            enabled = false
          }
          fulfillment_code_hook = {
            enabled = false
          }
          parent_intent_signature = "AMAZON.FallbackIntent"
        }
      ]
    }
  ]
}
  1. Run terraform plan
  2. Run terraform apply
  3. Bot creation should complete successfully without errors.

Actual Behavior

Steps to Reproduce

  1. Configure the AWSCC provider:
provider "awscc" {
  region = var.region
  assume_role = {
    role_arn = var.resource_role_arn
  }
}
  1. Create a minimal Lex bot configuration:
resource "awscc_lex_bot" "demo_lexv2_bot" {
  name     = "botTest"
  role_arn = aws_iam_role.lex_role.arn
  data_privacy = {
    child_directed = false
  }
  idle_session_ttl_in_seconds = 300
  auto_build_bot_locales      = true
  bot_locales = [
    {
      locale_id                = "en_US"
      nlu_confidence_threshold = 0.7
      voice_settings = {
        engine   = "standard"
        voice_id = "Kevin"
      }
      intents = [
        {
          name = "Sales"
          sample_utterances = [
            {
              utterance = "sales"
            }
          ]
          dialog_code_hook = {
            enabled = false
          }
          fulfillment_code_hook = {
            enabled = false
          }
        },
        {
          name        = "FallbackIntent"
          description = "Default intent when no other intent matches"
          dialog_code_hook = {
            enabled = false
          }
          fulfillment_code_hook = {
            enabled = false
          }
          parent_intent_signature = "AMAZON.FallbackIntent"
        }
      ]
    }
  ]
}
  1. Run terraform plan (completes successfully)
  2. Run terraform apply (fails with above error)

Steps to Reproduce

Important Factoids

  • The error occurs consistently across multiple provider versions (1.17.0, 1.19.0)
  • The issue manifests both during initial creation and updates of the bot
  • terraform plan completes successfully, suggesting the configuration is valid
  • The error appears to be related to state handling within the provider, specifically around the bot_locales attribute
  • The error occurs in both CI/CD pipeline and is expected to reproduce locally

Possible Impact

This issue prevents the creation and management of Lex bots through Terraform, requiring manual intervention or alternative approaches.

References

  • #0000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant