【发布时间】:2020-07-19 04:50:29
【问题描述】:
我正在尝试在根 api 网关 URL 上使用 terraform 创建 POST 方法,例如 https://somehash.execute-api.us-east-1.amazonaws.com/dev,其中将包括舞台。以下是关注的 terraform 计划的一部分:
resource "aws_api_gateway_rest_api" "api" {
name = "submit-dev-gateway-api"
}
resource "aws_api_gateway_resource" "resource" {
rest_api_id = "${aws_api_gateway_rest_api.api.id}"
parent_id = "${aws_api_gateway_rest_api.api.root_resource_id}"
path_part = "submit"
}
resource "aws_api_gateway_method" "post_form" {
rest_api_id = "${aws_api_gateway_rest_api.api.id}"
resource_id = "${aws_api_gateway_resource.resource.id}"
http_method = "POST"
authorization = "NONE"
}
...
我尝试将 path_part 更改为“/”,但没有成功。如果没有 aws_api_gateway_resource,我无法创建 aws_api_gateway_method 资源。我可以在没有 terraform 的情况下手动在根目录创建 POST,如下所示:
如何使用 terraform 在根目录创建 POST?
【问题讨论】:
-
如果从 terraform 脚本中删除
path_part = "submit"会怎样? -
我收到此错误:
The argument "path_part" is required, but no definition was found. -
尝试输入
path_part = ""或path_part = "\" -
空字符串
BadRequestException: Resource's path part must be specified出现此错误。"\"与"/"相同。没用。
标签: amazon-web-services terraform aws-api-gateway