【发布时间】:2018-08-09 23:00:18
【问题描述】:
我已尝试将以下内容添加到我当前工作的 apigateway API 设置中
resource "aws_api_gateway_method" "enable_head_request" {
provider = "aws.default"
rest_api_id = "${aws_api_gateway_rest_api.petshop.id}"
resource_id = "${aws_api_gateway_rest_api.petshop.root_resource_id}"
http_method = "HEAD"
authorization = "NONE"
# api_key_required = "False"
}
resource "aws_api_gateway_integration" "enable_head_request" {
provider = "aws.default"
rest_api_id = "${aws_api_gateway_rest_api.petshop.id}"
resource_id = "${aws_api_gateway_rest_api.petshop.root_resource_id}"
http_method = "${aws_api_gateway_method.enable_head_request.http_method}"
integration_http_method = "POST"
type = "AWS_PROXY"
uri = "${aws_lambda_function.petshop.invoke_arn}"
}
resource "aws_api_gateway_method_response" "200_for_head_request" {
provider = "aws.default"
rest_api_id = "${aws_api_gateway_rest_api.petshop.id}"
resource_id = "${aws_api_gateway_rest_api.petshop.root_resource_id}"
http_method = "${aws_api_gateway_method.enable_head_request.http_method}"
status_code = "200"
}
但是在部署并尝试 curl 我得到的端点之后;
curl --head https://test.com
HTTP/1.1 403 Forbidden
Date: Thu, 01 Mar 2018 18:47:07 GMT
Content-Type: application/json
Content-Length: 42
Connection: keep-alive
x-amzn-RequestId: f1811ce9-1d80-11e8-b15c-cf44af523470
x-amzn-ErrorType: MissingAuthenticationTokenException
编辑: 问题确实是部署没有重新部署。但正如我的回答中提到的那样,我找到了一种更好的方法。
【问题讨论】:
-
curl命令应该类似于:curl --head "xxx: xxx" https://test.com? -
取消授权后需要重新部署。最近有一个问题有完全相同的问题。 Terraform 在您申请时不会自动重新部署 API Gateway,因为它根本无法很好地处理 API Gateway 发布模型。
-
@ydaetskcoR 我已经能够毫无问题地将新的 GET 请求添加到不同的路径
标签: aws-api-gateway terraform terraform-provider-aws