我发现一个错误有问题。我正在尝试将WafACL连接到API部署,并使用以下命令:
aws wafv2 associate-web-acl --web-acl-arn d3b11jj1-30c6-46ae-8e58-6a90ae69eeaf --resource-arn 'arn:aws:apigateway:us-east-1::/restapis/*api-id*/stages/dev'调用AssociateWebACL操作时发生错误(WAFInvalidParameterException):错误原因: ARN无效。有效的ARN以arn:开头,并包括用冒号或斜杠分隔的其他信息。字段: RESOURCE_ARN,参数:d3b11j1-30c6-46ae-8e58-6a90ae69eeaf。
我还尝试使用CloudFormation:
AWSTemplateFormatVersion: "2010-09-09"
Description: "DB Management Service"
Resources:
WebACLAssociation:
Type: AWS::WAFv2::WebACLAssociation
Properties:
ResourceArn: 'arn:aws:apigateway:us-east-1::/restapis/*api-id*/stages/dev'
WebACLArn:
Ref: WebACL
WebACL:
Type: AWS::WAFv2::WebACL
Properties:
DefaultAction:
Allow: {}
Rules:
- Name: WebACLRule
Action:
Block: {}
Priority: 0
Statement:
RateBasedStatement:
AggregateKeyType: IP
Limit: 2048
VisibilityConfig:
CloudWatchMetricsEnabled: true
MetricName: Requests
SampledRequestsEnabled: false
Scope: REGIONAL
VisibilityConfig:
CloudWatchMetricsEnabled: true
MetricName: WafACL
SampledRequestsEnabled: true但在这里我也得到了:
错误原因: ARN无效。有效的ARN以arn:开头,并包括用冒号或斜杠分隔的其他信息。,字段: RESOURCE_ARN。
我不认为阿恩是错误的。我试着用在不同的组合上。
发布于 2020-04-09 17:36:37
Wafv2对于arn有一个不同的方案。Waf v1使用的是一个看起来像UUID的UUID,因为Wafv2使用了一个完全限定的ARN。
aws wafv2 associate-web-acl \
--web-acl-arn arn:aws:wafv2:us-west-2:123456789012:regional/webacl/test-cli/a1b2c3d4-5678-90ab-cdef-EXAMPLE11111 \
--resource-arn arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/waf-cli-alb/1ea17125f8b25a2a \
--region us-west-2
所以在你的情况下它可能看起来
aws wafv2 associate-web-acl --web-acl-arn arn:aws:wafv2:<region>:<account>:regional/webacl/<webacl name>/d3b11jj1-30c6-46ae-8e58-6a90ae69eeaf --resource-arn 'arn:aws:apigateway:us-east-1::/restapis/*api-id*/stages/dev'同样,在CFN中,Wafv2有多个返回点,所以您不能做好
WebACLArn: !Ref <webacl>但你要做的事情是
WebACLArn: !GetAtt <webacl>.Arn参考文献https://docs.aws.amazon.com/cli/latest/reference/wafv2/associate-web-acl.html
https://stackoverflow.com/questions/60955745
复制相似问题