

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

# Contoh Firewall Manager menggunakan AWS CLI
<a name="cli_fms_code_examples"></a>

Contoh kode berikut menunjukkan cara melakukan tindakan dan mengimplementasikan skenario umum dengan menggunakan AWS Command Line Interface With Firewall Manager.

*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>

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

Contoh kode berikut menunjukkan cara menggunakan`associate-admin-account`.

**AWS CLI**  
**Untuk mengatur akun administrator Firewall Manager**  
`associate-admin-account`Contoh berikut menetapkan akun administrator untuk Firewall Manager.  

```
aws fms associate-admin-account \
    --admin-account 123456789012
```
Perintah ini tidak menghasilkan output.  
Untuk informasi selengkapnya, lihat [Mengatur Akun Administrator Manajer AWS Firewall](https://docs.aws.amazon.com/waf/latest/developerguide/enable-integration.html) di *AWS WAF, AWS Firewall Manager, dan Panduan Pengembang Lanjutan AWS Shield*.  
+  Untuk detail API, lihat [AssociateAdminAccount](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/fms/associate-admin-account.html)di *Referensi AWS CLI Perintah*. 

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

Contoh kode berikut menunjukkan cara menggunakan`delete-notification-channel`.

**AWS CLI**  
**Untuk menghapus informasi topik SNS untuk log Firewall Manager**  
`delete-notification-channel`Contoh berikut menghapus informasi topik SNS.  

```
aws fms delete-notification-channel
```
Perintah ini tidak menghasilkan output.  
Untuk informasi selengkapnya, lihat [Mengonfigurasi Notifikasi Amazon SNS dan CloudWatch Alarm Amazon](https://docs.aws.amazon.com/waf/latest/developerguide/get-started-fms-shield-cloudwatch.html) di *AWS WAF, Firewall Manager, dan Panduan AWS Pengembang Lanjutan AWS Shield*.  
+  Untuk detail API, lihat [DeleteNotificationChannel](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/fms/delete-notification-channel.html)di *Referensi AWS CLI Perintah*. 

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

Contoh kode berikut menunjukkan cara menggunakan`delete-policy`.

**AWS CLI**  
**Untuk menghapus kebijakan Firewall Manager**  
`delete-policy`Contoh berikut menghapus kebijakan dengan ID yang ditentukan, beserta semua sumber dayanya.  

```
aws fms delete-policy \
    --policy-id a1b2c3d4-5678-90ab-cdef-EXAMPLE11111 \
    --delete-all-policy-resources
```
Perintah ini tidak menghasilkan output.  
Untuk informasi selengkapnya, lihat [Bekerja dengan Kebijakan AWS Firewall Manager](https://docs.aws.amazon.com/waf/latest/developerguide/working-with-policies.html) di *AWS WAF, AWS Firewall Manager, dan AWS Shield Advanced Developer Guide*.  
+  Untuk detail API, lihat [DeletePolicy](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/fms/delete-policy.html)di *Referensi AWS CLI Perintah*. 

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

Contoh kode berikut menunjukkan cara menggunakan`disassociate-admin-account`.

**AWS CLI**  
**Untuk menghapus akun administrator Firewall Manager**  
`disassociate-admin-account`Contoh berikut menghapus asosiasi akun administrator saat ini dari Firewall Manager.  

```
aws fms disassociate-admin-account
```
Perintah ini tidak menghasilkan output.  
Untuk informasi selengkapnya, lihat [Mengatur Akun Administrator Manajer AWS Firewall](https://docs.aws.amazon.com/waf/latest/developerguide/enable-integration.html) di *AWS WAF, AWS Firewall Manager, dan Panduan Pengembang Lanjutan AWS Shield*.  
+  Untuk detail API, lihat [DisassociateAdminAccount](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/fms/disassociate-admin-account.html)di *Referensi AWS CLI Perintah*. 

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

Contoh kode berikut menunjukkan cara menggunakan`get-admin-account`.

**AWS CLI**  
**Untuk mengambil akun administrator Firewall Manager**  
`get-admin-account`Contoh berikut mengambil akun administrator.  

```
aws fms get-admin-account
```
Output:  

```
{
    "AdminAccount": "123456789012",
    "RoleStatus": "READY"
}
```
Untuk informasi selengkapnya, lihat [Prasyarat AWS Firewall Manager](https://docs.aws.amazon.com/waf/latest/developerguide/fms-prereq.html) di WAF *AWS , Firewall AWS Manager, dan AWS Shield* Advanced Developer Guide.  
+  Untuk detail API, lihat [GetAdminAccount](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/fms/get-admin-account.html)di *Referensi AWS CLI Perintah*. 

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

Contoh kode berikut menunjukkan cara menggunakan`get-compliance-detail`.

**AWS CLI**  
**Untuk mengambil informasi kepatuhan untuk akun**  
`get-compliance-detail`Contoh berikut mengambil informasi kepatuhan untuk kebijakan dan akun anggota yang ditentukan.  

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

```
{
    "PolicyComplianceDetail": {
    "EvaluationLimitExceeded": false,
    "IssueInfoMap": {},
    "MemberAccount": "123456789012",
    "PolicyId": "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111",
    "PolicyOwner": "123456789012",
    "Violators": []
}
```
Untuk informasi selengkapnya, lihat [Melihat Kepatuhan Sumber Daya dengan Kebijakan](https://docs.aws.amazon.com/waf/latest/developerguide/fms-compliance.html) di *AWS WAF, AWS Firewall Manager, dan Panduan Pengembang Lanjutan AWS Shield*.  
+  Untuk detail API, lihat [GetComplianceDetail](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/fms/get-compliance-detail.html)di *Referensi AWS CLI Perintah*. 

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

Contoh kode berikut menunjukkan cara menggunakan`get-notification-channel`.

**AWS CLI**  
**Untuk mengambil informasi topik SNS untuk log Firewall Manager**  
`get-notification-channel`Contoh berikut mengambil informasi topik SNS.  

```
aws fms get-notification-channel
```
Output:  

```
{
    "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"
}
```
Untuk informasi selengkapnya, lihat [Mengonfigurasi Notifikasi Amazon SNS dan CloudWatch Alarm Amazon](https://docs.aws.amazon.com/waf/latest/developerguide/get-started-fms-shield-cloudwatch.html) di *AWS WAF, Firewall Manager, dan Panduan AWS Pengembang Lanjutan AWS Shield*.  
+  Untuk detail API, lihat [GetNotificationChannel](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/fms/get-notification-channel.html)di *Referensi AWS CLI Perintah*. 

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

Contoh kode berikut menunjukkan cara menggunakan`get-policy`.

**AWS CLI**  
**Untuk mengambil kebijakan Firewall Manager**  
`get-policy`Contoh berikut mengambil kebijakan dengan ID yang ditentukan.  

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

```
{
    "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"
}
```
Untuk informasi selengkapnya, lihat [Bekerja dengan Kebijakan AWS Firewall Manager](https://docs.aws.amazon.com/waf/latest/developerguide/working-with-policies.html) di *AWS WAF, AWS Firewall Manager, dan AWS Shield Advanced Developer Guide*.  
+  Untuk detail API, lihat [GetPolicy](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/fms/get-policy.html)di *Referensi AWS CLI Perintah*. 

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

Contoh kode berikut menunjukkan cara menggunakan`list-compliance-status`.

**AWS CLI**  
**Untuk mengambil informasi kepatuhan kebijakan untuk akun anggota**  
`list-compliance-status`Contoh berikut mengambil informasi kepatuhan akun anggota untuk kebijakan yang ditentukan.  

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

```
{
    "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": {}
        }
    ]
}
```
Untuk informasi selengkapnya, lihat [Melihat Kepatuhan Sumber Daya dengan Kebijakan](https://docs.aws.amazon.com/waf/latest/developerguide/fms-compliance.html) di *AWS WAF, AWS Firewall Manager, dan Panduan Pengembang Lanjutan AWS Shield*.  
+  Untuk detail API, lihat [ListComplianceStatus](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/fms/list-compliance-status.html)di *Referensi AWS CLI Perintah*. 

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

Contoh kode berikut menunjukkan cara menggunakan`list-member-accounts`.

**AWS CLI**  
**Untuk mengambil akun anggota di organisasi**  
`list-member-accounts`Contoh berikut mencantumkan semua akun anggota yang ada di organisasi administrator Firewall Manager.  

```
aws fms list-member-accounts
```
Output:  

```
{
    "MemberAccounts": [
        "222222222222",
        "333333333333",
        "444444444444"
    ]
}
```
Untuk informasi selengkapnya, lihat [AWS Firewall Manager](https://docs.aws.amazon.com/waf/latest/developerguide/fms-chapter.html) di *AWS WAF, AWS Firewall Manager, dan AWS Shield Advanced Developer Guide*.  
+  Untuk detail API, lihat [ListMemberAccounts](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/fms/list-member-accounts.html)di *Referensi AWS CLI Perintah*. 

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

Contoh kode berikut menunjukkan cara menggunakan`list-policies`.

**AWS CLI**  
**Untuk mengambil semua kebijakan Firewall Manager**  
`list-policies`Contoh berikut mengambil daftar kebijakan untuk akun. Dalam contoh ini, output dibatasi hingga dua hasil per permintaan. Setiap panggilan mengembalikan sebuah `NextToken` yang dapat digunakan sebagai nilai untuk `--starting-token` parameter dalam `list-policies` panggilan berikutnya untuk mendapatkan set hasil berikutnya untuk daftar.  

```
aws fms list-policies \
    --max-items 2
```
Output:  

```
{
    "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=="
}
```
Untuk informasi selengkapnya, lihat [Bekerja dengan Kebijakan AWS Firewall Manager](https://docs.aws.amazon.com/waf/latest/developerguide/working-with-policies.html) di *AWS WAF, AWS Firewall Manager, dan AWS Shield Advanced Developer Guide*.  
+  Untuk detail API, lihat [ListPolicies](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/fms/list-policies.html)di *Referensi AWS CLI Perintah*. 

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

Contoh kode berikut menunjukkan cara menggunakan`put-notification-channel`.

**AWS CLI**  
**Untuk mengatur informasi topik SNS untuk log Firewall Manager**  
`put-notification-channel`Contoh berikut menetapkan informasi topik 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
```
Perintah ini tidak menghasilkan output.  
Untuk informasi selengkapnya, lihat [Mengonfigurasi Notifikasi Amazon SNS dan CloudWatch Alarm Amazon](https://docs.aws.amazon.com/waf/latest/developerguide/get-started-fms-shield-cloudwatch.html) di *AWS WAF, Firewall Manager, dan Panduan AWS Pengembang Lanjutan AWS Shield*.  
+  Untuk detail API, lihat [PutNotificationChannel](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/fms/put-notification-channel.html)di *Referensi AWS CLI Perintah*. 

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

Contoh kode berikut menunjukkan cara menggunakan`put-policy`.

**AWS CLI**  
**Untuk membuat kebijakan Firewall Manager**  
`put-policy`Contoh berikut membuat kebijakan grup keamanan Firewall Manager.  

```
aws fms put-policy \
    --cli-input-json file://policy.json
```
Isi dari `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"
        }
    ]
}
```
Output:  

```
{
    "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"
}
```
Untuk informasi selengkapnya, lihat [Bekerja dengan Kebijakan AWS Firewall Manager](https://docs.aws.amazon.com/waf/latest/developerguide/working-with-policies.html) di *AWS WAF, AWS Firewall Manager, dan AWS Shield Advanced Developer Guide*.  
+  Untuk detail API, lihat [PutPolicy](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/fms/put-policy.html)di *Referensi AWS CLI Perintah*. 