amazon-web-services - 创建 API 网关方法时出错响应:NotFoundException:指定的方法标识符无效
问题描述
我正在尝试使用 Terraform 创建一个 AWS API 网关,该网关具有资源和方法,但出现此错误:“指定的方法标识符无效”
完整错误(行号与下面的代码片段不匹配):
Error: Error creating API Gateway Method Response: NotFoundException: Invalid Method identifier specified
on api-gateway/api-gateway.tf line 204, in resource "aws_api_gateway_method_response" "method-response-public-get-sites":
204: resource "aws_api_gateway_method_response" "method-response-public-get-sites" {
Error: Error creating API Gateway Integration: NotFoundException: Invalid Method identifier specified
on api-gateway/api-gateway.tf line 214, in resource "aws_api_gateway_integration" "method-integration-public-get-sites":
214: resource "aws_api_gateway_integration" "method-integration-public-get-sites" {
我不清楚“方法标识符”是什么——它是指定的 HTTP 方法(例如 GET、POST)吗?在这种情况下,我认为我已经正确定义了这些。
这是我的 Terraform 代码。我的目标是定义以下端点:GET /public/sites
.
resource "aws_api_gateway_rest_api" "api" {
name = "${var.api_gateway_name}-api"
description = "${var.api_gateway_name} api"
policy = data.aws_iam_policy_document.api_policy_doc.json
endpoint_configuration {
types = [
"REGIONAL"
]
}
}
resource "aws_api_gateway_resource" "resource-public" {
rest_api_id = aws_api_gateway_rest_api.api.id
parent_id = aws_api_gateway_rest_api.api.root_resource_id
path_part = "public"
depends_on = [aws_api_gateway_rest_api.api]
}
resource "aws_api_gateway_resource" "resource-public-sites" {
rest_api_id = aws_api_gateway_rest_api.api.id
parent_id = aws_api_gateway_resource.resource-public.id
path_part = "sites"
depends_on = [
aws_api_gateway_resource.resource-public
]
}
resource "aws_api_gateway_method" "method-public-get-sites" {
rest_api_id = aws_api_gateway_rest_api.api.id
resource_id = aws_api_gateway_resource.resource-public.id
http_method = "GET"
authorization = "NONE"
depends_on = [
aws_api_gateway_resource.resource-public-sites
]
}
resource "aws_api_gateway_method_response" "method-response-public-get-sites" {
rest_api_id = aws_api_gateway_rest_api.api.id
resource_id = aws_api_gateway_resource.resource-public-sites.id
http_method = aws_api_gateway_method.method-public-get-sites.http_method
status_code = "200"
depends_on = [
aws_api_gateway_method.method-public-get-sites
]
}
resource "aws_api_gateway_integration" "method-integration-public-get-sites" {
rest_api_id = aws_api_gateway_rest_api.api.id
resource_id = aws_api_gateway_resource.resource-public-sites.id
http_method = aws_api_gateway_method.method-public-get-sites.http_method
integration_http_method = "POST"
type = "AWS_PROXY"
uri = var.lambda_invoke_arn
depends_on = [
aws_api_gateway_method.method-public-get-sites
]
}
resource "aws_api_gateway_integration_response" "integration-response-public-get-sites" {
rest_api_id = aws_api_gateway_rest_api.api.id
resource_id = aws_api_gateway_resource.resource-public.id
http_method = aws_api_gateway_method.method-public-get-sites.http_method
status_code = aws_api_gateway_method_response.method-response-public-get-sites.status_code
depends_on = [
aws_api_gateway_integration.method-integration-public-get-sites,
aws_api_gateway_method_response.method-response-public-get-sites
]
}
我已经阅读了一些关于 SO 和 Github 的帖子,其中建议实施depends_on
,我已经这样做了,但不幸的是它没有产生效果。我已经在没有方法/资源/等(只是网关 rest api 资源)的情况下运行了一次 terraform 来创建它,然后使用资源/方法/等进行了第二次运行
谢谢
解决方案
推荐阅读
- php - 如果管理员登录,添加更多导航链接
- hibernate - 无法让 FetchType.EAGER 与 @ElementCollection 一起使用
- azure - Azure 应用程序网关升级
- vue.js - npm 安装 -g
E401 失败 - c# - 按日期将两个列表合并为一个
- c# - 将数据参数从模型传递到下一页 Prism Xamarin Forms
- python - 如何在气流中创建自定义运算符并在通过云作曲家运行的气流模板中使用它们(在谷歌云平台中)
- angular-material - 如何将 Angular Mat-select 字段中的选定选项输出为 Html 中的文本?
- c# - 使用属性路由找到了与 Web Api 中的请求匹配的多个操作
- python - 从另一个文本文件中存在的文本文件中删除单词 - Python