-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathecr_repository.tf
35 lines (31 loc) · 911 Bytes
/
ecr_repository.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
resource "aws_ecr_repository" "repository" {
name = lower(var.service_name)
image_scanning_configuration {
scan_on_push = true
}
}
resource "aws_ecr_lifecycle_policy" "image_policy" {
repository = aws_ecr_repository.repository.name
policy = jsonencode(
{
rules = [
{
rulePriority = 1
description = join(" ", ["Expire images older than", tostring(var.retention) ,"days"])
selection = {
tagStatus = "untagged"
countType = "sinceImagePushed"
countUnit = "days"
countNumber = var.retention
}
action = {
type = "expire"
}
}
]
}
)
}
output "repository_url" {
value = aws_ecr_repository.repository.repository_url
}