

Ada lebih banyak contoh AWS SDK yang tersedia di repo Contoh [SDK AWS Doc](https://github.com/awsdocs/aws-doc-sdk-examples). GitHub 

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

# Contoh kode untuk AWS Config menggunakan AWS SDKs
<a name="config-service_code_examples"></a>

Contoh kode berikut menunjukkan cara menggunakan AWS Config kit pengembangan AWS perangkat lunak (SDK).

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

**Sumber daya lainnya**
+  **[AWS Config Panduan Pengembang](https://docs.aws.amazon.com/config/latest/developerguide/WhatIsConfig.html)** - Informasi lebih lanjut tentang AWS Config.
+ **[AWS Config Referensi API](https://docs.aws.amazon.com/config/latest/APIReference/Welcome.html)** — Detail tentang semua AWS Config tindakan yang tersedia.
+ **[AWS Pusat Pengembang](https://aws.amazon.com/developer/code-examples/?awsf.sdk-code-examples-product=product%23config)** - Contoh kode yang dapat Anda filter berdasarkan kategori atau pencarian teks lengkap.
+ **[AWS Contoh SDK](https://github.com/awsdocs/aws-doc-sdk-examples)** — GitHub repo dengan kode lengkap dalam bahasa pilihan. Termasuk instruksi untuk mengatur dan menjalankan kode.

**Contents**
+ [Hal-hal mendasar](config-service_code_examples_basics.md)
  + [Tindakan](config-service_code_examples_actions.md)
    + [`DeleteConfigRule`](config-service_example_config-service_DeleteConfigRule_section.md)
    + [`DescribeComplianceByConfigRule`](config-service_example_config-service_DescribeComplianceByConfigRule_section.md)
    + [`DescribeComplianceByResource`](config-service_example_config-service_DescribeComplianceByResource_section.md)
    + [`DescribeConfigRuleEvaluationStatus`](config-service_example_config-service_DescribeConfigRuleEvaluationStatus_section.md)
    + [`DescribeConfigRules`](config-service_example_config-service_DescribeConfigRules_section.md)
    + [`DescribeConfigurationRecorderStatus`](config-service_example_config-service_DescribeConfigurationRecorderStatus_section.md)
    + [`DescribeConfigurationRecorders`](config-service_example_config-service_DescribeConfigurationRecorders_section.md)
    + [`DescribeDeliveryChannels`](config-service_example_config-service_DescribeDeliveryChannels_section.md)
    + [`GetComplianceDetailsByConfigRule`](config-service_example_config-service_GetComplianceDetailsByConfigRule_section.md)
    + [`GetComplianceDetailsByResource`](config-service_example_config-service_GetComplianceDetailsByResource_section.md)
    + [`GetComplianceSummaryByConfigRule`](config-service_example_config-service_GetComplianceSummaryByConfigRule_section.md)
    + [`GetComplianceSummaryByResourceType`](config-service_example_config-service_GetComplianceSummaryByResourceType_section.md)
    + [`PutConfigRule`](config-service_example_config-service_PutConfigRule_section.md)
    + [`PutDeliveryChannel`](config-service_example_config-service_PutDeliveryChannel_section.md)

# Contoh dasar untuk AWS Config menggunakan AWS SDKs
<a name="config-service_code_examples_basics"></a>

Contoh kode berikut menunjukkan cara menggunakan dasar-dasar AWS Config dengan AWS SDKs. 

**Contents**
+ [Tindakan](config-service_code_examples_actions.md)
  + [`DeleteConfigRule`](config-service_example_config-service_DeleteConfigRule_section.md)
  + [`DescribeComplianceByConfigRule`](config-service_example_config-service_DescribeComplianceByConfigRule_section.md)
  + [`DescribeComplianceByResource`](config-service_example_config-service_DescribeComplianceByResource_section.md)
  + [`DescribeConfigRuleEvaluationStatus`](config-service_example_config-service_DescribeConfigRuleEvaluationStatus_section.md)
  + [`DescribeConfigRules`](config-service_example_config-service_DescribeConfigRules_section.md)
  + [`DescribeConfigurationRecorderStatus`](config-service_example_config-service_DescribeConfigurationRecorderStatus_section.md)
  + [`DescribeConfigurationRecorders`](config-service_example_config-service_DescribeConfigurationRecorders_section.md)
  + [`DescribeDeliveryChannels`](config-service_example_config-service_DescribeDeliveryChannels_section.md)
  + [`GetComplianceDetailsByConfigRule`](config-service_example_config-service_GetComplianceDetailsByConfigRule_section.md)
  + [`GetComplianceDetailsByResource`](config-service_example_config-service_GetComplianceDetailsByResource_section.md)
  + [`GetComplianceSummaryByConfigRule`](config-service_example_config-service_GetComplianceSummaryByConfigRule_section.md)
  + [`GetComplianceSummaryByResourceType`](config-service_example_config-service_GetComplianceSummaryByResourceType_section.md)
  + [`PutConfigRule`](config-service_example_config-service_PutConfigRule_section.md)
  + [`PutDeliveryChannel`](config-service_example_config-service_PutDeliveryChannel_section.md)

# Tindakan untuk AWS Config menggunakan AWS SDKs
<a name="config-service_code_examples_actions"></a>

Contoh kode berikut menunjukkan bagaimana melakukan AWS Config tindakan individu dengan AWS SDKs. Setiap contoh menyertakan tautan ke GitHub, di mana Anda dapat menemukan instruksi untuk mengatur dan menjalankan kode. 

 Contoh berikut hanya mencakup tindakan yang paling umum digunakan. Untuk daftar lengkapnya, lihat [Referensi AWS Config API](https://docs.aws.amazon.com/config/latest/APIReference/Welcome.html). 

**Topics**
+ [`DeleteConfigRule`](config-service_example_config-service_DeleteConfigRule_section.md)
+ [`DescribeComplianceByConfigRule`](config-service_example_config-service_DescribeComplianceByConfigRule_section.md)
+ [`DescribeComplianceByResource`](config-service_example_config-service_DescribeComplianceByResource_section.md)
+ [`DescribeConfigRuleEvaluationStatus`](config-service_example_config-service_DescribeConfigRuleEvaluationStatus_section.md)
+ [`DescribeConfigRules`](config-service_example_config-service_DescribeConfigRules_section.md)
+ [`DescribeConfigurationRecorderStatus`](config-service_example_config-service_DescribeConfigurationRecorderStatus_section.md)
+ [`DescribeConfigurationRecorders`](config-service_example_config-service_DescribeConfigurationRecorders_section.md)
+ [`DescribeDeliveryChannels`](config-service_example_config-service_DescribeDeliveryChannels_section.md)
+ [`GetComplianceDetailsByConfigRule`](config-service_example_config-service_GetComplianceDetailsByConfigRule_section.md)
+ [`GetComplianceDetailsByResource`](config-service_example_config-service_GetComplianceDetailsByResource_section.md)
+ [`GetComplianceSummaryByConfigRule`](config-service_example_config-service_GetComplianceSummaryByConfigRule_section.md)
+ [`GetComplianceSummaryByResourceType`](config-service_example_config-service_GetComplianceSummaryByResourceType_section.md)
+ [`PutConfigRule`](config-service_example_config-service_PutConfigRule_section.md)
+ [`PutDeliveryChannel`](config-service_example_config-service_PutDeliveryChannel_section.md)

# Gunakan `DeleteConfigRule` dengan AWS SDK atau CLI
<a name="config-service_example_config-service_DeleteConfigRule_section"></a>

Contoh kode berikut menunjukkan cara menggunakan`DeleteConfigRule`.

------
#### [ CLI ]

**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 *Referensi AWS CLI Perintah*. 

------
#### [ Python ]

**SDK untuk Python (Boto3)**  
 Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara mengatur dan menjalankannya di [Repositori Contoh Kode AWS](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/python/example_code/config#code-examples). 

```
class ConfigWrapper:
    """
    Encapsulates AWS Config functions.
    """

    def __init__(self, config_client):
        """
        :param config_client: A Boto3 AWS Config client.
        """
        self.config_client = config_client


    def delete_config_rule(self, rule_name):
        """
        Delete the specified rule.

        :param rule_name: The name of the rule to delete.
        """
        try:
            self.config_client.delete_config_rule(ConfigRuleName=rule_name)
            logger.info("Deleted rule %s.", rule_name)
        except ClientError:
            logger.exception("Couldn't delete rule %s.", rule_name)
            raise
```
+  Untuk detail API, lihat [DeleteConfigRule](https://docs.aws.amazon.com/goto/boto3/config-2014-11-12/DeleteConfigRule)di *AWS SDK for Python (Boto3) Referensi* API. 

------
#### [ SAP ABAP ]

**SDK for SAP ABAP**  
 Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara mengatur dan menjalankannya di [Repositori Contoh Kode AWS](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/sap-abap/services/cfs#code-examples). 

```
    lo_cfs->deleteconfigrule( iv_rule_name ).
    MESSAGE 'Deleted AWS Config rule.' TYPE 'I'.
```
+  Untuk detail API, lihat [DeleteConfigRule](https://docs.aws.amazon.com/sdk-for-sap-abap/v1/api/latest/index.html)di *AWS SDK untuk referensi SAP ABAP* API. 

------

# Gunakan `DescribeComplianceByConfigRule` dengan CLI
<a name="config-service_example_config-service_DescribeComplianceByConfigRule_section"></a>

Contoh kode berikut menunjukkan cara menggunakan`DescribeComplianceByConfigRule`.

------
#### [ CLI ]

**AWS CLI**  
**Untuk mendapatkan informasi kepatuhan untuk aturan AWS Config**  
Perintah berikut menampilkan informasi kepatuhan untuk setiap aturan AWS Config yang dilanggar oleh satu atau beberapa sumber daya: AWS   

```
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 *Referensi AWS CLI Perintah*. 

------
#### [ PowerShell ]

**Alat untuk PowerShell V4**  
**Contoh 1: Contoh ini mengambil rincian kepatuhan untuk aturan ebs-optimized-instance, yang tidak ada hasil evaluasi saat ini untuk aturan, sehingga mengembalikan INSUFFICIENT\$1DATA**  

```
(Get-CFGComplianceByConfigRule -ConfigRuleName ebs-optimized-instance).Compliance
```
**Output:**  

```
ComplianceContributorCount ComplianceType
-------------------------- --------------
                           INSUFFICIENT_DATA
```
**Contoh 2: Contoh ini mengembalikan jumlah sumber daya yang tidak sesuai untuk aturan ALB\$1HTTP\$1TO\$1HTTPS\$1REDIRECTION\$1CHECK.**  

```
(Get-CFGComplianceByConfigRule -ConfigRuleName ALB_HTTP_TO_HTTPS_REDIRECTION_CHECK -ComplianceType NON_COMPLIANT).Compliance.ComplianceContributorCount
```
**Output:**  

```
CapExceeded CappedCount
----------- -----------
False       2
```
+  Untuk detail API, lihat [DescribeComplianceByConfigRule](https://docs.aws.amazon.com/powershell/v4/reference)di *Referensi Alat AWS untuk PowerShell Cmdlet (V4)*. 

**Alat untuk PowerShell V5**  
**Contoh 1: Contoh ini mengambil rincian kepatuhan untuk aturan ebs-optimized-instance, yang tidak ada hasil evaluasi saat ini untuk aturan, sehingga mengembalikan INSUFFICIENT\$1DATA**  

```
(Get-CFGComplianceByConfigRule -ConfigRuleName ebs-optimized-instance).Compliance
```
**Output:**  

```
ComplianceContributorCount ComplianceType
-------------------------- --------------
                           INSUFFICIENT_DATA
```
**Contoh 2: Contoh ini mengembalikan jumlah sumber daya yang tidak sesuai untuk aturan ALB\$1HTTP\$1TO\$1HTTPS\$1REDIRECTION\$1CHECK.**  

```
(Get-CFGComplianceByConfigRule -ConfigRuleName ALB_HTTP_TO_HTTPS_REDIRECTION_CHECK -ComplianceType NON_COMPLIANT).Compliance.ComplianceContributorCount
```
**Output:**  

```
CapExceeded CappedCount
----------- -----------
False       2
```
+  Untuk detail API, lihat [DescribeComplianceByConfigRule](https://docs.aws.amazon.com/powershell/v5/reference)di *Referensi Alat AWS untuk PowerShell Cmdlet (V5)*. 

------

# Gunakan `DescribeComplianceByResource` dengan CLI
<a name="config-service_example_config-service_DescribeComplianceByResource_section"></a>

Contoh kode berikut menunjukkan cara menggunakan`DescribeComplianceByResource`.

------
#### [ CLI ]

**AWS CLI**  
**Untuk mendapatkan informasi kepatuhan untuk AWS sumber daya Anda**  
Perintah berikut mengembalikan informasi kepatuhan untuk setiap instans EC2 yang direkam oleh AWS Config dan yang melanggar satu atau beberapa 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 *Referensi AWS CLI Perintah*. 

------
#### [ PowerShell ]

**Alat untuk PowerShell V4**  
**Contoh 1: Contoh ini memeriksa jenis `AWS::SSM::ManagedInstanceInventory` sumber daya untuk jenis kepatuhan 'COMPLIANT'.**  

```
Get-CFGComplianceByResource -ComplianceType COMPLIANT -ResourceType AWS::SSM::ManagedInstanceInventory
```
**Output:**  

```
Compliance                            ResourceId          ResourceType
----------                            ----------          ------------
Amazon.ConfigService.Model.Compliance i-0123bcf4b567890e3 AWS::SSM::ManagedInstanceInventory
Amazon.ConfigService.Model.Compliance i-0a1234f6f5d6b78f7 AWS::SSM::ManagedInstanceInventory
```
+  Untuk detail API, lihat [DescribeComplianceByResource](https://docs.aws.amazon.com/powershell/v4/reference)di *Referensi Alat AWS untuk PowerShell Cmdlet (V4)*. 

**Alat untuk PowerShell V5**  
**Contoh 1: Contoh ini memeriksa jenis `AWS::SSM::ManagedInstanceInventory` sumber daya untuk jenis kepatuhan 'COMPLIANT'.**  

```
Get-CFGComplianceByResource -ComplianceType COMPLIANT -ResourceType AWS::SSM::ManagedInstanceInventory
```
**Output:**  

```
Compliance                            ResourceId          ResourceType
----------                            ----------          ------------
Amazon.ConfigService.Model.Compliance i-0123bcf4b567890e3 AWS::SSM::ManagedInstanceInventory
Amazon.ConfigService.Model.Compliance i-0a1234f6f5d6b78f7 AWS::SSM::ManagedInstanceInventory
```
+  Untuk detail API, lihat [DescribeComplianceByResource](https://docs.aws.amazon.com/powershell/v5/reference)di *Referensi Alat AWS untuk PowerShell Cmdlet (V5)*. 

------

# Gunakan `DescribeConfigRuleEvaluationStatus` dengan CLI
<a name="config-service_example_config-service_DescribeConfigRuleEvaluationStatus_section"></a>

Contoh kode berikut menunjukkan cara menggunakan`DescribeConfigRuleEvaluationStatus`.

------
#### [ CLI ]

**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 *Referensi AWS CLI Perintah*. 

------
#### [ PowerShell ]

**Alat untuk PowerShell V4**  
**Contoh 1: Contoh ini mengembalikan informasi status untuk aturan konfigurasi yang diberikan.**  

```
Get-CFGConfigRuleEvaluationStatus -ConfigRuleName root-account-mfa-enabled, vpc-flow-logs-enabled
```
**Output:**  

```
ConfigRuleArn                : arn:aws:config:eu-west-1:123456789012:config-rule/config-rule-kvq1wk
ConfigRuleId                 : config-rule-kvq1wk
ConfigRuleName               : root-account-mfa-enabled
FirstActivatedTime           : 8/27/2019 8:05:17 AM
FirstEvaluationStarted       : True
LastErrorCode                :
LastErrorMessage             :
LastFailedEvaluationTime     : 1/1/0001 12:00:00 AM
LastFailedInvocationTime     : 1/1/0001 12:00:00 AM
LastSuccessfulEvaluationTime : 12/13/2019 8:12:03 AM
LastSuccessfulInvocationTime : 12/13/2019 8:12:03 AM

ConfigRuleArn                : arn:aws:config:eu-west-1:123456789012:config-rule/config-rule-z1s23b
ConfigRuleId                 : config-rule-z1s23b
ConfigRuleName               : vpc-flow-logs-enabled
FirstActivatedTime           : 8/14/2019 6:23:44 AM
FirstEvaluationStarted       : True
LastErrorCode                :
LastErrorMessage             :
LastFailedEvaluationTime     : 1/1/0001 12:00:00 AM
LastFailedInvocationTime     : 1/1/0001 12:00:00 AM
LastSuccessfulEvaluationTime : 12/13/2019 7:12:01 AM
LastSuccessfulInvocationTime : 12/13/2019 7:12:01 AM
```
+  Untuk detail API, lihat [DescribeConfigRuleEvaluationStatus](https://docs.aws.amazon.com/powershell/v4/reference)di *Referensi Alat AWS untuk PowerShell Cmdlet (V4)*. 

**Alat untuk PowerShell V5**  
**Contoh 1: Contoh ini mengembalikan informasi status untuk aturan konfigurasi yang diberikan.**  

```
Get-CFGConfigRuleEvaluationStatus -ConfigRuleName root-account-mfa-enabled, vpc-flow-logs-enabled
```
**Output:**  

```
ConfigRuleArn                : arn:aws:config:eu-west-1:123456789012:config-rule/config-rule-kvq1wk
ConfigRuleId                 : config-rule-kvq1wk
ConfigRuleName               : root-account-mfa-enabled
FirstActivatedTime           : 8/27/2019 8:05:17 AM
FirstEvaluationStarted       : True
LastErrorCode                :
LastErrorMessage             :
LastFailedEvaluationTime     : 1/1/0001 12:00:00 AM
LastFailedInvocationTime     : 1/1/0001 12:00:00 AM
LastSuccessfulEvaluationTime : 12/13/2019 8:12:03 AM
LastSuccessfulInvocationTime : 12/13/2019 8:12:03 AM

ConfigRuleArn                : arn:aws:config:eu-west-1:123456789012:config-rule/config-rule-z1s23b
ConfigRuleId                 : config-rule-z1s23b
ConfigRuleName               : vpc-flow-logs-enabled
FirstActivatedTime           : 8/14/2019 6:23:44 AM
FirstEvaluationStarted       : True
LastErrorCode                :
LastErrorMessage             :
LastFailedEvaluationTime     : 1/1/0001 12:00:00 AM
LastFailedInvocationTime     : 1/1/0001 12:00:00 AM
LastSuccessfulEvaluationTime : 12/13/2019 7:12:01 AM
LastSuccessfulInvocationTime : 12/13/2019 7:12:01 AM
```
+  Untuk detail API, lihat [DescribeConfigRuleEvaluationStatus](https://docs.aws.amazon.com/powershell/v5/reference)di *Referensi Alat AWS untuk PowerShell Cmdlet (V5)*. 

------

# Gunakan `DescribeConfigRules` dengan AWS SDK atau CLI
<a name="config-service_example_config-service_DescribeConfigRules_section"></a>

Contoh kode berikut menunjukkan cara menggunakan`DescribeConfigRules`.

------
#### [ CLI ]

**AWS CLI**  
**Untuk mendapatkan detail tentang aturan AWS Config**  
Perintah berikut mengembalikan rincian 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 *Referensi AWS CLI Perintah*. 

------
#### [ PowerShell ]

**Alat untuk PowerShell V4**  
**Contoh 1: Contoh ini mencantumkan aturan konfigurasi untuk akun, dengan properti yang dipilih.**  

```
Get-CFGConfigRule | Select-Object ConfigRuleName, ConfigRuleId, ConfigRuleArn, ConfigRuleState
```
**Output:**  

```
ConfigRuleName                                    ConfigRuleId       ConfigRuleArn                                                        ConfigRuleState
--------------                                    ------------       -------------                                                        ---------------
ALB_REDIRECTION_CHECK                             config-rule-12iyn3 arn:aws:config-service:eu-west-1:123456789012:config-rule/config-rule-12iyn3 ACTIVE
access-keys-rotated                               config-rule-aospfr arn:aws:config-service:eu-west-1:123456789012:config-rule/config-rule-aospfr ACTIVE
autoscaling-group-elb-healthcheck-required        config-rule-cn1f2x arn:aws:config-service:eu-west-1:123456789012:config-rule/config-rule-cn1f2x ACTIVE
```
+  Untuk detail API, lihat [DescribeConfigRules](https://docs.aws.amazon.com/powershell/v4/reference)di *Referensi Alat AWS untuk PowerShell Cmdlet (V4)*. 

**Alat untuk PowerShell V5**  
**Contoh 1: Contoh ini mencantumkan aturan konfigurasi untuk akun, dengan properti yang dipilih.**  

```
Get-CFGConfigRule | Select-Object ConfigRuleName, ConfigRuleId, ConfigRuleArn, ConfigRuleState
```
**Output:**  

```
ConfigRuleName                                    ConfigRuleId       ConfigRuleArn                                                        ConfigRuleState
--------------                                    ------------       -------------                                                        ---------------
ALB_REDIRECTION_CHECK                             config-rule-12iyn3 arn:aws:config-service:eu-west-1:123456789012:config-rule/config-rule-12iyn3 ACTIVE
access-keys-rotated                               config-rule-aospfr arn:aws:config-service:eu-west-1:123456789012:config-rule/config-rule-aospfr ACTIVE
autoscaling-group-elb-healthcheck-required        config-rule-cn1f2x arn:aws:config-service:eu-west-1:123456789012:config-rule/config-rule-cn1f2x ACTIVE
```
+  Untuk detail API, lihat [DescribeConfigRules](https://docs.aws.amazon.com/powershell/v5/reference)di *Referensi Alat AWS untuk PowerShell Cmdlet (V5)*. 

------
#### [ Python ]

**SDK untuk Python (Boto3)**  
 Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara mengatur dan menjalankannya di [Repositori Contoh Kode AWS](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/python/example_code/config#code-examples). 

```
class ConfigWrapper:
    """
    Encapsulates AWS Config functions.
    """

    def __init__(self, config_client):
        """
        :param config_client: A Boto3 AWS Config client.
        """
        self.config_client = config_client


    def describe_config_rule(self, rule_name):
        """
        Gets data for the specified rule.

        :param rule_name: The name of the rule to retrieve.
        :return: The rule data.
        """
        try:
            response = self.config_client.describe_config_rules(
                ConfigRuleNames=[rule_name]
            )
            rule = response["ConfigRules"]
            logger.info("Got data for rule %s.", rule_name)
        except ClientError:
            logger.exception("Couldn't get data for rule %s.", rule_name)
            raise
        else:
            return rule
```
+  Untuk detail API, lihat [DescribeConfigRules](https://docs.aws.amazon.com/goto/boto3/config-2014-11-12/DescribeConfigRules)di *AWS SDK for Python (Boto3) Referensi* API. 

------
#### [ SAP ABAP ]

**SDK for SAP ABAP**  
 Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara mengatur dan menjalankannya di [Repositori Contoh Kode AWS](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/sap-abap/services/cfs#code-examples). 

```
    DATA(lo_result) = lo_cfs->describeconfigrules(
      it_configrulenames = VALUE /aws1/cl_cfsconfigrulenames_w=>tt_configrulenames(
        ( NEW /aws1/cl_cfsconfigrulenames_w( iv_rule_name ) )
      )
    ).
    ot_cfg_rules = lo_result->get_configrules( ).
    MESSAGE 'Retrieved AWS Config rule data.' TYPE 'I'.
```
+  Untuk detail API, lihat [DescribeConfigRules](https://docs.aws.amazon.com/sdk-for-sap-abap/v1/api/latest/index.html)di *AWS SDK untuk referensi SAP ABAP* API. 

------

# Gunakan `DescribeConfigurationRecorderStatus` dengan CLI
<a name="config-service_example_config-service_DescribeConfigurationRecorderStatus_section"></a>

Contoh kode berikut menunjukkan cara menggunakan`DescribeConfigurationRecorderStatus`.

------
#### [ CLI ]

**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 *Referensi AWS CLI Perintah*. 

------
#### [ PowerShell ]

**Alat untuk PowerShell V4**  
**Contoh 1: Sampel ini mengembalikan status perekam konfigurasi.**  

```
Get-CFGConfigurationRecorderStatus
```
**Output:**  

```
LastErrorCode        :
LastErrorMessage     :
LastStartTime        : 10/11/2019 10:13:51 AM
LastStatus           : Success
LastStatusChangeTime : 12/31/2019 6:14:12 AM
LastStopTime         : 10/11/2019 10:13:46 AM
Name                 : default
Recording            : True
```
+  Untuk detail API, lihat [DescribeConfigurationRecorderStatus](https://docs.aws.amazon.com/powershell/v4/reference)di *Referensi Alat AWS untuk PowerShell Cmdlet (V4)*. 

**Alat untuk PowerShell V5**  
**Contoh 1: Sampel ini mengembalikan status perekam konfigurasi.**  

```
Get-CFGConfigurationRecorderStatus
```
**Output:**  

```
LastErrorCode        :
LastErrorMessage     :
LastStartTime        : 10/11/2019 10:13:51 AM
LastStatus           : Success
LastStatusChangeTime : 12/31/2019 6:14:12 AM
LastStopTime         : 10/11/2019 10:13:46 AM
Name                 : default
Recording            : True
```
+  Untuk detail API, lihat [DescribeConfigurationRecorderStatus](https://docs.aws.amazon.com/powershell/v5/reference)di *Referensi Alat AWS untuk PowerShell Cmdlet (V5)*. 

------

# Gunakan `DescribeConfigurationRecorders` dengan CLI
<a name="config-service_example_config-service_DescribeConfigurationRecorders_section"></a>

Contoh kode berikut menunjukkan cara menggunakan`DescribeConfigurationRecorders`.

------
#### [ CLI ]

**AWS CLI**  
**Untuk mendapatkan detail tentang perekam konfigurasi**  
Perintah berikut mengembalikan rincian 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 *Referensi AWS CLI Perintah*. 

------
#### [ PowerShell ]

**Alat untuk PowerShell V4**  
**Contoh 1: Contoh ini mengembalikan rincian perekam konfigurasi.**  

```
Get-CFGConfigurationRecorder | Format-List
```
**Output:**  

```
Name           : default
RecordingGroup : Amazon.ConfigService.Model.RecordingGroup
RoleARN        : arn:aws:iam::123456789012:role/aws-service-role/config.amazonaws.com/AWSServiceRoleForConfig
```
+  Untuk detail API, lihat [DescribeConfigurationRecorders](https://docs.aws.amazon.com/powershell/v4/reference)di *Referensi Alat AWS untuk PowerShell Cmdlet (V4)*. 

**Alat untuk PowerShell V5**  
**Contoh 1: Contoh ini mengembalikan rincian perekam konfigurasi.**  

```
Get-CFGConfigurationRecorder | Format-List
```
**Output:**  

```
Name           : default
RecordingGroup : Amazon.ConfigService.Model.RecordingGroup
RoleARN        : arn:aws:iam::123456789012:role/aws-service-role/config.amazonaws.com/AWSServiceRoleForConfig
```
+  Untuk detail API, lihat [DescribeConfigurationRecorders](https://docs.aws.amazon.com/powershell/v5/reference)di *Referensi Alat AWS untuk PowerShell Cmdlet (V5)*. 

------

# Gunakan `DescribeDeliveryChannels` dengan CLI
<a name="config-service_example_config-service_DescribeDeliveryChannels_section"></a>

Contoh kode berikut menunjukkan cara menggunakan`DescribeDeliveryChannels`.

------
#### [ CLI ]

**AWS CLI**  
**Untuk mendapatkan detail tentang saluran pengiriman**  
Perintah berikut mengembalikan rincian 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 *Referensi AWS CLI Perintah*. 

------
#### [ PowerShell ]

**Alat untuk PowerShell V4**  
**Contoh 1: Contoh ini mengambil saluran pengiriman untuk wilayah tersebut dan menampilkan detailnya.**  

```
Get-CFGDeliveryChannel -Region eu-west-1 | Select-Object Name, S3BucketName, S3KeyPrefix, @{N="DeliveryFrequency";E={$_.ConfigSnapshotDeliveryProperties.DeliveryFrequency}}
```
**Output:**  

```
Name    S3BucketName               S3KeyPrefix DeliveryFrequency
----    ------------               ----------- -----------------
default config-bucket-NA my          TwentyFour_Hours
```
+  Untuk detail API, lihat [DescribeDeliveryChannels](https://docs.aws.amazon.com/powershell/v4/reference)di *Referensi Alat AWS untuk PowerShell Cmdlet (V4)*. 

**Alat untuk PowerShell V5**  
**Contoh 1: Contoh ini mengambil saluran pengiriman untuk wilayah tersebut dan menampilkan detailnya.**  

```
Get-CFGDeliveryChannel -Region eu-west-1 | Select-Object Name, S3BucketName, S3KeyPrefix, @{N="DeliveryFrequency";E={$_.ConfigSnapshotDeliveryProperties.DeliveryFrequency}}
```
**Output:**  

```
Name    S3BucketName               S3KeyPrefix DeliveryFrequency
----    ------------               ----------- -----------------
default config-bucket-NA my          TwentyFour_Hours
```
+  Untuk detail API, lihat [DescribeDeliveryChannels](https://docs.aws.amazon.com/powershell/v5/reference)di *Referensi Alat AWS untuk PowerShell Cmdlet (V5)*. 

------

# Gunakan `GetComplianceDetailsByConfigRule` dengan CLI
<a name="config-service_example_config-service_GetComplianceDetailsByConfigRule_section"></a>

Contoh kode berikut menunjukkan cara menggunakan`GetComplianceDetailsByConfigRule`.

------
#### [ CLI ]

**AWS CLI**  
**Untuk mendapatkan hasil evaluasi untuk aturan AWS Config**  
Perintah berikut mengembalikan hasil evaluasi untuk semua sumber daya yang tidak sesuai dengan 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 *Referensi AWS CLI Perintah*. 

------
#### [ PowerShell ]

**Alat untuk PowerShell V4**  
**Contoh 1: Contoh ini memperoleh hasil evaluasi untuk aturan access-keys-rotated dan mengembalikan output yang dikelompokkan berdasarkan tipe kepatuhan**  

```
Get-CFGComplianceDetailsByConfigRule -ConfigRuleName access-keys-rotated | Group-Object ComplianceType
```
**Output:**  

```
Count Name                      Group
----- ----                      -----
    2 COMPLIANT                 {Amazon.ConfigService.Model.EvaluationResult, Amazon.ConfigService.Model.EvaluationResult}
    5 NON_COMPLIANT             {Amazon.ConfigService.Model.EvaluationResult, Amazon.ConfigService.Model.EvaluationResult, Amazon.ConfigService.Model.EvaluationRes...
```
**Contoh 2: Contoh ini menanyakan detail kepatuhan access-keys-rotated untuk aturan sumber daya COMPLIANT.**  

```
Get-CFGComplianceDetailsByConfigRule -ConfigRuleName access-keys-rotated -ComplianceType COMPLIANT | ForEach-Object {$_.EvaluationResultIdentifier.EvaluationResultQualifier}
```
**Output:**  

```
ConfigRuleName      ResourceId            ResourceType
--------------      ----------            ------------
access-keys-rotated BCAB1CDJ2LITAPVEW3JAH AWS::IAM::User
access-keys-rotated BCAB1CDJ2LITL3EHREM4Q AWS::IAM::User
```
+  Untuk detail API, lihat [GetComplianceDetailsByConfigRule](https://docs.aws.amazon.com/powershell/v4/reference)di *Referensi Alat AWS untuk PowerShell Cmdlet (V4)*. 

**Alat untuk PowerShell V5**  
**Contoh 1: Contoh ini memperoleh hasil evaluasi untuk aturan access-keys-rotated dan mengembalikan output yang dikelompokkan berdasarkan tipe kepatuhan**  

```
Get-CFGComplianceDetailsByConfigRule -ConfigRuleName access-keys-rotated | Group-Object ComplianceType
```
**Output:**  

```
Count Name                      Group
----- ----                      -----
    2 COMPLIANT                 {Amazon.ConfigService.Model.EvaluationResult, Amazon.ConfigService.Model.EvaluationResult}
    5 NON_COMPLIANT             {Amazon.ConfigService.Model.EvaluationResult, Amazon.ConfigService.Model.EvaluationResult, Amazon.ConfigService.Model.EvaluationRes...
```
**Contoh 2: Contoh ini menanyakan detail kepatuhan access-keys-rotated untuk aturan sumber daya COMPLIANT.**  

```
Get-CFGComplianceDetailsByConfigRule -ConfigRuleName access-keys-rotated -ComplianceType COMPLIANT | ForEach-Object {$_.EvaluationResultIdentifier.EvaluationResultQualifier}
```
**Output:**  

```
ConfigRuleName      ResourceId            ResourceType
--------------      ----------            ------------
access-keys-rotated BCAB1CDJ2LITAPVEW3JAH AWS::IAM::User
access-keys-rotated BCAB1CDJ2LITL3EHREM4Q AWS::IAM::User
```
+  Untuk detail API, lihat [GetComplianceDetailsByConfigRule](https://docs.aws.amazon.com/powershell/v5/reference)di *Referensi Alat AWS untuk PowerShell Cmdlet (V5)*. 

------

# Gunakan `GetComplianceDetailsByResource` dengan CLI
<a name="config-service_example_config-service_GetComplianceDetailsByResource_section"></a>

Contoh kode berikut menunjukkan cara menggunakan`GetComplianceDetailsByResource`.

------
#### [ CLI ]

**AWS CLI**  
**Untuk mendapatkan hasil evaluasi untuk sumber AWS daya**  
Perintah berikut mengembalikan hasil evaluasi untuk setiap aturan yang `i-1a2b3c4d` tidak dipatuhi oleh instans 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 *Referensi AWS CLI Perintah*. 

------
#### [ PowerShell ]

**Alat untuk PowerShell V4**  
**Contoh 1: Contoh evaulasi ini menghasilkan sumber daya yang diberikan.**  

```
Get-CFGComplianceDetailsByResource -ResourceId ABCD5STJ4EFGHIVEW6JAH -ResourceType 'AWS::IAM::User'
```
**Output:**  

```
Annotation                 :
ComplianceType             : COMPLIANT
ConfigRuleInvokedTime      : 8/25/2019 11:34:56 PM
EvaluationResultIdentifier : Amazon.ConfigService.Model.EvaluationResultIdentifier
ResultRecordedTime         : 8/25/2019 11:34:56 PM
ResultToken                :
```
+  Untuk detail API, lihat [GetComplianceDetailsByResource](https://docs.aws.amazon.com/powershell/v4/reference)di *Referensi Alat AWS untuk PowerShell Cmdlet (V4)*. 

**Alat untuk PowerShell V5**  
**Contoh 1: Contoh evaulasi ini menghasilkan sumber daya yang diberikan.**  

```
Get-CFGComplianceDetailsByResource -ResourceId ABCD5STJ4EFGHIVEW6JAH -ResourceType 'AWS::IAM::User'
```
**Output:**  

```
Annotation                 :
ComplianceType             : COMPLIANT
ConfigRuleInvokedTime      : 8/25/2019 11:34:56 PM
EvaluationResultIdentifier : Amazon.ConfigService.Model.EvaluationResultIdentifier
ResultRecordedTime         : 8/25/2019 11:34:56 PM
ResultToken                :
```
+  Untuk detail API, lihat [GetComplianceDetailsByResource](https://docs.aws.amazon.com/powershell/v5/reference)di *Referensi Alat AWS untuk PowerShell Cmdlet (V5)*. 

------

# Gunakan `GetComplianceSummaryByConfigRule` dengan CLI
<a name="config-service_example_config-service_GetComplianceSummaryByConfigRule_section"></a>

Contoh kode berikut menunjukkan cara menggunakan`GetComplianceSummaryByConfigRule`.

------
#### [ CLI ]

**AWS CLI**  
**Untuk mendapatkan ringkasan kepatuhan untuk aturan AWS Config**  
Perintah berikut mengembalikan jumlah aturan yang sesuai dan nomor 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 *Referensi AWS CLI Perintah*. 

------
#### [ PowerShell ]

**Alat untuk PowerShell V4**  
**Contoh 1: Contoh ini mengembalikan jumlah aturan Config yang tidak sesuai.**  

```
Get-CFGComplianceSummaryByConfigRule -Select ComplianceSummary.NonCompliantResourceCount
```
**Output:**  

```
CapExceeded CappedCount
----------- -----------
False       9
```
+  Untuk detail API, lihat [GetComplianceSummaryByConfigRule](https://docs.aws.amazon.com/powershell/v4/reference)di *Referensi Alat AWS untuk PowerShell Cmdlet (V4)*. 

**Alat untuk PowerShell V5**  
**Contoh 1: Contoh ini mengembalikan jumlah aturan Config yang tidak sesuai.**  

```
Get-CFGComplianceSummaryByConfigRule -Select ComplianceSummary.NonCompliantResourceCount
```
**Output:**  

```
CapExceeded CappedCount
----------- -----------
False       9
```
+  Untuk detail API, lihat [GetComplianceSummaryByConfigRule](https://docs.aws.amazon.com/powershell/v5/reference)di *Referensi Alat AWS untuk PowerShell Cmdlet (V5)*. 

------

# Gunakan `GetComplianceSummaryByResourceType` dengan CLI
<a name="config-service_example_config-service_GetComplianceSummaryByResourceType_section"></a>

Contoh kode berikut menunjukkan cara menggunakan`GetComplianceSummaryByResourceType`.

------
#### [ CLI ]

**AWS CLI**  
**Untuk mendapatkan ringkasan kepatuhan untuk semua jenis sumber daya**  
Perintah berikut mengembalikan jumlah AWS sumber daya yang tidak sesuai dan nomor 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 nomor 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 *Referensi AWS CLI Perintah*. 

------
#### [ PowerShell ]

**Alat untuk PowerShell V4**  
**Contoh 1: Sampel ini mengembalikan jumlah sumber daya yang sesuai atau tidak sesuai dan mengubah output menjadi json.**  

```
Get-CFGComplianceSummaryByResourceType -Select ComplianceSummariesByResourceType.ComplianceSummary | ConvertTo-Json
{
  "ComplianceSummaryTimestamp": "2019-12-14T06:14:49.778Z",
  "CompliantResourceCount": {
    "CapExceeded": false,
    "CappedCount": 2
  },
  "NonCompliantResourceCount": {
    "CapExceeded": true,
    "CappedCount": 100
  }
}
```
+  Untuk detail API, lihat [GetComplianceSummaryByResourceType](https://docs.aws.amazon.com/powershell/v4/reference)di *Referensi Alat AWS untuk PowerShell Cmdlet (V4)*. 

**Alat untuk PowerShell V5**  
**Contoh 1: Sampel ini mengembalikan jumlah sumber daya yang sesuai atau tidak sesuai dan mengubah output menjadi json.**  

```
Get-CFGComplianceSummaryByResourceType -Select ComplianceSummariesByResourceType.ComplianceSummary | ConvertTo-Json
{
  "ComplianceSummaryTimestamp": "2019-12-14T06:14:49.778Z",
  "CompliantResourceCount": {
    "CapExceeded": false,
    "CappedCount": 2
  },
  "NonCompliantResourceCount": {
    "CapExceeded": true,
    "CappedCount": 100
  }
}
```
+  Untuk detail API, lihat [GetComplianceSummaryByResourceType](https://docs.aws.amazon.com/powershell/v5/reference)di *Referensi Alat AWS untuk PowerShell Cmdlet (V5)*. 

------

# Gunakan `PutConfigRule` dengan AWS SDK atau CLI
<a name="config-service_example_config-service_PutConfigRule_section"></a>

Contoh kode berikut menunjukkan cara menggunakan`PutConfigRule`.

------
#### [ CLI ]

**AWS CLI**  
**Untuk menambahkan aturan Config AWS terkelola**  
Perintah berikut menyediakan kode JSON untuk menambahkan aturan Config AWS terkelola:  

```
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 cakupan sumber daya `AWS::EC2::Instance` tipe, jadi AWS Config hanya akan mengevaluasi instans EC2 terhadap aturan. Karena aturan adalah aturan terkelola, `Owner` atribut diatur ke`AWS`, dan `SourceIdentifier` atribut diatur ke pengidentifikasi aturan,`REQUIRED_TAGS`. Untuk `InputParameters` atribut, kunci tag yang dibutuhkan aturan, `CostCenter` dan`Owner`, ditentukan.  
Jika perintah berhasil, AWS Config tidak mengembalikan output. Untuk memverifikasi konfigurasi aturan, jalankan describe-config-rules perintah, dan tentukan nama aturan.  
**Untuk menambahkan aturan Config terkelola pelanggan**  
Perintah berikut menyediakan kode JSON untuk menambahkan aturan Config terkelola 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 cakupan sumber daya `AWS::EC2::Instance` tipe, jadi AWS Config hanya akan mengevaluasi instans EC2 terhadap aturan. Karena aturan ini adalah aturan yang dikelola pelanggan, `Owner` atribut disetel ke`CUSTOM_LAMBDA`, dan `SourceIdentifier` atribut disetel ke ARN dari fungsi Lambda AWS . `SourceDetails`Objek diperlukan. Parameter yang ditentukan untuk `InputParameters` atribut diteruskan ke fungsi AWS Lambda saat AWS Config memanggilnya untuk mengevaluasi sumber daya terhadap aturan.  
Jika perintah berhasil, AWS Config tidak mengembalikan output. Untuk memverifikasi konfigurasi aturan, jalankan describe-config-rules perintah, dan tentukan nama aturan.  
+  Untuk detail API, lihat [PutConfigRule](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/configservice/put-config-rule.html)di *Referensi AWS CLI Perintah*. 

------
#### [ Python ]

**SDK untuk Python (Boto3)**  
 Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara mengatur dan menjalankannya di [Repositori Contoh Kode AWS](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/python/example_code/config#code-examples). 

```
class ConfigWrapper:
    """
    Encapsulates AWS Config functions.
    """

    def __init__(self, config_client):
        """
        :param config_client: A Boto3 AWS Config client.
        """
        self.config_client = config_client


    def put_config_rule(self, rule_name):
        """
        Sets a configuration rule that prohibits making Amazon S3 buckets publicly
        readable.

        :param rule_name: The name to give the rule.
        """
        try:
            self.config_client.put_config_rule(
                ConfigRule={
                    "ConfigRuleName": rule_name,
                    "Description": "S3 Public Read Prohibited Bucket Rule",
                    "Scope": {
                        "ComplianceResourceTypes": [
                            "AWS::S3::Bucket",
                        ],
                    },
                    "Source": {
                        "Owner": "AWS",
                        "SourceIdentifier": "S3_BUCKET_PUBLIC_READ_PROHIBITED",
                    },
                    "InputParameters": "{}",
                    "ConfigRuleState": "ACTIVE",
                }
            )
            logger.info("Created configuration rule %s.", rule_name)
        except ClientError:
            logger.exception("Couldn't create configuration rule %s.", rule_name)
            raise
```
+  Untuk detail API, lihat [PutConfigRule](https://docs.aws.amazon.com/goto/boto3/config-2014-11-12/PutConfigRule)di *AWS SDK for Python (Boto3) Referensi* API. 

------
#### [ SAP ABAP ]

**SDK for SAP ABAP**  
 Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara mengatur dan menjalankannya di [Repositori Contoh Kode AWS](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/sap-abap/services/cfs#code-examples). 

```
    " Create a config rule for S3 bucket public read prohibition
    lo_cfs->putconfigrule(
      io_configrule = NEW /aws1/cl_cfsconfigrule(
        iv_configrulename = iv_rule_name
        iv_description = |S3 Public Read Prohibited Bucket Rule|
        io_scope = NEW /aws1/cl_cfsscope(
          it_complianceresourcetypes = VALUE /aws1/cl_cfscplncresrctypes_w=>tt_complianceresourcetypes(
            ( NEW /aws1/cl_cfscplncresrctypes_w( |AWS::S3::Bucket| ) )
          )
        )
        io_source = NEW /aws1/cl_cfssource(
          iv_owner = |AWS|
          iv_sourceidentifier = |S3_BUCKET_PUBLIC_READ_PROHIBITED|
        )
        iv_inputparameters = '{}'
        iv_configrulestate = |ACTIVE|
      )
    ).
    MESSAGE 'Created AWS Config rule.' TYPE 'I'.
```
+  Untuk detail API, lihat [PutConfigRule](https://docs.aws.amazon.com/sdk-for-sap-abap/v1/api/latest/index.html)di *AWS SDK untuk referensi SAP ABAP* API. 

------

# Gunakan `PutDeliveryChannel` dengan CLI
<a name="config-service_example_config-service_PutDeliveryChannel_section"></a>

Contoh kode berikut menunjukkan cara menggunakan`PutDeliveryChannel`.

------
#### [ CLI ]

**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 untuk mengubah nama, lihat Mengganti nama Saluran Pengiriman. `s3BucketName` - Nama bucket Amazon S3 tempat AWS Config memberikan snapshot konfigurasi dan file riwayat konfigurasi. Jika Anda menentukan bucket milik AWS akun lain, bucket tersebut harus memiliki kebijakan yang memberikan izin akses ke Config. AWS Untuk informasi selengkapnya, lihat Izin untuk Bucket Amazon S3.  
`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 tersebut harus memiliki kebijakan yang memberikan izin akses ke Config. AWS Untuk informasi selengkapnya, lihat Izin untuk Topik Amazon SNS.  
`configSnapshotDeliveryProperties`- Berisi `deliveryFrequency` atribut, yang menetapkan seberapa sering AWS Config memberikan snapshot konfigurasi dan seberapa sering ia memanggil evaluasi untuk aturan Config periodik.  
Jika perintah berhasil, AWS Config tidak mengembalikan output. Untuk memverifikasi pengaturan saluran pengiriman Anda, jalankan describe-delivery-channels perintah.  
+  Untuk detail API, lihat [PutDeliveryChannel](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/configservice/put-delivery-channel.html)di *Referensi AWS CLI Perintah*. 

------
#### [ PowerShell ]

**Alat untuk PowerShell V4**  
**Contoh 1: Contoh ini mengubah properti DeliveryFrequency dari saluran pengiriman yang ada.**  

```
Write-CFGDeliveryChannel -ConfigSnapshotDeliveryProperties_DeliveryFrequency TwentyFour_Hours -DeliveryChannelName default -DeliveryChannel_S3BucketName amzn-s3-demo-bucket -DeliveryChannel_S3KeyPrefix my
```
+  Untuk detail API, lihat [PutDeliveryChannel](https://docs.aws.amazon.com/powershell/v4/reference)di *Referensi Alat AWS untuk PowerShell Cmdlet (V4)*. 

**Alat untuk PowerShell V5**  
**Contoh 1: Contoh ini mengubah properti DeliveryFrequency dari saluran pengiriman yang ada.**  

```
Write-CFGDeliveryChannel -ConfigSnapshotDeliveryProperties_DeliveryFrequency TwentyFour_Hours -DeliveryChannelName default -DeliveryChannel_S3BucketName amzn-s3-demo-bucket -DeliveryChannel_S3KeyPrefix my
```
+  Untuk detail API, lihat [PutDeliveryChannel](https://docs.aws.amazon.com/powershell/v5/reference)di *Referensi Alat AWS untuk PowerShell Cmdlet (V5)*. 

------