-
Notifications
You must be signed in to change notification settings - Fork 0
/
secrets.tf
57 lines (51 loc) · 1.89 KB
/
secrets.tf
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
data "azurerm_client_config" "current" {}
resource "azurerm_key_vault" "vault" {
name = trim(substr(var.name, -24, -1), "-")
location = var.resource_group.location
resource_group_name = var.resource_group.name
sku_name = "standard"
tenant_id = data.azurerm_client_config.current.tenant_id
enabled_for_deployment = true
soft_delete_retention_days = 7
purge_protection_enabled = false
tags = var.tags
}
resource "azurerm_key_vault_access_policy" "vault_owner_access_policy" {
key_vault_id = azurerm_key_vault.vault.id
tenant_id = data.azurerm_client_config.current.tenant_id
object_id = data.azurerm_client_config.current.object_id
secret_permissions = [
"Delete",
"Get",
"Purge",
"Set",
]
}
resource "azurerm_key_vault_access_policy" "vault_vm_access_policy" {
key_vault_id = azurerm_key_vault.vault.id
tenant_id = data.azurerm_client_config.current.tenant_id
object_id = azurerm_user_assigned_identity.user_assigned_identity.principal_id
secret_permissions = [
"Get",
]
}
resource "azurerm_key_vault_secret" "admin_analytics_registration_password" {
name = join("-", [var.name, "admin", "analytics", "registration", "password"])
value = var.admin_registration_password
key_vault_id = azurerm_key_vault.vault.id
content_type = "DRA admin registration password"
tags = var.tags
depends_on = [
azurerm_key_vault_access_policy.vault_owner_access_policy
]
}
resource "azurerm_key_vault_secret" "ssh_password" {
name = join("-", [var.name, "admin", "ssh", "password"])
value = var.admin_ssh_password
key_vault_id = azurerm_key_vault.vault.id
content_type = "DRA Admin ssh password"
tags = var.tags
depends_on = [
azurerm_key_vault_access_policy.vault_owner_access_policy
]
}