1
我有一個terraform腳本api_gateway
這是工作正常。我有很多模板重複。我想使用"data" "template_file"
來提取所有模板。Terraform - response_parameters:應該是一個地圖
工作液:
resource "aws_api_gateway_integration_response" "ApiResponse" {
//something goes here
response_parameters = {
"method.response.header.Access-Control-Allow-Headers" = "'Content-Type,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token'"
"method.response.header.Access-Control-Allow-Methods" = "'GET,DELETE,PUT,OPTIONS'"
"method.response.header.Access-Control-Allow-Origin" = "'*'"
}
}
重構後:
resource "aws_api_gateway_integration_response" "ApiResponse" {
//something goes here
response_parameters = "${data.template_file.response_parameters.template}"
}
data "template_file" "response_parameters" {
template = "${file("${path.module}/response_parameters.tptl")}"
}
response_parameters.tptl:
{
"method.response.header.Access-Control-Allow-Headers" = "'Content-Type,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token'"
"method.response.header.Access-Control-Allow-Methods" = "'GET,DELETE,PUT,OPTIONS'"
"method.response.header.Access-Control-Allow-Origin" = "'*'"
}
錯誤:
* aws_api_gateway_integration_response.ApiResponse: response_parameters: should be a map
由於響應參數對我所有的aws_api_gateway_integration_response
都是通用的,所以我想在所有資源中都有一個通用模板並重用。
爲什麼我得到這個錯誤?