hashicorp / terraform-provider-aws

The AWS Provider enables Terraform to manage AWS resources.
https://registry.terraform.io/providers/hashicorp/aws
Mozilla Public License 2.0
9.63k stars 9.01k forks source link

[Bug]: Unable to create lexv2 model slot type #36849

Open npenin opened 3 months ago

npenin commented 3 months ago

Terraform Core Version

1.6.6,1.8.0

AWS Provider Version

5.44.0

Affected Resource(s)

Expected Behavior

runs without error success

Actual Behavior

creashes with the below error message

Relevant Error/Panic Output Snippet

Error: Unable to Convert Configuration
│ 
│   with aws_lexv2models_slot_type.slots,
│   on main.tf line 178, in resource "aws_lexv2models_slot_type" "slots":
│  178: resource "aws_lexv2models_slot_type" "slots" {
│ 
│ An unexpected error was encountered when converting the configuration from the protocol type. This is always an issue in terraform-plugin-framework
│ used to implement the provider and should be reported to the provider developers.
│ 
│ Please report this to the provider developer:
│ 
│ Unable to unmarshal DynamicValue: AttributeName("slot_type_values").ElementKeyInt(0): unknown attribute "slot_type_value"

Terraform Configuration Files

terraform {
  required_providers {
    aws = {
      source                = "hashicorp/aws"
      version               = ">= 5.31.0"
      configuration_aliases = [aws]
    }

    local = {
      source  = "hashicorp/local"
      version = "~> 2.4.0"
    }
  }

  backend "s3" {
    bucket = "medzie-terraform2"
    key    = "ai"
    region = "eu-west-3"
  }

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

resource "aws_iam_role_policy_attachment" "tts" {
  role=aws_iam_role.airole.arn
  policy_arn = "arn:aws:iam::aws:policy/aws-service-role/AmazonLexV2BotPolicy"
}

resource "aws_lexv2models_bot" "ai" {
  name = "ai"
  data_privacy {
    child_directed = false
  }
  idle_session_ttl_in_seconds = 3600
  role_arn                    = aws_iam_role.airole.arn
}

resource "aws_lexv2models_bot_locale" "locales" {
  for_each = local.locales
  bot_id = aws_lexv2models_bot.ai.id
  bot_version = "DRAFT"
  locale_id = each.value.locale_id
  n_lu_intent_confidence_threshold = 0.70

  voice_settings {
    voice_id = each.value.voice_id
    engine = each.value.engine
  }
}

locals{
    locales={
      fr={locale_id="fr-FR", voice_id="Lea", engine="neural"},
      en={locale_id="en-US", voice_id="Danielle", engine="neural"},
      de={locale_id="de-DE", voice_id="Vicky", engine="neural"}
    }
    slots=tolist(["a"])
    localizedSlots={for x in flatten([for locale, _ in local.locales: [for slot in local.slots: {key="${locale}-${slot}", locale=locale, slot=slot }]]): x.key=>x}
}

resource "aws_lexv2models_slot_type" "slots" {
  for_each    = local.localizedSlots
  bot_id      = aws_lexv2models_bot.ai.id
  bot_version = aws_lexv2models_bot_locale.locales[each.value.locale].bot_version
  name        = each.key
  locale_id   = aws_lexv2models_bot_locale.locales[each.value.locale].locale_id

  slot_type_values  {
    slot_type_value {
       value = "a"
    }
  }
}

Steps to Reproduce

just run apply

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

No response

Would you like to implement a fix?

None

github-actions[bot] commented 3 months ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue

npenin commented 3 months ago

Please also note the documentation is not consistent with the actually expected bloc names

cuongdev commented 1 month ago

I met the same issues, have you found another way to create a custom slot yet @npenin ?

npenin commented 1 month ago

unfortunately, no. I had to do it manually. Since there were no feedback on this issue, I guess it will not be fixed any time soon :(