variable "subscription_id" { description = "Subscription that contains the perimeter, as a GUID. Resources it protects may be in any subscription of the tenant." type = string validation { condition = can(regex("^[0-9a-fA-F-]{36}$", var.subscription_id)) error_message = "Give the subscription ID as a GUID." } } variable "resource_group_name" { description = "Resource group for the perimeter and its alerts." type = string } variable "protected_resource_ids" { description = "Resource IDs of the storage accounts, key vaults, and other perimeter-aware resources to put inside. Each one then answers only the networks and subscriptions named below." type = list(string) validation { condition = length(var.protected_resource_ids) > 0 && alltrue([for id in var.protected_resource_ids : can(regex("^/subscriptions/[^/]+/resourceGroups/[^/]+/providers/", id))]) error_message = "Give at least one resource ID, each a full /subscriptions/.../providers/... ID." } } variable "allowed_ip_ranges" { description = "Public address ranges people and systems work from, as CIDR. Requests from them may enter the perimeter. Empty allows none." type = list(string) default = [] validation { condition = alltrue([for r in var.allowed_ip_ranges : can(cidrhost(r, 0)) && tonumber(split("/", r)[1]) >= (strcontains(r, ":") ? 16 : 8)]) error_message = "Each range must be a CIDR of /8 or narrower for IPv4, /16 or narrower for IPv6. A wider range lets most of the internet in." } } variable "allowed_subscription_ids" { description = "Subscriptions whose resources may call in, such as the ones containing your applications' managed identities, as GUIDs. Each is a way in, so keep the list short. Callers from them must sign in with Microsoft Entra ID; a SAS from those subscriptions is refused." type = list(string) default = [] validation { condition = alltrue([for s in var.allowed_subscription_ids : can(regex("^(/subscriptions/)?[0-9a-fA-F-]{36}$", s))]) error_message = "Give each subscription as a GUID." } } variable "access_mode" { description = "Enforced refuses what the perimeter's rules do not allow, whatever each resource's own firewall says. Learning, which Azure now calls Transition, falls back to each resource's own firewall where the perimeter's rules do not allow, and logs which one decided. Start with Learning, read the log for a week, then switch." type = string default = "Enforced" validation { condition = contains(["Enforced", "Learning"], var.access_mode) error_message = "access_mode is Enforced or Learning." } } variable "log_analytics_workspace_id" { description = "A Log Analytics workspace to receive the perimeter's access log, allowed and refused, with an alert on every refusal. Empty keeps no log." type = string default = "" } variable "alert_emails" { description = "Addresses told about every refusal, and in Learning mode about every request that passed only on a resource's own firewall. Needs log_analytics_workspace_id." type = list(string) default = [] validation { condition = length(distinct([for e in var.alert_emails : lower(e)])) == length(var.alert_emails) error_message = "Name each address once." } } variable "policy_management_group_id" { description = "A management group, as /providers/Microsoft.Management/managementGroups/, where Azure Policy refuses the settings that would carry data around the perimeter in every subscription beneath it. The settings are cross-tenant replication, shared keys, public network access, public blobs, copies from outside the tenant, and key vaults without a firewall. Needs Resource Policy Contributor there." type = string default = "" validation { condition = var.policy_management_group_id == "" || startswith(var.policy_management_group_id, "/providers/Microsoft.Management/managementGroups/") error_message = "Give the management group's full ID, /providers/Microsoft.Management/managementGroups/, or leave it empty." } } variable "assign_policies_to_subscription" { description = "With no management group named, assign the same policies to this template's own subscription. A definition can only be assigned at or below the scope it is made in, so other subscriptions need the management group." type = bool default = false } variable "owner" { description = "Tag contract: accountable team." type = string default = "security-engineering" } variable "environment" { description = "Tag contract: environment." type = string default = "prod" } variable "extra_tags" { description = "Additional tags merged over the contract." type = map(string) default = {} }