

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

# AWS Config contoh menggunakan AWS CLI
<a name="cli_config-service_code_examples"></a>

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

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

### `hapus-config-aturan`
<a name="config-service_DeleteConfigRule_cli_topic"></a>

Contoh kode berikut menunjukkan cara menggunakan`delete-config-rule`.

**AWS CLI**  
**Untuk menghapus aturan AWS Config **  
Perintah berikut menghapus aturan AWS Config bernama: `MyConfigRule`  

```
aws configservice delete-config-rule --config-rule-name {{MyConfigRule}}
```
+  Untuk detail API, lihat [ DeleteConfigRule ](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/configservice/delete-config-rule.html) di Refer *AWS CLI ensi Perintah*. 

### `hapus saluran-pengiriman`
<a name="config-service_DeleteDeliveryChannel_cli_topic"></a>

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

**AWS CLI**  
**Untuk menghapus saluran pengiriman **  
Perintah berikut menghapus saluran pengiriman default:  

```
aws configservice delete-delivery-channel --delivery-channel-name {{default}}
```
+  Untuk detail API, lihat [ DeleteDeliveryChannel ](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/configservice/delete-delivery-channel.html) di Refer *AWS CLI ensi Perintah*. 

### `hapus-evaluasi-hasil`
<a name="config-service_DeleteEvaluationResults_cli_topic"></a>

Contoh kode berikut menunjukkan cara menggunakan`delete-evaluation-results`.

**AWS CLI**  
**Untuk menghapus hasil evaluasi secara manual **  
Perintah berikut menghapus hasil evaluasi saat ini untuk aturan terkelola s3-bucket- AWS versioning-enabled:  

```
aws configservice delete-evaluation-results --config-rule-name {{s3-bucket-versioning-enabled}}
```
+  Untuk detail API, lihat [ DeleteEvaluationResults ](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/configservice/delete-evaluation-results.html) di Refer *AWS CLI ensi Perintah*. 

### `kirim-config-snapshot`
<a name="config-service_DeliverConfigSnapshot_cli_topic"></a>

Contoh kode berikut menunjukkan cara menggunakan`deliver-config-snapshot`.

**AWS CLI**  
**Untuk mengirimkan snapshot konfigurasi **  
Perintah berikut mengirimkan snapshot konfigurasi ke bucket Amazon S3 yang termasuk dalam saluran pengiriman default:  

```
aws configservice deliver-config-snapshot --delivery-channel-name {{default}}
```
Output:  

```
{
    "configSnapshotId": "d0333b00-a683-44af-921e-examplefb794"
}
```
+  Untuk detail API, lihat [ DeliverConfigSnapshot ](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/configservice/deliver-config-snapshot.html) di Refer *AWS CLI ensi Perintah*. 

### `deskripsikan-kepatuhan-by-config-rule`
<a name="config-service_DescribeComplianceByConfigRule_cli_topic"></a>

Contoh kode berikut menunjukkan cara menggunakan`describe-compliance-by-config-rule`.

**AWS CLI**  
**Untuk mendapatkan informasi kepatuhan untuk aturan AWS Konfigurasi Anda **  
Perintah berikut mengembalikan informasi kepatuhan untuk setiap aturan AWS Config yang dilanggar oleh satu atau lebih AWS sumber daya:  

```
aws configservice describe-compliance-by-config-rule --compliance-types {{NON_COMPLIANT}}
```
Dalam output, nilai untuk setiap `CappedCount` atribut menunjukkan berapa banyak sumber daya yang tidak sesuai dengan aturan terkait. Misalnya, output berikut menunjukkan bahwa 3 sumber daya tidak sesuai dengan aturan bernama`InstanceTypesAreT2micro`.  
Output:  

```
{
    "ComplianceByConfigRules": [
        {
            "Compliance": {
                "ComplianceContributorCount": {
                    "CappedCount": 3,
                    "CapExceeded": false
                },
                "ComplianceType": "NON_COMPLIANT"
            },
            "ConfigRuleName": "InstanceTypesAreT2micro"
        },
        {
            "Compliance": {
                "ComplianceContributorCount": {
                    "CappedCount": 10,
                    "CapExceeded": false
                },
                "ComplianceType": "NON_COMPLIANT"
            },
            "ConfigRuleName": "RequiredTagsForVolumes"
        }
    ]
}
```
+  Untuk detail API, lihat [ DescribeComplianceByConfigRule ](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/configservice/describe-compliance-by-config-rule.html) di Refer *AWS CLI ensi Perintah*. 

### `deskripsikan kepatuhan-berdasarkan sumber daya`
<a name="config-service_DescribeComplianceByResource_cli_topic"></a>

Contoh kode berikut menunjukkan cara menggunakan`describe-compliance-by-resource`.

**AWS CLI**  
**Untuk mendapatkan informasi kepatuhan untuk AWS sumber daya Anda **  
Perintah berikut mengembalikan informasi kepatuhan untuk setiap instance EC2 yang direkam oleh AWS Config dan yang melanggar satu atau lebih aturan:  

```
aws configservice describe-compliance-by-resource --resource-type {{AWS::EC2::Instance}} --compliance-types {{NON_COMPLIANT}}
```
Dalam output, nilai untuk setiap `CappedCount` atribut menunjukkan berapa banyak aturan yang dilanggar sumber daya. Misalnya, output berikut menunjukkan bahwa instance `i-1a2b3c4d` melanggar 2 aturan.  
Output:  

```
{
    "ComplianceByResources": [
        {
            "ResourceType": "AWS::EC2::Instance",
            "ResourceId": "i-1a2b3c4d",
            "Compliance": {
                "ComplianceContributorCount": {
                    "CappedCount": 2,
                    "CapExceeded": false
                },
                "ComplianceType": "NON_COMPLIANT"
            }
        },
        {
            "ResourceType": "AWS::EC2::Instance",
            "ResourceId": "i-2a2b3c4d ",
            "Compliance": {
                "ComplianceContributorCount": {
                    "CappedCount": 3,
                    "CapExceeded": false
                },
                "ComplianceType": "NON_COMPLIANT"
            }
        }
    ]
}
```
+  Untuk detail API, lihat [ DescribeComplianceByResource ](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/configservice/describe-compliance-by-resource.html) di Refer *AWS CLI ensi Perintah*. 

### `deskripsi-config-rule-evaluation-status`
<a name="config-service_DescribeConfigRuleEvaluationStatus_cli_topic"></a>

Contoh kode berikut menunjukkan cara menggunakan`describe-config-rule-evaluation-status`.

**AWS CLI**  
**Untuk mendapatkan informasi status untuk aturan AWS Config **  
Perintah berikut mengembalikan informasi status untuk aturan AWS Config bernama`MyConfigRule`:  

```
aws configservice describe-config-rule-evaluation-status --config-rule-names {{MyConfigRule}}
```
Output:  

```
{
    "ConfigRulesEvaluationStatus": [
        {
            "ConfigRuleArn": "arn:aws:config:us-east-1:123456789012:config-rule/config-rule-abcdef",
            "FirstActivatedTime": 1450311703.844,
            "ConfigRuleId": "config-rule-abcdef",
            "LastSuccessfulInvocationTime": 1450314643.156,
            "ConfigRuleName": "MyConfigRule"
        }
    ]
}
```
+  Untuk detail API, lihat [ DescribeConfigRuleEvaluationStatus ](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/configservice/describe-config-rule-evaluation-status.html) di Refer *AWS CLI ensi Perintah*. 

### `deskripsi-config-rules`
<a name="config-service_DescribeConfigRules_cli_topic"></a>

Contoh kode berikut menunjukkan cara menggunakan`describe-config-rules`.

**AWS CLI**  
**Untuk mendapatkan detail aturan AWS Config **  
Perintah berikut mengembalikan detail untuk aturan AWS Config bernama`InstanceTypesAreT2micro`:  

```
aws configservice describe-config-rules --config-rule-names {{InstanceTypesAreT2micro}}
```
Output:  

```
{
    "ConfigRules": [
        {
            "ConfigRuleState": "ACTIVE",
            "Description": "Evaluates whether EC2 instances are the t2.micro type.",
            "ConfigRuleName": "InstanceTypesAreT2micro",
            "ConfigRuleArn": "arn:aws:config:us-east-1:123456789012:config-rule/config-rule-abcdef",
            "Source": {
                "Owner": "CUSTOM_LAMBDA",
                "SourceIdentifier": "arn:aws:lambda:us-east-1:123456789012:function:InstanceTypeCheck",
                "SourceDetails": [
                    {
                        "EventSource": "aws.config",
                        "MessageType": "ConfigurationItemChangeNotification"
                    }
                ]
            },
            "InputParameters": "{\"desiredInstanceType\":\"t2.micro\"}",
            "Scope": {
                "ComplianceResourceTypes": [
                    "AWS::EC2::Instance"
                ]
            },
            "ConfigRuleId": "config-rule-abcdef"
        }
    ]
}
```
+  Untuk detail API, lihat [ DescribeConfigRules ](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/configservice/describe-config-rules.html) di Refer *AWS CLI ensi Perintah*. 

### `deskripsi-konfigurasi-perekam-status`
<a name="config-service_DescribeConfigurationRecorderStatus_cli_topic"></a>

Contoh kode berikut menunjukkan cara menggunakan`describe-configuration-recorder-status`.

**AWS CLI**  
**Untuk mendapatkan informasi status untuk perekam konfigurasi **  
Perintah berikut mengembalikan status perekam konfigurasi default:  

```
aws configservice describe-configuration-recorder-status
```
Output:  

```
{
    "ConfigurationRecordersStatus": [
        {
            "name": "default",
            "lastStatus": "SUCCESS",
            "recording": true,
            "lastStatusChangeTime": 1452193834.344,
            "lastStartTime": 1441039997.819,
            "lastStopTime": 1441039992.835
        }
    ]
}
```
+  Untuk detail API, lihat [ DescribeConfigurationRecorderStatus ](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/configservice/describe-configuration-recorder-status.html) di Refer *AWS CLI ensi Perintah*. 

### `deskripsi-konfigurasi-perekam`
<a name="config-service_DescribeConfigurationRecorders_cli_topic"></a>

Contoh kode berikut menunjukkan cara menggunakan`describe-configuration-recorders`.

**AWS CLI**  
**Untuk mendapatkan detail tentang perekam konfigurasi **  
Perintah berikut mengembalikan detail tentang perekam konfigurasi default:  

```
aws configservice describe-configuration-recorders
```
Output:  

```
{
    "ConfigurationRecorders": [
        {
            "recordingGroup": {
                "allSupported": true,
                "resourceTypes": [],
                "includeGlobalResourceTypes": true
            },
            "roleARN": "arn:aws:iam::123456789012:role/config-ConfigRole-A1B2C3D4E5F6",
            "name": "default"
        }
    ]
}
```
+  Untuk detail API, lihat [ DescribeConfigurationRecorders ](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/configservice/describe-configuration-recorders.html) di Refer *AWS CLI ensi Perintah*. 

### `deskripsikan-pengiriman-saluran-status`
<a name="config-service_DescribeDeliveryChannelStatus_cli_topic"></a>

Contoh kode berikut menunjukkan cara menggunakan`describe-delivery-channel-status`.

**AWS CLI**  
**Untuk mendapatkan informasi status untuk saluran pengiriman **  
Perintah berikut mengembalikan status saluran pengiriman:  

```
aws configservice describe-delivery-channel-status
```
Output:  

```
{
    "DeliveryChannelsStatus": [
        {
            "configStreamDeliveryInfo": {
                "lastStatusChangeTime": 1452193834.381,
                "lastStatus": "SUCCESS"
            },
            "configHistoryDeliveryInfo": {
                "lastSuccessfulTime": 1450317838.412,
                "lastStatus": "SUCCESS",
                "lastAttemptTime": 1450317838.412
            },
            "configSnapshotDeliveryInfo": {
                "lastSuccessfulTime": 1452185597.094,
                "lastStatus": "SUCCESS",
                "lastAttemptTime": 1452185597.094
            },
            "name": "default"
        }
    ]
}
```
+  Untuk detail API, lihat [ DescribeDeliveryChannelStatus ](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/configservice/describe-delivery-channel-status.html) di Refer *AWS CLI ensi Perintah*. 

### `deskripsi-saluran-pengiriman`
<a name="config-service_DescribeDeliveryChannels_cli_topic"></a>

Contoh kode berikut menunjukkan cara menggunakan`describe-delivery-channels`.

**AWS CLI**  
**Untuk mendapatkan detail tentang saluran pengiriman **  
Perintah berikut mengembalikan detail tentang saluran pengiriman:  

```
aws configservice describe-delivery-channels
```
Output:  

```
{
    "DeliveryChannels": [
        {
            "snsTopicARN": "arn:aws:sns:us-east-1:123456789012:config-topic",
            "name": "default",
            "s3BucketName": "config-bucket-123456789012"
        }
    ]
}
```
+  Untuk detail API, lihat [ DescribeDeliveryChannels ](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/configservice/describe-delivery-channels.html) di Refer *AWS CLI ensi Perintah*. 

### `dapatkan perincian kepatuhan berdasarkan aturan konfigurasi`
<a name="config-service_GetComplianceDetailsByConfigRule_cli_topic"></a>

Contoh kode berikut menunjukkan cara menggunakan`get-compliance-details-by-config-rule`.

**AWS CLI**  
**Untuk mendapatkan hasil evaluasi untuk aturan AWS Config **  
Perintah berikut mengembalikan hasil evaluasi untuk semua sumber daya yang tidak mematuhi aturan AWS Config bernama`InstanceTypesAreT2micro`:  

```
aws configservice get-compliance-details-by-config-rule --config-rule-name {{InstanceTypesAreT2micro}} --compliance-types {{NON_COMPLIANT}}
```
Output:  

```
{
    "EvaluationResults": [
        {
            "EvaluationResultIdentifier": {
                "OrderingTimestamp": 1450314635.065,
                "EvaluationResultQualifier": {
                    "ResourceType": "AWS::EC2::Instance",
                    "ResourceId": "i-1a2b3c4d",
                    "ConfigRuleName": "InstanceTypesAreT2micro"
                }
            },
            "ResultRecordedTime": 1450314645.261,
            "ConfigRuleInvokedTime": 1450314642.948,
            "ComplianceType": "NON_COMPLIANT"
        },
        {
            "EvaluationResultIdentifier": {
                "OrderingTimestamp": 1450314635.065,
                "EvaluationResultQualifier": {
                    "ResourceType": "AWS::EC2::Instance",
                    "ResourceId": "i-2a2b3c4d",
                    "ConfigRuleName": "InstanceTypesAreT2micro"
                }
            },
            "ResultRecordedTime": 1450314645.18,
            "ConfigRuleInvokedTime": 1450314642.902,
            "ComplianceType": "NON_COMPLIANT"
        },
        {
            "EvaluationResultIdentifier": {
                "OrderingTimestamp": 1450314635.065,
                "EvaluationResultQualifier": {
                    "ResourceType": "AWS::EC2::Instance",
                    "ResourceId": "i-3a2b3c4d",
                    "ConfigRuleName": "InstanceTypesAreT2micro"
                }
            },
            "ResultRecordedTime": 1450314643.346,
            "ConfigRuleInvokedTime": 1450314643.124,
            "ComplianceType": "NON_COMPLIANT"
        }
    ]
}
```
+  Untuk detail API, lihat [ GetComplianceDetailsByConfigRule ](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/configservice/get-compliance-details-by-config-rule.html) di Refer *AWS CLI ensi Perintah*. 

### `dapatkan perincian kepatuhan berdasarkan sumber daya`
<a name="config-service_GetComplianceDetailsByResource_cli_topic"></a>

Contoh kode berikut menunjukkan cara menggunakan`get-compliance-details-by-resource`.

**AWS CLI**  
**Untuk mendapatkan hasil evaluasi untuk AWS sumber daya **  
Perintah berikut mengembalikan hasil evaluasi untuk setiap aturan yang `i-1a2b3c4d` tidak mematuhi instance EC2:  

```
aws configservice get-compliance-details-by-resource --resource-type {{AWS::EC2::Instance}} --resource-id {{i-1a2b3c4d}} --compliance-types {{NON_COMPLIANT}}
```
Output:  

```
{
    "EvaluationResults": [
        {
            "EvaluationResultIdentifier": {
                "OrderingTimestamp": 1450314635.065,
                "EvaluationResultQualifier": {
                    "ResourceType": "AWS::EC2::Instance",
                    "ResourceId": "i-1a2b3c4d",
                    "ConfigRuleName": "InstanceTypesAreT2micro"
                }
            },
            "ResultRecordedTime": 1450314643.288,
            "ConfigRuleInvokedTime": 1450314643.034,
            "ComplianceType": "NON_COMPLIANT"
        },
        {
            "EvaluationResultIdentifier": {
                "OrderingTimestamp": 1450314635.065,
                "EvaluationResultQualifier": {
                    "ResourceType": "AWS::EC2::Instance",
                    "ResourceId": "i-1a2b3c4d",
                    "ConfigRuleName": "RequiredTagForEC2Instances"
                }
            },
            "ResultRecordedTime": 1450314645.261,
            "ConfigRuleInvokedTime": 1450314642.948,
            "ComplianceType": "NON_COMPLIANT"
        }
    ]
}
```
+  Untuk detail API, lihat [ GetComplianceDetailsByResource ](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/configservice/get-compliance-details-by-resource.html) di Refer *AWS CLI ensi Perintah*. 

### `dapatkan kesimpulan kesesuaian-by-config-rule`
<a name="config-service_GetComplianceSummaryByConfigRule_cli_topic"></a>

Contoh kode berikut menunjukkan cara menggunakan`get-compliance-summary-by-config-rule`.

**AWS CLI**  
**Untuk mendapatkan ringkasan kepatuhan untuk aturan AWS Konfigurasi Anda **  
Perintah berikut mengembalikan jumlah aturan yang sesuai dan jumlah yang tidak sesuai:  

```
aws configservice get-compliance-summary-by-config-rule
```
Dalam output, nilai untuk setiap `CappedCount` atribut menunjukkan berapa banyak aturan yang sesuai atau tidak sesuai.  
Output:  

```
{
    "ComplianceSummary": {
        "NonCompliantResourceCount": {
            "CappedCount": 3,
            "CapExceeded": false
        },
        "ComplianceSummaryTimestamp": 1452204131.493,
        "CompliantResourceCount": {
            "CappedCount": 2,
            "CapExceeded": false
        }
    }
}
```
+  Untuk detail API, lihat [ GetComplianceSummaryByConfigRule ](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/configservice/get-compliance-summary-by-config-rule.html) di Refer *AWS CLI ensi Perintah*. 

### `dapatkan ringkasan kepatuhan berdasarkan jenis sumber daya`
<a name="config-service_GetComplianceSummaryByResourceType_cli_topic"></a>

Contoh kode berikut menunjukkan cara menggunakan`get-compliance-summary-by-resource-type`.

**AWS CLI**  
**Untuk mendapatkan ringkasan kepatuhan untuk semua jenis sumber daya **  
Perintah berikut mengembalikan jumlah AWS sumber daya yang tidak sesuai dan jumlah yang sesuai:  

```
aws configservice get-compliance-summary-by-resource-type
```
Dalam output, nilai untuk setiap `CappedCount` atribut menunjukkan berapa banyak sumber daya yang sesuai atau tidak sesuai.  
Output:  

```
{
    "ComplianceSummariesByResourceType": [
        {
            "ComplianceSummary": {
                "NonCompliantResourceCount": {
                    "CappedCount": 16,
                    "CapExceeded": false
                },
                "ComplianceSummaryTimestamp": 1453237464.543,
                "CompliantResourceCount": {
                    "CappedCount": 10,
                    "CapExceeded": false
                }
            }
        }
    ]
}
```
**Untuk mendapatkan ringkasan kepatuhan untuk jenis sumber daya tertentu **  
Perintah berikut mengembalikan jumlah instans EC2 yang tidak sesuai dan jumlah yang sesuai:  

```
aws configservice get-compliance-summary-by-resource-type --resource-types {{AWS::EC2::Instance}}
```
Dalam output, nilai untuk setiap `CappedCount` atribut menunjukkan berapa banyak sumber daya yang sesuai atau tidak sesuai.  
Output:  

```
{
    "ComplianceSummariesByResourceType": [
        {
            "ResourceType": "AWS::EC2::Instance",
            "ComplianceSummary": {
                "NonCompliantResourceCount": {
                    "CappedCount": 3,
                    "CapExceeded": false
                },
                "ComplianceSummaryTimestamp": 1452204923.518,
                "CompliantResourceCount": {
                    "CappedCount": 7,
                    "CapExceeded": false
                }
            }
        }
    ]
}
```
+  Untuk detail API, lihat [ GetComplianceSummaryByResourceType ](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/configservice/get-compliance-summary-by-resource-type.html) di Refer *AWS CLI ensi Perintah*. 

### `get-resource-config-history`
<a name="config-service_GetResourceConfigHistory_cli_topic"></a>

Contoh kode berikut menunjukkan cara menggunakan`get-resource-config-history`.

**AWS CLI**  
**Untuk mendapatkan riwayat konfigurasi AWS sumber daya **  
Perintah berikut mengembalikan daftar item konfigurasi untuk instance EC2 dengan ID: `i-1a2b3c4d`  

```
aws configservice get-resource-config-history --resource-type {{AWS::EC2::Instance}} --resource-id {{i-1a2b3c4d}}
```
+  Untuk detail API, lihat [ GetResourceConfigHistory ](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/configservice/get-resource-config-history.html) di Refer *AWS CLI ensi Perintah*. 

### `dapatkan status`
<a name="config-service_GetStatus_cli_topic"></a>

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

**AWS CLI**  
**Untuk mendapatkan status untuk AWS Config **  
Perintah berikut mengembalikan status saluran pengiriman dan perekam konfigurasi:  

```
aws configservice get-status
```
Output:  

```
Configuration Recorders:

name: default
recorder: ON
last status: SUCCESS

Delivery Channels:

name: default
last stream delivery status: SUCCESS
last history delivery status: SUCCESS
last snapshot delivery status: SUCCESS
```
+  Untuk detail API, lihat [ GetStatus ](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/configservice/get-status.html) di Refer *AWS CLI ensi Perintah*. 

### `daftar sumber daya yang ditemukan`
<a name="config-service_ListDiscoveredResources_cli_topic"></a>

Contoh kode berikut menunjukkan cara menggunakan`list-discovered-resources`.

**AWS CLI**  
**Untuk membuat daftar sumber daya yang ditemukan AWS Config **  
Perintah berikut mencantumkan instance EC2 yang ditemukan AWS Config:  

```
aws configservice list-discovered-resources --resource-type {{AWS::EC2::Instance}}
```
Output:  

```
{
    "resourceIdentifiers": [
        {
            "resourceType": "AWS::EC2::Instance",
            "resourceId": "i-1a2b3c4d"
        },
        {
            "resourceType": "AWS::EC2::Instance",
            "resourceId": "i-2a2b3c4d"
        },
        {
            "resourceType": "AWS::EC2::Instance",
            "resourceId": "i-3a2b3c4d"
        }
    ]
}
```
+  Untuk detail API, lihat [ ListDiscoveredResources ](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/configservice/list-discovered-resources.html) di Refer *AWS CLI ensi Perintah*. 

### `put-config-aturan`
<a name="config-service_PutConfigRule_cli_topic"></a>

Contoh kode berikut menunjukkan cara menggunakan`put-config-rule`.

**AWS CLI**  
**Untuk menambahkan aturan Con AWS fig terkelola **  
Perintah berikut menyediakan kode JSON untuk menambahkan aturan Config yang AWS dikelola:  

```
aws configservice put-config-rule --config-rule {{file://RequiredTagsForEC2Instances.json}}
```
`RequiredTagsForEC2Instances.json`adalah file JSON yang berisi konfigurasi aturan:  

```
{
  "ConfigRuleName": "RequiredTagsForEC2Instances",
  "Description": "Checks whether the CostCenter and Owner tags are applied to EC2 instances.",
  "Scope": {
    "ComplianceResourceTypes": [
      "AWS::EC2::Instance"
    ]
  },
  "Source": {
    "Owner": "AWS",
    "SourceIdentifier": "REQUIRED_TAGS"
  },
  "InputParameters": "{\"tag1Key\":\"CostCenter\",\"tag2Key\":\"Owner\"}"
}
```
Untuk `ComplianceResourceTypes` atribut, kode JSON ini membatasi ruang lingkup ke sumber daya `AWS::EC2::Instance` jenis, jadi AWS Config hanya akan mengevaluasi instance EC2 terhadap aturan. Karena aturan adalah aturan terkelola, `Owner` atribut disetel ke`AWS`, dan `SourceIdentifier` atribut disetel ke pengenal aturan,`REQUIRED_TAGS`. Untuk `InputParameters` atribut, kunci tag yang diperlukan aturan, `CostCenter` dan`Owner`, ditentukan.  
Jika perintah berhasil, AWS Config tidak mengembalikan output. Untuk memverifikasi konfigurasi aturan, jalankan perintah describe-config-rules, dan tentukan nama aturan.  
**Untuk menambahkan aturan Konfigurasi yang dikelola pelanggan **  
Perintah berikut menyediakan kode JSON untuk menambahkan aturan Config yang dikelola pelanggan:  

```
aws configservice put-config-rule --config-rule {{file://InstanceTypesAreT2micro.json}}
```
`InstanceTypesAreT2micro.json`adalah file JSON yang berisi konfigurasi aturan:  

```
{
  "ConfigRuleName": "InstanceTypesAreT2micro",
  "Description": "Evaluates whether EC2 instances are the t2.micro type.",
  "Scope": {
    "ComplianceResourceTypes": [
      "AWS::EC2::Instance"
    ]
  },
  "Source": {
    "Owner": "CUSTOM_LAMBDA",
    "SourceIdentifier": "arn:aws:lambda:us-east-1:123456789012:function:InstanceTypeCheck",
    "SourceDetails": [
      {
        "EventSource": "aws.config",
        "MessageType": "ConfigurationItemChangeNotification"
      }
    ]
  },
  "InputParameters": "{\"desiredInstanceType\":\"t2.micro\"}"
}
```
Untuk `ComplianceResourceTypes` atribut, kode JSON ini membatasi ruang lingkup ke sumber daya `AWS::EC2::Instance` jenis, jadi AWS Config hanya akan mengevaluasi instance EC2 terhadap aturan. Karena aturan ini adalah aturan yang dikelola pelanggan, `Owner` atribut disetel ke`CUSTOM_LAMBDA`, dan `SourceIdentifier` atribut disetel ke ARN fungsi AWS Lambda. Ob `SourceDetails` jek diperlukan. Parameter yang ditentukan untuk `InputParameters` atribut diteruskan ke fungsi AWS Lambda ketika AWS Config memanggilnya untuk mengevaluasi sumber daya terhadap aturan.  
Jika perintah berhasil, AWS Config tidak mengembalikan output. Untuk memverifikasi konfigurasi aturan, jalankan perintah describe-config-rules, dan tentukan nama aturan.  
+  Untuk detail API, lihat [ PutConfigRule ](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/configservice/put-config-rule.html) di Refer *AWS CLI ensi Perintah*. 

### `put-konfigurasi-perekam`
<a name="config-service_PutConfigurationRecorder_cli_topic"></a>

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

**AWS CLI**  
**Contoh 1: Untuk merekam semua sumber daya yang didukung **  
Perintah berikut membuat perekam konfigurasi yang melacak perubahan pada semua jenis sumber daya yang didukung, termasuk tipe sumber daya global:  

```
aws configservice put-configuration-recorder \
    --configuration-recorder {{name=default,roleARN=arn:aws:iam::123456789012:role/config-role}} \
    --recording-group {{allSupported=true,includeGlobalResourceTypes=true}}
```
Jika perintah berhasil, AWS Config tidak mengembalikan output. Untuk memverifikasi pengaturan perekam konfigurasi Anda, jalankan perintah describe-configuration-recorders.  
**Contoh 2: Untuk merekam jenis sumber daya tertentu **  
Perintah berikut membuat perekam konfigurasi yang melacak perubahan hanya pada jenis sumber daya yang ditentukan dalam file JSON untuk opsi --recording-group:  

```
aws configservice put-configuration-recorder \
    --configuration-recorder {{name=default,roleARN=arn:aws:iam::123456789012:role/config-role}} \
    --recording-group {{file://recordingGroup.json}}
```
rekaman Group.json adalah file JSON yang menentukan jenis sumber daya yang akan direkam AWS Config:  

```
{
    "allSupported": false,
    "includeGlobalResourceTypes": false,
    "resourceTypes": [
        "AWS::EC2::EIP",
        "AWS::EC2::Instance",
        "AWS::EC2::NetworkAcl",
        "AWS::EC2::SecurityGroup",
        "AWS::CloudTrail::Trail",
        "AWS::EC2::Volume",
        "AWS::EC2::VPC",
        "AWS::IAM::User",
        "AWS::IAM::Policy"
    ]
}
```
Sebelum Anda dapat menentukan jenis sumber daya untuk kunci ResourceTypes, Anda harus menyetel GlobalResourceTypes opsi AllSupported dan sertakan ke false atau menghilangkannya.  
Jika perintah berhasil, AWS Config tidak mengembalikan output. Untuk memverifikasi pengaturan perekam konfigurasi Anda, jalankan perintah describe-configuration-recorders.  
**Contoh 3: Untuk memilih semua sumber daya yang didukung tidak termasuk jenis sumber daya tertentu **  
Perintah berikut membuat perekam konfigurasi yang melacak perubahan pada semua jenis sumber daya yang didukung saat ini dan yang akan datang tidak termasuk jenis sumber daya yang ditentukan dalam file JSON untuk opsi --recording-group:  

```
aws configservice put-configuration-recorder \
    --configuration-recorder {{name=default,roleARN=arn:aws:iam::123456789012:role/config-role}} \
    --recording-group {{file://recordingGroup.json}}
```
rekaman Group.json adalah file JSON yang menentukan jenis sumber daya yang akan direkam AWS Config:  

```
{
    "allSupported": false,
    "exclusionByResourceTypes": {
        "resourceTypes": [
        "AWS::Redshift::ClusterSnapshot",
        "AWS::RDS::DBClusterSnapshot",
        "AWS::CloudFront::StreamingDistribution"
    ]
    },
        "includeGlobalResourceTypes": false,
        "recordingStrategy": {
        "useOnly": "EXCLUSION_BY_RESOURCE_TYPES"
    },
}
```
Sebelum Anda dapat menentukan jenis sumber daya untuk dikecualikan dari perekaman: 1) Anda harus mengatur GlobalResourceTypes opsi AllSupported dan sertakan ke false atau menghilangkannya, dan 2) Anda harus mengatur bidang useOnly ke EXCLUSION\_BY\_RESOURCE\_TYPES. RecordingStrategy   
Jika perintah berhasil, AWS Config tidak mengembalikan output. Untuk memverifikasi pengaturan perekam konfigurasi Anda, jalankan perintah describe-configuration-recorders.  
+  Untuk detail API, lihat [ PutConfigurationRecorder ](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/configservice/put-configuration-recorder.html) di Refer *AWS CLI ensi Perintah*. 

### `put-pengiriman saluran`
<a name="config-service_PutDeliveryChannel_cli_topic"></a>

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

**AWS CLI**  
**Untuk membuat saluran pengiriman **  
Perintah berikut menyediakan pengaturan untuk saluran pengiriman sebagai kode JSON:  

```
aws configservice put-delivery-channel --delivery-channel {{file://deliveryChannel.json}}
```
`deliveryChannel.json`File menentukan atribut saluran pengiriman:  

```
{
    "name": "default",
    "s3BucketName": "config-bucket-123456789012",
    "snsTopicARN": "arn:aws:sns:us-east-1:123456789012:config-topic",
    "configSnapshotDeliveryProperties": {
        "deliveryFrequency": "Twelve_Hours"
    }
}
```
Contoh ini menetapkan atribut berikut:  
`name`- Nama saluran pengiriman. Secara default, AWS Config menetapkan nama `default` ke saluran pengiriman baru. Anda tidak dapat memperbarui nama saluran pengiriman dengan perintah. `put-delivery-channel` Untuk langkah-langkah mengubah nama, lihat Mengganti nama Saluran Pengiriman. `s3BucketName` - Nama bucket Amazon S3 tempat Config mengirimkan snapshot AWS konfigurasi dan file riwayat konfigurasi. Jika Anda menentukan bucket milik AWS akun lain, bucket itu harus memiliki kebijakan yang memberikan izin akses ke Config. AWS Untuk informasi selengkapnya, lihat Izin untuk Amazon S3 Bucket.  
`snsTopicARN`- Nama Sumber Daya Amazon (ARN) dari topik Amazon SNS tempat AWS Config mengirimkan pemberitahuan tentang perubahan konfigurasi. Jika Anda memilih topik dari akun lain, topik harus memiliki kebijakan yang memberikan izin akses ke Config. AWS Untuk informasi selengkapnya, lihat Izin untuk Topik Amazon SNS.  
`configSnapshotDeliveryProperties`- Berisi `deliveryFrequency` atribut, yang mengatur seberapa sering AWS Config memberikan snapshot konfigurasi dan seberapa sering ia memanggil evaluasi untuk aturan Konfigurasi berkala.  
Jika perintah berhasil, AWS Config tidak mengembalikan output. Untuk memverifikasi pengaturan saluran pengiriman Anda, jalankan perintah describe-delivery-channels.  
+  Untuk detail API, lihat [ PutDeliveryChannel ](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/configservice/put-delivery-channel.html) di Refer *AWS CLI ensi Perintah*. 

### `start-config-aturan-evaluasi`
<a name="config-service_StartConfigRulesEvaluation_cli_topic"></a>

Contoh kode berikut menunjukkan cara menggunakan`start-config-rules-evaluation`.

**AWS CLI**  
**Untuk menjalankan evaluasi sesuai permintaan untuk aturan AWS Config **  
Perintah berikut memulai evaluasi untuk dua aturan ter AWS kelola:  

```
aws configservice start-config-rules-evaluation --config-rule-names {{s3-bucket-versioning-enabled}} {{cloudtrail-enabled}}
```
+  Untuk detail API, lihat [ StartConfigRulesEvaluation ](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/configservice/start-config-rules-evaluation.html) di Refer *AWS CLI ensi Perintah*. 

### `mula-konfigurasi-perekam`
<a name="config-service_StartConfigurationRecorder_cli_topic"></a>

Contoh kode berikut menunjukkan cara menggunakan`start-configuration-recorder`.

**AWS CLI**  
**Untuk memulai perekam konfigurasi **  
Perintah berikut memulai perekam konfigurasi default:  

```
aws configservice start-configuration-recorder --configuration-recorder-name {{default}}
```
Jika perintah berhasil, AWS Config tidak mengembalikan output. Untuk memverifikasi bahwa AWS Config merekam sumber daya Anda, jalankan perintah get-status.  
+  Untuk detail API, lihat [ StartConfigurationRecorder ](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/configservice/start-configuration-recorder.html) di Refer *AWS CLI ensi Perintah*. 

### `stop-konfigurasi-perekam`
<a name="config-service_StopConfigurationRecorder_cli_topic"></a>

Contoh kode berikut menunjukkan cara menggunakan`stop-configuration-recorder`.

**AWS CLI**  
**Untuk menghentikan perekam konfigurasi **  
Perintah berikut menghentikan perekam konfigurasi default:  

```
aws configservice stop-configuration-recorder --configuration-recorder-name {{default}}
```
Jika perintah berhasil, AWS Config tidak mengembalikan output. Untuk memverifikasi bahwa AWS Config tidak merekam sumber daya Anda, jalankan perintah get-status.  
+  Untuk detail API, lihat [ StopConfigurationRecorder ](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/configservice/stop-configuration-recorder.html) di Refer *AWS CLI ensi Perintah*. 

### `langganan`
<a name="config-service_Subscribe_cli_topic"></a>

Contoh kode berikut menunjukkan cara menggunakan`subscribe`.

**AWS CLI**  
**Untuk berlangganan AWS Config **  
Perintah berikut membuat saluran pengiriman default dan perekam konfigurasi. Perintah ini juga menentukan bucket Amazon S3 dan topik Amazon SNS tempat AWS Config akan mengirimkan informasi konfigurasi:  

```
aws configservice subscribe --s3-bucket {{config-bucket-123456789012}} --sns-topic {{arn:aws:sns:us-east-1:123456789012:config-topic}} --iam-role {{arn:aws:iam::123456789012:role/ConfigRole-A1B2C3D4E5F6}}
```
Output:  

```
Using existing S3 bucket: config-bucket-123456789012
Using existing SNS topic: arn:aws:sns:us-east-1:123456789012:config-topic
Subscribe succeeded:

Configuration Recorders: [
    {
        "recordingGroup": {
            "allSupported": true,
            "resourceTypes": [],
            "includeGlobalResourceTypes": false
        },
        "roleARN": "arn:aws:iam::123456789012:role/ConfigRole-A1B2C3D4E5F6",
        "name": "default"
    }
]

Delivery Channels: [
    {
        "snsTopicARN": "arn:aws:sns:us-east-1:123456789012:config-topic",
        "name": "default",
        "s3BucketName": "config-bucket-123456789012"
    }
]
```
+  Untuk detail API, lihat Ber [ langganan ](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/configservice/subscribe.html) di Refer *AWS CLI ensi Perintah*. 