[英]Terraform AWS API Gateway with Proxy BadRequest Exception Invalid Mapping
I am trying to create an aws proxy with terraform. I am currently stuck when applying the changes.我正在尝试使用 terraform 创建一个 aws 代理。我目前在应用更改时卡住了。 The error I get within the resource "aws_api_gateway_integration" is the following:
我在资源“aws_api_gateway_integration”中遇到的错误如下:
Error: Error creating API Gateway Integration: BadRequestException: Invalid mapping expression specified: Validation Result: warnings : [], errors : [Parameter name should match the following regular expression: ^[a-zA-Z0-9:._$-]+$]
Here is my code:这是我的代码:
resource "aws_api_gateway_integration" "itemPutMethod-ApiProxyIntegration" {
rest_api_id = "${aws_api_gateway_rest_api.apiGateway.id}"
resource_id = "${aws_api_gateway_resource.itemResource.id}"
http_method = "${aws_api_gateway_method.itemPutMethod.http_method}"
type = "AWS"
integration_http_method = "PUT"
credentials = "${aws_iam_role.s3_proxy_role.arn}"
uri = "arn:aws:apigateway:${var.region}:s3:path/{bucket}/{folder}/{item}"
request_parameters = {
"integration.request.header.x-amz-meta-fileinfo" = "method.request.header.x-amz-meta-fileinfo"
"integration.request.header.Accept" = "method.request.header.Accept"
"integration.request.header.Content-Type " = "method.request.header.Content-Type"
"integration.request.path.item" = "method.request.path.item"
"integration.request.path.folder" = "method.request.path.folder"
"integration.request.path.bucket" = "method.request.path.bucket"
}
}
And here is my code for the method:这是我的方法代码:
resource "aws_api_gateway_method" "itemPutMethod" {
rest_api_id = "${aws_api_gateway_rest_api.apiGateway.id}"
resource_id = "${aws_api_gateway_resource.itemResource.id}"
http_method = "PUT"
authorization = "NONE"
api_key_required = true
request_parameters = {
"method.request.header.Accept" = false
"method.request.header.Content-Type" = false
"method.request.header.x-amz-meta-fileinfo" = false
"method.request.path.bucket" = true
"method.request.path.folder" = true
"method.request.path.item" = true
}
}
As far as I understand I have a bad character in the parameter names but I can't figure out where.据我所知,我在参数名称中有一个坏字符,但我不知道在哪里。 Any help would be greatly appreciated, thank you!
任何帮助将不胜感激,谢谢!
API Gateway Resource API 网关资源
resource "aws_api_gateway_resource" "bucketResource" {
rest_api_id = "${aws_api_gateway_rest_api.apiGateway.id}"
parent_id = "${aws_api_gateway_rest_api.apiGateway.root_resource_id}"
path_part = "{bucket}"
}
resource "aws_api_gateway_resource" "folderResource" {
rest_api_id = "${aws_api_gateway_rest_api.apiGateway.id}"
parent_id = "${aws_api_gateway_resource.bucketResource.id}"
path_part = "{folder}"
}
resource "aws_api_gateway_resource" "itemResource" {
rest_api_id = "${aws_api_gateway_rest_api.apiGateway.id}"
parent_id = "${aws_api_gateway_resource.folderResource.id}"
path_part = "{item}"
}
Link to tutorial code: https://github.com/robty123/s3-proxy教程代码链接: https://github.com/robty123/s3-proxy
Your request_parameters
argument in aws_api_gateway_integration
resource have a space in one of the mappings. aws_api_gateway_integration
资源中的request_parameters
参数在其中一个映射中有一个空格。 That seems to be the cause of failing regex match.这似乎是正则表达式匹配失败的原因。
Change this改变这个
"integration.request.header.Content-Type " = "method.request.header.Content-Type"
to到
"integration.request.header.Content-Type" = "method.request.header.Content-Type"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.