How to Clean Up AWS CloudWatch Alarms
When deleting EC2 instances, CloudWatch alarms are sometimes left behind.
Resoto's cleanup_aws_alarms
plugin can find and delete these orphaned alarms.
Prerequisites​
This guide assumes that you have already installed and configured Resoto to collect your AWS resources.
Directions​
Execute the following command in Resoto Shell to open the Resoto Worker configuration for editing:
> config edit resoto.worker
Enable cleanup by modifying the
resotoworker
section of the configuration as follows:resotoworker:
# Enable cleanup of resources
cleanup: true
# Do not actually cleanup resources, just create log messages
cleanup_dry_run: false
# How many cleanup threads to run in parallel
cleanup_pool_size: 16When cleanup is enabled, marked resources will be deleted as a part of the
collect_and_cleanup
workflow, which runs each hour by default.tipSet
cleanup_dry_run
totrue
to simulate cleanup without actually deleting resources.Update the
plugin_cleanup_aws_alarms
section with the desired target cloud account IDs and setting theenabled
property totrue
:cleanup_aws_alarms plugin configurationplugin_cleanup_aws_alarms:
# Dictionary of key cloud with list of account IDs for which the plugin should be active as value
config:
aws:
- '1234567'
- '567890'
# Enable plugin?
enabled: true
The plugin will now run each time Resoto emits the post_cleanup_plan
event. The post_cleanup_plan
event is emitted in the cleanup
phase of the collect_and_cleanup
workflow.
Each time the cleanup_aws_alarms
plugin runs, orphaned CloudWatch alarms will be flagged for removal during the next cleanup run.