Skip to main content
Version: 3.9.0

How to Clean Up Expired Resources

A resource can be tagged with an expiration tag that instructs Resoto to clean it up after it has reached a certain age. This can serve as a safety net for when a CI job fails or the IaC tool aborts halfway through its run, or even as the primary means of managing resource lifecycles.

Resoto's cleanup_expired plugin can find and delete expired resources.


This guide assumes that you have already installed and configured Resoto to collect your cloud resources.


  1. Execute the following command in Resoto Shell to open the Resoto Worker configuration for editing:

    > config edit resoto.worker
  2. Enable cleanup by modifying the resotoworker section of the configuration as follows:

    # 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: 16

    When cleanup is enabled, marked resources will be deleted as a part of the collect_and_cleanup workflow, which runs each hour by default.


    Set cleanup_dry_run to true to simulate cleanup without actually deleting resources.

  3. Update the plugin_cleanup_expired section, setting the enabled property to true:

    cleanup_expired plugin configuration
    # 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_expired plugin runs, expired resources will be flagged for removal during the next cleanup run.


A resource's expiration time can be defined either with an ISO 8601 timestamp or time delta:

Tag NameDescriptionExample
resoto:expiresISO 8601 timestamp2022-09-21T10:40:11+00:00
resoto:expiration or expirationTime delta from resource creation time24h

Please see the Resource Expiration for more information about expiration tags.


If you would like to apply expiration tags to existing resources, How to Find Untagged Resources describes how to find untagged resources.

How to Clean Up Untagged Resources describes how to clean up untagged resources, which can be helpful in enforcing tagging policies.

Further Reading

Contact Us

Have feedback or need help? Don’t be shy—we’d love to hear from you!




Some Engineering Inc.