Skip to content

Commit

Permalink
feat: add scanning and policy support
Browse files Browse the repository at this point in the history
Signed-off-by: Kevin Lefevre <lefevre.kevin@gmail.com>
  • Loading branch information
ArchiFleKs committed Nov 7, 2019
1 parent 6b93946 commit 73c60b6
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 6 deletions.
17 changes: 15 additions & 2 deletions ecr.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,21 @@ locals {

resource "aws_ecr_repository" "ecr" {
count = length(var.registries)
name = var.registries[count.index]
tags = merge(local.common_tags, var.custom_tags)
name = var.registries[count.index]["name"]

image_tag_mutability = var.registries[count.index]["image_tag_mutability"]

image_scanning_configuration {
scan_on_push = var.registries[count.index]["scan_on_push"]
}

tags = merge(local.common_tags, var.custom_tags)
}

resource "aws_ecr_repository_policy" "ecr" {
count = length(var.registries_policies)
repository = var.registries_policies[count.index]["name"]
policy = var.registries_policies[count.index]["policy"]
}

resource "aws_iam_user" "ecr_user" {
Expand Down
16 changes: 13 additions & 3 deletions examples/terragrunt.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,18 @@ inputs = {
)

registries = [
"myproject/one",
"myproject/two",
"myproject/three"
{
name = "myproject/one"
image_tag_mutability = "MUTABLE"
scan_on_push = true
}
]

registries_policies = [
{
name = "myproject/one"
policy = <<POLICY
POLICY
}
]
}
7 changes: 6 additions & 1 deletion variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@ variable "aws" {

variable "registries" {
type = any
default = {}
default = []
}

variable "registries_policies" {
type = any
default = []
}

variable "custom_tags" {
Expand Down

0 comments on commit 73c60b6

Please sign in to comment.