

# AWS CLI를 사용한 Firewall Manager 예제
<a name="cli_fms_code_examples"></a>

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

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

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

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

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

### `associate-admin-account`
<a name="fms_AssociateAdminAccount_cli_topic"></a>

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

**AWS CLI**  
**Firewall Manager 관리자 계정을 설정하는 방법**  
다음 `associate-admin-account` 예제에서는 Firewall Manager의 관리자 계정을 설정합니다.  

```
aws fms associate-admin-account \
    --admin-account 123456789012
```
이 명령은 출력을 생성하지 않습니다.  
자세한 내용은 *AWS WAF, AWS Firewall Manager 및 AWS Shield Advanced 개발자 가이드*의 [AWS Firewall Manager 관리자 계정 설정](https://docs.aws.amazon.com/waf/latest/developerguide/enable-integration.html)을 참조하세요.  
+  API 세부 정보는 *AWS CLI 명령 참조*의 [AssociateAdminAccount](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/fms/associate-admin-account.html)를 참조하세요.

### `delete-notification-channel`
<a name="fms_DeleteNotificationChannel_cli_topic"></a>

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

**AWS CLI**  
**Firewall Manager 로그에 대한 SNS 주제 정보를 제거하는 방법**  
다음 `delete-notification-channel` 예제에서는 SNS 주제 정보를 제거합니다.  

```
aws fms delete-notification-channel
```
이 명령은 출력을 생성하지 않습니다.  
자세한 내용은 *AWS WAF, AWS Firewall Manager 및 AWS Shield Advanced 개발자 가이드*의 [Amazon SNS Notifications 및 Amazon CloudWatch 경보 구성](https://docs.aws.amazon.com/waf/latest/developerguide/get-started-fms-shield-cloudwatch.html)을 참조하세요.  
+  API 세부 정보는 *AWS CLI 명령 참조*의 [DeleteNotificationChannel](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/fms/delete-notification-channel.html)을 참조하세요.

### `delete-policy`
<a name="fms_DeletePolicy_cli_topic"></a>

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

**AWS CLI**  
**Firewall Manager 정책을 삭제하는 방법**  
다음 `delete-policy` 예제에서는 지정된 ID가 있는 정책을 모든 리소스와 함께 제거합니다.  

```
aws fms delete-policy \
    --policy-id a1b2c3d4-5678-90ab-cdef-EXAMPLE11111 \
    --delete-all-policy-resources
```
이 명령은 출력을 생성하지 않습니다.  
자세한 내용은 *AWS WAF, AWS Firewall Manager 및 AWS Shield Advanced 개발자 가이드*의 [AWS Firewall Manager 정책 작업](https://docs.aws.amazon.com/waf/latest/developerguide/working-with-policies.html)을 참조하세요.  
+  API 세부 정보는 **AWS CLI 명령 참조의 [DeletePolicy](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/fms/delete-policy.html)를 참조하세요.

### `disassociate-admin-account`
<a name="fms_DisassociateAdminAccount_cli_topic"></a>

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

**AWS CLI**  
**Firewall Manager 관리자 계정을 제거하는 방법**  
다음 `disassociate-admin-account` 예제에서는 Firewall Manager에서 현재 관리자 계정 연결을 제거합니다.  

```
aws fms disassociate-admin-account
```
이 명령은 출력을 생성하지 않습니다.  
자세한 내용은 *AWS WAF, AWS Firewall Manager 및 AWS Shield Advanced 개발자 가이드*의 [AWS Firewall Manager 관리자 계정 설정](https://docs.aws.amazon.com/waf/latest/developerguide/enable-integration.html)을 참조하세요.  
+  API 세부 정보는 *AWS CLI 명령 참조*의 [DisassociateAdminAccount](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/fms/disassociate-admin-account.html)를 참조하세요.

### `get-admin-account`
<a name="fms_GetAdminAccount_cli_topic"></a>

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

**AWS CLI**  
**Firewall Manager 관리자 계정을 검색하는 방법**  
다음 `get-admin-account` 예제에서는 관리자 계정을 검색합니다.  

```
aws fms get-admin-account
```
출력:  

```
{
    "AdminAccount": "123456789012",
    "RoleStatus": "READY"
}
```
자세한 내용은 *AWS WAF, AWS Firewall Manager 및 AWS Shield Advanced 개발자 가이드*의 [AWS Firewall Manager 사전 조건](https://docs.aws.amazon.com/waf/latest/developerguide/fms-prereq.html)을 참조하세요.  
+  API 세부 정보는 *AWS CLI 명령 참조*의 [GetAdminAccount](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/fms/get-admin-account.html)를 참조하세요.

### `get-compliance-detail`
<a name="fms_GetComplianceDetail_cli_topic"></a>

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

**AWS CLI**  
**계정의 규정 준수 정보를 검색하는 방법**  
다음 `get-compliance-detail` 예제에서는 지정된 정책 및 멤버 계정에 대한 규정 준수 정보를 검색합니다.  

```
aws fms get-compliance-detail \
    --policy-id a1b2c3d4-5678-90ab-cdef-EXAMPLE11111 \
    --member-account 123456789012
```
출력:  

```
{
    "PolicyComplianceDetail": {
    "EvaluationLimitExceeded": false,
    "IssueInfoMap": {},
    "MemberAccount": "123456789012",
    "PolicyId": "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111",
    "PolicyOwner": "123456789012",
    "Violators": []
}
```
자세한 내용은 *AWS WAF, AWS Firewall Manager 및 AWS Shield Advanced 개발자 가이드*의 [정책을 통한 리소스 규정 준수 보기](https://docs.aws.amazon.com/waf/latest/developerguide/fms-compliance.html)를 참조하세요.  
+  API 세부 정보는 *AWS CLI 명령 참조*의 [GetComplianceDetail](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/fms/get-compliance-detail.html)을 참조하세요.

### `get-notification-channel`
<a name="fms_GetNotificationChannel_cli_topic"></a>

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

**AWS CLI**  
**Firewall Manager 로그에 대한 SNS 주제 정보를 검색하는 방법**  
다음 `get-notification-channel` 예제에서는 SNS 주제 정보를 검색합니다.  

```
aws fms get-notification-channel
```
출력:  

```
{
    "SnsTopicArn": "arn:aws:sns:us-west-2:123456789012:us-west-2-fms",
    "SnsRoleName": "arn:aws:iam::123456789012:role/aws-service-role/fms.amazonaws.com/AWSServiceRoleForFMS"
}
```
자세한 내용은 *AWS WAF, AWS Firewall Manager 및 AWS Shield Advanced 개발자 가이드*의 [Amazon SNS Notifications 및 Amazon CloudWatch 경보 구성](https://docs.aws.amazon.com/waf/latest/developerguide/get-started-fms-shield-cloudwatch.html)을 참조하세요.  
+  API 세부 정보는 *AWS CLI 명령 참조*의 [GetNotificationChannel](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/fms/get-notification-channel.html)을 참조하세요.

### `get-policy`
<a name="fms_GetPolicy_cli_topic"></a>

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

**AWS CLI**  
**Firewall Manager 정책을 검색하는 방법**  
다음 `get-policy` 예제에서는 지정된 ID로 정책을 검색합니다.  

```
aws fms get-policy \
    --policy-id a1b2c3d4-5678-90ab-cdef-EXAMPLE11111
```
출력:  

```
{
    "Policy": {
        "PolicyId": "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111",
        "PolicyName": "test",
        "PolicyUpdateToken": "1:p+2RpKR4wPFx7mcrL1UOQQ==",
        "SecurityServicePolicyData": {
            "Type": "SECURITY_GROUPS_COMMON",
            "ManagedServiceData": "{\"type\":\"SECURITY_GROUPS_COMMON\",\"revertManualSecurityGroupChanges\":true,\"exclusiveResourceSecurityGroupManagement\":false,\"securityGroups\":[{\"id\":\"sg-045c43ccc9724e63e\"}]}"
        },
        "ResourceType": "AWS::EC2::Instance",
        "ResourceTags": [],
        "ExcludeResourceTags": false,
        "RemediationEnabled": false
    },
    "PolicyArn": "arn:aws:fms:us-west-2:123456789012:policy/d1ac59b8-938e-42b3-b2e0-7c620422ddc2"
}
```
자세한 내용은 *AWS WAF, AWS Firewall Manager 및 AWS Shield Advanced 개발자 가이드*의 [AWS Firewall Manager 정책 작업](https://docs.aws.amazon.com/waf/latest/developerguide/working-with-policies.html)을 참조하세요.  
+  API 세부 정보는 *AWS CLI 명령 참조*의 [GetPolicy](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/fms/get-policy.html)를 참조하세요.

### `list-compliance-status`
<a name="fms_ListComplianceStatus_cli_topic"></a>

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

**AWS CLI**  
**멤버 계정에 대한 정책 규정 준수 정보를 검색하는 방법**  
다음 `list-compliance-status` 예제에서는 지정된 정책에 대한 멤버 계정 규정 준수 정보를 검색합니다.  

```
aws fms list-compliance-status \
    --policy-id a1b2c3d4-5678-90ab-cdef-EXAMPLE11111
```
출력:  

```
{
    "PolicyComplianceStatusList": [
        {
            "PolicyOwner": "123456789012",
            "PolicyId": "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111",
            "PolicyName": "test",
            "MemberAccount": "123456789012",
            "EvaluationResults": [
                {
                    "ComplianceStatus": "COMPLIANT",
                    "ViolatorCount": 0,
                    "EvaluationLimitExceeded": false
                },
                {
                    "ComplianceStatus": "NON_COMPLIANT",
                    "ViolatorCount": 2,
                    "EvaluationLimitExceeded": false
                }
            ],
            "LastUpdated": 1576283774.0,
            "IssueInfoMap": {}
        }
    ]
}
```
자세한 내용은 *AWS WAF, AWS Firewall Manager 및 AWS Shield Advanced 개발자 가이드*의 [정책을 통한 리소스 규정 준수 보기](https://docs.aws.amazon.com/waf/latest/developerguide/fms-compliance.html)를 참조하세요.  
+  API 세부 정보는 *AWS CLI 명령 참조*의 [ListComplianceStatus](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/fms/list-compliance-status.html)를 참조하세요.

### `list-member-accounts`
<a name="fms_ListMemberAccounts_cli_topic"></a>

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

**AWS CLI**  
**조직의 멤버 계정을 검색하는 방법**  
다음 `list-member-accounts` 예제에서는 Firewall Manager 관리자 조직에 있는 모든 멤버 계정을 나열합니다.  

```
aws fms list-member-accounts
```
출력:  

```
{
    "MemberAccounts": [
        "222222222222",
        "333333333333",
        "444444444444"
    ]
}
```
자세한 내용은 *AWS WAF, AWS Firewall Manager 및 AWS Shield Advanced 개발자 가이드*의 [AWS Firewall Manager](https://docs.aws.amazon.com/waf/latest/developerguide/fms-chapter.html)를 참조하세요.  
+  API 세부 정보는 *AWS CLI 명령 참조*의 [ListMemberAccounts](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/fms/list-member-accounts.html)를 참조하세요.

### `list-policies`
<a name="fms_ListPolicies_cli_topic"></a>

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

**AWS CLI**  
**모든 Firewall Manager 정책을 검색하는 방법**  
다음 `list-policies` 예제에서는 계정의 정책 목록을 검색합니다. 이 예제에서 출력은 요청당 2개의 결과로 제한됩니다. 각 호출은 목록에 대한 다음 결과 집합을 얻기 위해 다음 `list-policies` 호출에서 `--starting-token` 파라미터의 값으로 사용할 수 있는 `NextToken`을 반환합니다.  

```
aws fms list-policies \
    --max-items 2
```
출력:  

```
{
    "PolicyList": [
        {
            "PolicyArn": "arn:aws:fms:us-west-2:123456789012:policy/a1b2c3d4-5678-90ab-cdef-EXAMPLE11111",
            "PolicyId": "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111",
            "PolicyName": "test",
            "ResourceType": "AWS::EC2::Instance",
            "SecurityServiceType": "SECURITY_GROUPS_COMMON",
            "RemediationEnabled": false
        },
        {
            "PolicyArn": "arn:aws:fms:us-west-2:123456789012:policy/a1b2c3d4-5678-90ab-cdef-EXAMPLE22222",
            "PolicyId": "457c9b21-fc94-406c-ae63-21217395ba72",
            "PolicyName": "test",
            "ResourceType": "AWS::EC2::Instance",
            "SecurityServiceType": "SECURITY_GROUPS_COMMON",
            "RemediationEnabled": false
        }
    ],
    "NextToken": "eyJOZXh0VG9rZW4iOiBudWxsLCAiYm90b190cnVuY2F0ZV9hbW91bnQiOiAyfQ=="
}
```
자세한 내용은 *AWS WAF, AWS Firewall Manager 및 AWS Shield Advanced 개발자 가이드*의 [AWS Firewall Manager 정책 작업](https://docs.aws.amazon.com/waf/latest/developerguide/working-with-policies.html)을 참조하세요.  
+  API 세부 정보는 *AWS CLI 명령 참조*의 [ListPolicies](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/fms/list-policies.html)를 참조하세요.

### `put-notification-channel`
<a name="fms_PutNotificationChannel_cli_topic"></a>

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

**AWS CLI**  
**Firewall Manager 로그에 대한 SNS 주제 정보를 설정하는 방법**  
다음 `put-notification-channel` 예제에서는 SNS 주제 정보를 설정합니다.  

```
aws fms put-notification-channel \
    --sns-topic-arn arn:aws:sns:us-west-2:123456789012:us-west-2-fms \
    --sns-role-name arn:aws:iam::123456789012:role/aws-service-role/fms.amazonaws.com/AWSServiceRoleForFMS
```
이 명령은 출력을 생성하지 않습니다.  
자세한 내용은 *AWS WAF, AWS Firewall Manager 및 AWS Shield Advanced 개발자 가이드*의 [Amazon SNS Notifications 및 Amazon CloudWatch 경보 구성](https://docs.aws.amazon.com/waf/latest/developerguide/get-started-fms-shield-cloudwatch.html)을 참조하세요.  
+  API 세부 정보는 *AWS CLI 명령 참조*의 [PutNotificationChannel](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/fms/put-notification-channel.html)을 참조하세요.

### `put-policy`
<a name="fms_PutPolicy_cli_topic"></a>

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

**AWS CLI**  
**Firewall Manager 정책을 생성하는 방법**  
다음 `put-policy` 예제에서는 Firewall Manager 보안 그룹 정책을 생성합니다.  

```
aws fms put-policy \
    --cli-input-json file://policy.json
```
`policy.json`의 콘텐츠:  

```
{
    "Policy": {
        "PolicyName": "test",
        "SecurityServicePolicyData": {
            "Type": "SECURITY_GROUPS_USAGE_AUDIT",
            "ManagedServiceData": "{\"type\":\"SECURITY_GROUPS_USAGE_AUDIT\",\"deleteUnusedSecurityGroups\":false,\"coalesceRedundantSecurityGroups\":true}"
        },
        "ResourceType": "AWS::EC2::SecurityGroup",
        "ResourceTags": [],
        "ExcludeResourceTags": false,
        "RemediationEnabled": false
    },
    "TagList": [
        {
            "Key": "foo",
            "Value": "foo"
        }
    ]
}
```
출력:  

```
{
    "Policy": {
        "PolicyId": "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111",
        "PolicyName": "test",
        "PolicyUpdateToken": "1:X9QGexP7HASDlsFp+G31Iw==",
        "SecurityServicePolicyData": {
            "Type": "SECURITY_GROUPS_USAGE_AUDIT",
            "ManagedServiceData": "{\"type\":\"SECURITY_GROUPS_USAGE_AUDIT\",\"deleteUnusedSecurityGroups\":false,\"coalesceRedundantSecurityGroups\":true,\"optionalDelayForUnusedInMinutes\":null}"
        },
        "ResourceType": "AWS::EC2::SecurityGroup",
        "ResourceTags": [],
        "ExcludeResourceTags": false,
        "RemediationEnabled": false
    },
    "PolicyArn": "arn:aws:fms:us-west-2:123456789012:policy/a1b2c3d4-5678-90ab-cdef-EXAMPLE11111"
}
```
자세한 내용은 *AWS WAF, AWS Firewall Manager 및 AWS Shield Advanced 개발자 가이드*의 [AWS Firewall Manager 정책 작업](https://docs.aws.amazon.com/waf/latest/developerguide/working-with-policies.html)을 참조하세요.  
+  API 세부 정보는 *AWS CLI 명령 참조*의 [PutPolicy](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/fms/put-policy.html)를 참조하세요.