Difference between revisions of "Terrafrom resource: aws ecr lifecycle policy"

From wikieduonline
Jump to navigation Jump to search
Line 1: Line 1:
 
{{lc}}
 
{{lc}}
 
* https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ecr_lifecycle_policy
 
* https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ecr_lifecycle_policy
 +
 +
 +
resource "aws_ecr_repository" "foo" {
 +
  name = "bar"
 +
}
 +
 +
resource "aws_ecr_lifecycle_policy" "foopolicy" {
 +
  repository = aws_ecr_repository.foo.name
 +
 +
  policy = <<EOF
 +
{
 +
    "rules": [
 +
        {
 +
            "rulePriority": 1,
 +
            "description": "Expire images older than 14 days",
 +
            "selection": {
 +
                "tagStatus": "untagged",
 +
                "countType": "sinceImagePushed",
 +
                "countUnit": "days",
 +
                "countNumber": 14
 +
            },
 +
            "action": {
 +
                "type": "expire"
 +
            }
 +
        }
 +
    ]
 +
}
 +
EOF
 +
}
 +
 +
 +
{{AWS ECR}}

Revision as of 11:20, 12 September 2022


resource "aws_ecr_repository" "foo" {
 name = "bar"
}
resource "aws_ecr_lifecycle_policy" "foopolicy" {
  repository = aws_ecr_repository.foo.name

  policy = <<EOF
{
   "rules": [
       {
           "rulePriority": 1,
           "description": "Expire images older than 14 days",
           "selection": {
               "tagStatus": "untagged",
               "countType": "sinceImagePushed",
               "countUnit": "days",
               "countNumber": 14
           },
           "action": {
               "type": "expire"
           }
       }
   ]
}
EOF
}


AWS ECR, CannotPullContainerError

Advertising: