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.87k stars 9.21k forks source link

[Bug]: aws_lexv2models_slot resource cannot create slot #36845

Closed mohan-reviewer1 closed 3 months ago

mohan-reviewer1 commented 7 months ago

Terraform Core Version

1.3.6

AWS Provider Version

5.44.0

Affected Resource(s)

aws_lexv2models_slot

Expected Behavior

Would expect that a slot with an elicitation prompt would be created after converting the block:

resource "aws_lexv2models_slot" "fill_timeshet_duration" {
  bot_id      = aws_lexv2models_bot.fill_timeshet.id
  bot_version =  aws_lexv2models_bot_locale.fill_timeshet_locale.bot_version
  locale_id   =  aws_lexv2models_bot_locale.fill_timeshet_locale.locale_id
  intent_id   = aws_lexv2models_intent.fill_timeshet.intent_id
  name        = "Duration"
  slot_type_id = "AMAZON.Duration"

  value_elicitation_setting {
    slot_constraint = "Required"

    prompt_specification {
      message_group {
       message {
         plain_text_message {
           value = "Please Enter Duration"
         }
       }
      }

      max_retries = 4
      allow_interrupt = true
    }
  }
}

Actual Behavior

The Error message pasted below is shown. I'm not able apply

Relevant Error/Panic Output Snippet

╷
│ Error: Provider produced inconsistent result after apply
│ 
│ When applying changes to module.lexv2.aws_lexv2models_slot.fill_timeshet_duration, provider
│ "provider[\"registry.terraform.io/hashicorp/aws\"]" produced an unexpected new value:
│ .value_elicitation_setting[0].prompt_specification[0].message_selection_strategy: was null, but now
│ cty.StringVal("Random").
│ 
│ This is a bug in the provider, which should be reported in the provider's own issue tracker.
╵
╷
│ Error: Provider produced inconsistent result after apply
│ 
│ When applying changes to module.lexv2.aws_lexv2models_slot.fill_timeshet_duration, provider
│ "provider[\"registry.terraform.io/hashicorp/aws\"]" produced an unexpected new value:
│ .value_elicitation_setting[0].prompt_specification[0].prompt_attempts_specification: actual set element
│ cty.ObjectVal(map[string]cty.Value{"allow_interrupt":cty.True,
│ "allowed_input_types":cty.ListVal([]cty.Value{cty.ObjectVal(map[string]cty.Value{"allow_audio_input":cty.True,
│ "allow_dtmf_input":cty.True})}),
│ "audio_and_dtmf_input_specification":cty.ListVal([]cty.Value{cty.ObjectVal(map[string]cty.Value{"audio_specification":cty.ListVal([]cty.Value{cty.ObjectVal(map[string]cty.Value{"end_timeout_ms":cty.NumberIntVal(640),
│ "max_length_ms":cty.NumberIntVal(15000)})}),
│ "dtmf_specification":cty.ListVal([]cty.Value{cty.ObjectVal(map[string]cty.Value{"deletion_character":cty.StringVal("*"),
│ "end_character":cty.StringVal("#"), "end_timeout_ms":cty.NumberIntVal(5000),
│ "max_length":cty.NumberIntVal(513)})}), "start_timeout_ms":cty.NumberIntVal(4000)})}),
│ "map_block_key":cty.StringVal("Initial"),
│ "text_input_specification":cty.ListVal([]cty.Value{cty.ObjectVal(map[string]cty.Value{"start_timeout_ms":cty.NumberIntVal(30000)})})})
│ does not correlate with any element in plan.
│ 
│ This is a bug in the provider, which should be reported in the provider's own issue tracker.
╵
╷
│ Error: Provider produced inconsistent result after apply
│ 
│ When applying changes to module.lexv2.aws_lexv2models_slot.fill_timeshet_duration, provider
│ "provider[\"registry.terraform.io/hashicorp/aws\"]" produced an unexpected new value:
│ .value_elicitation_setting[0].prompt_specification[0].prompt_attempts_specification: actual set element
│ cty.ObjectVal(map[string]cty.Value{"allow_interrupt":cty.True,
│ "allowed_input_types":cty.ListVal([]cty.Value{cty.ObjectVal(map[string]cty.Value{"allow_audio_input":cty.True,
│ "allow_dtmf_input":cty.True})}),
│ "audio_and_dtmf_input_specification":cty.ListVal([]cty.Value{cty.ObjectVal(map[string]cty.Value{"audio_specification":cty.ListVal([]cty.Value{cty.ObjectVal(map[string]cty.Value{"end_timeout_ms":cty.NumberIntVal(640),
│ "max_length_ms":cty.NumberIntVal(15000)})}),
│ "dtmf_specification":cty.ListVal([]cty.Value{cty.ObjectVal(map[string]cty.Value{"deletion_character":cty.StringVal("*"),
│ "end_character":cty.StringVal("#"), "end_timeout_ms":cty.NumberIntVal(5000),
│ "max_length":cty.NumberIntVal(513)})}), "start_timeout_ms":cty.NumberIntVal(4000)})}),
│ "map_block_key":cty.StringVal("Retry1"),
│ "text_input_specification":cty.ListVal([]cty.Value{cty.ObjectVal(map[string]cty.Value{"start_timeout_ms":cty.NumberIntVal(30000)})})})
│ does not correlate with any element in plan.
│ 
│ This is a bug in the provider, which should be reported in the provider's own issue tracker.
╵
╷
│ Error: Provider produced inconsistent result after apply
│ 
│ When applying changes to module.lexv2.aws_lexv2models_slot.fill_timeshet_duration, provider
│ "provider[\"registry.terraform.io/hashicorp/aws\"]" produced an unexpected new value:
│ .value_elicitation_setting[0].prompt_specification[0].prompt_attempts_specification: actual set element
│ cty.ObjectVal(map[string]cty.Value{"allow_interrupt":cty.True,
│ "allowed_input_types":cty.ListVal([]cty.Value{cty.ObjectVal(map[string]cty.Value{"allow_audio_input":cty.True,
│ "allow_dtmf_input":cty.True})}),
│ "audio_and_dtmf_input_specification":cty.ListVal([]cty.Value{cty.ObjectVal(map[string]cty.Value{"audio_specification":cty.ListVal([]cty.Value{cty.ObjectVal(map[string]cty.Value{"end_timeout_ms":cty.NumberIntVal(640),
│ "max_length_ms":cty.NumberIntVal(15000)})}),
│ "dtmf_specification":cty.ListVal([]cty.Value{cty.ObjectVal(map[string]cty.Value{"deletion_character":cty.StringVal("*"),
│ "end_character":cty.StringVal("#"), "end_timeout_ms":cty.NumberIntVal(5000),
│ "max_length":cty.NumberIntVal(513)})}), "start_timeout_ms":cty.NumberIntVal(4000)})}),
│ "map_block_key":cty.StringVal("Retry2"),
│ "text_input_specification":cty.ListVal([]cty.Value{cty.ObjectVal(map[string]cty.Value{"start_timeout_ms":cty.NumberIntVal(30000)})})})
│ does not correlate with any element in plan.
│ 
│ This is a bug in the provider, which should be reported in the provider's own issue tracker.
╵
╷
│ Error: Provider produced inconsistent result after apply
│ 
│ When applying changes to module.lexv2.aws_lexv2models_slot.fill_timeshet_duration, provider
│ "provider[\"registry.terraform.io/hashicorp/aws\"]" produced an unexpected new value:
│ .value_elicitation_setting[0].prompt_specification[0].prompt_attempts_specification: actual set element
│ cty.ObjectVal(map[string]cty.Value{"allow_interrupt":cty.True,
│ "allowed_input_types":cty.ListVal([]cty.Value{cty.ObjectVal(map[string]cty.Value{"allow_audio_input":cty.True,
│ "allow_dtmf_input":cty.True})}),
│ "audio_and_dtmf_input_specification":cty.ListVal([]cty.Value{cty.ObjectVal(map[string]cty.Value{"audio_specification":cty.ListVal([]cty.Value{cty.ObjectVal(map[string]cty.Value{"end_timeout_ms":cty.NumberIntVal(640),
│ "max_length_ms":cty.NumberIntVal(15000)})}),
│ "dtmf_specification":cty.ListVal([]cty.Value{cty.ObjectVal(map[string]cty.Value{"deletion_character":cty.StringVal("*"),
│ "end_character":cty.StringVal("#"), "end_timeout_ms":cty.NumberIntVal(5000),
│ "max_length":cty.NumberIntVal(513)})}), "start_timeout_ms":cty.NumberIntVal(4000)})}),
│ "map_block_key":cty.StringVal("Retry3"),
│ "text_input_specification":cty.ListVal([]cty.Value{cty.ObjectVal(map[string]cty.Value{"start_timeout_ms":cty.NumberIntVal(30000)})})})
│ does not correlate with any element in plan.
│ 
│ This is a bug in the provider, which should be reported in the provider's own issue tracker.
╵
╷
│ Error: Provider produced inconsistent result after apply
│ 
│ When applying changes to module.lexv2.aws_lexv2models_slot.fill_timeshet_duration, provider
│ "provider[\"registry.terraform.io/hashicorp/aws\"]" produced an unexpected new value:
│ .value_elicitation_setting[0].prompt_specification[0].prompt_attempts_specification: actual set element
│ cty.ObjectVal(map[string]cty.Value{"allow_interrupt":cty.True,
│ "allowed_input_types":cty.ListVal([]cty.Value{cty.ObjectVal(map[string]cty.Value{"allow_audio_input":cty.True,
│ "allow_dtmf_input":cty.True})}),
│ "audio_and_dtmf_input_specification":cty.ListVal([]cty.Value{cty.ObjectVal(map[string]cty.Value{"audio_specification":cty.ListVal([]cty.Value{cty.ObjectVal(map[string]cty.Value{"end_timeout_ms":cty.NumberIntVal(640),
│ "max_length_ms":cty.NumberIntVal(15000)})}),
│ "dtmf_specification":cty.ListVal([]cty.Value{cty.ObjectVal(map[string]cty.Value{"deletion_character":cty.StringVal("*"),
│ "end_character":cty.StringVal("#"), "end_timeout_ms":cty.NumberIntVal(5000),
│ "max_length":cty.NumberIntVal(513)})}), "start_timeout_ms":cty.NumberIntVal(4000)})}),
│ "map_block_key":cty.StringVal("Retry4"),
│ "text_input_specification":cty.ListVal([]cty.Value{cty.ObjectVal(map[string]cty.Value{"start_timeout_ms":cty.NumberIntVal(30000)})})})
│ does not correlate with any element in plan.
│ 
│ This is a bug in the provider, which should be reported in the provider's own issue tracker.
╵
╷
│ Error: Provider produced inconsistent result after apply
│ 
│ When applying changes to module.lexv2.aws_lexv2models_slot.fill_timeshet_duration, provider
│ "provider[\"registry.terraform.io/hashicorp/aws\"]" produced an unexpected new value:
│ .value_elicitation_setting[0].prompt_specification[0].prompt_attempts_specification: block set length changed
│ from 0 to 5.
│ 
│ This is a bug in the provider, which should be reported in the provider's own issue tracker.
╵
Releasing state lock. This may take a few moments...

Terraform Configuration Files

awslexv2bot.zip

Steps to Reproduce

terraform init terraform plan

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 7 months ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue

repl-mohan-krishna commented 7 months ago

@justinretzolk will it take time fix this issue?

jar-b commented 3 months ago

Hey @mohan-reviewer1 👋 - Thanks for the report.

The inconsistent result after apply is caused by AWS returning a default configuration for value_elicitation_setting.prompt_specification.prompt_attempt_specification which the provider cannot currently suppress differences for.

Updating the configuration to contain the appropriate prompt_attempt_specification blocks should allow the apply operation to complete successfully. Here is an example similar to the configuration above (I’ve reduced the number of retry attempts to 1, as each retry will have a corresponding attempt specification block and I wanted to keep the example small-ish).

resource "aws_lexv2models_slot" "test" {
  bot_id      = aws_lexv2models_bot.test.id
  bot_version = aws_lexv2models_bot_locale.test.bot_version
  intent_id   = aws_lexv2models_intent.test.intent_id
  name        = "jb-test"
  locale_id   = aws_lexv2models_bot_locale.test.locale_id

  value_elicitation_setting {
    slot_constraint = "Required"
    prompt_specification {
      allow_interrupt            = true
      max_retries                = 1
      message_selection_strategy = "Random"

      message_group {
        message {
          plain_text_message {
            value = "What is your favorite color?"
          }
        }
      }

      # Match AWS defaults for "Initial"
      prompt_attempts_specification {
        allow_interrupt = true
        map_block_key   = "Initial"

        allowed_input_types {
          allow_audio_input = true
          allow_dtmf_input  = true
        }

        audio_and_dtmf_input_specification {
          start_timeout_ms = 4000

          audio_specification {
            end_timeout_ms = 640
            max_length_ms  = 15000
          }

          dtmf_specification {
            deletion_character = "*"
            end_character      = "#"
            end_timeout_ms     = 5000
            max_length         = 513
          }
        }

        text_input_specification {
          start_timeout_ms = 30000
        }
      }

      # Match AWS defaults for "Retry1"
      prompt_attempts_specification {
        allow_interrupt = true
        map_block_key   = "Retry1"

        allowed_input_types {
          allow_audio_input = true
          allow_dtmf_input  = true
        }

        audio_and_dtmf_input_specification {
          start_timeout_ms = 4000

          audio_specification {
            end_timeout_ms = 640
            max_length_ms  = 15000
          }

          dtmf_specification {
            deletion_character = "*"
            end_character      = "#"
            end_timeout_ms     = 5000
            max_length         = 513
          }
        }

        text_input_specification {
          start_timeout_ms = 30000
        }
      }

    }
  }
}

The aws_lexv2models_intent registry documentation includes an example which describes this behavior for the confirmation_setting block on that resource. I'll be opening a PR shortly to add a similar example for aws_lexv2models_slot.

jar-b commented 3 months ago

39145 adds documentation describing the behavior in my previous comment.

I'm proposing we close this issue pending those documentation changes, and leave #35346 to cover the broader feature request for handling suppression of default prompt_attempts_specification values returned by AWS. Any suppression logic implemented on the aws_lexv2models_intent resource should be translatable to aws_lexv2models_slot as the schema definitions for prompt_specification are identical.

github-actions[bot] commented 3 months ago

[!WARNING] This issue has been closed, meaning that any additional comments are hard for our team to see. Please assume that the maintainers will not see them.

Ongoing conversations amongst community members are welcome, however, the issue will be locked after 30 days. Moving conversations to another venue, such as the AWS Provider forum, is recommended. If you have additional concerns, please open a new issue, referencing this one where needed.

github-actions[bot] commented 2 months ago

This functionality has been released in v5.66.0 of the Terraform AWS Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

github-actions[bot] commented 1 month ago

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.