Skip to content

Commit 103f8f1

Browse files
authored
feat: add permissions for aks agentless discovery (#38)
1 parent 2c5236a commit 103f8f1

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

modules/services/service-principal/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ No modules.
5555
| <a name="input_sysdig_client_id"></a> [sysdig\_client\_id](#input\_sysdig\_client\_id) | The application ID of the service client in the Sysdig tenant. Service principal will be created for this application client ID | `string` | n/a | yes |
5656
| <a name="input_is_organizational"></a> [is\_organizational](#input\_is\_organizational) | true/false whether secure-for-cloud should be deployed in an organizational setup (all subscriptions of tenant) or not (only on default azure provider subscription) | `bool` | `false` | no |
5757
| <a name="input_management_group_ids"></a> [management\_group\_ids](#input\_management\_group\_ids) | List of Azure Management Group IDs. secure-for-cloud will be deployed to all the subscriptions under these management groups. | `set(string)` | `[]` | no |
58+
| <a name="agentless_aks_connection_enabled"></a> [agentless\_aks\_connection\_enabled](#input\_agentless\_aks\_connection\_enabled) | true/false whether secure-for-cloud should be deployed with access to the Azure AKS clusters | `bool` | `false` | no |
5859

5960
## Outputs
6061

modules/services/service-principal/main.tf

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@ data "azurerm_subscription" "primary" {
66
subscription_id = var.subscription_id
77
}
88

9+
10+
locals {
11+
sysdig_cspm_role_default_permissions_actions = ["Microsoft.Web/sites/config/list/action"]
12+
agentless_aks_connection_permissions_actions = var.agentless_aks_connection_enabled ? ["Microsoft.ContainerService/managedClusters/listClusterAdminCredential/action"] : []
13+
14+
sysdig_cspm_role_permissions_actions = tolist(setunion(local.sysdig_cspm_role_default_permissions_actions, local.agentless_aks_connection_permissions_actions))
15+
}
16+
917
#---------------------------------------------------------------------------------------------
1018
# Create service principal in customer tenant
1119
#
@@ -50,9 +58,7 @@ resource "azurerm_role_definition" "sysdig_cspm_role" {
5058
description = "Custom role for collecting Authsettings for CIS Benchmark"
5159

5260
permissions {
53-
actions = [
54-
"Microsoft.Web/sites/config/list/action"
55-
]
61+
actions = local.sysdig_cspm_role_permissions_actions
5662
not_actions = []
5763
}
5864

@@ -68,4 +74,4 @@ resource "azurerm_role_assignment" "sysdig_cspm_role_assignment" {
6874
scope = data.azurerm_subscription.primary.id
6975
role_definition_id = azurerm_role_definition.sysdig_cspm_role.role_definition_resource_id
7076
principal_id = azuread_service_principal.sysdig_sp.object_id
71-
}
77+
}

modules/services/service-principal/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,9 @@ variable "management_group_ids" {
1919
type = set(string)
2020
default = []
2121
}
22+
23+
variable "agentless_aks_connection_enabled" {
24+
type = bool
25+
description = "Enable the Agentless AKS connection to the K8s clusters within the cloud. This allows admin access. Read more about why this is needed in the official docs."
26+
default = false
27+
}

0 commit comments

Comments
 (0)