

# AWS WAF Classic를 사용한 예시AWS CLI
<a name="cli_waf_code_examples"></a>

다음 코드 예시에서는 AWS WAF Classic에서 AWS Command Line Interface를 사용하여 작업을 수행하고 일반적인 시나리오를 구현하는 방법을 보여줍니다.

*작업*은 대규모 프로그램에서 발췌한 코드이며 컨텍스트에 맞춰 실행해야 합니다. 작업은 개별 서비스 함수를 직접적으로 호출하는 방법을 보여주며 관련 시나리오의 컨텍스트에 맞는 작업을 볼 수 있습니다.

각 예시에는 전체 소스 코드에 대한 링크가 포함되어 있으며, 여기에서 컨텍스트에 맞춰 코드를 설정하고 실행하는 방법에 대한 지침을 찾을 수 있습니다.

**Topics**
+ [작업](#actions)

## 작업
<a name="actions"></a>

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

다음 코드 예시는 `put-logging-configuration`의 사용 방법을 보여줍니다.

**AWS CLI**  
**지정된 Kinesis Firehose 스트림 ARN을 사용하여 웹 ACL ARN에 대한 로깅 구성을 생성하는 방법**  
다음 `put-logging-configuration` 예제에서는 CloudFront를 사용한 WAF에 대한 로깅 구성을 표시합니다.  

```
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=[]
```
출력:  

```
{
    "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"
        ]
    }
}
```
+  API 세부 정보는 **AWS CLI 명령 참조의 [PutLoggingConfiguration](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/waf/put-logging-configuration.html) 섹션을 참조하세요.

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

다음 코드 예시는 `update-byte-match-set`의 사용 방법을 보여줍니다.

**AWS CLI**  
**바이트 일치 세트를 업데이트하는 방법**  
다음 `update-byte-match-set` 명령은 ByteMatchSet에서 ByteMatchTuple 객체(필터)를 삭제합니다.  

```
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"}
```
자세한 내용은 **AWS WAF 개발자 안내서의 문자열 일치 조건 작업을 참조하세요.  
+  API 세부 정보는 **AWS CLI 명령 참조의 [UpdateByteMatchSet](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/waf/update-byte-match-set.html) 섹션을 참조하세요.

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

다음 코드 예시는 `update-ip-set`의 사용 방법을 보여줍니다.

**AWS CLI**  
**IP 세트를 업데이트하는 방법**  
다음 `update-ip-set` 명령은 IPv4 주소로 IPSet를 업데이트하고 IPv6 주소를 삭제합니다.  

```
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"}
```
또는 JSON 파일을 사용하여 입력을 지정할 수도 있습니다. 예제:  

```
aws waf update-ip-set --ip-set-id a123fae4-b567-8e90-1234-5ab67ac8ca90 --change-token 12cs345-67cd-890b-1cd2-c3a4567d89f1  --updates file://change.json
```
JSON 파일의 콘텐츠가 있는 위치:  

```
[
{
"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"
}
}
]
```
자세한 내용은 **AWS WAF 개발자 안내서의 IP 일치 조건 작업을 참조하세요.  
+  API 세부 정보는 **AWS CLI 명령 참조의 [UpdateIpSet](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/waf/update-ip-set.html) 섹션을 참조하세요.

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

다음 코드 예시는 `update-rule`의 사용 방법을 보여줍니다.

**AWS CLI**  
**규칙을 업데이트하는 방법**  
다음 `update-rule` 명령은 규칙에서 Predicate 객체를 삭제합니다.  

```
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"}
```
자세한 내용은 **AWS WAF 개발자 안내서의 규칙 작업을 참조하세요.  
+  API 세부 정보는 **AWS CLI 명령 참조의 [UpdateRule](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/waf/update-rule.html) 섹션을 참조하세요.

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

다음 코드 예시는 `update-size-constraint-set`의 사용 방법을 보여줍니다.

**AWS CLI**  
**크기 제약 조건 세트를 업데이트하는 방법**  
다음 `update-size-constraint-set` 명령은 크기 제약 조건 세트에서 SizeConstraint 객체(필터)를 삭제합니다.  

```
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}
```
자세한 내용은 **AWS WAF 개발자 안내서의 크기 제약 조건 작업을 참조하세요.  
+  API 세부 정보는 **AWS CLI 명령 참조의 [UpdateSizeConstraintSet](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/waf/update-size-constraint-set.html) 섹션을 참조하세요.

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

다음 코드 예시는 `update-sql-injection-match-set`의 사용 방법을 보여줍니다.

**AWS CLI**  
**SQL 인젝션 일치 세트를 업데이트하는 방법**  
다음 `update-sql-injection-match-set` 명령은 SQL 인젝션 일치 세트의 SqlInjectionMatchTuple 객체(필터)를 삭제합니다.  

```
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"}
```
자세한 내용은 **AWS WAF 개발자 안내서의 SQL 인젝션 일치 조건 작업을 참조하세요.  
+  API 세부 정보는 **AWS CLI 명령 참조의 [UpdateSqlInjectionMatchSet](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/waf/update-sql-injection-match-set.html) 섹션을 참조하세요.

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

다음 코드 예시는 `update-web-acl`의 사용 방법을 보여줍니다.

**AWS CLI**  
**웹 ACL 업데이트**  
다음 `update-web-acl` 명령은 WebACL 에서 `ActivatedRule` 객체를 삭제합니다.  
aws waf update-web-acl --web-acl-id a123fae4-b567-8e90-1234-5ab67ac8ca90 --change-token 12cs345-67cd-890b-1cd2-c3a4567d89f1 --updates Action="DELETE",ActivatedRule='\$1Priority=1,RuleId="WAFRule-1-Example",Action=\$1Type="ALLOW"\$1,Type="REGULAR"\$1'  
출력:  

```
{
    "ChangeToken": "12cs345-67cd-890b-1cd2-c3a4567d89f1"
}
```
자세한 내용은 *AWS WAF*, AWS Firewall Manager, AWS Shield Advanced 개발자 안내서의 [웹 ACL 작업](https://docs.aws.amazon.com/waf/latest/developerguide/classic-web-acl-working-with.html)을 참조하세요.  
+  API 세부 정보는 *AWS CLI 명령 참조*의 [UpdateWebAcl](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/waf/update-web-acl.html) 섹션을 참조하세요.

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

다음 코드 예시는 `update-xss-match-set`의 사용 방법을 보여줍니다.

**AWS CLI**  
**XSSMatchSet를 업데이트하는 방법**  
다음 `update-xss-match-set` 명령은 XssMatchSet에서 XssMatchTuple 객체(필터)를 삭제합니다.  

```
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"}
```
자세한 내용은 **AWS WAF 개발자 안내서의 교차 사이트 스크립팅 일치 조건 작업을 참조하세요.  
+  API 세부 정보는 **AWS CLI 명령 참조의 [UpdateXssMatchSet](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/waf/update-xss-match-set.html) 섹션을 참조하세요.