Created
          March 24, 2023 15:50 
        
      - 
      
- 
        Save hendrixroa/e3748396a294df8a2c89303669ed679a to your computer and use it in GitHub Desktop. 
    AWS ECR untagged policies to remove images 
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | resource "aws_ecr_lifecycle_policy" "default_policy" { | |
| repository = aws_ecr_repository.noiselesstech.name | |
| policy = <<EOF | |
| { | |
| "rules": [ | |
| { | |
| "rulePriority": 1, | |
| "description": "Keep only the last ${var.untagged_images} untagged images.", | |
| "selection": { | |
| "tagStatus": "untagged", | |
| "countType": "imageCountMoreThan", | |
| "countNumber": ${var.untagged_images} | |
| }, | |
| "action": { | |
| "type": "expire" | |
| } | |
| } | |
| ] | |
| } | |
| EOF | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment