Terraform aws\u api\u网关\u方法\u设置日志记录级别上的BADDREQUEST
我在“terraform应用”上遇到以下错误:Terraform aws\u api\u网关\u方法\u设置日志记录级别上的BADDREQUEST,terraform,Terraform,我在“terraform应用”上遇到以下错误: *`aws_api_gateway_method_settings.api_gateway_method_settings_property_lambda: Updating API Gateway Stage failed: BadRequestException: Invalid method setting path: /property/ANY/metrics/enabled. Must be one of: [/deploymentId,
*`aws_api_gateway_method_settings.api_gateway_method_settings_property_lambda: Updating API Gateway Stage failed: BadRequestException: Invalid method setting path: /property/ANY/metrics/enabled. Must be one of: [/deploymentId, /description, /cacheClusterEnabled, /cacheClusterSize, /clientCertificateId, /accessLogSettings, /accessLogSettings/destinationArn, /accessLogSettings/format, /{resourcePath}/{httpMethod}/metrics/enabled, /{resourcePath}/{httpMethod}/logging/dataTrace, /{resourcePath}/{httpMethod}/logging/loglevel, /{resourcePath}/{httpMethod}/throttling/burstLimit/{resourcePath}/{httpMethod}/throttling/rateLimit/{resourcePath}/{httpMethod}/caching/ttlInSeconds, /{resourcePath}/{httpMethod}/caching/enabled, /{resourcePath}/{httpMethod}/caching/dataEncrypted, /{resourcePath}/{httpMethod}/caching/requireAuthorizationForCacheControl, /{resourcePath}/{httpMethod}/caching/unauthorizedCacheControlHeaderStrategy, /*/*/metrics/enabled, /*/*/logging/dataTrace, /*/*/logging/loglevel, /*/*/throttling/burstLimit /*/*/throttling/rateLimit /*/*/caching/ttlInSeconds, /*/*/caching/enabled, /*/*/caching/dataEncrypted, /*/*/caching/requireAuthorizationForCacheControl, /*/*/caching/unauthorizedCacheControlHeaderStrategy, /variables/{variable_name}, /tracingEnabled]`
status code: 400, request id: 7f7ec35e-97ec-11e8-b95f-7f3d88cdbe6b
我已经查看了日志记录级别上的所有文档。我只能找到按照我的编码方式进行编码的例子。我找不到关于这个错误的任何信息。我的地形:
resource "aws_iam_role" "role_lambda_property" {
name = "${local.project-prefix}-role-lambda-property"
assume_role_policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Action": "sts:AssumeRole",
"Principal": {
"Service": [
"lambda.amazonaws.com",
"apigateway.amazonaws.com"
]
},
"Effect": "Allow",
"Sid": ""
}
]
}
EOF
}
resource "aws_iam_role_policy" "policy_property_lambda" {
name = "${local.project-prefix}-policy-property-lambda"
role = "${aws_iam_role.role_lambda_property.id}"
policy = <<EOF
{
"Version": "2012-10-17",
"Statement":
[
{
"Effect": "Allow",
"Action": [
"logs:CreateLogGroup",
"logs:CreateLogStream",
"logs:PutLogEvents"
],
"Resource": "arn:aws:logs:*:*:*"
},
{
"Effect": "Allow",
"Action": [
"s3:GetObject",
"s3:GetObjectVersion",
"s3:PutObject",
"s3:DeleteObject"
],
"Resource": "arn:aws:s3:::${local.s3_bucket_lambda_name}/*"
},
{
"Effect": "Allow",
"Action": [
"s3:GetObject",
"s3:GetObjectVersion",
"s3:PutObject",
"s3:DeleteObject",
"s3:ListBucket"
],
"Resource": "arn:aws:s3:::${local.s3_bucket_library_name}/*"
}
]
}
EOF
}
resource "aws_cloudwatch_log_group" "cloudwatch_log_group_useast1" {
name = "${local.project_name}-cloudwatch-log-group-useast1"
tags {
Environment = "${var.short_env}"
}
}
resource "aws_api_gateway_stage" "api_gateway_stage_property_lambda" {
stage_name = "${var.short_env}"
rest_api_id =
"${aws_api_gateway_rest_api.api_gateway_rest_api_property_lambda.id}"
deployment_id =
"${aws_api_gateway_deployment.api_gateway_deployment_property_lambda.id}"
}
有人知道我做错了什么吗?看起来问题是特定于地形的。也许我错过了一个我应该做的设置,或者错过了一个terraform包?解决了。问题是我在使用:
resource "aws_api_gateway_method" "api_gateway_method_get_property_lambda" {
http_method = "ANY"
当我通过以下方式访问该文件时:
resource "aws_api_gateway_method_settings"
"api_gateway_method_settings_property_lambda" {
depends_on = [
"aws_api_gateway_deployment.api_gateway_deployment_property_lambda"
]
rest_api_id =
"${aws_api_gateway_rest_api.api_gateway_rest_api_property_lambda.id}"
stage_name = "${aws_api_gateway_deployment.api_gateway_deployment_property_lambda.stage_name}"
method_path = "${aws_api_gateway_resource.api_gateway_resource_property_lambda.path_part}/${aws_api_gateway_method.api_gateway_method_get_property_lambda.http_method}"
它显然不支持将“ANY”作为HTTP方法更改为:
resource "aws_api_gateway_method" "api_gateway_method_get_property_lambda" {
http_method = "GET"
我没有发现错误。我知道,经过数小时的搜索后,我一发布它,就会发现问题所在。
resource "aws_api_gateway_method_settings"
"api_gateway_method_settings_property_lambda" {
depends_on = [
"aws_api_gateway_deployment.api_gateway_deployment_property_lambda"
]
rest_api_id =
"${aws_api_gateway_rest_api.api_gateway_rest_api_property_lambda.id}"
stage_name = "${aws_api_gateway_deployment.api_gateway_deployment_property_lambda.stage_name}"
method_path = "${aws_api_gateway_resource.api_gateway_resource_property_lambda.path_part}/${aws_api_gateway_method.api_gateway_method_get_property_lambda.http_method}"
resource "aws_api_gateway_method" "api_gateway_method_get_property_lambda" {
http_method = "GET"