Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 33 additions & 0 deletions infrastructure/terraform/modules/ecr-repositories/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,18 @@ terraform {
}
}

data "aws_ecr_lifecycle_policy_document" "default_policy" {
rule {
priority = 1
description = "Only keep 10 images at a time"

selection {
tag_status = "any"
count_type = "imageCountMoreThan"
count_number = 10
}
}
}

# ecr repositories for all containers
resource "aws_ecr_repository" "pubpub_v7" {
Expand All @@ -20,7 +32,11 @@ resource "aws_ecr_repository" "pubpub_v7" {
scan_on_push = false # can set this to true if we want
}
}
resource "aws_ecr_lifecycle_policy" "pubpub_v7" {
repository = aws_ecr_repository.pubpub_v7.name

policy = data.aws_ecr_lifecycle_policy_document.default_policy.json
}
resource "aws_ecr_repository" "pubpub_v7_core" {
name = "pubpub-v7-core"
image_tag_mutability = "MUTABLE"
Expand All @@ -30,6 +46,12 @@ resource "aws_ecr_repository" "pubpub_v7_core" {
}
}

resource "aws_ecr_lifecycle_policy" "pubpub_v7_core" {
repository = aws_ecr_repository.pubpub_v7_core.name

policy = data.aws_ecr_lifecycle_policy_document.default_policy.json
}

resource "aws_ecr_repository" "pubpub_v7_jobs" {
name = "pubpub-v7-jobs"
image_tag_mutability = "MUTABLE"
Expand All @@ -39,6 +61,12 @@ resource "aws_ecr_repository" "pubpub_v7_jobs" {
}
}

resource "aws_ecr_lifecycle_policy" "pubpub_v7_jobs" {
repository = aws_ecr_repository.pubpub_v7_jobs.name

policy = data.aws_ecr_lifecycle_policy_document.default_policy.json
}

# tiny image that just removes the a path prefix
resource "aws_ecr_repository" "nginx" {
name = "nginx"
Expand All @@ -49,3 +77,8 @@ resource "aws_ecr_repository" "nginx" {
}
}

resource "aws_ecr_lifecycle_policy" "nginx" {
repository = aws_ecr_repository.nginx.name

policy = data.aws_ecr_lifecycle_policy_document.default_policy.json
}
Loading