How do I create or update a lifecycle policy rule in Amazon ECR for Amazon ECS?

Last updated: 2019-07-19

How do I update a lifecycle policy rule in Amazon Elastic Container Registry (Amazon ECR) for Amazon Elastic Container Service (Amazon ECS)?

Short Description

You can use Amazon ECR lifecycle policies to manage the lifecycle of images in a repository.

Resolution

Create or update a lifecycle policy rule

  1. Open the Amazon ECR console.
  2. Choose the repository where you want to add or modify a lifecycle policy.
  3. In the navigation pane, in the Amazon ECR section, choose Lifecycle Policy.
  4. To update an existing policy, select the lifecycle policy rule that you want to update, and then choose Edit. Or, to create a new lifecycle policy, choose Create Rule.
    Note: Lifecycle policy rules can apply to tagged or untagged images, or both depending on the options that you specify.
  5. Update the rule or create a new rule, and then choose Save.
    Note: You can create multiple rules and apply them with different priorities. Priorities are applied in ascending order. For an example of a lifecycle policy that combines different rule types in a single policy, see Filtering on Multiple Rules. For more example policies (formatted in JSON), see Examples of Lifecycle Policies.
  6. (Optional) To view the JSON document for your policy, select your rule, choose Actions, and then choose View JSON. To edit your policy, choose Actions, and then choose Edit JSON.

Create a test rule to confirm that it works before applying the rule as a lifecycle policy

  1. Open the Amazon ECR console.
  2. Choose a repository where you want to add or modify a lifecycle policy.
  3. In the navigation pane, in the Amazon ECR section, choose Lifecycle Policy.
  4. Select the lifecycle policy rule that you want to test, and then choose Edit test rules.
  5. Choose Create rule.
  6. Choose Save.
  7. Choose Save and run test.
  8. If the test is successful, choose Apply as Lifecycle Policy to apply the rule as a lifecycle policy.

Did this article help you?

Anything we could improve?


Need more help?