Skip to content

Commit

Permalink
feat!: Allow multiple scan filters per scan type in registry; Raise M…
Browse files Browse the repository at this point in the history
…SV of Terraform and AWS provider to 1.0 and 5.0 respectively (#29)

* feat: Add support for multiple scan filters per scan type in registry scan rules

* refactor repository_filter var name and raise MSV of Terraform and AWS provider to 1.0 and 5.0 respectively

* chore: Fix example version

---------

Co-authored-by: Bryant Biggs <[email protected]>
  • Loading branch information
vrnvikas and bryantbiggs authored Mar 15, 2024
1 parent c15cb78 commit cbba4fd
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/antonbabenko/pre-commit-terraform
rev: v1.88.0
rev: v1.88.2
hooks:
- id: terraform_fmt
- id: terraform_wrapper_module_for_each
Expand Down
27 changes: 19 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,23 @@ module "ecr_registry" {
registry_scan_rules = [
{
scan_frequency = "SCAN_ON_PUSH"
filter = "*"
filter_type = "WILDCARD"
}, {
filter = [
{
filter = "example1"
filter_type = "WILDCARD"
},
{ filter = "example2"
filter_type = "WILDCARD"
}
]
}, {
scan_frequency = "CONTINUOUS_SCAN"
filter = "example"
filter_type = "WILDCARD"
filter = [
{
filter = "example"
filter_type = "WILDCARD"
}
]
}
]
Expand Down Expand Up @@ -181,14 +192,14 @@ Examples codified under the [`examples`](https://github.com/terraform-aws-module

| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.13.1 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.22 |
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.0 |

## Providers

| Name | Version |
|------|---------|
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 4.22 |
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 5.0 |

## Modules

Expand Down
6 changes: 3 additions & 3 deletions examples/complete/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ Note that this example may create resources which will incur monetary charges on

| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.13.1 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.22 |
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.0 |

## Providers

| Name | Version |
|------|---------|
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 4.22 |
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 5.0 |

## Modules

Expand Down
19 changes: 15 additions & 4 deletions examples/complete/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,23 @@ module "ecr_registry" {
registry_scan_rules = [
{
scan_frequency = "SCAN_ON_PUSH"
filter = "*"
filter_type = "WILDCARD"
filter = [
{
filter = "example1"
filter_type = "WILDCARD"
},
{ filter = "example2"
filter_type = "WILDCARD"
}
]
}, {
scan_frequency = "CONTINUOUS_SCAN"
filter = "example"
filter_type = "WILDCARD"
filter = [
{
filter = "example"
filter_type = "WILDCARD"
}
]
}
]

Expand Down
4 changes: 2 additions & 2 deletions examples/complete/versions.tf
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
terraform {
required_version = ">= 0.13.1"
required_version = ">= 1.0"

required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 4.22"
version = ">= 5.0"
}
}
}
10 changes: 7 additions & 3 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -287,9 +287,13 @@ resource "aws_ecr_registry_scanning_configuration" "this" {
content {
scan_frequency = rule.value.scan_frequency

repository_filter {
filter = rule.value.filter
filter_type = try(rule.value.filter_type, "WILDCARD")
dynamic "repository_filter" {
for_each = rule.value.filter

content {
filter = repository_filter.value.filter
filter_type = try(repository_filter.value.filter_type, "WILDCARD")
}
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions versions.tf
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
terraform {
required_version = ">= 0.13.1"
required_version = ">= 1.0"

required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 4.22"
version = ">= 5.0"
}
}
}

0 comments on commit cbba4fd

Please sign in to comment.