Skip to content

CICD-462 · Container registry cleanup ​

Encyclopedia · FinOps and resource optimization · All snippets

Previous · CICD-461 · Next · CICD-463

1. Where it fits ​

  • Placement CI run step or authorized lab terminal.
  • Prerequisites authorized read reports, explicit pricing period and reviewed ownership for cleanup.
  • Platforms local-linux, github-actions, gitea-actions.
  • Parameters ECR_REPOSITORY.

2. Copy the snippet ​

bash
aws ecr list-images --repository-name "${ECR_REPOSITORY:?}" --filter tagStatus=UNTAGGED --output json | jq -r '.imageIds[].imageDigest'

3. How it works ​

Registry inventory returns candidate image metadata. Compare output against deployments before deleting retained digests. The expression filters or transforms the input JSON. Where jq -e is used, a false or empty result can fail the gate.

4. Verify the result ​

Untagged digests can still be deployed. Compare against live usage and use an approved lifecycle policy.

Validation syntax-validated (Bash parse). Status definitions.