-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathmain.tf
More file actions
118 lines (103 loc) · 2.69 KB
/
main.tf
File metadata and controls
118 lines (103 loc) · 2.69 KB
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# Copyright IBM Corp. 2021, 2025
# SPDX-License-Identifier: MPL-2.0
# Vault AppRole
# -------------
resource "hcp_vault_cluster" "test" {
cluster_id = var.hcp_vault_cluster_id
hvn_id = var.hcp_vault_cluster_hvn_id
public_endpoint = var.hcp_vault_cluster_public_endpoint
tier = var.hcp_vault_cluster_tier
}
resource "hcp_vault_cluster_admin_token" "test" {
cluster_id = hcp_vault_cluster.test.cluster_id
}
# Vault Policy
# -------------
resource "vault_policy" "ptfe" {
name = var.vault_policy_name
policy = <<EOT
# To renew leases.
path "sys/leases/renew" {
capabilities = ["create", "update"]
}
path "sys/renew" {
capabilities = ["create", "update"]
}
# To renew tokens.
path "auth/token/renew" {
capabilities = ["create", "update"]
}
path "auth/token/renew-self" {
capabilities = ["create", "update"]
}
# To perform a login.
path "auth/approle/login" {
capabilities = ["create", "update"]
}
# To upsert transit keys used for key generation.
path "transit/keys/atlas_*" {
capabilities = ["read", "create", "update"]
}
path "transit/keys/archivist_*" {
capabilities = ["read", "create", "update"]
}
# Encryption and decryption of data.
path "transit/encrypt/atlas_*" {
capabilities = ["create", "update"]
}
path "transit/decrypt/atlas_*" {
capabilities = ["create", "update"]
}
path "transit/encrypt/archivist_*" {
capabilities = ["create", "update"]
}
path "transit/decrypt/archivist_*" {
capabilities = ["create", "update"]
}
# For performing key derivation.
path "transit/datakey/plaintext/archivist_*" {
capabilities = ["create", "update"]
}
# For backup/restore operations.
path "transit/keys/atlas_*/config" {
capabilities = ["read", "create", "update"]
}
path "transit/backup/atlas_*" {
capabilities = ["read"]
}
path "transit/restore/atlas_*" {
capabilities = ["read", "create", "update"]
}
path "transit/keys/archivist_*/config" {
capabilities = ["read", "create", "update"]
}
path "transit/backup/archivist_*" {
capabilities = ["read"]
}
path "transit/restore/archivist_*" {
capabilities = ["read", "create", "update"]
}
# For health checks to read the mount table.
path "sys/mounts" {
capabilities = ["read"]
}
EOT
}
# Vault AppRole
# -------------
resource "vault_auth_backend" "approle" {
type = "approle"
}
resource "vault_approle_auth_backend_role" "approle" {
backend = vault_auth_backend.approle.path
role_name = var.vault_role_name
token_policies = [vault_policy.ptfe.name]
}
resource "vault_approle_auth_backend_role_secret_id" "approle" {
backend = vault_auth_backend.approle.path
role_name = vault_approle_auth_backend_role.approle.role_name
}
resource "vault_mount" "transit" {
path = "transit"
type = "transit"
}