

# AWS WAFV2 examples using AWS CLI
<a name="cli_wafv2_code_examples"></a>

次のコード例では、AWS WAFV2 で AWS Command Line Interface を使用してアクションを実行し、一般的なシナリオを実装する方法を示しています。

*アクション*はより大きなプログラムからのコードの抜粋であり、コンテキスト内で実行する必要があります。アクションは個々のサービス機能を呼び出す方法を示していますが、コンテキスト内のアクションは、関連するシナリオで確認できます。

各例には完全なソースコードへのリンクが含まれており、コードの設定方法と実行方法に関する手順を確認できます。

**Topics**
+ [アクション](#actions)

## アクション
<a name="actions"></a>

### `associate-web-acl`
<a name="wafv2_AssociateWebAcl_cli_topic"></a>

次のコード例は、`associate-web-acl` を使用する方法を示しています。

**AWS CLI**  
**ウェブ ACL をリージョン AWS リソースに関連付けるには**  
次の `associate-web-acl` の例では、指定されたウェブ 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
```
このコマンドでは何も出力されません。  
詳細については、「*AWS WAF、AWS Firewall Manager、AWS Shield Advanced デベロッパーガイド*」の「[ウェブ ACL と AWS リソースの関連付けまたは関連付け解除](https://docs.aws.amazon.com/waf/latest/developerguide/web-acl-associating-aws-resource.html)」を参照してください。  
+  API の詳細については、「*AWS CLI コマンドリファレンス*」の「[AssociateWebAcl](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/wafv2/associate-web-acl.html)」を参照してください。

### `check-capacity`
<a name="wafv2_CheckCapacity_cli_topic"></a>

次のコード例は、`check-capacity` を使用する方法を示しています。

**AWS 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
}
```
詳細については、「*AWS WAF、AWS Firewall Manager、および AWS Shield Advanced デベロッパーガイド*」の「[AWS WAF ウェブ ACL キャパシティーユニット (WCU)](https://docs.aws.amazon.com/waf/latest/developerguide/how-aws-waf-works.html#aws-waf-capacity-units)」を参照してください。  
+  API の詳細については、「*AWS CLI コマンドリファレンス*」の「[CheckCapacity](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/wafv2/check-capacity.html)」を参照してください。

### `create-ip-set`
<a name="wafv2_CreateIpSet_cli_topic"></a>

次のコード例は、`create-ip-set` を使用する方法を示しています。

**AWS CLI**  
**ウェブ ACL とルールグループで使用する IP セットを作成するには**  
次の `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"
    }
}
```
詳細については、「*AWS WAF、AWS Firewall Manager、および AWS Shield Advanced デベロッパーガイド*」の「[IP セットおよび正規表現パターンセット](https://docs.aws.amazon.com/waf/latest/developerguide/waf-referenced-set-managing.html)」を参照してください。  
+  API の詳細については、「*AWS CLI コマンドリファレンス*」の「[CreateIpSet](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/wafv2/create-ip-set.html)」を参照してください。

### `create-regex-pattern-set`
<a name="wafv2_CreateRegexPatternSet_cli_topic"></a>

次のコード例は、`create-regex-pattern-set` を使用する方法を示しています。

**AWS CLI**  
**ウェブ ACL とルールグループで使用する正規表現パターンセットを作成するには**  
次の `create-regex-pattern-set` コマンドは、2 つの正規表現パターンを指定して正規表現パターンセットを作成します。  

```
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"
    }
}
```
詳細については、「*AWS WAF、AWS Firewall Manager、および AWS Shield Advanced デベロッパーガイド*」の「[IP セットおよび正規表現パターンセット](https://docs.aws.amazon.com/waf/latest/developerguide/waf-referenced-set-managing.html)」を参照してください。  
+  API の詳細については、「*AWS CLI コマンドリファレンス*」の「[CreateRegexPatternSet](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/wafv2/create-regex-pattern-set.html)」を参照してください。

### `create-rule-group`
<a name="wafv2_CreateRuleGroup_cli_topic"></a>

次のコード例は、`create-rule-group` を使用する方法を示しています。

**AWS CLI**  
**ウェブ 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
```
file://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"
    }
}
```
詳細については、「*AWS WAF、AWS Firewall Manager、および AWS Shield Advanced デベロッパーガイド*」の「[独自のルールグループの管理](https://docs.aws.amazon.com/waf/latest/developerguide/waf-user-created-rule-groups.html)」を参照してください。  
+  API の詳細については、「*AWS CLI コマンドリファレンス*」の「[CreateRuleGroup](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/wafv2/create-rule-group.html)」を参照してください。

### `create-web-acl`
<a name="wafv2_CreateWebAcl_cli_topic"></a>

次のコード例は、`create-web-acl` を使用する方法を示しています。

**AWS CLI**  
**ウェブ ACL を作成するには**  
次の `create-web-acl` コマンドは、リージョンで使用するウェブ ACL を作成します。ウェブ 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
```
file://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"
    }
}
```
詳細については、「*AWS WAF、AWS Firewall Manager、および AWS Shield Advanced デベロッパーガイド*」の「[ウェブアクセスコントロールリスト（ウェブ ACL）の管理と使用](https://docs.aws.amazon.com/waf/latest/developerguide/web-acl.html)」を参照してください。  
+  API の詳細については、「*AWS CLI コマンドリファレンス*」の「[CreateWebAcl](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/wafv2/create-web-acl.html)」を参照してください。

### `delete-ip-set`
<a name="wafv2_DeleteIpSet_cli_topic"></a>

次のコード例は、`delete-ip-set` を使用する方法を示しています。

**AWS CLI**  
**IP セットを削除するには**  
以下の `delete-ip-set` は指定した IP セットを削除します。この呼び出しには、呼び出しから取得できる ID、`list-ip-sets`、および呼び出しから取得できるロックトークン、`list-ip-sets` と `get-ip-set` が必要です。  

```
aws wafv2 delete-ip-set \
    --name test1 \
    --scope REGIONAL \
    --id a1b2c3d4-5678-90ab-cdef-EXAMPLE11111 \
    --lock-token 46851772-db6f-459d-9385-49428812e357
```
このコマンドでは何も出力されません。  
詳細については、「*AWS WAF、AWS Firewall Manager、および AWS Shield Advanced デベロッパーガイド*」の「[IP セットおよび正規表現パターンセット](https://docs.aws.amazon.com/waf/latest/developerguide/waf-referenced-set-managing.html)」を参照してください。  
+  API の詳細については、「*AWS CLI コマンドリファレンス*」の「[DeleteIpSet](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/wafv2/delete-ip-set.html)」を参照してください。

### `delete-logging-configuration`
<a name="wafv2_DeleteLoggingConfiguration_cli_topic"></a>

次のコード例は、`delete-logging-configuration` を使用する方法を示しています。

**AWS CLI**  
**ウェブ ACL でログ記録を無効にするには**  
次の `delete-logging-configuration` は、指定されたウェブ ACL からログ記録設定を削除します。  

```
aws wafv2 delete-logging-configuration \
    --resource-arn arn:aws:wafv2:us-west-2:123456789012:regional/webacl/test/a1b2c3d4-5678-90ab-cdef-EXAMPLE22222
```
このコマンドでは何も出力されません。  
詳細については、「*AWS WAF、AWS Firewall Manager、および AWS Shield Advanced デベロッパーガイド*」の「[ウェブ ACL トラフィック情報のログ記録](https://docs.aws.amazon.com/waf/latest/developerguide/logging.html)」を参照してください。  
+  API の詳細については、「*AWS CLI コマンドリファレンス*」の「[DeleteLoggingConfiguration](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/wafv2/delete-logging-configuration.html)」を参照してください。

### `delete-regex-pattern-set`
<a name="wafv2_DeleteRegexPatternSet_cli_topic"></a>

次のコード例は、`delete-regex-pattern-set` を使用する方法を示しています。

**AWS CLI**  
**正規表現パターンセットを削除するには**  
次の `delete-regex-pattern-set` は、指定された正規表現パターンセットの設定を更新します。この呼び出しには、呼び出しから取得できる ID、`list-regex-pattern-sets`、および呼び出し `list-regex-pattern-sets` または呼び出し `get-regex-pattern-set` から取得できるロックトークンが必要です。  

```
aws wafv2 delete-regex-pattern-set \
    --name regexPatterSet01 \
    --scope REGIONAL \
    --id a1b2c3d4-5678-90ab-cdef-EXAMPLE11111 \
    --lock-token 0bc01e21-03c9-4b98-9433-6229cbf1ef1c
```
このコマンドでは何も出力されません。  
詳細については、「*AWS WAF、AWS Firewall Manager、および AWS Shield Advanced デベロッパーガイド*」の「[IP セットおよび正規表現パターンセット](https://docs.aws.amazon.com/waf/latest/developerguide/waf-referenced-set-managing.html)」を参照してください。  
+  API の詳細については、「*AWS CLI コマンドリファレンス*」の「[DeleteRegexPatternSet](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/wafv2/delete-regex-pattern-set.html)」を参照してください。

### `delete-rule-group`
<a name="wafv2_DeleteRuleGroup_cli_topic"></a>

次のコード例は、`delete-rule-group` を使用する方法を示しています。

**AWS CLI**  
**カスタムルールグループを削除するには**  
次の `delete-rule-group` は、指定されたカスタムルールグループを削除します。この呼び出しには、呼び出しから取得できる ID、`list-rule-groups`、および呼び出し `list-rule-groups` または呼び出し `get-rule-group` から取得できるロックトークンが必要です。  

```
aws wafv2 delete-rule-group \
    --name TestRuleGroup \
    --scope REGIONAL \
    --id a1b2c3d4-5678-90ab-cdef-EXAMPLE11111 \
    --lock-token 7b3bcec2-0000-0000-0000-563bf47249f0
```
このコマンドでは何も出力されません。  
詳細については、「*AWS WAF、AWS Firewall Manager、および AWS Shield Advanced デベロッパーガイド*」の「[独自のルールグループの管理](https://docs.aws.amazon.com/waf/latest/developerguide/waf-user-created-rule-groups.html)」を参照してください。  
+  API の詳細については、「*AWS CLI コマンドリファレンス*」の「[DeleteRuleGroup](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/wafv2/delete-rule-group.html)」を参照してください。

### `delete-web-acl`
<a name="wafv2_DeleteWebAcl_cli_topic"></a>

次のコード例は、`delete-web-acl` を使用する方法を示しています。

**AWS CLI**  
**ウェブ ACL を削除するには**  
次の `delete-web-acl` は、アカウントから指定されたウェブ ACL を削除します。ウェブ ACL は、リソースに関連付けられていない場合にのみ削除できます。この呼び出しには、呼び出しから取得できる ID、`list-web-acls`、および呼び出し `list-web-acls` または呼び出し `get-web-acl` から取得できるロックトークンが必要です。  

```
aws wafv2 delete-web-acl \
    --name test \
    --scope REGIONAL \
    --id a1b2c3d4-5678-90ab-cdef-EXAMPLE11111 \
    --lock-token ebab4ed2-155e-4c9a-9efb-e4c45665b1f5
```
このコマンドでは何も出力されません。  
詳細については、「*AWS WAF、AWS Firewall Manager、および AWS Shield Advanced デベロッパーガイド*」の「[ウェブアクセスコントロールリスト（ウェブ ACL）の管理と使用](https://docs.aws.amazon.com/waf/latest/developerguide/web-acl.html)」を参照してください。  
+  API の詳細については、「*AWS CLI コマンドリファレンス*」の「[DeleteWebAcl](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/wafv2/delete-web-acl.html)」を参照してください。

### `describe-managed-rule-group`
<a name="wafv2_DescribeManagedRuleGroup_cli_topic"></a>

次のコード例は、`describe-managed-rule-group` を使用する方法を示しています。

**AWS CLI**  
**マネージドルールグループの説明を取得するには**  
次の `describe-managed-rule-group` は、AWS マネージドルールグループの説明を取得します。  

```
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": {}
            }
        }
    ]
}
```
詳細については、「*AWS WAF、AWS Firewall Manager、および AWS Shield Advanced デベロッパーガイド*」の「[マネージドルールグループ](https://docs.aws.amazon.com/waf/latest/developerguide/waf-managed-rule-groups.html)」を参照してください。  
+  API の詳細については、「*AWS CLI コマンドリファレンス*」の「[DescribeManagedRuleGroup](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/wafv2/describe-managed-rule-group.html)」を参照してください。

### `disassociate-web-acl`
<a name="wafv2_DisassociateWebAcl_cli_topic"></a>

次のコード例は、`disassociate-web-acl` を使用する方法を示しています。

**AWS CLI**  
**AWS リソースからウェブ ACL の関連付けを解除するには**  
次の `disassociate-web-acl` の例では、指定された Application Load Balancer から既存のウェブ 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
```
このコマンドでは何も出力されません。  
詳細については、「*AWS WAF、AWS Firewall Manager、AWS Shield Advanced デベロッパーガイド*」の「[ウェブ ACL と AWS リソースの関連付けまたは関連付け解除](https://docs.aws.amazon.com/waf/latest/developerguide/web-acl-associating-aws-resource.html)」を参照してください。  
+  API の詳細については、「*AWS CLI コマンドリファレンス*」の「[DisassociateWebAcl](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/wafv2/disassociate-web-acl.html)」を参照してください。

### `get-ip-set`
<a name="wafv2_GetIpSet_cli_topic"></a>

次のコード例は、`get-ip-set` を使用する方法を示しています。

**AWS CLI**  
**特定の IP セットを取得するには**  
次の `get-ip-set` は、指定された名前、スコープ、および ID を持つ IP セットを取得します。コマンド `create-ip-set` と `list-ip-sets` から IP セットの ID を取得できます。  

```
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"
}
```
詳細については、「*AWS WAF、AWS Firewall Manager、および AWS Shield Advanced デベロッパーガイド*」の「[IP セットおよび正規表現パターンセット](https://docs.aws.amazon.com/waf/latest/developerguide/waf-referenced-set-managing.html)」を参照してください。  
+  API の詳細については、「*AWS CLI コマンドリファレンス*」の「[GetIpSet](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/wafv2/get-ip-set.html)」を参照してください。

### `get-logging-configuration`
<a name="wafv2_GetLoggingConfiguration_cli_topic"></a>

次のコード例は、`get-logging-configuration` を使用する方法を示しています。

**AWS CLI**  
**ウェブ ACL のログ記録設定を取得するには**  
次の `get-logging-configuration` は、指定されたウェブ 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"
        ]
    }
}
```
詳細については、「*AWS WAF、AWS Firewall Manager、および AWS Shield Advanced デベロッパーガイド*」の「[ウェブ ACL トラフィック情報のログ記録](https://docs.aws.amazon.com/waf/latest/developerguide/logging.html)」を参照してください。  
+  API の詳細については、「*AWS CLI コマンドリファレンス*」の「[GetLoggingConfiguration](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/wafv2/get-logging-configuration.html)」を参照してください。

### `get-rate-based-statement-managed-keys`
<a name="wafv2_GetRateBasedStatementManagedKeys_cli_topic"></a>

次のコード例は、`get-rate-based-statement-managed-keys` を使用する方法を示しています。

**AWS 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":[

        ]
    }
}
```
詳細については、「*AWS WAF、AWS Firewall Manager、および AWS Shield Advanced デベロッパーガイド*」の「[レートベースのルールステートメント](https://docs.aws.amazon.com/waf/latest/developerguide/waf-rule-statement-type-rate-based.html)」を参照してください。  
+  API の詳細については、「*AWS CLI コマンドリファレンス*」の「[GetRateBasedStatementManagedKeys](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/wafv2/get-rate-based-statement-managed-keys.html)」を参照してください。

### `get-regex-pattern-set`
<a name="wafv2_GetRegexPatternSet_cli_topic"></a>

次のコード例は、`get-regex-pattern-set` を使用する方法を示しています。

**AWS CLI**  
**特定の正規表現パターンセットを取得するには**  
次の `get-regex-pattern-set` は、指定された名前、スコープ、リージョン、および ID を持つ正規表現パターンセットを取得します。コマンド `create-regex-pattern-set` と `list-regex-pattern-sets` から正規表現パターンセットの ID を取得できます。  

```
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"
}
```
詳細については、「*AWS WAF、AWS Firewall Manager、および AWS Shield Advanced デベロッパーガイド*」の「[IP セットおよび正規表現パターンセット](https://docs.aws.amazon.com/waf/latest/developerguide/waf-referenced-set-managing.html)」を参照してください。  
+  API の詳細については、「*AWS CLI コマンドリファレンス*」の「[GetRegexPatternSet](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/wafv2/get-regex-pattern-set.html)」を参照してください。

### `get-rule-group`
<a name="wafv2_GetRuleGroup_cli_topic"></a>

次のコード例は、`get-rule-group` を使用する方法を示しています。

**AWS CLI**  
**特定のカスタムルールグループを取得するには**  
次の `get-rule-group` は、指定された名前、スコープ、および ID を持つカスタムルールグループを取得します。コマンド `create-rule-group` と `list-rule-groups` からルールグループの ID を取得できます。  

```
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"
}
```
詳細については、「*AWS WAF、AWS Firewall Manager、および AWS Shield Advanced デベロッパーガイド*」の「[独自のルールグループの管理](https://docs.aws.amazon.com/waf/latest/developerguide/waf-user-created-rule-groups.html)」を参照してください。  
+  API の詳細については、「*AWS CLI コマンドリファレンス*」の「[GetRuleGroup](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/wafv2/get-rule-group.html)」を参照してください。

### `get-sampled-requests`
<a name="wafv2_GetSampledRequests_cli_topic"></a>

次のコード例は、`get-sampled-requests` を使用する方法を示しています。

**AWS CLI**  
**ウェブ ACL のウェブリクエストのサンプルを取得するには**  
次の `get-sampled-requests` は、指定されたウェブ ACL、ルールメトリクス、時間枠のサンプルされたウェブリクエストを取得します。  

```
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
}
```
詳細については、「*AWS WAF、AWS Firewall Manager、および AWS Shield Advanced デベロッパーガイド*」の「[ウェブリクエストのサンプルの表示](https://docs.aws.amazon.com/waf/latest/developerguide/web-acl-testing.html#web-acl-testing-view-sample)」を参照してください。  
+  API の詳細については、「*AWS CLI コマンドリファレンス*」の「[GetSampledRequests](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/wafv2/get-sampled-requests.html)」を参照してください。

### `get-web-acl-for-resource`
<a name="wafv2_GetWebAclForResource_cli_topic"></a>

次のコード例は、`get-web-acl-for-resource` を使用する方法を示しています。

**AWS CLI**  
**AWS リソースに関連付けられているウェブ ACL を取得するには**  
次の `get-web-acl-for-resource` は、指定されたリソースに関連付けられているウェブ 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"
    }
}
```
詳細については、「*AWS WAF、AWS Firewall Manager、AWS Shield Advanced デベロッパーガイド*」の「[ウェブ ACL と AWS リソースの関連付けまたは関連付け解除](https://docs.aws.amazon.com/waf/latest/developerguide/web-acl-associating-aws-resource.html)」を参照してください。  
+  API の詳細については、「*AWS CLI コマンドリファレンス*」の「[GetWebAclForResource](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/wafv2/get-web-acl-for-resource.html)」を参照してください。

### `get-web-acl`
<a name="wafv2_GetWebAcl_cli_topic"></a>

次のコード例は、`get-web-acl` を使用する方法を示しています。

**AWS CLI**  
**ウェブ ACL を取得するには**  
次の `get-web-acl` は、指定された名前、スコープ、および ID を持つウェブ ACL を取得します。コマンド `create-web-acl` と `list-web-acls` からウェブ ACL の ID を取得できます。  

```
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"
}
```
詳細については、「*AWS WAF、AWS Firewall Manager、および AWS Shield Advanced デベロッパーガイド*」の「[ウェブアクセスコントロールリスト（ウェブ ACL）の管理と使用](https://docs.aws.amazon.com/waf/latest/developerguide/web-acl.html)」を参照してください。  
+  API の詳細については、「*AWS CLI コマンドリファレンス*」の「[GetWebAcl](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/wafv2/get-web-acl.html)」を参照してください。

### `list-available-managed-rule-groups`
<a name="wafv2_ListAvailableManagedRuleGroups_cli_topic"></a>

次のコード例は、`list-available-managed-rule-groups` を使用する方法を示しています。

**AWS CLI**  
**マネージドルールグループを取得するには**  
次の `list-available-managed-rule-groups` は、ウェブ 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."
        }
    ]
}
```
詳細については、「*AWS WAF、AWS Firewall Manager、および AWS Shield Advanced デベロッパーガイド*」の「[マネージドルールグループ](https://docs.aws.amazon.com/waf/latest/developerguide/waf-managed-rule-groups.html)」を参照してください。  
+  API の詳細については、「*AWS CLI コマンドリファレンス*」の「[ListAvailableManagedRuleGroups](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/wafv2/list-available-managed-rule-groups.html)」を参照してください。

### `list-ip-sets`
<a name="wafv2_ListIpSets_cli_topic"></a>

次のコード例は、`list-ip-sets` を使用する方法を示しています。

**AWS 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"
}
```
詳細については、「*AWS WAF、AWS Firewall Manager、および AWS Shield Advanced デベロッパーガイド*」の「[IP セットおよび正規表現パターンセット](https://docs.aws.amazon.com/waf/latest/developerguide/waf-referenced-set-managing.html)」を参照してください。  
+  API の詳細については、「*AWS CLI コマンドリファレンス*」の「[ListIpSets](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/wafv2/list-ip-sets.html)」を参照してください。

### `list-logging-configurations`
<a name="wafv2_ListLoggingConfigurations_cli_topic"></a>

次のコード例は、`list-logging-configurations` を使用する方法を示しています。

**AWS CLI**  
**リージョンのすべてのログ記録設定のリストを取得するには**  
次の `list-logging-configurations` は、`us-west-2` リージョンでリージョンでの使用がスコープされているウェブ ACL のすべてのログ記録設定を取得します。  

```
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"
            ]
        }
    ]
}
```
詳細については、「*AWS WAF、AWS Firewall Manager、および AWS Shield Advanced デベロッパーガイド*」の「[ウェブ ACL トラフィック情報のログ記録](https://docs.aws.amazon.com/waf/latest/developerguide/logging.html)」を参照してください。  
+  API の詳細については、「*AWS CLI コマンドリファレンス*」の「[ListLoggingConfigurations](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/wafv2/list-logging-configurations.html)」を参照してください。

### `list-regex-pattern-sets`
<a name="wafv2_ListRegexPatternSets_cli_topic"></a>

次のコード例は、`list-regex-pattern-sets` を使用する方法を示しています。

**AWS 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"
        }
    ]
}
```
詳細については、「*AWS WAF、AWS Firewall Manager、および AWS Shield Advanced デベロッパーガイド*」の「[IP セットおよび正規表現パターンセット](https://docs.aws.amazon.com/waf/latest/developerguide/waf-referenced-set-managing.html)」を参照してください。  
+  API の詳細については、「*AWS CLI コマンドリファレンス*」の「[ListRegexPatternSets](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/wafv2/list-regex-pattern-sets.html)」を参照してください。

### `list-resources-for-web-acl`
<a name="wafv2_ListResourcesForWebAcl_cli_topic"></a>

次のコード例は、`list-resources-for-web-acl` を使用する方法を示しています。

**AWS CLI**  
**ウェブ 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"
    ]
}
```
詳細については、「*AWS WAF、AWS Firewall Manager、AWS Shield Advanced デベロッパーガイド*」の「[ウェブ ACL と AWS リソースの関連付けまたは関連付け解除](https://docs.aws.amazon.com/waf/latest/developerguide/web-acl-associating-aws-resource.html)」を参照してください。  
+  API の詳細については、「*AWS CLI コマンドリファレンス*」の「[ListResourcesForWebAcl](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/wafv2/list-resources-for-web-acl.html)」を参照してください。

### `list-rule-groups`
<a name="wafv2_ListRuleGroups_cli_topic"></a>

次のコード例は、`list-rule-groups` を使用する方法を示しています。

**AWS 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"
}
```
詳細については、「*AWS WAF、AWS Firewall Manager、および AWS Shield Advanced デベロッパーガイド*」の「[独自のルールグループの管理](https://docs.aws.amazon.com/waf/latest/developerguide/waf-user-created-rule-groups.html)」を参照してください。  
+  API の詳細については、「*AWS CLI コマンドリファレンス*」の「[ListRuleGroups](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/wafv2/list-rule-groups.html)」を参照してください。

### `list-tags-for-resource`
<a name="wafv2_ListTagsForResource_cli_topic"></a>

次のコード例は、`list-tags-for-resource` を使用する方法を示しています。

**AWS CLI**  
**AWS WAF リソースのすべてのタグを取得するには**  
次の `list-tags-for-resource` は、指定されたウェブ 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":[

        ]
    }
}
```
詳細については、「*AWS WAF、AWS Firewall Manager、および AWS Shield Advanced デベロッパーガイド*」の「[AWS WAF の開始方法](https://docs.aws.amazon.com/waf/latest/developerguide/getting-started.html)」を参照してください。  
+  API の詳細については、「AWS CLI コマンドリファレンス」の「[ListTagsForResource](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/wafv2/list-tags-for-resource.html)」を参照してください。

### `list-web-acls`
<a name="wafv2_ListWebAcls_cli_topic"></a>

次のコード例は、`list-web-acls` を使用する方法を示しています。

**AWS CLI**  
**スコープのウェブ ACL を取得するには**  
次の `list-web-acls` は、指定されたスコープのアカウントに定義されているすべてのウェブ 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"
        }
    ]
}
```
詳細については、「*AWS WAF、AWS Firewall Manager、および AWS Shield Advanced デベロッパーガイド*」の「[ウェブアクセスコントロールリスト（ウェブ ACL）の管理と使用](https://docs.aws.amazon.com/waf/latest/developerguide/web-acl.html)」を参照してください。  
+  API の詳細については、「*AWS CLI コマンドリファレンス*」の「[ListWebAcls](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/wafv2/list-web-acls.html)」を参照してください。

### `put-logging-configuration`
<a name="wafv2_PutLoggingConfiguration_cli_topic"></a>

次のコード例は、`put-logging-configuration` を使用する方法を示しています。

**AWS CLI**  
**ウェブ ACL にログ記録設定を追加するには**  
次の `put-logging-configuration` は、Amazon Kinesis Data Firehose ログ記録設定 `aws-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"
        ]
    }
}
```
詳細については、「*AWS WAF、AWS Firewall Manager、および AWS Shield Advanced デベロッパーガイド*」の「[ウェブ ACL トラフィック情報のログ記録](https://docs.aws.amazon.com/waf/latest/developerguide/logging.html)」を参照してください。  
+  API の詳細については、「*AWS CLI コマンドリファレンス*」の「[PutLoggingConfiguration](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/wafv2/put-logging-configuration.html)」を参照してください。

### `tag-resource`
<a name="wafv2_TagResource_cli_topic"></a>

次のコード例は、`tag-resource` を使用する方法を示しています。

**AWS CLI**  
**AWS WAF リソースにタグを追加するには**  
次の `tag-resource` の例では、指定されたウェブ 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
```
このコマンドでは何も出力されません。  
詳細については、「*AWS WAF、AWS Firewall Manager、および AWS Shield Advanced デベロッパーガイド*」の「[AWS WAF の開始方法](https://docs.aws.amazon.com/waf/latest/developerguide/getting-started.html)」を参照してください。  
+  API の詳細については、「*AWS CLI コマンドリファレンス*」の「[TagResource](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/wafv2/tag-resource.html)」を参照してください。

### `untag-resource`
<a name="wafv2_UntagResource_cli_topic"></a>

次のコード例は、`untag-resource` を使用する方法を示しています。

**AWS CLI**  
**AWS WAF リソースからタグを削除するには**  
次の `untag-resource` の例では、キー名 `KeyName` を持つタグを指定されたウェブ 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"
```
このコマンドでは何も出力されません。  
詳細については、「*AWS WAF、AWS Firewall Manager、および AWS Shield Advanced デベロッパーガイド*」の「[AWS WAF の開始方法](https://docs.aws.amazon.com/waf/latest/developerguide/getting-started.html)」を参照してください。  
+  API の詳細については、「AWS CLI コマンドリファレンス」の「[UntagResource](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/wafv2/untag-resource.html)」を参照してください。

### `update-ip-set`
<a name="wafv2_UpdateIpSet_cli_topic"></a>

次のコード例は、`update-ip-set` を使用する方法を示しています。

**AWS CLI**  
**既存の IP セットの設定を変更するには**  
次の `update-ip-set` は、指定された IP セットの設定を更新します。この呼び出しには、呼び出しから取得できる ID、`list-ip-sets`、および呼び出しから取得できるロックトークン、`list-ip-sets` と `get-ip-set` が必要です。この呼び出しは、後続の更新に使用できるロックトークンも返します。  

```
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"
}
```
詳細については、「*AWS WAF、AWS Firewall Manager、および AWS Shield Advanced デベロッパーガイド*」の「[IP セットおよび正規表現パターンセット](https://docs.aws.amazon.com/waf/latest/developerguide/waf-referenced-set-managing.html)」を参照してください。  
+  API の詳細については、「*AWS CLI コマンドリファレンス*」の「[UpdateIpSet](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/wafv2/update-ip-set.html)」を参照してください。

### `update-regex-pattern-set`
<a name="wafv2_UpdateRegexPatternSet_cli_topic"></a>

次のコード例は、`update-regex-pattern-set` を使用する方法を示しています。

**AWS CLI**  
**既存の正規表現パターンセットの設定を変更するには**  
次の `update-regex-pattern-set` は、指定された正規表現パターンセットの設定を更新します。この呼び出しには、呼び出しから取得できる ID、`list-regex-pattern-sets`、および呼び出しから取得できるロックトークン、`list-regex-pattern-sets` と `get-regex-pattern-set` が必要です。この呼び出しは、後続の更新に使用できるロックトークンも返します。  

```
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"
}
```
詳細については、「*AWS WAF、AWS Firewall Manager、および AWS Shield Advanced デベロッパーガイド*」の「[IP セットおよび正規表現パターンセット](https://docs.aws.amazon.com/waf/latest/developerguide/waf-referenced-set-managing.html)」を参照してください。  
+  API の詳細については、「*AWS CLI コマンドリファレンス*」の「[UpdateRegexPatternSet](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/wafv2/update-regex-pattern-set.html)」を参照してください。

### `update-rule-group`
<a name="wafv2_UpdateRuleGroup_cli_topic"></a>

次のコード例は、`update-rule-group` を使用する方法を示しています。

**AWS CLI**  
**カスタムルールグループを更新するには**  
次の `update-rule-group` は、既存のカスタムルールグループの可視性設定を変更します。この呼び出しには、呼び出しから取得できる ID、`list-rule-groups`、および呼び出しから取得できるロックトークン、`list-rule-groups` と `get-rule-group` が必要です。この呼び出しは、後続の更新に使用できるロックトークンも返します。  

```
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"
}
```
詳細については、「*AWS WAF、AWS Firewall Manager、および AWS Shield Advanced デベロッパーガイド*」の「[独自のルールグループの管理](https://docs.aws.amazon.com/waf/latest/developerguide/waf-user-created-rule-groups.html)」を参照してください。  
+  API の詳細については、「*AWS CLI コマンドリファレンス*」の「[UpdateRuleGroup](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/wafv2/update-rule-group.html)」を参照してください。

### `update-web-acl`
<a name="wafv2_UpdateWebAcl_cli_topic"></a>

次のコード例は、`update-web-acl` を使用する方法を示しています。

**AWS CLI**  
**ウェブ ACL を更新するには**  
次の `update-web-acl` は、既存のウェブ 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"
}
```
詳細については、「*AWS WAF、AWS Firewall Manager、および AWS Shield Advanced デベロッパーガイド*」の「[ウェブアクセスコントロールリスト（ウェブ ACL）の管理と使用](https://docs.aws.amazon.com/waf/latest/developerguide/web-acl.html)」を参照してください。  
+  API の詳細については、「*AWS CLI コマンドリファレンス*」の「[UpdateWebAcl](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/wafv2/update-web-acl.html)」を参照してください。