Resource: aws_lexv2models_intent

Terraform resource for managing an AWS Lex V2 Models Intent.

Example Usage

Basic Usage

data "aws_partition" "current" {}

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

resource "aws_iam_role_policy_attachment" "test" {
  role       = aws_iam_role.test.name
  policy_arn = "arn:${data.aws_partition.current.partition}:iam::aws:policy/AmazonLexFullAccess"
}

resource "aws_lexv2models_bot" "test" {
  name                        = "botens_namn"
  idle_session_ttl_in_seconds = 60
  role_arn                    = aws_iam_role.test.arn

  data_privacy {
    child_directed = true
  }
}

resource "aws_lexv2models_bot_locale" "test" {
  locale_id                        = "en_US"
  bot_id                           = aws_lexv2models_bot.test.id
  bot_version                      = "DRAFT"
  n_lu_intent_confidence_threshold = 0.7
}

resource "aws_lexv2models_bot_version" "test" {
  bot_id = aws_lexv2models_bot.test.id
  locale_specification = {
    (aws_lexv2models_bot_locale.test.locale_id) = {
      source_bot_version = "DRAFT"
    }
  }
}

resource "aws_lexv2models_intent" "example" {
  bot_id      = aws_lexv2models_bot.test.id
  bot_version = aws_lexv2models_bot_locale.test.bot_version
  name        = "botens_namn"
  locale_id   = aws_lexv2models_bot_locale.test.locale_id
}

confirmation_setting Example

When using confirmation_setting, if you do not provide a prompt_attempts_specification, AWS Lex will provide default prompt_attempts_specifications. As a result, Terraform will report a difference in the configuration. To avoid this behavior, include the default prompt_attempts_specification configuration shown below.

resource "aws_lexv2models_intent" "example" {
  bot_id      = aws_lexv2models_bot.test.id
  bot_version = aws_lexv2models_bot_locale.test.bot_version
  name        = "botens_namn"
  locale_id   = aws_lexv2models_bot_locale.test.locale_id

  confirmation_setting {
    active = true

    prompt_specification {
      allow_interrupt            = true
      max_retries                = 1
      message_selection_strategy = "Ordered"

      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
        }
      }

      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
        }
      }
    }
  }
}

Argument Reference

The following arguments are required:

The following arguments are optional:

closing_setting

closing_response

message_group
message and variation
custom_payload
image_response_card
button
plain_text_message
ssml_message

conditional

conditional_branch
condition
response
default_branch

next_step

dialog_action
intent
slot
Slot value

confirmation_setting

prompt_specification

prompt_attempts_specification
allowed_input_types
audio_and_dtmf_input_specification
audio_specification
dtmf_specification
text_input_specification

code_hook

post_code_hook_specification

failure_conditional
failure_next_step
failure_response
success_conditional
success_next_step
success_response
timeout_conditional
timeout_next_step
timeout_response

confirmation_conditional

confirmation_next_step

confirmation_response

declination_conditional

declination_next_step

declination_response

elicitation_code_hook

dialog_code_hook

fulfillment_code_hook

fulfillment_updates_specification

start_response
update_response

post_fulfillment_status_specification

initial_response_setting

initial_response

input_context

kendra_configuration

output_context

sample_utterance

slot_priority

Attribute Reference

This resource exports the following attributes in addition to the arguments above:

Timeouts

Configuration options:

Import

In Terraform v1.5.0 and later, use an import block to import Lex V2 Models Intent using the intent_id:bot_id:bot_version:locale_id. For example:

import {
  to = aws_lexv2models_intent.example
  id = "intent-42874:bot-11376:DRAFT:en_US"
}

Using terraform import, import Lex V2 Models Intent using the intent_id:bot_id:bot_version:locale_id. For example:

% terraform import aws_lexv2models_intent.example intent-42874:bot-11376:DRAFT:en_US