Adding an Image Retention Policy

You can add a retention policy to an image in SWR to automatically delete image tags that might not be in use anymore. The policy takes effect immediately after you set it. There are two types of policies:

  • Number of days: Image tags are retained based on how many days it has been since they were pushed to SWR. Any tags pushed to SWR more than a certain number of days ago are deleted.
  • Number of tags: Image tags are retained based on how many tags have been pushed to SWR. Any tags pushed in excess of a certain number of tags are deleted on a first-in-first-out basis.

You can configure filters for your retention policy to prevent certain image tags from being affected by the retention policy.

Constraint

Currently, only one policy can be configured for each image. If you want to add a new retention policy, the existing policy must be deleted first.

Procedure

  1. Log in to the SWR console.
  2. In the navigation pane on the left, choose My Images, and click the desired image to enter its details page.
  3. On the Retention tab page, click Add Retention Policy. Configure the policy based on Table 1 and click OK.

    Figure 1 Adding an image retention policy
    Table 1 Adding an image retention policy

    Parameter

    Description

    Policy Type

    There are two types of retention policies:

    • Number of days: Keep only image tags that have been pushed to SWR within a certain number of days.
    • Number of tags: Keep only a certain number of the most recent image tags. You can set filtering criteria for a retention policy. Image tags meetings the criteria will not be affected by this policy.

    Count Limit

    • When you set Policy Type to Number of days, the value indicates how many days an image tag can be stored. The value should be an integer ranging from 1 to 365.
    • When you set Policy Type to Number of tags, the value indicates the maximum number of the most recent image tags to be retained. The value should be an integer ranging from 1 to 1000.

    Tag Filter

    Enter image tags that you do not want this retention policy to apply to.

    Regular Expression Filter

    Enter a regular expression. Image tags meeting this regular expression will not be affected by this retention policy.

    When a retention policy is added, SWR immediately applies the policy and displays deleted image tags (if any) in the Retention Logs area.
    Figure 2 Viewing the retention policy and logs