How do I manage disk space used by Spacelift worker binaries on EC2 instances?

Last updated: September 15, 2025

Context

When running Spacelift on EC2 instances, the `/opt/spacelift/binaries/worker/` directory can grow over time as new worker versions are downloaded. This can eventually lead to disk space issues on long-running instances.

Answer

There are several ways to manage the disk space used by Spacelift worker binaries:

  1. Configure Disk Usage Threshold
    Set the environment variable `SPACELIFT_LAUNCHER_DISK_USAGE_THRESHOLD` on the launcher to automatically kill the launcher based on disk usage. By default, the worker will only be killed when the disk is completely full.

  2. Instance Rotation
    The recommended approach is to regularly rotate your EC2 instances. This can be done by:

    • Using the official Spacelift module to manage instances, which handles rotation automatically

    • Implementing your own instance rotation schedule if not using the Spacelift module

How Worker Binary Updates Work:
Each time a new version of the worker is released, the launcher downloads the new version and stores it in a new directory under `/opt/spacelift/binaries/worker/`. The directory name is based on the first 8 characters of the binary hash. This is why long-running instances can accumulate multiple versions over time.