本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
Amazon WAFV2 使用示例 Amazon CLI
以下代码示例向您展示了如何使用with来执行操作和实现常见场景 Amazon WAFV2。 Amazon Command Line Interface
操作是大型程序的代码摘录,必须在上下文中运行。您可以通过操作了解如何调用单个服务函数,还可以通过函数相关场景和跨服务示例的上下文查看操作。
场景是展示如何通过在同一服务中调用多个函数来完成特定任务任务的代码示例。
每个示例都包含一个指向的链接 GitHub,您可以在其中找到有关如何在上下文中设置和运行代码的说明。
主题
操作
以下代码示例演示如何使用 associate-web-acl
。
- Amazon CLI
-
将 Web ACL 与区域 Amazon 资源关联
以下
associate-web-acl
示例将指定的 Web ACL 与 Application Load Balancer 关联起来。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
此命令不生成任何输出。
有关更多信息,请参阅《WAF、Fi Amazon rewall Manager Amazon 和 Amazon Sh ield 高级开发者指南》中的 “将 Web ACL 与 Amazon 资源关联或取消关联”。
-
有关 API 的详细信息,请参阅Amazon CLI 命令参考AssociateWebAcl
中的。
-
以下代码示例演示如何使用 check-capacity
。
- Amazon CLI
-
获取一组规则使用的容量
以下内容
check-capacity
检索包含基于速率的规则语句和包含嵌套规则的 AND 规则语句的规则集的容量要求。aws wafv2 check-capacity \ --scope REGIONAL \ --rules file://waf-rule-list.json \ --region us-west-2
文件内容://waf-rule-list.json:
[ { "Name":"basic-rule", "Priority":0, "Statement":{ "AndStatement":{ "Statements":[ { "ByteMatchStatement":{ "SearchString":"example.com", "FieldToMatch":{ "SingleHeader":{ "Name":"host" } }, "TextTransformations":[ { "Priority":0, "Type":"LOWERCASE" } ], "PositionalConstraint":"EXACTLY" } }, { "GeoMatchStatement":{ "CountryCodes":[ "US", "IN" ] } } ] } }, "Action":{ "Allow":{ } }, "VisibilityConfig":{ "SampledRequestsEnabled":true, "CloudWatchMetricsEnabled":true, "MetricName":"basic-rule" } }, { "Name":"rate-rule", "Priority":1, "Statement":{ "RateBasedStatement":{ "Limit":1000, "AggregateKeyType":"IP" } }, "Action":{ "Block":{ } }, "VisibilityConfig":{ "SampledRequestsEnabled":true, "CloudWatchMetricsEnabled":true, "MetricName":"rate-rule" } } ]
输出:
{ "Capacity":15 }
有关更多信息,请参阅 Amazon WAF、Fi Amazon rewall Manager 和 Amazon Shield 高级开发者指南中的 W Amazon AF Web ACL 容量单位 (WCU)。
-
有关 API 的详细信息,请参阅Amazon CLI 命令参考CheckCapacity
中的。
-
以下代码示例演示如何使用 create-ip-set
。
- Amazon CLI
-
创建 IP 集以供您的 Web ACL 和规则组使用
以下
create-ip-set
命令创建具有单一地址范围规范的 IP 集。aws wafv2 create-ip-set \ --name testip \ --scope REGIONAL \ --ip-address-version IPV4 \ --addresses 198.51.100.0/16
输出:
{ "Summary":{ "ARN":"arn:aws:wafv2:us-west-2:123456789012:regional/ipset/testip/a1b2c3d4-5678-90ab-cdef-EXAMPLE11111", "Description":"", "Name":"testip", "LockToken":"447e55ac-0000-0000-0000-86b67c17f8b5", "Id":"a1b2c3d4-5678-90ab-cdef-EXAMPLE11111" } }
有关更多信息,请参阅 Amazon WAF、Firewal Amazon l Manager 和 Amazon Shield 高级开发者指南中的 IP 集和正则表达式模式集。
-
有关 API 的详细信息,请参阅Amazon CLI 命令参考CreateIpSet
中的。
-
以下代码示例演示如何使用 create-regex-pattern-set
。
- Amazon CLI
-
创建用于您的 Web ACL 和规则组的正则表达式模式集
以下
create-regex-pattern-set
命令创建指定了两个正则表达式模式的正则表达式模式集。aws wafv2 create-regex-pattern-set \ --name regexPatterSet01 \ --scope REGIONAL \ --description 'Test web-acl' \ --regular-expression-list '[{"RegexString": "/[0-9]*/"},{"RegexString": "/[a-z]*/"}]'
输出:
{ "Summary":{ "ARN":"arn:aws:wafv2:us-west-2:123456789012:regional/regexpatternset/regexPatterSet01/a1b2c3d4-5678-90ab-cdef-EXAMPLE11111", "Description":"Test web-acl", "Name":"regexPatterSet01", "LockToken":"0bc01e21-03c9-4b98-9433-6229cbf1ef1c", "Id":"a1b2c3d4-5678-90ab-cdef-EXAMPLE11111" } }
有关更多信息,请参阅 Amazon WAF、Firewal Amazon l Manager 和 Amazon Shield 高级开发者指南中的 IP 集和正则表达式模式集。
-
有关 API 的详细信息,请参阅Amazon CLI 命令参考CreateRegexPatternSet
中的。
-
以下代码示例演示如何使用 create-rule-group
。
- Amazon CLI
-
创建用于您的 Web ACL 的自定义规则组
以下
create-rule-group
命令创建供区域使用的自定义规则组。该组的规则语句以 JSON 格式的文件提供。aws wafv2 create-rule-group \ --name "TestRuleGroup" \ --scope REGIONAL \ --capacity 250 \ --rules file://waf-rule.json \ --visibility-config SampledRequestsEnabled=true,CloudWatchMetricsEnabled=true,MetricName=TestRuleGroupMetrics \ --region us-west-2
文件内容://waf-rule.json:
[ { "Name":"basic-rule", "Priority":0, "Statement":{ "AndStatement":{ "Statements":[ { "ByteMatchStatement":{ "SearchString":"example.com", "FieldToMatch":{ "SingleHeader":{ "Name":"host" } }, "TextTransformations":[ { "Priority":0, "Type":"LOWERCASE" } ], "PositionalConstraint":"EXACTLY" } }, { "GeoMatchStatement":{ "CountryCodes":[ "US", "IN" ] } } ] } }, "Action":{ "Allow":{ } }, "VisibilityConfig":{ "SampledRequestsEnabled":true, "CloudWatchMetricsEnabled":true, "MetricName":"basic-rule" } } ]
输出:
{ "Summary":{ "ARN":"arn:aws:wafv2:us-west-2:123456789012:regional/rulegroup/TestRuleGroup/a1b2c3d4-5678-90ab-cdef-EXAMPLE11111", "Description":"", "Name":"TestRuleGroup", "LockToken":"7b3bcec2-374e-4c5a-b2b9-563bf47249f0", "Id":"a1b2c3d4-5678-90ab-cdef-EXAMPLE11111" } }
有关更多信息,请参阅《Amazon WAF》、《Fi Amazon rewall Manager》和《 Amazon Shield 高级开发者指南》中的 “管理自己的规则组”。
-
有关 API 的详细信息,请参阅Amazon CLI 命令参考CreateRuleGroup
中的。
-
以下代码示例演示如何使用 create-web-acl
。
- Amazon CLI
-
创建 Web ACL
以下
create-web-acl
命令创建供区域使用的 Web ACL。Web ACL 的规则语句在 JSON 格式的文件中提供。aws wafv2 create-web-acl \ --name TestWebAcl \ --scope REGIONAL \ --default-action Allow={} \ --visibility-config SampledRequestsEnabled=true,CloudWatchMetricsEnabled=true,MetricName=TestWebAclMetrics \ --rules file://waf-rule.json \ --region us-west-2
文件内容://waf-rule.json:
[ { "Name":"basic-rule", "Priority":0, "Statement":{ "AndStatement":{ "Statements":[ { "ByteMatchStatement":{ "SearchString":"example.com", "FieldToMatch":{ "SingleHeader":{ "Name":"host" } }, "TextTransformations":[ { "Priority":0, "Type":"LOWERCASE" } ], "PositionalConstraint":"EXACTLY" } }, { "GeoMatchStatement":{ "CountryCodes":[ "US", "IN" ] } } ] } }, "Action":{ "Allow":{ } }, "VisibilityConfig":{ "SampledRequestsEnabled":true, "CloudWatchMetricsEnabled":true, "MetricName":"basic-rule" } } ]
输出:
{ "Summary":{ "ARN":"arn:aws:wafv2:us-west-2:123456789012:regional/webacl/TestWebAcl/a1b2c3d4-5678-90ab-cdef-EXAMPLE11111", "Description":"", "Name":"TestWebAcl", "LockToken":"2294b3a1-eb60-4aa0-a86f-a3ae04329de9", "Id":"a1b2c3d4-5678-90ab-cdef-EXAMPLE11111" } }
有关更多信息,请参阅 W Amazon AF、Fi Amazon rewall Manager 和 Amazon Shield 高级开发者指南中的管理和使用 Web 访问控制列表 (Web ACL)。
-
有关 API 的详细信息,请参阅Amazon CLI 命令参考CreateWebAcl
中的。
-
以下代码示例演示如何使用 delete-ip-set
。
- Amazon CLI
-
删除 IP 集
以下内容
delete-ip-set
删除指定的 IP 集。此调用需要一个 ID(您可以从调用中获取)和一个锁定令牌(可以从调用中获取)list-ip-sets
和get-ip-set
。list-ip-sets
aws wafv2 delete-ip-set \ --name test1 \ --scope REGIONAL \ --id a1b2c3d4-5678-90ab-cdef-EXAMPLE11111 \ --lock-token 46851772-db6f-459d-9385-49428812e357
此命令不生成任何输出。
有关更多信息,请参阅 Amazon WAF、Firewal Amazon l Manager 和 Amazon Shield 高级开发者指南中的 IP 集和正则表达式模式集。
-
有关 API 的详细信息,请参阅Amazon CLI 命令参考DeleteIpSet
中的。
-
以下代码示例演示如何使用 delete-logging-configuration
。
- Amazon CLI
-
禁用 Web ACL 的日志记录
以下内容从指定的 Web ACL 中
delete-logging-configuration
删除所有日志配置。aws wafv2 delete-logging-configuration \ --resource-arn arn:aws:wafv2:us-west-2:123456789012:regional/webacl/test/a1b2c3d4-5678-90ab-cdef-EXAMPLE22222
此命令不生成任何输出。
有关更多信息,请参阅 W Amazon AF、Fi Amazon rewall Manager 和 Amazon Shield 高级开发者指南中的记录 Web ACL 流量信息。
-
有关 API 的详细信息,请参阅Amazon CLI 命令参考DeleteLoggingConfiguration
中的。
-
以下代码示例演示如何使用 delete-regex-pattern-set
。
- Amazon CLI
-
删除正则表达式模式集
以下内容
delete-regex-pattern-set
更新了指定正则表达式模式集的设置。此呼叫需要一个 ID(您可以从呼叫中获取)和一个锁定令牌(您可以从通话list-regex-pattern-sets
或呼叫中获取)get-regex-pattern-set
。list-regex-pattern-sets
aws wafv2 delete-regex-pattern-set \ --name regexPatterSet01 \ --scope REGIONAL \ --id a1b2c3d4-5678-90ab-cdef-EXAMPLE11111 \ --lock-token 0bc01e21-03c9-4b98-9433-6229cbf1ef1c
此命令不生成任何输出。
有关更多信息,请参阅 Amazon WAF、Firewal Amazon l Manager 和 Amazon Shield 高级开发者指南中的 IP 集和正则表达式模式集。
-
有关 API 的详细信息,请参阅Amazon CLI 命令参考DeleteRegexPatternSet
中的。
-
以下代码示例演示如何使用 delete-rule-group
。
- Amazon CLI
-
删除自定义规则组
以下内容
delete-rule-group
删除了指定的自定义规则组。此呼叫需要一个 ID(您可以从呼叫中获取)和一个锁定令牌(您可以从通话list-rule-groups
或呼叫中获取)get-rule-group
。list-rule-groups
aws wafv2 delete-rule-group \ --name TestRuleGroup \ --scope REGIONAL \ --id a1b2c3d4-5678-90ab-cdef-EXAMPLE11111 \ --lock-token 7b3bcec2-0000-0000-0000-563bf47249f0
此命令不生成任何输出。
有关更多信息,请参阅《Amazon WAF》、《Fi Amazon rewall Manager》和《 Amazon Shield 高级开发者指南》中的 “管理自己的规则组”。
-
有关 API 的详细信息,请参阅Amazon CLI 命令参考DeleteRuleGroup
中的。
-
以下代码示例演示如何使用 delete-web-acl
。
- Amazon CLI
-
删除 Web ACL
以下
delete-web-acl
操作会从您的账户中删除指定的 Web ACL。只有当 Web ACL 未与任何资源关联时,才能将其删除。此呼叫需要一个 ID(您可以从呼叫中获取)和一个锁定令牌(您可以从通话list-web-acls
或呼叫中获取)get-web-acl
。list-web-acls
aws wafv2 delete-web-acl \ --name test \ --scope REGIONAL \ --id a1b2c3d4-5678-90ab-cdef-EXAMPLE11111 \ --lock-token ebab4ed2-155e-4c9a-9efb-e4c45665b1f5
此命令不生成任何输出。
有关更多信息,请参阅 W Amazon AF、Fi Amazon rewall Manager 和 Amazon Shield 高级开发者指南中的管理和使用 Web 访问控制列表 (Web ACL)。
-
有关 API 的详细信息,请参阅Amazon CLI 命令参考DeleteWebAcl
中的。
-
以下代码示例演示如何使用 describe-managed-rule-group
。
- Amazon CLI
-
检索托管规则组的描述
以下内容
describe-managed-rule-group
检索 Amazon 托管规则组的描述。aws wafv2 describe-managed-rule-group \ --vendor-name AWS \ --name AWSManagedRulesCommonRuleSet \ --scope REGIONAL
输出:
{ "Capacity": 700, "Rules": [ { "Name": "NoUserAgent_HEADER", "Action": { "Block": {} } }, { "Name": "UserAgent_BadBots_HEADER", "Action": { "Block": {} } }, { "Name": "SizeRestrictions_QUERYSTRING", "Action": { "Block": {} } }, { "Name": "SizeRestrictions_Cookie_HEADER", "Action": { "Block": {} } }, { "Name": "SizeRestrictions_BODY", "Action": { "Block": {} } }, { "Name": "SizeRestrictions_URIPATH", "Action": { "Block": {} } }, { "Name": "EC2MetaDataSSRF_BODY", "Action": { "Block": {} } }, { "Name": "EC2MetaDataSSRF_COOKIE", "Action": { "Block": {} } }, { "Name": "EC2MetaDataSSRF_URIPATH", "Action": { "Block": {} } }, { "Name": "EC2MetaDataSSRF_QUERYARGUMENTS", "Action": { "Block": {} } }, { "Name": "GenericLFI_QUERYARGUMENTS", "Action": { "Block": {} } }, { } "Name": "GenericLFI_URIPATH", "Action": { "Block": {} } }, { "Name": "GenericLFI_BODY", "Action": { "Block": {} } }, { "Name": "RestrictedExtensions_URIPATH", "Action": { "Block": {} } }, { "Name": "RestrictedExtensions_QUERYARGUMENTS", "Action": { "Block": {} } }, { "Name": "GenericRFI_QUERYARGUMENTS", "Action": { "Block": {} } }, { "Name": "GenericRFI_BODY", "Action": { "Block": {} } }, { "Name": "GenericRFI_URIPATH", "Action": { "Block": {} } }, { "Name": "CrossSiteScripting_COOKIE", "Action": { "Block": {} } }, { "Name": "CrossSiteScripting_QUERYARGUMENTS", "Action": { "Block": {} } }, { "Name": "CrossSiteScripting_BODY", "Action": { "Block": {} } }, { "Name": "CrossSiteScripting_URIPATH", "Action": { "Block": {} } } ] }
有关更多信息,请参阅 Amazon WAF、Fi Amazon rewall Manager 和 Amazon Shield 高级开发者指南中的托管规则组。
-
有关 API 的详细信息,请参阅Amazon CLI 命令参考DescribeManagedRuleGroup
中的。
-
以下代码示例演示如何使用 disassociate-web-acl
。
- Amazon CLI
-
解除 Web ACL 与区域 Amazon 资源的关联
以下
disassociate-web-acl
示例从指定的 Application Load Balancer 中删除任何现有 Web ACL 关联。aws wafv2 disassociate-web-acl \ --resource-arn arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/waf-cli-alb/1ea17125f8b25a2a \ --region us-west-2
此命令不生成任何输出。
有关更多信息,请参阅《WAF、Fi Amazon rewall Manager Amazon 和 Amazon Sh ield 高级开发者指南》中的 “将 Web ACL 与 Amazon 资源关联或取消关联”。
-
有关 API 的详细信息,请参阅Amazon CLI 命令参考DisassociateWebAcl
中的。
-
以下代码示例演示如何使用 get-ip-set
。
- Amazon CLI
-
检索特定的 IP 集
以下内容
get-ip-set
检索具有指定名称、范围和 ID 的 IP 集。您可以从命令create-ip-set
和中获取 IP 集的 IDlist-ip-sets
。aws wafv2 get-ip-set \ --name testip \ --scope REGIONAL \ --id a1b2c3d4-5678-90ab-cdef-EXAMPLE11111
输出:
{ "IPSet":{ "Description":"", "Name":"testip", "IPAddressVersion":"IPV4", "Id":"a1b2c3d4-5678-90ab-cdef-EXAMPLE1111", "ARN":"arn:aws:wafv2:us-west-2:123456789012:regional/ipset/testip/a1b2c3d4-5678-90ab-cdef-EXAMPLE1111", "Addresses":[ "192.0.2.0/16" ] }, "LockToken":"447e55ac-2396-4c6d-b9f9-86b67c17f8b5" }
有关更多信息,请参阅 Amazon WAF、Firewal Amazon l Manager 和 Amazon Shield 高级开发者指南中的 IP 集和正则表达式模式集。
-
有关 API 的详细信息,请参阅Amazon CLI 命令参考GetIpSet
中的。
-
以下代码示例演示如何使用 get-logging-configuration
。
- Amazon CLI
-
检索 Web ACL 的日志配置
以下内容
get-logging-configuration
检索指定 Web ACL 的日志配置。aws wafv2 get-logging-configuration \ --resource-arn arn:aws:wafv2:us-west-2:123456789012:regional/webacl/test/a1b2c3d4-5678-90ab-cdef-EXAMPLE22222 \ --region us-west-2
输出:
{ "LoggingConfiguration":{ "ResourceArn":"arn:aws:wafv2:us-west-2:123456789012:regional/webacl/test/a1b2c3d4-5678-90ab-cdef-EXAMPLE22222", "RedactedFields":[ { "Method":{ } } ], "LogDestinationConfigs":[ "arn:aws:firehose:us-west-2:123456789012:deliverystream/aws-waf-logs-custom-transformation" ] } }
有关更多信息,请参阅 W Amazon AF、Fi Amazon rewall Manager 和 Amazon Shield 高级开发者指南中的记录 Web ACL 流量信息。
-
有关 API 的详细信息,请参阅Amazon CLI 命令参考GetLoggingConfiguration
中的。
-
以下代码示例演示如何使用 get-rate-based-statement-managed-keys
。
- Amazon CLI
-
检索被基于速率的规则屏蔽的 IP 地址列表
以下内容
get-rate-based-statement-managed-keys
检索当前被区域应用程序使用的基于速率的规则屏蔽的 IP 地址。aws wafv2 get-rate-based-statement-managed-keys \ --scope REGIONAL \ --web-acl-name testwebacl2 \ --web-acl-id a1b2c3d4-5678-90ab-cdef-EXAMPLE11111 \ --rule-name ratebasedtest
输出:
{ "ManagedKeysIPV4":{ "IPAddressVersion":"IPV4", "Addresses":[ "198.51.100.0/32" ] }, "ManagedKeysIPV6":{ "IPAddressVersion":"IPV6", "Addresses":[ ] } }
有关更多信息,请参阅 Amazon WAF、Fi Amazon rewall Manager 和 Amazon Shield 高级开发者指南中的基于速率的规则声明。
-
有关 API 的详细信息,请参阅Amazon CLI 命令参考GetRateBasedStatementManagedKeys
中的。
-
以下代码示例演示如何使用 get-regex-pattern-set
。
- Amazon CLI
-
检索特定的正则表达式模式集
以下内容
get-regex-pattern-set
检索具有指定名称、范围、区域和 ID 的正则表达式模式集。您可以从命令create-regex-pattern-set
和中获取正则表达式模式集的 ID。list-regex-pattern-sets
aws wafv2 get-regex-pattern-set \ --name regexPatterSet01 \ --scope REGIONAL \ --id a1b2c3d4-5678-90ab-cdef-EXAMPLE11111 \ --region us-west-2
输出:
{ "RegexPatternSet":{ "Description":"Test web-acl", "RegularExpressionList":[ { "RegexString":"/[0-9]*/" }, { "RegexString":"/[a-z]*/" } ], "Name":"regexPatterSet01", "ARN":"arn:aws:wafv2:us-west-2:123456789012:regional/regexpatternset/regexPatterSet01/a1b2c3d4-5678-90ab-cdef-EXAMPLE11111", "Id":"a1b2c3d4-5678-90ab-cdef-EXAMPLE11111" }, "LockToken":"c8abf33f-b6fc-46ae-846e-42f994d57b29" }
有关更多信息,请参阅 Amazon WAF、Firewal Amazon l Manager 和 Amazon Shield 高级开发者指南中的 IP 集和正则表达式模式集。
-
有关 API 的详细信息,请参阅Amazon CLI 命令参考GetRegexPatternSet
中的。
-
以下代码示例演示如何使用 get-rule-group
。
- Amazon CLI
-
检索特定的自定义规则组
以下内容
get-rule-group
检索具有指定名称、范围和 ID 的自定义规则组。您可以从命令create-rule-group
和中获取规则组的 IDlist-rule-groups
。aws wafv2 get-rule-group \ --name ff \ --scope REGIONAL \ --id a1b2c3d4-5678-90ab-cdef-EXAMPLE11111
输出:
{ "RuleGroup":{ "Capacity":1, "Description":"", "Rules":[ { "Priority":0, "Action":{ "Block":{ } }, "VisibilityConfig":{ "SampledRequestsEnabled":true, "CloudWatchMetricsEnabled":true, "MetricName":"jj" }, "Name":"jj", "Statement":{ "SizeConstraintStatement":{ "ComparisonOperator":"LE", "TextTransformations":[ { "Priority":0, "Type":"NONE" } ], "FieldToMatch":{ "UriPath":{ } }, "Size":7 } } } ], "VisibilityConfig":{ "SampledRequestsEnabled":true, "CloudWatchMetricsEnabled":true, "MetricName":"ff" }, "Id":"a1b2c3d4-5678-90ab-cdef-EXAMPLE11111", "ARN":"arn:aws:wafv2:us-west-2:123456789012:regional/rulegroup/ff/a1b2c3d4-5678-90ab-cdef-EXAMPLE11111", "Name":"ff" }, "LockToken":"485458c9-1830-4234-af31-ec4d52ced1b3" }
有关更多信息,请参阅《Amazon WAF》、《Fi Amazon rewall Manager》和《 Amazon Shield 高级开发者指南》中的 “管理自己的规则组”。
-
有关 API 的详细信息,请参阅Amazon CLI 命令参考GetRuleGroup
中的。
-
以下代码示例演示如何使用 get-sampled-requests
。
- Amazon CLI
-
检索 Web ACL 的 Web 请求示例
以下内容
get-sampled-requests
检索指定 Web ACL、规则指标和时间范围的 Web 请求样本。aws wafv2 get-sampled-requests \ --web-acl-arn arn:aws:wafv2:us-west-2:123456789012:regional/webacl/test-cli/a1b2c3d4-5678-90ab-cdef-EXAMPLE11111 \ --rule-metric-name AWS-AWSManagedRulesSQLiRuleSet \ --scope=REGIONAL \ --time-window StartTime=2020-02-12T20:00Z,EndTime=2020-02-12T21:10Z \ --max-items 100
输出:
{ "TimeWindow": { "EndTime": 1581541800.0, "StartTime": 1581537600.0 }, "SampledRequests": [ { "Action": "BLOCK", "Timestamp": 1581541799.564, "RuleNameWithinRuleGroup": "AWS#AWSManagedRulesSQLiRuleSet#SQLi_BODY", "Request": { "Country": "US", "URI": "/", "Headers": [ { "Name": "Host", "Value": "alb-test-1EXAMPLE1.us-east-1.elb.amazonaws.com" }, { "Name": "Content-Length", "Value": "7456" }, { "Name": "User-Agent", "Value": "curl/7.53.1" }, { "Name": "Accept", "Value": "/" }, { "Name": "Content-Type", "Value": "application/x-www-form-urlencoded" } ], "ClientIP": "198.51.100.08", "Method": "POST", "HTTPVersion": "HTTP/1.1" }, "Weight": 1 }, { "Action": "BLOCK", "Timestamp": 1581541799.988, "RuleNameWithinRuleGroup": "AWS#AWSManagedRulesSQLiRuleSet#SQLi_BODY", "Request": { "Country": "US", "URI": "/", "Headers": [ { "Name": "Host", "Value": "alb-test-1EXAMPLE1.us-east-1.elb.amazonaws.com" }, { "Name": "Content-Length", "Value": "7456" }, { "Name": "User-Agent", "Value": "curl/7.53.1" }, { "Name": "Accept", "Value": "/" }, { "Name": "Content-Type", "Value": "application/x-www-form-urlencoded" } ], "ClientIP": "198.51.100.08", "Method": "POST", "HTTPVersion": "HTTP/1.1" }, "Weight": 3 }, { "Action": "BLOCK", "Timestamp": 1581541799.846, "RuleNameWithinRuleGroup": "AWS#AWSManagedRulesSQLiRuleSet#SQLi_BODY", "Request": { "Country": "US", "URI": "/", "Headers": [ { "Name": "Host", "Value": "alb-test-1EXAMPLE1.us-east-1.elb.amazonaws.com" }, { "Name": "Content-Length", "Value": "7456" }, { "Name": "User-Agent", "Value": "curl/7.53.1" }, { "Name": "Accept", "Value": "/" }, { "Name": "Content-Type", "Value": "application/x-www-form-urlencoded" } ], "ClientIP": "198.51.100.08", "Method": "POST", "HTTPVersion": "HTTP/1.1" }, "Weight": 1 }, { "Action": "BLOCK", "Timestamp": 1581541799.4, "RuleNameWithinRuleGroup": "AWS#AWSManagedRulesSQLiRuleSet#SQLi_BODY", "Request": { "Country": "US", "URI": "/", "Headers": [ { "Name": "Host", "Value": "alb-test-1EXAMPLE1.us-east-1.elb.amazonaws.com" }, { "Name": "Content-Length", "Value": "7456" }, { "Name": "User-Agent", "Value": "curl/7.53.1" }, { "Name": "Accept", "Value": "/" }, { "Name": "Content-Type", "Value": "application/x-www-form-urlencoded" } ], "ClientIP": "198.51.100.08", "Method": "POST", "HTTPVersion": "HTTP/1.1" }, "Weight": 1 } ], "PopulationSize": 4 }
有关更多信息,请参阅 Amazon WAF、Fi Amazon rewall Manager 和 Amazon Shield 高级开发者指南中的查看 Web 请求示例。
-
有关 API 的详细信息,请参阅Amazon CLI 命令参考GetSampledRequests
中的。
-
以下代码示例演示如何使用 get-web-acl-for-resource
。
- Amazon CLI
-
检索与 Amazon 资源关联的 Web ACL
以下内容
get-web-acl-for-resource
检索与指定资源关联的 Web ACL 的 JSON。aws wafv2 get-web-acl-for-resource \ --resource-arn arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/waf-cli-alb/1ea17125f8b25a2a
输出:
{ "WebACL":{ "Capacity":3, "Description":"", "Rules":[ { "Priority":1, "Action":{ "Block":{ } }, "VisibilityConfig":{ "SampledRequestsEnabled":true, "CloudWatchMetricsEnabled":true, "MetricName":"testrule01" }, "Name":"testrule01", "Statement":{ "AndStatement":{ "Statements":[ { "ByteMatchStatement":{ "PositionalConstraint":"EXACTLY", "TextTransformations":[ { "Priority":0, "Type":"NONE" } ], "SearchString":"dGVzdHN0cmluZw==", "FieldToMatch":{ "UriPath":{ } } } }, { "SizeConstraintStatement":{ "ComparisonOperator":"EQ", "TextTransformations":[ { "Priority":0, "Type":"NONE" } ], "FieldToMatch":{ "QueryString":{ } }, "Size":0 } } ] } } } ], "VisibilityConfig":{ "SampledRequestsEnabled":true, "CloudWatchMetricsEnabled":true, "MetricName":"test01" }, "DefaultAction":{ "Allow":{ } }, "Id":"9a1b2c3d4-5678-90ab-cdef-EXAMPLE11111 ", "ARN":"arn:aws:wafv2:us-west-2:123456789012:regional/webacl/test01/a1b2c3d4-5678-90ab-cdef-EXAMPLE11111 ", "Name":"test01" } }
有关更多信息,请参阅《WAF、Fi Amazon rewall Manager Amazon 和 Amazon Sh ield 高级开发者指南》中的 “将 Web ACL 与 Amazon 资源关联或取消关联”。
-
有关 API 的详细信息,请参阅Amazon CLI 命令参考GetWebAclForResource
中的。
-
以下代码示例演示如何使用 get-web-acl
。
- Amazon CLI
-
检索 Web ACL
以下内容
get-web-acl
检索具有指定名称、范围和 ID 的 Web ACL。您可以从命令create-web-acl
和中获取 Web ACL 的 IDlist-web-acls
。aws wafv2 get-web-acl \ --name test01 \ --scope REGIONAL \ --id a1b2c3d4-5678-90ab-cdef-EXAMPLE11111
输出:
{ "WebACL":{ "Capacity":3, "Description":"", "Rules":[ { "Priority":1, "Action":{ "Block":{ } }, "VisibilityConfig":{ "SampledRequestsEnabled":true, "CloudWatchMetricsEnabled":true, "MetricName":"testrule01" }, "Name":"testrule01", "Statement":{ "AndStatement":{ "Statements":[ { "ByteMatchStatement":{ "PositionalConstraint":"EXACTLY", "TextTransformations":[ { "Priority":0, "Type":"NONE" } ], "SearchString":"dGVzdHN0cmluZw==", "FieldToMatch":{ "UriPath":{ } } } }, { "SizeConstraintStatement":{ "ComparisonOperator":"EQ", "TextTransformations":[ { "Priority":0, "Type":"NONE" } ], "FieldToMatch":{ "QueryString":{ } }, "Size":0 } } ] } } } ], "VisibilityConfig":{ "SampledRequestsEnabled":true, "CloudWatchMetricsEnabled":true, "MetricName":"test01" }, "DefaultAction":{ "Allow":{ } }, "Id":"a1b2c3d4-5678-90ab-cdef-EXAMPLE11111", "ARN":"arn:aws:wafv2:us-west-2:123456789012:regional/webacl/test01/a1b2c3d4-5678-90ab-cdef-EXAMPLE11111", "Name":"test01" }, "LockToken":"e3db7e2c-d58b-4ee6-8346-6aec5511c6fb" }
有关更多信息,请参阅 W Amazon AF、Fi Amazon rewall Manager 和 Amazon Shield 高级开发者指南中的管理和使用 Web 访问控制列表 (Web ACL)。
-
有关 API 的详细信息,请参阅Amazon CLI 命令参考GetWebAcl
中的。
-
以下代码示例演示如何使用 list-available-managed-rule-groups
。
- Amazon CLI
-
检索托管规则组
以下内容
list-available-managed-rule-groups
返回当前可用于您的 Web ACL 的所有托管规则组的列表。aws wafv2 list-available-managed-rule-groups \ --scope REGIONAL
输出:
{ "ManagedRuleGroups": [ { "VendorName": "AWS", "Name": "AWSManagedRulesCommonRuleSet", "Description": "Contains rules that are generally applicable to web applications. This provides protection against exploitation of a wide range of vulnerabilities, including those described in OWASP publications and common Common Vulnerabilities and Exposures (CVE)." }, { "VendorName": "AWS", "Name": "AWSManagedRulesAdminProtectionRuleSet", "Description": "Contains rules that allow you to block external access to exposed admin pages. This may be useful if you are running third-party software or would like to reduce the risk of a malicious actor gaining administrative access to your application." }, { "VendorName": "AWS", "Name": "AWSManagedRulesKnownBadInputsRuleSet", "Description": "Contains rules that allow you to block request patterns that are known to be invalid and are associated with exploitation or discovery of vulnerabilities. This can help reduce the risk of a malicious actor discovering a vulnerable application." }, { "VendorName": "AWS", "Name": "AWSManagedRulesSQLiRuleSet", "Description": "Contains rules that allow you to block request patterns associated with exploitation of SQL databases, like SQL injection attacks. This can help prevent remote injection of unauthorized queries." }, { "VendorName": "AWS", "Name": "AWSManagedRulesLinuxRuleSet", "Description": "Contains rules that block request patterns associated with exploitation of vulnerabilities specific to Linux, including LFI attacks. This can help prevent attacks that expose file contents or execute code for which the attacker should not have had access." }, { "VendorName": "AWS", "Name": "AWSManagedRulesUnixRuleSet", "Description": "Contains rules that block request patterns associated with exploiting vulnerabilities specific to POSIX/POSIX-like OS, including LFI attacks. This can help prevent attacks that expose file contents or execute code for which access should not been allowed." }, { "VendorName": "AWS", "Name": "AWSManagedRulesWindowsRuleSet", "Description": "Contains rules that block request patterns associated with exploiting vulnerabilities specific to Windows, (e.g., PowerShell commands). This can help prevent exploits that allow attacker to run unauthorized commands or execute malicious code." }, { "VendorName": "AWS", "Name": "AWSManagedRulesPHPRuleSet", "Description": "Contains rules that block request patterns associated with exploiting vulnerabilities specific to the use of the PHP, including injection of unsafe PHP functions. This can help prevent exploits that allow an attacker to remotely execute code or commands." }, { "VendorName": "AWS", "Name": "AWSManagedRulesWordPressRuleSet", "Description": "The WordPress Applications group contains rules that block request patterns associated with the exploitation of vulnerabilities specific to WordPress sites." }, { "VendorName": "AWS", "Name": "AWSManagedRulesAmazonIpReputationList", "Description": "This group contains rules that are based on Amazon threat intelligence. This is useful if you would like to block sources associated with bots or other threats." } ] }
有关更多信息,请参阅 Amazon WAF、Fi Amazon rewall Manager 和 Amazon Shield 高级开发者指南中的托管规则组。
-
有关 API 的详细信息,请参阅Amazon CLI 命令参考ListAvailableManagedRuleGroups
中的。
-
以下代码示例演示如何使用 list-ip-sets
。
- Amazon CLI
-
检索 IP 集列表
以下内容
list-ip-sets
检索该账户中具有区域范围的所有 IP 集。aws wafv2 list-ip-sets \ --scope REGIONAL
输出:
{ "IPSets":[ { "ARN":"arn:aws:wafv2:us-west-2:123456789012:regional/ipset/testip/a1b2c3d4-5678-90ab-cdef-EXAMPLE11111", "Description":"", "Name":"testip", "LockToken":"0674c84b-0304-47fe-8728-c6bff46af8fc", "Id":"a1b2c3d4-5678-90ab-cdef-EXAMPLE11111 " } ], "NextMarker":"testip" }
有关更多信息,请参阅 Amazon WAF、Firewal Amazon l Manager 和 Amazon Shield 高级开发者指南中的 IP 集和正则表达式模式集。
-
有关 API 的详细信息,请参阅Amazon CLI 命令参考ListIpSets
中的。
-
以下代码示例演示如何使用 list-logging-configurations
。
- Amazon CLI
-
检索某个区域的所有日志配置列表
以下内容
list-logging-configurations
检索 Web ACL 的所有日志配置,这些配置仅限于该区域的区域使用。us-west-2
aws wafv2 list-logging-configurations \ --scope REGIONAL \ --region us-west-2
输出:
{ "LoggingConfigurations":[ { "ResourceArn":"arn:aws:wafv2:us-west-2:123456789012:regional/webacl/test-2/a1b2c3d4-5678-90ab-cdef-EXAMPLE11111", "RedactedFields":[ { "QueryString":{ } } ], "LogDestinationConfigs":[ "arn:aws:firehose:us-west-2:123456789012:deliverystream/aws-waf-logs-test" ] }, { "ResourceArn":"arn:aws:wafv2:us-west-2:123456789012:regional/webacl/test/a1b2c3d4-5678-90ab-cdef-EXAMPLE22222", "RedactedFields":[ { "Method":{ } } ], "LogDestinationConfigs":[ "arn:aws:firehose:us-west-2:123456789012:deliverystream/aws-waf-logs-custom-transformation" ] } ] }
有关更多信息,请参阅 W Amazon AF、Fi Amazon rewall Manager 和 Amazon Shield 高级开发者指南中的记录 Web ACL 流量信息。
-
有关 API 的详细信息,请参阅Amazon CLI 命令参考ListLoggingConfigurations
中的。
-
以下代码示例演示如何使用 list-regex-pattern-sets
。
- Amazon CLI
-
检索正则表达式模式集列表
以下内容
list-regex-pattern-sets
检索在该区域中定义的账户的所有正则表达式模式集。us-west-2
aws wafv2 list-regex-pattern-sets \ --scope REGIONAL \ --region us-west-2
输出:
{ "NextMarker":"regexPatterSet01", "RegexPatternSets":[ { "ARN":"arn:aws:wafv2:us-west-2:123456789012:regional/regexpatternset/regexPatterSet01/a1b2c3d4-5678-90ab-cdef-EXAMPLE11111", "Description":"Test web-acl", "Name":"regexPatterSet01", "LockToken":"f17743f7-0000-0000-0000-19a8b93bfb01", "Id":"a1b2c3d4-5678-90ab-cdef-EXAMPLE11111" } ] }
有关更多信息,请参阅 Amazon WAF、Firewal Amazon l Manager 和 Amazon Shield 高级开发者指南中的 IP 集和正则表达式模式集。
-
有关 API 的详细信息,请参阅Amazon CLI 命令参考ListRegexPatternSets
中的。
-
以下代码示例演示如何使用 list-resources-for-web-acl
。
- Amazon CLI
-
检索与 Web ACL 关联的资源
以下内容
list-resources-for-web-acl
检索当前与该地区us-west-2
指定网页 ACL 关联的 API Gateway REST API 资源。aws wafv2 list-resources-for-web-acl \ --web-acl-arn arn:aws:wafv2:us-west-2:123456789012:regional/webacl/TestWebAcl/a1b2c3d4-5678-90ab-cdef-EXAMPLE11111 \ --resource-type API_GATEWAY \ --region us-west-2
输出:
{ "ResourceArns": [ "arn:aws:apigateway:us-west-2::/restapis/EXAMPLE111/stages/testing" ] }
有关更多信息,请参阅《WAF、Fi Amazon rewall Manager Amazon 和 Amazon Sh ield 高级开发者指南》中的 “将 Web ACL 与 Amazon 资源关联或取消关联”。
-
有关 API 的详细信息,请参阅Amazon CLI 命令参考ListResourcesForWebAcl
中的。
-
以下代码示例演示如何使用 list-rule-groups
。
- Amazon CLI
-
检索自定义规则组列表
以下内容
list-rule-groups
检索为指定范围和区域位置的账户定义的所有自定义规则组。aws wafv2 list-rule-groups \ --scope REGIONAL \ --region us-west-2
输出:
{ "RuleGroups":[ { "ARN":"arn:aws:wafv2:us-west-2:123456789012:regional/rulegroup/TestRuleGroup/a1b2c3d4-5678-90ab-cdef-EXAMPLE11111", "Description":"", "Name":"TestRuleGroup", "LockToken":"1eb5ec48-0000-0000-0000-ee9b906c541e", "Id":"a1b2c3d4-5678-90ab-cdef-EXAMPLE11111" }, { "ARN":"arn:aws:wafv2:us-west-2:123456789012:regional/rulegroup/test/a1b2c3d4-5678-90ab-cdef-EXAMPLE22222", "Description":"", "Name":"test", "LockToken":"b0f4583e-998b-4880-9069-3fbe45738b43", "Id":"a1b2c3d4-5678-90ab-cdef-EXAMPLE22222" } ], "NextMarker":"test" }
有关更多信息,请参阅《Amazon WAF》、《Fi Amazon rewall Manager》和《 Amazon Shield 高级开发者指南》中的 “管理自己的规则组”。
-
有关 API 的详细信息,请参阅Amazon CLI 命令参考ListRuleGroups
中的。
-
以下代码示例演示如何使用 list-tags-for-resource
。
- Amazon CLI
-
检索 Amazon WAF 资源的所有标签
以下内容
list-tags-for-resource
检索指定 Web ACL 的所有标签键和值对的列表。aws wafv2 list-tags-for-resource \ --resource-arn arn:aws:wafv2:us-west-2:123456789012:regional/webacl/testwebacl2/a1b2c3d4-5678-90ab-cdef-EXAMPLE11111
输出:
{ "NextMarker":"", "TagInfoForResource":{ "ResourceARN":"arn:aws:wafv2:us-west-2:123456789012:regional/webacl/testwebacl2/a1b2c3d4-5678-90ab-cdef-EXAMPLE11111", "TagList":[ ] } }
有关更多信息,请参阅 Amazon WAF、Fi Amazon rewall Manager 和 Amazon Shield 高级开发者指南中的Amazon WAF 入门。
-
有关 API 的详细信息,请参阅Amazon CLI 命令参考ListTagsForResource
中的。
-
以下代码示例演示如何使用 list-web-acls
。
- Amazon CLI
-
检索作用域的 Web ACL
以下内容
list-web-acls
检索为指定范围内的账户定义的所有 Web ACL。aws wafv2 list-web-acls \ --scope REGIONAL
输出:
{ "NextMarker":"Testt", "WebACLs":[ { "ARN":"arn:aws:wafv2:us-west-2:123456789012:regional/webacl/Testt/a1b2c3d4-5678-90ab-cdef-EXAMPLE11111", "Description":"sssss", "Name":"Testt", "LockToken":"7f36cb30-74ef-4cff-8cd4-a77e1aba1746", "Id":"a1b2c3d4-5678-90ab-cdef-EXAMPLE11111" } ] }
有关更多信息,请参阅 W Amazon AF、Fi Amazon rewall Manager 和 Amazon Shield 高级开发者指南中的管理和使用 Web 访问控制列表 (Web ACL)。
-
有关 API 的详细信息,请参阅Amazon CLI 命令参考ListWebAcls
中的。
-
以下代码示例演示如何使用 put-logging-configuration
。
- Amazon CLI
-
向 Web ACL 添加日志配置
以下内容
put-logging-configuration
将 Amazon Kinesis Data Firehoseaws-waf-logs-custom-transformation
日志配置添加到指定的网络 ACL 中,但没有从日志中删除任何字段。aws wafv2 put-logging-configuration \ --logging-configuration ResourceArn=arn:aws:wafv2:us-west-2:123456789012:regional/webacl/test-cli/a1b2c3d4-5678-90ab-cdef-EXAMPLE11111,LogDestinationConfigs=arn:aws:firehose:us-west-2:123456789012:deliverystream/aws-waf-logs-custom-transformation \ --region us-west-2
输出:
{ "LoggingConfiguration":{ "ResourceArn":"arn:aws:wafv2:us-west-2:123456789012:regional/webacl/test-cli/a1b2c3d4-5678-90ab-cdef-EXAMPLE11111", "LogDestinationConfigs":[ "arn:aws:firehose:us-west-2:123456789012:deliverystream/aws-waf-logs-custom-transformation" ] } }
有关更多信息,请参阅 W Amazon AF、Fi Amazon rewall Manager 和 Amazon Shield 高级开发者指南中的记录 Web ACL 流量信息。
-
有关 API 的详细信息,请参阅Amazon CLI 命令参考PutLoggingConfiguration
中的。
-
以下代码示例演示如何使用 tag-resource
。
- Amazon CLI
-
向 Amazon WAF 资源添加标签
以下
tag-resource
示例向指定的 Web ACL 添加一个密钥为Name
、值设置AWSWAF
为的标签。aws wafv2 tag-resource \ --resource-arn arn:aws:wafv2:us-west-2:123456789012:regional/webacl/apiGatewayWebAcl/a1b2c3d4-5678-90ab-cdef-EXAMPLE11111 \ --tags Key=Name,Value=AWSWAF
此命令不生成任何输出。
有关更多信息,请参阅 Amazon WAF、Fi Amazon rewall Manager 和 Amazon Shield 高级开发者指南中的Amazon WAF 入门。
-
有关 API 的详细信息,请参阅Amazon CLI 命令参考TagResource
中的。
-
以下代码示例演示如何使用 untag-resource
。
- Amazon CLI
-
从 Amazon WAF 资源中移除标签
以下
untag-resource
示例KeyName
从指定的 Web ACL 中删除带有密钥的标签。aws wafv2 untag-resource \ --resource-arn arn:aws:wafv2:us-west-2:123456789012:regional/webacl/apiGatewayWebAcl/a1b2c3d4-5678-90ab-cdef-EXAMPLE11111 \ --tag-keys "KeyName"
此命令不生成任何输出。
有关更多信息,请参阅 Amazon WAF、Fi Amazon rewall Manager 和 Amazon Shield 高级开发者指南中的Amazon WAF 入门。
-
有关 API 的详细信息,请参阅Amazon CLI 命令参考UntagResource
中的。
-
以下代码示例演示如何使用 update-ip-set
。
- Amazon CLI
-
修改现有 IP 集的设置
以下内容
update-ip-set
更新了指定 IP 集的设置。此调用需要一个 ID(您可以从呼叫中获取)和一个可以从调用中获取的锁定令牌,list-ip-sets
以及get-ip-set
。list-ip-sets
此调用还会返回一个锁定令牌,您可以将其用于后续更新。aws wafv2 update-ip-set \ --name testip \ --scope REGIONAL \ --id a1b2c3d4-5678-90ab-cdef-EXAMPLE11111 \ --addresses 198.51.100.0/16 \ --lock-token 447e55ac-2396-4c6d-b9f9-86b67c17f8b5
输出:
{ "NextLockToken": "0674c84b-0304-47fe-8728-c6bff46af8fc" }
有关更多信息,请参阅 Amazon WAF、Firewal Amazon l Manager 和 Amazon Shield 高级开发者指南中的 IP 集和正则表达式模式集。
-
有关 API 的详细信息,请参阅Amazon CLI 命令参考UpdateIpSet
中的。
-
以下代码示例演示如何使用 update-regex-pattern-set
。
- Amazon CLI
-
修改现有正则表达式模式集的设置
以下内容
update-regex-pattern-set
更新了指定正则表达式模式集的设置。此调用需要一个 ID(您可以从呼叫中获取)和一个可以从调用中获取的锁定令牌,list-regex-pattern-sets
以及get-regex-pattern-set
。list-regex-pattern-sets
此调用还会返回一个锁定令牌,您可以将其用于后续更新。aws wafv2 update-regex-pattern-set \ --name ExampleRegex \ --scope REGIONAL \ --id a1b2c3d4-5678-90ab-cdef-EXAMPLE11111 \ --regular-expression-list RegexString="^.+$" \ --lock-token ed207e9c-82e9-4a77-aadd-81e6173ab7eb
输出:
{ "NextLockToken": "12ebc73e-fa68-417d-a9b8-2bdd761a4fa5" }
有关更多信息,请参阅 Amazon WAF、Firewal Amazon l Manager 和 Amazon Shield 高级开发者指南中的 IP 集和正则表达式模式集。
-
有关 API 的详细信息,请参阅Amazon CLI 命令参考UpdateRegexPatternSet
中的。
-
以下代码示例演示如何使用 update-rule-group
。
- Amazon CLI
-
更新自定义规则组
以下内容
update-rule-group
更改了现有自定义规则组的可见性配置。此调用需要一个 ID(您可以从呼叫中获取)和一个可以从调用中获取的锁定令牌,list-rule-groups
以及get-rule-group
。list-rule-groups
此调用还会返回一个锁定令牌,您可以将其用于后续更新。aws wafv2 update-rule-group \ --name TestRuleGroup \ --scope REGIONAL \ --id a1b2c3d4-5678-90ab-cdef-EXAMPLE11111 \ --lock-token 7b3bcec2-0000-0000-0000-563bf47249f0 \ --visibility-config SampledRequestsEnabled=false,CloudWatchMetricsEnabled=false,MetricName=TestMetricsForRuleGroup \ --region us-west-2
输出:
{ "NextLockToken": "1eb5ec48-0000-0000-0000-ee9b906c541e" }
有关更多信息,请参阅《Amazon WAF》、《Fi Amazon rewall Manager》和《 Amazon Shield 高级开发者指南》中的 “管理自己的规则组”。
-
有关 API 的详细信息,请参阅Amazon CLI 命令参考UpdateRuleGroup
中的。
-
以下代码示例演示如何使用 update-web-acl
。
- Amazon CLI
-
更新 Web ACL
以下内容
update-web-acl
更改了现有 Web ACL 的设置。此呼叫需要一个 ID(您可以从呼叫中获取)list-web-acls
、锁定令牌和其他设置(您可以从呼叫中获取)get-web-acl
。此调用还会返回一个锁定令牌,您可以将其用于后续更新。aws wafv2 update-web-acl \ --name TestWebAcl \ --scope REGIONAL \ --id a1b2c3d4-5678-90ab-cdef-EXAMPLE11111 \ --lock-token 2294b3a1-0000-0000-0000-a3ae04329de9 \ --default-action Block={} \ --visibility-config SampledRequestsEnabled=false,CloudWatchMetricsEnabled=false,MetricName=NewMetricTestWebAcl \ --rules file://waf-rule.json \ --region us-west-2
输出:
{ "NextLockToken": "714a0cfb-0000-0000-0000-2959c8b9a684" }
有关更多信息,请参阅 W Amazon AF、Fi Amazon rewall Manager 和 Amazon Shield 高级开发者指南中的管理和使用 Web 访问控制列表 (Web ACL)。
-
有关 API 的详细信息,请参阅Amazon CLI 命令参考UpdateWebAcl
中的。
-