1
api_gateway
用のterraformスクリプトが正常に動作しています。私は多くのテンプレートを複製しています。私は"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
に共通しているので、私は共通のテンプレートを持ち、すべてのリソースで再利用したいと思っています。
なぜこのエラーが発生しますか?