atmos icon indicating copy to clipboard operation
atmos copied to clipboard

Extend `atmos terraform clean` to clean up custom paths

Open osterman opened this issue 1 year ago • 2 comments

Describe the Feature

The atmos terraform clean command will clean up some well-known paths. However, running terraform commands and result in other temporary files getting created.

With this feature, atmos can clean up any files relative to the component's directory.

Path traversals (../../../../etc/passwd) are not allowed.

# atmos.yaml
terraform:
  clean:
    paths:
    - cache.txt
    - **/*.zip

Expected Behavior

Running atmos terraform clean will purge all well-known locations (like it does now), in addition to matching any of the terraform.clean.paths configured.

Use Case

  • Terraform component used to provision a lambda produces a .zip file that is orphaned
  • Terraform component writes some temporary files that are not cleaned up

Describe Ideal Solution

Modify the Atmos config to support the following:

# atmos.yaml
terraform:
  clean:
    paths:
    - cache.txt
    - **/*.zip

Alternatives Considered

We could create a "custom command" that also does this, but it's better that we have a core feature.

Additional Context

No response

osterman avatar Feb 04 '25 02:02 osterman

@osterman
What if user want to clean specific files based on component or a combination of component and stack but never all.

I assume we should have an option for the above scenario.
Because currently we provide atmos terraform clean with stack and component filters.

samtholiya avatar Jun 14 '25 11:06 samtholiya

Aha, such as in one component creates specific artifacts that should get cleaned up.

This would be in:

components:
  terraform:
    foobar:
      settings:
        terraform.clean.paths:
        - foo.txt
      vars:
        ...

osterman avatar Jun 18 '25 21:06 osterman