mirror of
https://github.com/Hestia-Homes/survey-extraction.git
synced 2026-06-08 11:17:29 +00:00
62 lines
No EOL
1.6 KiB
HCL
62 lines
No EOL
1.6 KiB
HCL
# ECR repo
|
|
resource "aws_ecr_repository" "extractor_and_loader" {
|
|
name = "extractor_and_loader"
|
|
}
|
|
|
|
# ECR policy to allow Lambda access
|
|
resource "aws_ecr_repository_policy" "extractor_loader_ecr_access" {
|
|
repository = aws_ecr_repository.extractor_and_loader.name
|
|
|
|
policy = jsonencode({
|
|
Version = "2008-10-17",
|
|
Statement = [{
|
|
Sid = "AllowLambdaPull",
|
|
Effect = "Allow",
|
|
Principal = {
|
|
Service = "lambda.amazonaws.com"
|
|
},
|
|
Action = [
|
|
"ecr:GetDownloadUrlForLayer",
|
|
"ecr:BatchGetImage",
|
|
"ecr:BatchCheckLayerAvailability"
|
|
]
|
|
}]
|
|
})
|
|
}
|
|
|
|
|
|
# ECR lifecycle policy to delete tagged images older than 14 days
|
|
resource "aws_ecr_lifecycle_policy" "extractor_loader_lifecycle" {
|
|
repository = aws_ecr_repository.extractor_and_loader.name
|
|
|
|
policy = jsonencode({
|
|
"rules": [
|
|
{
|
|
"rulePriority": 2,
|
|
"description": "Expire images older than 14 days",
|
|
"selection": {
|
|
"tagStatus": "untagged",
|
|
"countType": "sinceImagePushed",
|
|
"countUnit": "days",
|
|
"countNumber": 1
|
|
},
|
|
"action": {
|
|
"type": "expire"
|
|
}
|
|
},
|
|
{
|
|
"rulePriority": 1,
|
|
"description": "Keep last 5 images",
|
|
"selection": {
|
|
"tagStatus": "tagged",
|
|
"tagPrefixList": ["feature"],
|
|
"countType": "imageCountMoreThan",
|
|
"countNumber": 5
|
|
},
|
|
"action": {
|
|
"type": "expire"
|
|
}
|
|
}
|
|
]
|
|
})
|
|
} |