-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.tf
42 lines (40 loc) · 1002 Bytes
/
main.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
36
37
38
39
40
41
42
/**
* # ![AWS](aws-logo.png) ECR Repository
*
* ![AWS ECR Repository](aws_ecr_repository.png)
*
* Purpose: Defaults for ECR repositories.
*
* Requirements: To execute the image import the execution environment must have the following installed:
* * Docker
* * AWS CLI
*/
resource "aws_ecr_repository" "repository" {
name = var.name
image_tag_mutability = "IMMUTABLE"
image_scanning_configuration {
scan_on_push = var.scan_on_push
}
}
resource "aws_ecr_lifecycle_policy" "untagged_images" {
repository = aws_ecr_repository.repository.name
policy = <<EOF
{
"rules": [
{
"rulePriority": 1,
"description": "Remove untagged images older than ${var.untagged_image_expiry_days} days",
"selection": {
"tagStatus": "untagged",
"countType": "sinceImagePushed",
"countUnit": "days",
"countNumber": ${var.untagged_image_expiry_days}
},
"action": {
"type": "expire"
}
}
]
}
EOF
}