0

I wrote terraform script to create a lexbot in AWS. It is a very simple script. name, child_directed, abort_statment, intent are "Required" attributes for the "aws_lex_bot" resource.

It somehow throws error about the "intent" attribute Error: creating Lex Bot (Chat_AutoReply): BadRequestException: The resource 'FallbackIntent' referenced in resource 'Chat_AutoReply' was not found. Choose another resource.

   resource "aws_lex_bot" "chatbot-autoreply" {        
              name = "Chat_AutoReply"
              child_directed = false
              abort_statement {
                  message {
                      content_type = "PlainText"
                      content      = "Script aborted refer abort_statement"
                  }         
              }
              intent {
                   intent_name    = "FallbackIntent"
                   intent_version = "1"
              }
      }
Marcin
  • 215,873
  • 14
  • 235
  • 294
sutterhome1971
  • 380
  • 1
  • 9
  • 22

1 Answers1

2

You have to create aws_lex_intent and then use that in aws_lex_bot, e.g.:

resource "aws_lex_intent" "fallback" {
   ...
}

resource "aws_lex_bot" "chatbot-autoreply" {        
              name = "Chat_AutoReply"
              child_directed = false
              abort_statement {
                  message {
                      content_type = "PlainText"
                      content      = "Script aborted refer abort_statement"
                  }         
              }
              intent {
                   intent_name    = aws_lex_intent.fallback.name
                   intent_version = "1"
              }
      }
Marcin
  • 215,873
  • 14
  • 235
  • 294