-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkeyvault.tf
53 lines (44 loc) · 1.49 KB
/
keyvault.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
data "azurerm_client_config" "current" {}
resource "azurerm_key_vault" "key_vault" {
name = "${local.resource_prefix}-keyvault"
location = azurerm_resource_group.rg.location
resource_group_name = azurerm_resource_group.rg.name
enabled_for_disk_encryption = true
tenant_id = data.azurerm_client_config.current.tenant_id
soft_delete_retention_days = 7
purge_protection_enabled = false
sku_name = "standard"
access_policy {
tenant_id = data.azurerm_client_config.current.tenant_id
object_id = data.azurerm_client_config.current.object_id
key_permissions = [
"Get",
]
secret_permissions = [
"Get",
"Set",
"List",
"Delete",
"Purge",
"Recover"
]
storage_permissions = [
"Get",
]
}
}
resource "azurerm_key_vault_secret" "sqldb_connectionstring" {
name = "${local.resource_prefix}-db-connection-string"
value = local.db_connection_string
key_vault_id = azurerm_key_vault.key_vault.id
}
resource "azurerm_key_vault_secret" "sqldb_admin_password" {
name = "${local.resource_prefix}-db-admin-password"
value = random_password.admin_password.result
key_vault_id = azurerm_key_vault.key_vault.id
}
resource "azurerm_key_vault_secret" "api_admin_key" {
name = "${local.resource_prefix}-admin-api-key"
value = random_password.admin_api_key.result
key_vault_id = azurerm_key_vault.key_vault.id
}