为什么我在 AWS WAF 中收到“WAFInvalidParameterException”错误?

2 分钟阅读
0

我想知道为什么我会收到“WAFInvalidParameterException”错误。

简述

如果您正在执行的操作具有 AWS WAF 无法识别的参数,则操作会失败。AWS WAF 可能会返回一个错误 WAFInvalidParameterException。以下是出现此错误的常见原因:

  • 您指定的参数名称或值无效。
  • 嵌套语句无效。
  • 网络访问控制列表(Web ACL)已使用一个 DefaultAction 进行了更新,但该类型不可用。
  • 请求中引用的 ARN 来自无法与 Web ACL 关联的资源。

解决方案

无法识别参数名称或值

如果 AWS WAF 无法识别参数值,则您会看到一条与以下示例类似的消息:

"An error occurred (WAFInvalidParameterException) when calling the CreateRuleGroup operation: Error reason:
The scope is not valid., field: SCOPE_VALUE, parameter: <parameter value>"

例如,Scope 参数值不是 REGIONALCLOUDFRONT,则系统会返回之前的错误。

要解决此问题,请完成以下步骤:

  1. 确定 AWS WAF 无法识别的参数值。
  2. 将该参数修改为 AWS WAF 支持的值。有关详细信息,请参阅 AWS WAFV2

无法识别资源类型

AWS WAF 可以与 Amazon CloudFront 发行版、Amazon API Gateway REST API、应用程序负载均衡器或 AWS AppSync GraphQL API 相关联。如果您将其与其他资源类型关联,则会看到一条与以下示例类似的消息:

"An error occurred (WAFInvalidParameterException) when calling the AssociateWebACL operation: Error reason:
The ARN isn't valid.A valid ARN begins with arn: and includes other information separated by colons or slashes., field: RESOURCE_ARN, parameter: <resource arn"

要解决此问题,请完成以下步骤:

  1. 确定 AWS WAF 无法识别的参数值。
  2. 将该参数修改为 AWS WAF 支持的资源。

**注意:**与 Web ACL 关联的资源的 ARN 必须采用以下格式之一:

  • 应用程序负载均衡器:arn:aws:elasticloadbalancing:region:account-id:loadbalancer/app/load-balancer-name/load-balancer-id
  • Amazon API Gateway REST API:arn:aws:apigateway:region::/restapis/api-id/stages/stage-name
  • AWS AppSync GraphQL API:arn:aws:appsync:region:account-id:apis/GraphQLApiId
  • Amazon Cognito 用户群体:arn:aws:cognito-idp:region:account-id:userpool/user-pool-id
  • AWS App Runner 服务:arn:aws:apprunner:region:account-id:service/apprunner-service-name/apprunner-service-id

无法识别 DefaultAction 值

您可以将 AWS WAF 的 DefaultAction 字段设置为 AllowBlock。如果您将该字段设置为任何其他值,则会收到与以下示例类似的错误:

"You tried to update a Web ACL with a DefaultAction that isn't among the types available at DefaultAction."

有关可接受值的更多信息,请参阅 Request syntax

参考文献

Deciding on the default action for a web ACL

Class WAFInvalidParamterException

Namespace WAFInvalidParameterException

AWS 官方
AWS 官方已更新 6 个月前