Skip to content

Commit 5838afe

Browse files
authored
SSPROD-35351: Azure CSPM roles (#23)
* Update * SSPROD-35351: Add custom CSPM role for Authsettings and remove other roles * Update lifecycle macro * Updating version for sysdig provider
1 parent 3eed38a commit 5838afe

File tree

3 files changed

+39
-18
lines changed

3 files changed

+39
-18
lines changed

modules/services/service-principal/main.tf

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,21 +41,31 @@ resource "azurerm_role_assignment" "sysdig_reader" {
4141
role_definition_name = "Reader"
4242
principal_id = azuread_service_principal.sysdig_sp.object_id
4343
}
44-
4544
#---------------------------------------------------------------------------------------------
46-
# Assign "Azure Kubernetes Service Cluster User Role" role to Sysdig SP for primary subscription
45+
# Create a Custom role for collecting authsettings
4746
#---------------------------------------------------------------------------------------------
48-
resource "azurerm_role_assignment" "sysdig_k8s_reader" {
49-
scope = data.azurerm_subscription.primary.id
50-
role_definition_name = "Azure Kubernetes Service Cluster User Role"
51-
principal_id = azuread_service_principal.sysdig_sp.object_id
47+
resource "azurerm_role_definition" "sysdig_cspm_role" {
48+
name = "sysdig-cspm-role"
49+
scope = data.azurerm_subscription.primary.id
50+
description = "Custom role for collecting Authsettings for CIS Benchmark"
51+
52+
permissions {
53+
actions = [
54+
"Microsoft.Web/sites/config/list/action"
55+
]
56+
not_actions = []
57+
}
58+
59+
assignable_scopes = [
60+
data.azurerm_subscription.primary.id,
61+
]
5262
}
5363

5464
#---------------------------------------------------------------------------------------------
55-
# Assign "Virtual Machine User Login" role to Sysdig SP for primary subscription
65+
# Custom role assignment for collecting authsettings
5666
#---------------------------------------------------------------------------------------------
57-
resource "azurerm_role_assignment" "sysdig_vm_user" {
67+
resource "azurerm_role_assignment" "sysdig_cspm_role_assignment" {
5868
scope = data.azurerm_subscription.primary.id
59-
role_definition_name = "Virtual Machine User Login"
69+
role_definition_id = azurerm_role_definition.sysdig_cspm_role.role_definition_resource_id
6070
principal_id = azuread_service_principal.sysdig_sp.object_id
6171
}

modules/services/service-principal/organizational.tf

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,23 +24,34 @@ resource "azurerm_role_assignment" "sysdig_reader_for_tenant" {
2424
}
2525

2626
#---------------------------------------------------------------------------------------------
27-
# Assign "Azure Kubernetes Service Cluster User Role" role to Sysdig SP for customer tenant
27+
# Create a Custom role for collecting authsettings
2828
#---------------------------------------------------------------------------------------------
29-
resource "azurerm_role_assignment" "sysdig_k8s_reader_for_tenant" {
29+
resource "azurerm_role_definition" "sysdig_cspm_role_for_tenant" {
3030
for_each = var.is_organizational ? local.management_groups : []
3131

32-
scope = each.key
33-
role_definition_name = "Azure Kubernetes Service Cluster User Role"
34-
principal_id = azuread_service_principal.sysdig_sp.object_id
32+
name = "sysdig_cspm_role_for_tenant_${each.key}"
33+
scope = each.key
34+
description = "Custom role for collecting Authsettings for CIS Benchmark"
35+
36+
permissions {
37+
actions = [
38+
"Microsoft.Web/sites/config/list/action"
39+
]
40+
not_actions = []
41+
}
42+
43+
assignable_scopes = [
44+
each.key,
45+
]
3546
}
3647

3748
#---------------------------------------------------------------------------------------------
38-
# Assign "Virtual Machine User Login" role to Sysdig SP for customer tenant
49+
# Custom role assignment for collecting authsettings
3950
#---------------------------------------------------------------------------------------------
40-
resource "azurerm_role_assignment" "sysdig_vm_user_for_tenant" {
51+
resource "azurerm_role_assignment" "sysdig_cspm_role_assignment_for_tenant" {
4152
for_each = var.is_organizational ? local.management_groups : []
4253

4354
scope = each.key
44-
role_definition_name = "Virtual Machine User Login"
55+
role_definition_id = azurerm_role_definition.sysdig_cspm_role_for_tenant[each.key].role_definition_resource_id
4556
principal_id = azuread_service_principal.sysdig_sp.object_id
4657
}

modules/services/service-principal/versions.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ terraform {
1212
}
1313
sysdig = {
1414
source = "sysdiglabs/sysdig"
15-
version = ">= 1.18.0"
15+
version = ">= 1.19.0"
1616
}
1717
}
1818
}

0 commit comments

Comments
 (0)