

Terjemahan disediakan oleh mesin penerjemah. Jika konten terjemahan yang diberikan bertentangan dengan versi bahasa Inggris aslinya, utamakan versi bahasa Inggris.

# AWS WAF Classic contoh menggunakan AWS CLI
<a name="cli_waf_code_examples"></a>

Contoh kode berikut menunjukkan cara melakukan tindakan dan menerapkan skenario umum dengan menggunakan AWS Command Line Interface with AWS WAF Classic.

*Tindakan* merupakan kutipan kode dari program yang lebih besar dan harus dijalankan dalam konteks. Sementara tindakan menunjukkan cara memanggil fungsi layanan individual, Anda dapat melihat tindakan dalam konteks dalam skenario terkait.

Setiap contoh menyertakan tautan ke kode sumber lengkap, di mana Anda dapat menemukan instruksi tentang cara mengatur dan menjalankan kode dalam konteks.

**Topics**
+ [Tindakan](#actions)

## Tindakan
<a name="actions"></a>

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

Contoh kode berikut menunjukkan cara menggunakan`put-logging-configuration`.

**AWS CLI**  
**Untuk membuat konfigurasi logging untuk web ACL ARN dengan Kinesis Firehose stream ARN yang ditentukan**  
`put-logging-configuration`Contoh berikut menampilkan konfigurasi logging untuk WAF dengan CloudFront.  

```
aws waf put-logging-configuration \
    --logging-configuration ResourceArn=arn:aws:waf::123456789012:webacl/3bffd3ed-fa2e-445e-869f-a6a7cf153fd3,LogDestinationConfigs=arn:aws:firehose:us-east-1:123456789012:deliverystream/aws-waf-logs-firehose-stream,RedactedFields=[]
```
Output:  

```
{
    "LoggingConfiguration": {
        "ResourceArn": "arn:aws:waf::123456789012:webacl/3bffd3ed-fa2e-445e-869f-a6a7cf153fd3",
        "LogDestinationConfigs": [
            "arn:aws:firehose:us-east-1:123456789012:deliverystream/aws-waf-logs-firehose-stream"
        ]
    }
}
```
+  Untuk detail API, lihat [PutLoggingConfiguration](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/waf/put-logging-configuration.html)di *Referensi AWS CLI Perintah*. 

### `update-byte-match-set`
<a name="waf_UpdateByteMatchSet_cli_topic"></a>

Contoh kode berikut menunjukkan cara menggunakan`update-byte-match-set`.

**AWS CLI**  
**Untuk memperbarui set kecocokan byte**  
`update-byte-match-set`Perintah berikut menghapus ByteMatchTuple objek (filter) dalam ByteMatchSet:  

```
aws waf update-byte-match-set --byte-match-set-id a123fae4-b567-8e90-1234-5ab67ac8ca90 --change-token 12cs345-67cd-890b-1cd2-c3a4567d89f1 --updates Action="DELETE",ByteMatchTuple={FieldToMatch={Type="HEADER",Data="referer"},TargetString="badrefer1",TextTransformation="NONE",PositionalConstraint="CONTAINS"}
```
Untuk informasi selengkapnya, lihat Bekerja dengan Ketentuan Pencocokan String di panduan pengembang *AWS WAF*.  
+  Untuk detail API, lihat [UpdateByteMatchSet](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/waf/update-byte-match-set.html)di *Referensi AWS CLI Perintah*. 

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

Contoh kode berikut menunjukkan cara menggunakan`update-ip-set`.

**AWS CLI**  
**Untuk memperbarui set IP**  
`update-ip-set`Perintah berikut memperbarui IPSet dengan IPv4 alamat dan menghapus IPv6 alamat:  

```
aws waf update-ip-set --ip-set-id a123fae4-b567-8e90-1234-5ab67ac8ca90 --change-token 12cs345-67cd-890b-1cd2-c3a4567d89f1 --updates Action="INSERT",IPSetDescriptor={Type="IPV4",Value="12.34.56.78/16"},Action="DELETE",IPSetDescriptor={Type="IPV6",Value="1111:0000:0000:0000:0000:0000:0000:0111/128"}
```
Atau Anda dapat menggunakan file JSON untuk menentukan input. Contoh:  

```
aws waf update-ip-set --ip-set-id a123fae4-b567-8e90-1234-5ab67ac8ca90 --change-token 12cs345-67cd-890b-1cd2-c3a4567d89f1  --updates file://change.json
```
Dimana isi file JSON adalah:  

```
[
{
"Action": "INSERT",
"IPSetDescriptor":
{
"Type": "IPV4",
"Value": "12.34.56.78/16"
}
},
{
"Action": "DELETE",
"IPSetDescriptor":
{
"Type": "IPV6",
"Value": "1111:0000:0000:0000:0000:0000:0000:0111/128"
}
}
]
```
Untuk informasi selengkapnya, lihat Bekerja dengan Ketentuan Pencocokan IP di panduan pengembang *AWS WAF*.  
+  Untuk detail API, lihat [UpdateIpSet](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/waf/update-ip-set.html)di *Referensi AWS CLI Perintah*. 

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

Contoh kode berikut menunjukkan cara menggunakan`update-rule`.

**AWS CLI**  
**Untuk memperbarui aturan**  
`update-rule`Perintah berikut menghapus objek Predikat dalam aturan:  

```
aws waf update-rule --rule-id a123fae4-b567-8e90-1234-5ab67ac8ca90 --change-token 12cs345-67cd-890b-1cd2-c3a4567d89f1 --updates Action="DELETE",Predicate={Negated=false,Type="ByteMatch",DataId="MyByteMatchSetID"}
```
Untuk informasi selengkapnya, lihat Bekerja dengan Aturan di panduan pengembang *AWS WAF*.  
+  Untuk detail API, lihat [UpdateRule](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/waf/update-rule.html)di *Referensi AWS CLI Perintah*. 

### `update-size-constraint-set`
<a name="waf_UpdateSizeConstraintSet_cli_topic"></a>

Contoh kode berikut menunjukkan cara menggunakan`update-size-constraint-set`.

**AWS CLI**  
**Untuk memperbarui set batasan ukuran**  
`update-size-constraint-set`Perintah berikut menghapus SizeConstraint objek (filter) dalam set batasan ukuran:  

```
aws waf update-size-constraint-set --size-constraint-set-id a123fae4-b567-8e90-1234-5ab67ac8ca90 --change-token 12cs345-67cd-890b-1cd2-c3a4567d89f1 --updates Action="DELETE",SizeConstraint={FieldToMatch={Type="QUERY_STRING"},TextTransformation="NONE",ComparisonOperator="GT",Size=0}
```
Untuk informasi selengkapnya, lihat Bekerja dengan Ketentuan Kendala Ukuran di panduan pengembang *AWS WAF*.  
+  Untuk detail API, lihat [UpdateSizeConstraintSet](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/waf/update-size-constraint-set.html)di *Referensi AWS CLI Perintah*. 

### `update-sql-injection-match-set`
<a name="waf_UpdateSqlInjectionMatchSet_cli_topic"></a>

Contoh kode berikut menunjukkan cara menggunakan`update-sql-injection-match-set`.

**AWS CLI**  
**Untuk memperbarui SQL Injection Match Set**  
`update-sql-injection-match-set`Perintah berikut menghapus SqlInjectionMatchTuple objek (filter) dalam set kecocokan injeksi SQL:  

```
aws waf update-sql-injection-match-set --sql-injection-match-set-id a123fae4-b567-8e90-1234-5ab67ac8ca90 --change-token 12cs345-67cd-890b-1cd2-c3a4567d89f1 --updates Action="DELETE",SqlInjectionMatchTuple={FieldToMatch={Type="QUERY_STRING"},TextTransformation="URL_DECODE"}
```
Untuk informasi selengkapnya, lihat Bekerja dengan Ketentuan Pencocokan Injeksi SQL di panduan pengembang *AWS WAF*.  
+  Untuk detail API, lihat [UpdateSqlInjectionMatchSet](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/waf/update-sql-injection-match-set.html)di *Referensi AWS CLI Perintah*. 

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

Contoh kode berikut menunjukkan cara menggunakan`update-web-acl`.

**AWS CLI**  
**Untuk memperbarui ACL web**  
`update-web-acl`Perintah berikut menghapus `ActivatedRule` objek di WebACL.  
aws waf update-web-acl -- web-acl-id a123fae4-b567-8e90-1234-5ab67ac8ca90 --change-token 12cs345-67cd-890b-1cd2-c3a4567d89f1 --update action="Delete”, =' \$1Prioritas=1, =” -1-Contoh”, Action= \$1type="allow "\$1, Type="Regular"\$1 'ActivatedRuleRuleIdWAFRule  
Output:  

```
{
    "ChangeToken": "12cs345-67cd-890b-1cd2-c3a4567d89f1"
}
```
Untuk informasi selengkapnya, lihat [Bekerja dengan Web ACLs](https://docs.aws.amazon.com/waf/latest/developerguide/classic-web-acl-working-with.html) di *AWS WAF, AWS Firewall Manager, dan AWS Shield Advanced Developer Guide*.  
+  Untuk detail API, lihat [UpdateWebAcl](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/waf/update-web-acl.html)di *Referensi AWS CLI Perintah*. 

### `update-xss-match-set`
<a name="waf_UpdateXssMatchSet_cli_topic"></a>

Contoh kode berikut menunjukkan cara menggunakan`update-xss-match-set`.

**AWS CLI**  
**Untuk memperbarui XSSMatch Set**  
`update-xss-match-set`Perintah berikut menghapus XssMatchTuple objek (filter) dalam: XssMatchSet  

```
aws waf update-xss-match-set --xss-match-set-id a123fae4-b567-8e90-1234-5ab67ac8ca90 --change-token 12cs345-67cd-890b-1cd2-c3a4567d89f1 --updates Action="DELETE",XssMatchTuple={FieldToMatch={Type="QUERY_STRING"},TextTransformation="URL_DECODE"}
```
Untuk informasi selengkapnya, lihat Bekerja dengan Ketentuan Pencocokan Skrip Lintas Situs di panduan pengembang *AWS WAF*.  
+  Untuk detail API, lihat [UpdateXssMatchSet](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/waf/update-xss-match-set.html)di *Referensi AWS CLI Perintah*. 