Cleanup policy overview

An Artifact Registry cleanup policy defines criteria for automatically deleting artifact versions that you no longer need or for keeping artifacts that you want to store indefinitely.

Cleanup policies are useful if you store many versions of your artifacts, but only need to keep specific versions that you release to production. You can define delete policies with criteria for deleting artifacts and keep policies with criteria for retaining artifacts.

If an artifact version matches criteria in both a delete policy and a keep policy, Artifact Registry applies the keep policy.

Deletions triggered by delete policies count against your Artifact Registry per project delete request quota and are limited to 300,000 deletions per repository, per day.

Types of cleanup policies

A delete policy defines the minimum or maximum age for artifact deletion, with additional filtering criteria available to limit the policy to specific artifacts. When you have an active delete policy, you can also configure different types of keep policies so that Artifact Registry maintains specific artifacts:

  • Conditional keep policy: Defines criteria for retaining artifacts. You can configure conditional keep policies to maintain artifacts that your delete policies would otherwise remove. When an artifact matches the criteria for both a delete policy and a keep policy, the artifact is kept.
  • Keep most recent versions: Defines criteria for keeping a specific range of artifact versions. You can't use Conditional keep and Keep most recent versions criteria in the same cleanup policy.

Policy application order

If your repository has more than one cleanup policy, then Artifact Registry applies the policies in order unless a keep policy matches the same image as a delete policy. For example, your repository has cleanup policies with the following conditions:

  1. Delete images older than 100 days.
  2. Keep images with a version prefix of 2.0.6.
  3. Delete images with a default tag.

Your repository contains images with the following attributes:

Image Age Tag Version
Image A 120 Days default 2.0.1
Image B 150 Days default 2.0.6
Image C 20 Days patch 1.9.2

In this example, Image A is deleted and Image C is kept. Image B is also kept due to the keep policy matching the image version, even though Image B also matches the deletion criteria for the first and third policies.

Policy application schedule

Artifact Registry performs dry runs and active runs of cleanup policies using a background job that runs periodically. Changes take effect within approximately one day.

Maximum number of cleanup policies per repository

You can apply a maximum of 10 cleanup policies to a repository.

Supported formats

You can set a cleanup policy on standard and remote repositories for all repository formats.

What's next