Skip to content

Commit

Permalink
Merge pull request #8 from m4xmorris/add-device-policy
Browse files Browse the repository at this point in the history
Add ability to use WARP/device posture rules and policies
  • Loading branch information
m4xmorris authored Nov 27, 2023
2 parents 793d173 + 9847e11 commit d57ec48
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
12 changes: 12 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,16 @@ resource "cloudflare_access_policy" "email_policy" {
email = var.allowed_emails
}
count = length(var.allowed_emails) == 0 ? 0 : 1
}

resource "cloudflare_access_policy" "device_policy" {
application_id = cloudflare_access_application.application.id
zone_id = var.cloudflare_zone_id
name = "${var.name} Device Policy"
precedence = "10"
decision = var.device_policy_mode
include {
device_posture = var.device_policy_rules
}
count = var.device_policy_mode != "disabled" ? 1 : 0
}
17 changes: 17 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,21 @@ variable "github_teams" {
variable "allowed_emails" {
type = list(string)
description = "List of email addresses permitted to login via OTP"
}

variable "device_policy_mode" {
type = string
description = "Decision mode for the WARP/device policy"
default = "disabled"

validation {
condition = can(regex("^allow$|^deny$|^non_identity$|^bypass$|^disabled$", var.device_policy_mode))
error_message = "Invalid value for device_policy_mode. Must be one of allow, deny, non_identity, bypass, or disabled."
}
}

variable "device_policy_rules" {
type = list(string)
default = []
description = "List of WARP/device posture rule IDs to check for the device policy"
}

0 comments on commit d57ec48

Please sign in to comment.