Skip to content

entrepot_cleanup_policy

A cleanup policy deletes components matching all of its set criteria from the repositories that list it in cleanup_policies. Use the server’s preview endpoint (or the UI) for a dry run before attaching a policy.

A policy cannot be deleted while repositories use it; when repositories reference the policy resource, Terraform updates them first.

# Delete npm pre-releases older than 30 days, keeping the 3 newest versions.
resource "entrepot_cleanup_policy" "npm_prereleases" {
name = "npm-prereleases"
description = "Remove old release candidates"
format = "npm"
criteria = {
published_older_than_days = 30
prerelease_only = true
keep_latest = 3
}
}
# Remove untagged Docker manifests after a week.
resource "entrepot_cleanup_policy" "docker_untagged" {
name = "docker-untagged"
format = "docker"
criteria = { untagged_older_than_days = 7 }
}
resource "entrepot_repository" "npm" {
name = "npm-internal"
format = "npm"
kind = "hosted"
blob_store = "default"
cleanup_policies = [entrepot_cleanup_policy.npm_prereleases.name]
}
  • criteria (Attributes) What to delete. At least one criterion is required; all set criteria must match. (see below for nested schema)
  • name (String) Policy name. Changing it forces a new policy.
  • description (String) Free-form description.
  • format (String) Restrict the policy to repositories of one format (raw, pypi, npm, docker, apt, yum, helm). Unset: any format.
  • id (String) Same as name.
  • repositories (List of String) Repositories that currently use the policy (informational). It changes when repositories are configured and is refreshed on every read; it never causes a diff.

Optional:

  • keep_latest (Number) Always keep this many newest versions of each component.
  • last_downloaded_older_than_days (Number) Components last downloaded more than this many days ago (never-downloaded components count from their publish date).
  • name_regex (String) Go regular expression the component name must match.
  • prerelease_only (Boolean) Only versions with a pre-release part (1.2.0-rc.1, 1.0.0.dev3).
  • published_older_than_days (Number) Components published more than this many days ago.
  • untagged_older_than_days (Number) Docker only: delete untagged manifests (and unreferenced layers) older than this many days.
  • version_regex (String) Go regular expression the version must match.

The terraform import command can be used, for example:

Terminal window
# Cleanup policies are imported by name.
terraform import entrepot_cleanup_policy.npm_prereleases npm-prereleases

Resource documentation generated from the provider’s schema (docs/resources/cleanup_policy.md in terraform-provider-entrepot).