Skip to content

Commit 1c84465

Browse files
feat: Add inputs limit_by_labels, limit_by_tags, limit_by_repositories (#17)
Signed-off-by: Darren Murray <[email protected]>
1 parent af1212a commit 1c84465

File tree

7 files changed

+73
-1
lines changed

7 files changed

+73
-1
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ A Terraform Module to integrate Amazon Container Registries (ECR) with Lacework.
2222
| wait_time | Amount of time to wait before the next resource is provisioned | `string` | `"15s"` | no |
2323
| lacework_integration_name | The name of the external ECR integration | `string` | `"TF ECR IAM ROLE"` | no |
2424
| non_os_package_support | Whether or not the integration should check non-os packages in the container for vulnerabilities | `bool` | `false` | no |
25+
| `limit_by_tags` |A list of image tags to limit the assessment of images with matching tags. If you specify limit_by_tags and limit_by_labels limits, they function as an AND. Supported field input can be ["mytext\*mytext", "mytext", "mytext\*", "mytext". Only one * wildcard is supported.| `list(string)` | no |
26+
| `limit_by_labels` |A list of image labels to limit the assessment of images with matching labels. If you specify limit_by_tags and limit_by_labels limits, they function as an AND. Supported field input can be ["mytext\*mytext", "mytext", "mytext*", "mytext"].Only one * wildcard is supported.| `list(string)` | no |
27+
| `limit_by_repositories` |A list of repositories to assess.| `list(string)` | no |
2528

2629
## Outputs
2730

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Configure Lacework ECR Integration
2+
3+
This example creates a new least privilege IAM Role to access the Amazon Container Registry of the account running the automation and integrates it with Lacework.
4+
5+
```hcl
6+
terraform {
7+
required_providers {
8+
lacework = {
9+
source = "lacework/lacework"
10+
}
11+
}
12+
}
13+
14+
provider "lacework" {}
15+
16+
provider "aws" {}
17+
18+
module "lacework_ecr" {
19+
source = "lacework/ecr/aws"
20+
version = "~> 0.1"
21+
22+
limit_by_tags = ["example*"]
23+
limit_by_labels = {example: "example"}
24+
limit_by_repositories = ["foo","bar"]
25+
}
26+
```
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
provider "lacework" {}
2+
3+
provider "aws" {}
4+
5+
module "lacework_ecr" {
6+
source = "../.."
7+
8+
limit_by_tags = ["example*"]
9+
limit_by_labels = {example: "example"}
10+
limit_by_repositories = ["foo","bar"]
11+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
terraform {
2+
required_version = ">= 0.12.26"
3+
4+
required_providers {
5+
aws = "~> 3.0"
6+
lacework = {
7+
source = "lacework/lacework"
8+
}
9+
}
10+
}

main.tf

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,8 @@ resource "lacework_integration_ecr" "iam_role" {
4141
role_arn = local.iam_role_arn
4242
external_id = local.iam_role_external_id
4343
}
44-
depends_on = [time_sleep.wait_time]
44+
limit_by_tags = var.limit_by_tags
45+
limit_by_labels = var.limit_by_labels
46+
limit_by_repositories = var.limit_by_repositories
47+
depends_on = [time_sleep.wait_time]
4548
}

scripts/ci_tests.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ TEST_CASES=(
1212
examples/default
1313
examples/custom
1414
examples/multi-region
15+
examples/configure-lacework-ecr-integration
1516
)
1617

1718
log() {

variables.tf

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,24 @@ variable "iam_role_name" {
2828
description = "The IAM role name. Required to match with iam_role_arn if use_existing_iam_role is set to true"
2929
}
3030

31+
variable "limit_by_tags" {
32+
type = list(string)
33+
default = []
34+
description = "A list of tags to limit the assessment of images with matching tags. If you specify limit_by_tags and limit_by_label limits, they function as an AND."
35+
}
36+
37+
variable "limit_by_labels" {
38+
type = map(string)
39+
default = {}
40+
description = "A key based map of image labels to limit the assessment of images with matching labels. If you specify limit_by_tags and limit_by_label limits, they function as an AND."
41+
}
42+
43+
variable "limit_by_repositories" {
44+
type = list(string)
45+
default = []
46+
description = "A list of repositories to assess"
47+
}
48+
3149
variable "external_id_length" {
3250
type = number
3351
default = 16

0 commit comments

Comments
 (0)