Skip to content

Commit f4b059d

Browse files
authored
feat: Addition of optional user supplied exclusion filters (#18)
1 parent f760bbd commit f4b059d

File tree

9 files changed

+169
-1
lines changed

9 files changed

+169
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ cloudresourcemanager.googleapis.com
8282
| Name | Description | Type | Default | Required |
8383
|------|-------------|------|---------|:--------:|
8484
| <a name="input_existing_sink_name"></a> [existing\_sink\_name](#input\_existing\_sink\_name) | The name of an existing sink to be re-used for this integration | `string` | `""` | no |
85+
<a name="input_exclusion_filters"></a> [exclusion\_filters](#input\_exclusion\_filters) | Optional list of exclusion filters that can be passed to the integration to reduce logs | <pre>list(object({<br> filter = string<br> name = string<br> description = string<br>}))</pre> | `[]` | no |
8586
| <a name="input_integration_type"></a> [integration\_type](#input\_integration\_type) | Specify the integration type. Can only be PROJECT or ORGANIZATION. Defaults to PROJECT | `string` | `"PROJECT"` | no |
8687
| <a name="input_labels"></a> [labels](#input\_labels) | Set of labels which will be added to the resources managed by the module | `map(string)` | `{}` | no |
8788
| <a name="input_lacework_integration_name"></a> [lacework\_integration\_name](#input\_lacework\_integration\_name) | n/a | `string` | `"TF gke_audit_log"` | no |
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Integrate GCP Organization GKE Audit logs with Lacework
2+
The following provides an example of integrating a Google Cloud Project GKE Audit Logs with
3+
Lacework for analysis.
4+
5+
```hcl
6+
terraform {
7+
required_providers {
8+
lacework = {
9+
source = "lacework/lacework"
10+
}
11+
}
12+
}
13+
14+
provider "google" {}
15+
16+
provider "lacework" {}
17+
18+
module "gcp_organization_level_gke_audit_log" {
19+
source = "lacework/gke-audit-log/gcp"
20+
version = "~> 0.1"
21+
integration_type = "ORGANIZATION"
22+
project_id = "example-project-123"
23+
organization_id = "example-org-123"
24+
exclusion_filters = [
25+
{
26+
name = "filter-1"
27+
filter = "protoPayload.resourceName=\"readyz\""
28+
description = "Test Exclusion Filter 1 for readyz"
29+
},
30+
{
31+
name = "filter-2"
32+
filter = "protoPayload.resourceName=\"livez\""
33+
description = "Test Exclusion Filter 2 for livez"
34+
}
35+
]
36+
}
37+
```
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
provider "google" {}
2+
3+
provider "lacework" {}
4+
5+
variable "organization_id" {
6+
default = "my-organization-id"
7+
}
8+
9+
module "gcp_organization_level_gke_audit_log" {
10+
source = "../../"
11+
integration_type = "ORGANIZATION"
12+
organization_id = var.organization_id
13+
exclusion_filters = [
14+
{
15+
name = "filter-1"
16+
filter = "protoPayload.resourceName=\"readyz\""
17+
description = "Test Exclusion Filter 1 for readyz"
18+
},
19+
{
20+
name = "filter-2"
21+
filter = "protoPayload.resourceName=\"livez\""
22+
description = "Test Exclusion Filter 2 for livez"
23+
}
24+
]
25+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# required for Terraform 13
2+
terraform {
3+
required_providers {
4+
lacework = {
5+
source = "lacework/lacework"
6+
}
7+
}
8+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Integrate GCP Project GKE Audit logs with Lacework
2+
The following provides an example of integrating a Google Cloud Project GKE Audit Logs with
3+
Lacework for analysis.
4+
5+
```hcl
6+
terraform {
7+
required_providers {
8+
lacework = {
9+
source = "lacework/lacework"
10+
}
11+
}
12+
}
13+
14+
provider "google" {}
15+
16+
provider "lacework" {}
17+
18+
module "gcp_project_level_gke_audit" {
19+
source = "lacework/gke-audit-log/gcp"
20+
version = "~> 0.1"
21+
integration_type = "PROJECT"
22+
project_id = "example-project-123"
23+
exclusion_filters = [
24+
{
25+
name = "filter-1"
26+
filter = "protoPayload.resourceName=\"readyz\""
27+
description = "Test Exclusion Filter 1 for readyz"
28+
},
29+
{
30+
name = "filter-2"
31+
filter = "protoPayload.resourceName=\"livez\""
32+
description = "Test Exclusion Filter 2 for livez"
33+
}
34+
]
35+
}
36+
```
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
provider "google" {}
2+
3+
provider "lacework" {}
4+
5+
module "gcp_project_level_gke_audit_log" {
6+
source = "../../"
7+
integration_type = "PROJECT"
8+
# project_id is set using GOOGLE_PROJECT env var
9+
exclusion_filters = [
10+
{
11+
name = "filter-1"
12+
filter = "protoPayload.resourceName=\"readyz\""
13+
description = "Test Exclusion Filter 1 for readyz"
14+
},
15+
{
16+
name = "filter-2"
17+
filter = "protoPayload.resourceName=\"livez\""
18+
description = "Test Exclusion Filter 2 for livez"
19+
}
20+
]
21+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# required for Terraform 13
2+
terraform {
3+
required_providers {
4+
lacework = {
5+
source = "lacework/lacework"
6+
}
7+
}
8+
}

main.tf

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ resource "google_logging_project_sink" "lacework_project_sink" {
8686
unique_writer_identity = true
8787

8888
filter = local.log_filter
89-
89+
90+
# Standard exclusion filters
9091
exclusions {
9192
name = "livezexclusion"
9293
description = "Exclude livez logs"
@@ -111,6 +112,16 @@ resource "google_logging_project_sink" "lacework_project_sink" {
111112
filter = "protoPayload.resourceName=\"core/v1/namespaces/kube-system/configmaps/clustermetrics\" "
112113
}
113114

115+
# Additional user defined filters to exclude
116+
dynamic "exclusions" {
117+
for_each = var.exclusion_filters
118+
content {
119+
name = exclusions.value["name"]
120+
description = exclusions.value["description"]
121+
filter = exclusions.value["filter"]
122+
}
123+
}
124+
114125
depends_on = [google_pubsub_topic.lacework_topic]
115126
}
116127

@@ -147,6 +158,17 @@ resource "google_logging_organization_sink" "lacework_organization_sink" {
147158
filter = "protoPayload.resourceName=\"core/v1/namespaces/kube-system/configmaps/clustermetrics\" "
148159
}
149160

161+
# Additional user defined filters to exclude
162+
dynamic "exclusions" {
163+
for_each = var.exclusion_filters
164+
content {
165+
name = exclusions.value["name"]
166+
description = exclusions.value["description"]
167+
filter = exclusions.value["filter"]
168+
}
169+
}
170+
171+
150172
depends_on = [google_pubsub_topic.lacework_topic]
151173
}
152174

variables.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,13 @@ variable "pubsub_subscription_labels" {
9292
default = {}
9393
description = "Set of labels which will be added to the subscription"
9494
}
95+
96+
variable "exclusion_filters" {
97+
type = list(object({
98+
filter = string
99+
name = string
100+
description = string
101+
}))
102+
default = []
103+
description = "Set of filters that will be excluded from the audit log"
104+
}

0 commit comments

Comments
 (0)