Skip to content

Commit 17a9329

Browse files
rajchevalRajinder Singh
andauthored
fix: Use dynamic block to prevent empty device policies (#31)
* used dynamic block to handle lack of device policy * changed device_policy_enabled default value to true * fixed issues that were causing integration tests to break * removed device enabled variable * fixed string formatting error * refering to the variables using var. notation * update the expression that determines if device policy needs to be enabled Co-authored-by: Rajinder Singh <[email protected]>
1 parent 4aba2a1 commit 17a9329

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

modules/access_level/main.tf

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,18 @@ resource "google_access_context_manager_access_level" "access_level" {
3232
members = var.members
3333
negate = var.negate
3434

35-
device_policy {
36-
require_screen_lock = var.require_screen_lock
37-
allowed_encryption_statuses = var.allowed_encryption_statuses
38-
allowed_device_management_levels = var.allowed_device_management_levels
35+
dynamic "device_policy" {
36+
for_each = var.require_screen_lock || length(var.allowed_encryption_statuses) > 0 || length(var.allowed_device_management_levels) > 0 || var.minimum_version != "" || var.os_type != "OS_UNSPECIFIED" ? [{}] : []
3937

40-
os_constraints {
41-
minimum_version = var.minimum_version
42-
os_type = var.os_type
38+
content {
39+
require_screen_lock = var.require_screen_lock
40+
allowed_encryption_statuses = var.allowed_encryption_statuses
41+
allowed_device_management_levels = var.allowed_device_management_levels
42+
43+
os_constraints {
44+
minimum_version = var.minimum_version
45+
os_type = var.os_type
46+
}
4347
}
4448
}
4549
}

0 commit comments

Comments
 (0)