-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrole_assignments.tf
More file actions
133 lines (110 loc) · 6.56 KB
/
role_assignments.tf
File metadata and controls
133 lines (110 loc) · 6.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
locals {
create_role_assignment = var.create_role_assignment ? 1 : 0
agent_role_assignment_resource_groups = var.create_role_assignment ? local.resource_groups : {}
redpanda_operator_namespace = "redpanda"
# aks_oidc_issuer_url = "https://TODO"
}
// Allow storing Redpanda TF state to storage
resource "azurerm_role_assignment" "assign_identity_storage_blob_data_contributor" {
count = local.create_role_assignment
scope = azurerm_storage_account.management.id
principal_id = azurerm_user_assigned_identity.redpanda_agent.principal_id
role_definition_name = "Storage Blob Data Contributor"
}
// Allow access to key vault
resource "azurerm_role_assignment" "vault_secrets_officer" {
count = local.create_role_assignment
scope = local.redpanda_resource_group.id
principal_id = data.azurerm_client_config.current.object_id
role_definition_name = "Key Vault Secrets Officer"
}
resource "azurerm_role_assignment" "agent" {
for_each = local.agent_role_assignment_resource_groups
principal_id = azurerm_user_assigned_identity.redpanda_agent.principal_id
scope = each.value.id
role_definition_id = azurerm_role_definition.redpanda_agent.role_definition_resource_id
}
resource "azurerm_role_assignment" "aks_network_contributor" {
count = local.create_role_assignment
scope = local.redpanda_network_resource_group.id
principal_id = azurerm_user_assigned_identity.aks.principal_id
role_definition_name = "Network Contributor"
}
resource "azurerm_role_assignment" "redpanda_private_link" {
count = local.create_role_assignment
principal_id = azurerm_user_assigned_identity.aks.principal_id
scope = local.redpanda_resource_group.id
role_definition_id = azurerm_role_definition.redpanda_private_link.role_definition_resource_id
}
resource "azurerm_role_assignment" "redpanda_cluster" {
count = local.create_role_assignment
principal_id = azurerm_user_assigned_identity.redpanda_cluster.principal_id
# See https://learn.microsoft.com/en-us/azure/role-based-access-control/troubleshooting?tabs=bicep#symptom---assigning-a-role-to-a-new-principal-sometimes-fails
principal_type = "ServicePrincipal"
scope = azurerm_storage_account.tiered_storage.id
role_definition_name = "Storage Blob Data Contributor"
}
resource "azurerm_role_assignment" "redpanda_console" {
count = local.create_role_assignment
principal_id = azurerm_user_assigned_identity.redpanda_console.principal_id
scope = azurerm_key_vault.console[0].id
role_definition_id = azurerm_role_definition.redpanda_console.role_definition_resource_id
}
resource "azurerm_role_assignment" "cert_manager" {
count = local.create_role_assignment
# In TF provisioner, the scope is a DNS zone specific resource. We change it to RG here since DNS zone is not avaiable until cluster is being deployed.
# scope = "/subscriptions/60fc0bed-3072-4c53-906a-d130a934d520/resourceGroups/rg-rpcloud-cqclghd44f471cmf8ojg/providers/Microsoft.Network/dnsZones/cqclghd44f471cmf8ojg.byoc.ign.cloud.redpanda.com"
scope = local.redpanda_resource_group.id
role_definition_name = "DNS Zone Contributor"
principal_id = azurerm_user_assigned_identity.cert_manager.principal_id
# See https://learn.microsoft.com/en-us/azure/role-based-access-control/troubleshooting?tabs=bicep#symptom---assigning-a-role-to-a-new-principal-sometimes-fails
principal_type = "ServicePrincipal"
}
resource "azurerm_role_assignment" "external_dns_zone_contributor" {
count = local.create_role_assignment
# In TF provisioner, the scope is a DNS zone specific resource. We change it to RG here since DNS zone is not avaiable until cluster is being deployed.
#scope = "/subscriptions/60fc0bed-3072-4c53-906a-d130a934d520/resourceGroups/rg-rpcloud-cqclghd44f471cmf8ojg/providers/Microsoft.Network/dnsZones/cqclghd44f471cmf8ojg.byoc.ign.cloud.redpanda.com"
scope = local.redpanda_resource_group.id
role_definition_name = "DNS Zone Contributor"
principal_id = azurerm_user_assigned_identity.external_dns.principal_id
# See https://learn.microsoft.com/en-us/azure/role-based-access-control/troubleshooting?tabs=bicep#symptom---assigning-a-role-to-a-new-principal-sometimes-fails
principal_type = "ServicePrincipal"
}
resource "azurerm_role_assignment" "external_dns_rgreader" {
count = local.create_role_assignment
scope = local.redpanda_resource_group.id
role_definition_name = "Reader"
principal_id = azurerm_user_assigned_identity.external_dns.principal_id
# See https://learn.microsoft.com/en-us/azure/role-based-access-control/troubleshooting?tabs=bicep#symptom---assigning-a-role-to-a-new-principal-sometimes-fails
principal_type = "ServicePrincipal"
}
resource "azurerm_role_assignment" "kafka_connect" {
count = local.create_role_assignment
principal_id = azurerm_user_assigned_identity.kafka_connect.principal_id
scope = azurerm_key_vault.console[0].id
role_definition_id = azurerm_role_definition.kafka_connect.role_definition_resource_id
}
resource "azurerm_role_assignment" "redpanda_connect" {
count = local.create_role_assignment
principal_id = azurerm_user_assigned_identity.redpanda_connect.principal_id
scope = azurerm_key_vault.console[0].id
role_definition_id = azurerm_role_definition.redpanda_connect.role_definition_resource_id
}
resource "azurerm_role_assignment" "redpanda_connect_api" {
count = local.create_role_assignment
principal_id = azurerm_user_assigned_identity.redpanda_connect_api.principal_id
scope = azurerm_key_vault.console[0].id
role_definition_id = azurerm_role_definition.redpanda_connect_api.role_definition_resource_id
}
resource "azurerm_role_assignment" "redpanda_cluster_secrets_reader" {
count = local.create_role_assignment
principal_id = azurerm_user_assigned_identity.redpanda_cluster.principal_id
scope = azurerm_key_vault.console[0].id
role_definition_id = azurerm_role_definition.redpanda_secrets_reader.role_definition_resource_id
}
resource "azurerm_role_assignment" "redpanda_operator_secrets_reader" {
count = local.create_role_assignment
principal_id = azurerm_user_assigned_identity.redpanda_operator.principal_id
scope = azurerm_key_vault.console[0].id
role_definition_id = azurerm_role_definition.redpanda_secrets_reader.role_definition_resource_id
}