@@ -33,7 +33,6 @@ resource "azurerm_subnet" "example" {
33
33
address_prefixes = [" 10.0.0.0/23" ]
34
34
}
35
35
36
-
37
36
resource "azurerm_log_analytics_workspace" "example" {
38
37
name = " acctest-01"
39
38
location = azurerm_resource_group. colin_spike . location
@@ -52,6 +51,12 @@ resource "azurerm_container_app_environment" "example" {
52
51
internal_load_balancer_enabled = true
53
52
}
54
53
54
+ resource "azurerm_user_assigned_identity" "container_app_identity" {
55
+ name = " container-app-identity"
56
+ location = azurerm_resource_group. colin_spike . location
57
+ resource_group_name = azurerm_resource_group. colin_spike . name
58
+ }
59
+
55
60
resource "azurerm_container_app" "manage-breast-screening-django" {
56
61
# Limited to 32 characters
57
62
name = " manage-breast-screening-django"
@@ -60,7 +65,8 @@ resource "azurerm_container_app" "manage-breast-screening-django" {
60
65
revision_mode = " Single"
61
66
62
67
identity {
63
- type = " SystemAssigned"
68
+ type = " UserAssigned"
69
+ identity_ids = [ azurerm_user_assigned_identity . container_app_identity . id ]
64
70
}
65
71
66
72
dynamic "secret" {
@@ -69,8 +75,7 @@ resource "azurerm_container_app" "manage-breast-screening-django" {
69
75
# KV secrets are uppercase and hyphen separated
70
76
# app container secrets are lowercase and hyphen separated
71
77
name = lower (secret. value . name )
72
- # TODO: create MI
73
- identity = " System"
78
+ identity = azurerm_user_assigned_identity. container_app_identity . id
74
79
key_vault_secret_id = secret. value . id
75
80
}
76
81
}
@@ -118,3 +123,9 @@ resource "azurerm_container_app" "manage-breast-screening-django" {
118
123
}
119
124
}
120
125
}
126
+
127
+ resource "azurerm_role_assignment" "key_vault_reader" {
128
+ scope = azurerm_resource_group. colin_spike . id
129
+ role_definition_name = " Key Vault Reader"
130
+ principal_id = azurerm_user_assigned_identity. container_app_identity . principal_id
131
+ }
0 commit comments