Skip to content

Commit 64bc66d

Browse files
authored
Merge pull request #377 from aquasecurity/katy-tf-prometheus-SLK-109399
SLK-109399: expose enforcer group Prometheus flag
2 parents bdb8a31 + ab46bf3 commit 64bc66d

File tree

7 files changed

+24
-0
lines changed

7 files changed

+24
-0
lines changed

aquasec/data_enforcer_group.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,11 @@ func dataSourceEnforcerGroup() *schema.Resource {
9797
Description: "When set to `True` applies User Access Control Policies to containers. Note that Aqua Enforcers must be deployed with the AQUA_RUNC_INTERCEPTION environment variable set to 0 in order to use User Access Control Policies.",
9898
Computed: true,
9999
},
100+
"enable_enforcer_group_prometheus": {
101+
Type: schema.TypeBool,
102+
Description: "Enable Prometheus metrics for the enforcer group.",
103+
Computed: true,
104+
},
100105
"image_assurance": {
101106
Type: schema.TypeBool,
102107
Description: "When Set to `True` enables selected controls: Container Runtime Policy (`Block Non-Compliant Images`, `Block Unregistered Images`, and `Registries Allowed`) and Default Image Assurance Policy (`Images Blocked`).",
@@ -449,6 +454,7 @@ func dataEnforcerGroupRead(ctx context.Context, d *schema.ResourceData, m interf
449454
d.Set("host_forensics_collection", group.HostForensicsCollection)
450455
d.Set("host_network_protection", group.HostNetworkProtection)
451456
d.Set("user_access_control", group.UserAccessControl)
457+
d.Set("enable_enforcer_group_prometheus", group.EnableEnforcerGroupPrometheus)
452458
d.Set("image_assurance", group.ImageAssurance)
453459
d.Set("host_protection", group.HostProtection)
454460
d.Set("audit_all", group.AuditAll)

aquasec/resource_enforcer_group.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,11 @@ func resourceEnforcerGroup() *schema.Resource {
438438
Description: "Set `True` to apply User Access Control Policies to containers. Note that Aqua Enforcers must be deployed with the AQUA_RUNC_INTERCEPTION environment variable set to 0 in order to use User Access Control Policies.",
439439
Optional: true,
440440
},
441+
"enable_enforcer_group_prometheus": {
442+
Type: schema.TypeBool,
443+
Description: "Enable Prometheus metrics for the enforcer group.",
444+
Optional: true,
445+
},
441446
"unified_mode": {
442447
Type: schema.TypeBool,
443448
Description: "",
@@ -503,6 +508,7 @@ func resourceEnforcerGroupRead(ctx context.Context, d *schema.ResourceData, m in
503508
d.Set("host_forensics_collection", r.HostForensicsCollection)
504509
d.Set("host_network_protection", r.HostNetworkProtection)
505510
d.Set("user_access_control", r.UserAccessControl)
511+
d.Set("enable_enforcer_group_prometheus", r.EnableEnforcerGroupPrometheus)
506512
d.Set("image_assurance", r.ImageAssurance)
507513
d.Set("host_protection", r.HostProtection)
508514
d.Set("audit_all", r.AuditAll)
@@ -594,6 +600,7 @@ func resourceEnforcerGroupUpdate(ctx context.Context, d *schema.ResourceData, m
594600
"syscall_enabled",
595601
"type",
596602
"user_access_control",
603+
"enable_enforcer_group_prometheus",
597604
"orchestrator",
598605
"schedule_scan_settings",
599606
"unified_mode",
@@ -848,6 +855,11 @@ func expandEnforcerGroup(d *schema.ResourceData) client.EnforcerGroup {
848855
enforcerGroup.UserAccessControl = userAccessControl.(bool)
849856
}
850857

858+
enableEnforcerGroupPrometheus, ok := d.GetOk("enable_enforcer_group_prometheus")
859+
if ok {
860+
enforcerGroup.EnableEnforcerGroupPrometheus = enableEnforcerGroupPrometheus.(bool)
861+
}
862+
851863
unifiedMode, ok := d.GetOk("unified_mode")
852864
if ok {
853865
enforcerGroup.UnifiedMode = unifiedMode.(bool)

client/enforcers.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ type EnforcerGroup struct {
9797
AllowedLabels []string `json:"allowed_labels"`
9898
AllowedRegistries []string `json:"allowed_registries"`
9999
ScheduleScanSettings EnforcerScheduleScanSettings `json:"schedule_scan_settings"`
100+
EnableEnforcerGroupPrometheus bool `json:"enable_enforcer_group_prometheus"`
100101
UnifiedMode bool `json:"unified_mode"`
101102
}
102103

docs/data-sources/enforcer_groups.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ output "group_details" {
6161
- `description` (String) A description for the Aqua Enforcer group.
6262
- `disconnected_count` (Number) Number of disconnected enforcers in the enforcer group.
6363
- `enforce` (Boolean) Whether the enforce mode is enabled on the Enforcers.
64+
- `enable_enforcer_group_prometheus` (Boolean) Enable Prometheus metrics for the enforcer group.
6465
- `enforcer_image_name` (String) The specific Aqua Enforcer product image (with image tag) to be deployed.
6566
- `gateway_address` (String) Gateway Address
6667
- `gateway_name` (String) Gateway Name

docs/resources/enforcer_groups.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ description: |-
4343
- `container_activity_protection` (Boolean) Set `True` to apply Container Runtime Policies, Image Profiles, and Firewall Policies to containers.
4444
- `container_antivirus_protection` (Boolean) This setting is available only when you have license for `Advanced Malware Protection`. Send true to make use of the license and enable the `Real-time Malware Protection` control in the Container Runtime policies.
4545
- `description` (String) A description of the Aqua Enforcer group.
46+
- `enable_enforcer_group_prometheus` (Boolean) Enable Prometheus metrics for the enforcer group.
4647
- `enforce` (Boolean) Whether to enable enforce mode on the Enforcers, defaults to False.
4748
- `forensics` (Boolean) Select Enabled to send activity logs in your containers to the Aqua Server for forensics purposes.
4849
- `gateways` (List of String) List of Aqua gateway IDs for the Enforcers.

examples/resources/aquasec_enforcer_group/resource.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ resource "aquasec_enforcer_groups" "group" {
2222
sync_host_images = true
2323
# Risk Explorer
2424
risk_explorer_auto_discovery = true
25+
# Prometheus metrics
26+
enable_enforcer_group_prometheus = true
2527
# host_forensics
2628
host_forensics_collection = true
2729
# forensics

examples/resources/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ resource "aquasec_enforcer_groups" "new" {
9393
description = "Created1"
9494
logical_name = "terraform-eg"
9595
enforce = true
96+
enable_enforcer_group_prometheus = true
9697
gateways = [
9798
"local-cluster"
9899
]

0 commit comments

Comments
 (0)