API网关集成:BadRequestException:指定的无效映射表达式Terraform SNS集成



我正在尝试使用Terraform部署AWS API网关,并得到以下错误


Error: Error creating API Gateway Integration: BadRequestException: Invalid mapping expression specified: Validation Result: warnings : [], errors : [Invalid mapping expression specified: arn:aws:sns:us-west-2:************:com-service-receive-notification-inbound]

on Apps/CommunicationService/api-gateway.tf line 97, in resource "aws_api_gateway_integration" "integration_get":
97: resource "aws_api_gateway_integration" "integration_get" {

这个想法是部署一个API网关并将其与SNS集成,下面是我的GET方法和GET集成的一个片段


resource "aws_api_gateway_method" "method_get" {
count         = var.application_enabled ? 1 : 0
rest_api_id   = aws_api_gateway_rest_api.api_trumpic[count.index].id
resource_id   = aws_api_gateway_resource.resource_trumpic[count.index].id
http_method   = "GET"
authorization = "NONE"

request_parameters = {
"method.request.path.proxy"      = true
"method.request.querystring.xml" = true
"method.request.querystring.Message" = true
"method.request.querystring.TopicArn" = true
# "method.request.querystring.message"     = true
# "method.request.querystring.PhoneNumber" = true
}
}

resource "aws_api_gateway_integration" "integration_get" {
count                   = var.application_enabled ? 1 : 0
rest_api_id             = aws_api_gateway_rest_api.api_trumpic[count.index].id
resource_id             = aws_api_gateway_resource.resource_trumpic[count.index].id
http_method             = aws_api_gateway_method.method_get[count.index].http_method
credentials             = aws_iam_role.cloudwatch[count.index].arn
integration_http_method = "GET"
type                    = "AWS"
uri                     = "arn:aws:apigateway:us-west-2:sns:path//"

request_parameters = {
# "integration.request.querystring.Message"  = "method.request.querystring.message",
# "integration.request.querystring.Subject"  = "method.request.querystring.from",
"integration.request.querystring.Message"  = "method.request.querystring.xml"
"integration.request.querystring.TopicArn" = "${aws_sns_topic.com-service-receive-notification-inbound[count.index].arn}"
}
}

所以我发现一切都是正确的,我错过了",这就是问题所在。

"integration.request.querystring.TopicArn" = "'${aws_sns_topic.com-service-receive-notification-inbound[count.index].arn}'"

最新更新