According to the official doc, it still does not directly support by aws
provider, but as suggested in the GitHub issue you could use awscc
which supports V2. Check the issue here
Here is an example of how to use awscc
provider to make it
resource "aws_iam_role" "lex_bot_role" {
name = "lex_bot_role"
assume_role_policy = jsonencode({
Version = "2012-10-17"
Statement = [
{
Effect = "Allow"
Principal = {
Service = "lex.amazonaws.com"
}
Action = "sts:AssumeRole"
}
]
})
}
resource "aws_iam_policy" "lex_bot_policy" {
name = "lex_bot_policy"
path = "/"
description = "Policy that allows a Lex bot to access AWS resources."
policy = jsonencode({
Version = "2012-10-17"
Statement = [
{
Effect = "Allow"
Action = [
"logs:CreateLogGroup",
"logs:CreateLogStream",
"logs:PutLogEvents"
]
Resource = "*"
},
{
Effect = "Allow"
Action = [
"lex:CreateBotVersion",
"lex:CreateIntentVersion",
"lex:DeleteBot",
"lex:DeleteBotAlias",
"lex:DeleteBotChannelAssociation",
"lex:DeleteBotVersion",
"lex:DeleteIntent",
"lex:DeleteIntentVersion",
"lex:DeleteSlotType",
"lex:DeleteSlotTypeVersion",
"lex:PutBot",
"lex:PutBotAlias",
"lex:PutBotChannelAssociation",
"lex:PutIntent",
"lex:PutSlotType"
]
Resource = "*"
}
]
})
}
resource "aws_iam_role_policy_attachment" "lex_bot_policy_attachment" {
policy_arn = aws_iam_policy.lex_bot_policy.arn
role = aws_iam_role.lex_bot_role.name
}
resource "awscc_lex_bot" "pizza_order_bot" {
name = var.bot_name
description = "A bot for ordering pizza"
role_arn = aws_iam_role.lex_bot_role.arn
idle_session_ttl_in_seconds = 300
data_privacy = {
child_directed = false
}
bot_tags = [
{
key = "Environment"
value = "Development"
},
]
depends_on = [
#TODO: Fix this and try to make it use the variables
# aws_lex_intent.order_pizza # The bot depends on the intent
aws_iam_role.lex_bot_role
]
}