-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.tf
36 lines (29 loc) · 957 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
# ECR Configuration template:
# - ECR Repository
# - ECR Policy
# - ECR Lifecycle Policy
# Author: @mrexojo
# https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ecr_repository
resource "aws_ecr_repository" "ecr-repository" {
name = var.ecr_repo
image_scanning_configuration {
scan_on_push = var.scan_on_push
}
tags = {
"Name" = var.ecr_repo
"Mantainer" = var.mantainer
"Project" = var.project
"Author" = var.author
}
}
resource "aws_ecr_repository_policy" "ecr-repository-policy" {
repository = aws_ecr_repository.ecr-repository.name
policy = templatefile("${path.module}/policy.json.tpl", { sid_name = var.ecr_repo })
}
resource "aws_ecr_lifecycle_policy" "ecr-lifecycle-policy" {
repository = aws_ecr_repository.ecr-repository.name
policy = templatefile(
"${path.module}/policy-lifecycle.json.tpl",
{ expire = var.expire_days, keep = var.keep_days }
)
}