Skip to content

Commit 1fe210e

Browse files
committed
feat: [DTOSS-8469] implement policy remediation
1 parent db7269a commit 1fe210e

File tree

6 files changed

+24
-11
lines changed

6 files changed

+24
-11
lines changed

infrastructure/modules/policy/policy-assignments/variables.tf

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ variable "parameters" {
4949
description = "Parameters for the policy assignment."
5050
}
5151

52-
5352
variable "policy_assignment_scope" {
5453
type = string
5554
description = "The scope at which this assignment is assigned"
@@ -87,5 +86,3 @@ variable "requires_identity" {
8786
description = "True if the policy requires a managed identity, false otherwise"
8887
default = false
8988
}
90-
91-

infrastructure/modules/policy/policy-definition/variables.tf

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ variable "policy_rule" {
5252
type = object({
5353
if = any
5454
then = object({
55-
effect = string
55+
effect = string
56+
details = optional(any)
5657
})
5758
})
5859
validation {
@@ -70,6 +71,7 @@ Azure Policy Rule object. Must follow Microsoft schema:
7071
},
7172
"then": {
7273
"effect": "deny | audit | modify | denyAction | append | auditIfNotExists | deployIfNotExists | disabled"
74+
"details": <policy details>
7375
}
7476
}
7577
EOT
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
1-
2-
1+
resource "azurerm_resource_policy_remediation" "remediation" {
2+
name = var.remediation_name
3+
policy_assignment_id = var.policy_assignment_id
4+
resource_discovery_mode = "ExistingNonCompliant"
5+
resource_id = var.resource_id
6+
}
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
1+
output "policy_remediation_id" {
2+
value = azurerm_resource_policy_remediation.remediation.id
3+
description = "The ID of the created policy remediation."
4+
}
Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1+
variable "remediation_name" {
2+
type = string
3+
description = "The policy remediation name."
4+
}
15

2-
variable "policy_assignment_scope" {
6+
variable "policy_assignment_id" {
37
type = string
4-
description = "The scope at which this assignment is assigned"
8+
description = "The identifier of a specific policy assignment."
59
}
610

7-
variable "policy_assignment_principal_id" {
11+
variable "resource_id" {
812
type = string
9-
description = "The identifier of a specific service principal to use for the policy assignment"
13+
description = "The identifier of a specific resource to apply this policy onto."
14+
default = null
1015
}

infrastructure/modules/shared-config/output.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ locals {
9393
network-interface = upper("${var.env}-${var.location_map[var.location]}-${var.application}")
9494
network-security-group = upper("NSG-${var.env}-${var.location_map[var.location]}-${var.application}")
9595
postgres-sql-server = lower("postgres-${var.application}-${var.env}-${var.location_map[var.location]}")
96+
policy-definition = lower("policy-def-${var.application}-${var.env}-${var.location_map[var.location]}")
97+
policy-assignment = lower("policy-assign-${var.application}-${var.env}-${var.location_map[var.location]}")
9698
private-ssh-key = lower("ssh-pri-${var.env}${var.location_map[var.location]}${var.application}")
9799
private-link-scope = lower("ampls-${var.env}${var.application}")
98100
private-link-scope-private-endpoint = lower("ampls-${var.env}${var.location_map[var.location]}${var.application}-private-endpoint")

0 commit comments

Comments
 (0)