Skip to content

Commit

Permalink
Add scan_on_push capability
Browse files Browse the repository at this point in the history
AWS scan scan ECR images for vulnerabilities when they are pushed.
Add this capability via the `scan_on_push` variable, and set the
default to `true`.
  • Loading branch information
JonRoma committed Sep 9, 2024
1 parent 386ac3c commit 5a4f9d7
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ module "foo" {
"repo_name_1",
"repo_name_2",
]
readers = ["arn:aws:iam::874445906176:root"]
readers = ["arn:aws:iam::874445906176:root"]
scan_on_push = true
}
```

Expand All @@ -39,6 +40,8 @@ The following arguments are supported:

* `repos` - (Required) List of repository names.

* `scan_on_push` – (Optional) Boolean indicating whether images are scanned after being pushed to the repository. Defaults to `true`.

* `tags` - (Optional) Map of tags for resources where supported.

* `writers` - (Optional) List of account ARNs that can push images.
Expand Down
4 changes: 4 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ resource "aws_ecr_repository" "default" {
for_each = toset(var.repos)
name = each.key
tags = var.tags

image_scanning_configuration {
scan_on_push = var.scan_on_push
}
}

resource "aws_ecr_lifecycle_policy" "default" {
Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ variable "repos" {
type = list(string)
}

variable "scan_on_push" {
description = "Boolean indicating whether images are scanned after being pushed to the repository"
type = bool
default = true
}

variable "tags" {
description = "Map of tags for resources where supported"
type = map(string)
Expand Down

0 comments on commit 5a4f9d7

Please sign in to comment.