-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathsecrets.tf
61 lines (51 loc) · 1.38 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
58
59
60
61
resource "random_id" "server" {
keepers = {
ami_id = 1
}
byte_length = 8
}
#
# Create random password for BIG-IP
#
resource "random_password" "password" {
length = 16
min_upper = 1
min_lower = 1
min_numeric = 1
min_special = 1
special = true
override_special = "_%@"
}
resource "azurerm_key_vault" "bigip-vault" {
name = format("kv%s", random_id.randomId.hex)
location = azurerm_resource_group.main.location
resource_group_name = azurerm_resource_group.main.name
tenant_id = data.azurerm_client_config.current.tenant_id
sku_name = "premium"
access_policy {
tenant_id = data.azurerm_client_config.current.tenant_id
object_id = data.azurerm_client_config.current.object_id
key_permissions = [
"create",
"get",
]
secret_permissions = [
"set",
"get",
"delete",
"list",
]
}
tags = {
environment = var.environment
}
}
resource "azurerm_key_vault_secret" "bigip-password" {
name = format("bigip-password-%s",random_id.randomId.hex)
value = random_password.password.result
key_vault_id = azurerm_key_vault.bigip-vault.id
tags = {
environment = var.environment
}
}
data "azurerm_client_config" "current" {}