0

我在 Terraform 中有以下配置:

// ...

resource "aws_api_gateway_integration_response" "post_pet_200_integration" {
  rest_api_id = "${aws_api_gateway_rest_api.my_pets_api.id}"
  resource_id = "${aws_api_gateway_resource.pets_resource.id}"
  http_method = "${aws_api_gateway_method.post_pet_method.http_method}"
  status_code = "${aws_api_gateway_method_response.post_pet_200.status_code}"

  response_parameters = "foo"
}

运行时terraform apply,我得到:

错误:

  • aws_api_gateway_integration_response.post_pet_200_integration::无效或未知键:response_parameters

关于aws_api_gateway_integration_response的文档说:

response_parameters <- (可选)表示可以发回给调用者的响应参数

为什么我不能使用这个变量?


我尝试了以下方法:camelcase,带/不带 s,放入aws_api_gateway_method_responseoraws_api_gateway_deployment块,放入 terraformmap变量类型而不是字符串。但我每次都有同样的错误。我也试图从这个配置中获得灵感:https ://github.com/awslabs/aws-apigateway-importer ,但我仍然遇到了同样的错误。

编辑: terraform 的版本是 0.6.14。

4

1 回答 1

0

我不确定这是否是 terraform 中的错误。我会让 terraform 社区对此做出回应。

如果 responseParameters 的格式无效,或者指定的方法响应参数不存在,API Gateway 会抛出错误。

格式应该是这样的:

"responseParameters": {
    "method.response.header.foo": "integration.response.header.bar"              
}

以下是相关的 api 参考:https ://docs.aws.amazon.com/apigateway/api-reference/resource/integration-response/#responseParameters

于 2016-03-30T20:01:09.850 回答