-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathkey_vault.tf
84 lines (74 loc) · 2.05 KB
/
key_vault.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
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
locals {
# https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/key_vault#certificate_permissions
all_certificate_permissions = [
"Get",
"List",
"Update",
"Create",
"Import",
"Delete",
"Recover",
"Backup",
"Restore",
"ManageContacts",
"ManageIssuers",
"GetIssuers",
"ListIssuers",
"SetIssuers",
"DeleteIssuers",
]
all_key_permissions = [
"Get",
"List",
"Update",
"Create",
"Import",
"Delete",
"Recover",
"Backup",
"Restore",
"GetRotationPolicy",
"SetRotationPolicy",
"Rotate",
]
all_secret_permissions = [
"Get",
"List",
"Set",
"Delete",
"Recover",
"Backup",
"Restore",
]
}
resource "azurerm_key_vault" "main" {
name = "KV-CDT-PUB-CALITP-${local.env_letter}-001"
location = data.azurerm_resource_group.main.location
resource_group_name = data.azurerm_resource_group.main.name
sku_name = "standard"
tenant_id = data.azurerm_client_config.current.tenant_id
purge_protection_enabled = true
access_policy {
tenant_id = data.azurerm_client_config.current.tenant_id
object_id = var.ENGINEERING_GROUP_OBJECT_ID
certificate_permissions = local.all_certificate_permissions
key_permissions = local.all_key_permissions
secret_permissions = local.all_secret_permissions
}
access_policy {
tenant_id = data.azurerm_client_config.current.tenant_id
object_id = var.DEVSECOPS_OBJECT_ID
key_permissions = local.all_key_permissions
secret_permissions = local.all_secret_permissions
}
# https://learn.microsoft.com/en-us/azure/app-service/app-service-key-vault-references?tabs=azure-cli#granting-your-app-access-to-key-vault
access_policy {
tenant_id = data.azurerm_client_config.current.tenant_id
object_id = azurerm_linux_web_app.main.identity.0.principal_id
secret_permissions = ["Get"]
}
lifecycle {
prevent_destroy = true
ignore_changes = [tags]
}
}