

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

# Mengelola Sumber Daya yang Dihapus untuk AWS Config Aturan Lambda Kustom
<a name="evaluate-config_develop-rules-delete"></a>

Aturan pelaporan sumber daya yang dihapus harus mengembalikan hasil evaluasi untuk menghindari evaluasi aturan yang tidak perlu. `NOT_APPLICABLE`

Saat Anda menghapus sumber daya, AWS Config buat `configurationItem` dengan `ResourceDeleted` untuk file`configurationItemStatus`. Anda dapat menggunakan metadata ini untuk memeriksa apakah aturan melaporkan sumber daya yang dihapus. Untuk informasi selengkapnya tentang item konfigurasi, lihat [Konsep \$1 Item Konfigurasi](https://docs.aws.amazon.com/config/latest/developerguide/config-concepts.html#config-items.html).

Sertakan cuplikan kode berikut untuk memeriksa sumber daya yang dihapus dan setel hasil evaluasi aturan lambda AWS Config kustom `NOT_APPLICABLE` jika melaporkan sumber daya yang dihapus:

------
#### [ Custom Lambda Rules (Node.js) ]

```
// Check whether the resource has been deleted. If the resource was deleted, then the evaluation returns not applicable.
function isApplicable(configurationItem, event) {
    checkDefined(configurationItem, 'configurationItem');
    checkDefined(event, 'event');
    const status = configurationItem.configurationItemStatus;
    const eventLeftScope = event.eventLeftScope;
    return (status === 'OK' || status === 'ResourceDiscovered') && eventLeftScope === false;
}
```

------
#### [ Custom Lambda Rules (Python) ]

```
# Check whether the resource has been deleted. If the resource was deleted, then the evaluation returns not applicable.
def is_applicable(configurationItem, event):
    try:
        check_defined(configurationItem, 'configurationItem')
        check_defined(event, 'event')
    except:
        return True
    status = configurationItem['configurationItemStatus']
    eventLeftScope = event['eventLeftScope']
    if status == 'ResourceDeleted':
        print("Resource Deleted, setting Compliance Status to NOT_APPLICABLE.")
    return (status == 'OK' or status == 'ResourceDiscovered') and not eventLeftScope
```

------

**catatan**  
AWS Config aturan terkelola dan aturan kebijakan AWS Config khusus menangani perilaku ini secara default.  
Jika Anda membuat aturan lambd AWS Config kustom dengan Python menggunakan AWS Config Development Kit (RDK) AWS Config dan Development Kit Library RDKlib (), class Evaluator yang [diimpor akan memeriksa](https://github.com/awslabs/aws-config-rdklib/blob/master/rdklib/evaluator.py#L56) perilaku ini. Untuk informasi tentang cara menulis aturan dengan RDK dan RDKlib, lihat [Menulis aturan dengan RDK](https://docs.aws.amazon.com/config/latest/developerguide/evaluate-config_components.html#evaluate-config_components_logic) dan. RDKlib