Skip to content

Commit 84dc829

Browse files
committed
tf
1 parent 25559a2 commit 84dc829

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

infrastructure/terraform/main.tf

+15-4
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ resource "azurerm_subnet" "example" {
3333
address_prefixes = ["10.0.0.0/23"]
3434
}
3535

36-
3736
resource "azurerm_log_analytics_workspace" "example" {
3837
name = "acctest-01"
3938
location = azurerm_resource_group.colin_spike.location
@@ -52,6 +51,12 @@ resource "azurerm_container_app_environment" "example" {
5251
internal_load_balancer_enabled = true
5352
}
5453

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+
5560
resource "azurerm_container_app" "manage-breast-screening-django" {
5661
# Limited to 32 characters
5762
name = "manage-breast-screening-django"
@@ -60,7 +65,8 @@ resource "azurerm_container_app" "manage-breast-screening-django" {
6065
revision_mode = "Single"
6166

6267
identity {
63-
type = "SystemAssigned"
68+
type = "UserAssigned"
69+
identity_ids = [ azurerm_user_assigned_identity.container_app_identity.id ]
6470
}
6571

6672
dynamic "secret" {
@@ -69,8 +75,7 @@ resource "azurerm_container_app" "manage-breast-screening-django" {
6975
# KV secrets are uppercase and hyphen separated
7076
# app container secrets are lowercase and hyphen separated
7177
name = lower(secret.value.name)
72-
# TODO: create MI
73-
identity = "System"
78+
identity = azurerm_user_assigned_identity.container_app_identity.id
7479
key_vault_secret_id = secret.value.id
7580
}
7681
}
@@ -118,3 +123,9 @@ resource "azurerm_container_app" "manage-breast-screening-django" {
118123
}
119124
}
120125
}
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

Comments
 (0)