-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
44 lines (40 loc) · 982 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
43
44
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 4.0"
}
}
}
provider "aws" {
region = var.aws_region
}
resource "aws_ecr_repository" "ecr_repo" {
#checkov:skip=CKV_AWS_51: "Ensure ECR Image Tags are immutable"
#checkov:skip=CKV_AWS_163: "Ensure ECR image scanning on push is enabled"
name = var.ecr_repo_name
force_delete = true
encryption_configuration {
encryption_type = "KMS"
}
}
resource "aws_ecr_lifecycle_policy" "flask-resume-repo-lifecycle-policy" {
repository = aws_ecr_repository.ecr_repo.name
policy = jsonencode({
rules = [
{
rulePriority = 1,
description = "Expire images older than 14 days",
selection = {
tagStatus = "untagged",
countType = "sinceImagePushed",
countUnit = "days",
countNumber = 14
},
action = {
type = "expire"
}
}
]
})
}