我想将 WAFv2 Web ACL 关联到 API GatewayV2 HTTP 阶段。
按照 terraform docs,我尝试了这个:
resource "aws_wafv2_web_acl_association" "this" {
resource_arn = aws_apigatewayv2_stage.this.arn
web_acl_arn = aws_wafv2_web_acl.this.arn
}
Run Code Online (Sandbox Code Playgroud)
但是,这不被接受,错误是:
错误:WAFInvalidParameterException:错误原因:ARN 无效。有效的 ARN 以 arn: 开头,并包括以冒号或斜线分隔的其他信息。,字段:RESOURCE_ARN,参数:arn:aws:apigateway:eu-west-2::/apis/abcd1234/stages/my-stage
从 AWS docs 中,ARN 的模式是:
arn:aws:apigateway:region::/restapis/api-id/stages/stage-name
Run Code Online (Sandbox Code Playgroud)
但是,只有旧 API 网关的 ARN 在其 ARN 中使用“ restapis ”。v2 网关仅使用“ apis .
根据要求,这里是网关的代码:
resource "aws_apigatewayv2_api" "this" {
name = "example-http-api"
protocol_type = "HTTP"
}
resource "aws_lambda_function" "this" { …Run Code Online (Sandbox Code Playgroud) amazon-web-services aws-api-gateway amazon-waf terraform0.12+