forked from weka/terraform-gcp-weka
-
Notifications
You must be signed in to change notification settings - Fork 0
/
secret_manager.tf
72 lines (63 loc) · 1.82 KB
/
secret_manager.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
resource "google_project_service" "secret_manager" {
service = "secretmanager.googleapis.com"
disable_on_destroy = false
}
resource "google_secret_manager_secret" "secret_weka_password" {
secret_id = "${var.prefix}-${var.cluster_name}-password"
project = var.project_id
replication {
user_managed {
replicas {
location = var.region
}
}
}
depends_on = [google_project_service.secret_manager]
}
resource "google_secret_manager_secret_version" "password_secret_key" {
secret = google_secret_manager_secret.secret_weka_password.id
secret_data = random_password.password.result
lifecycle {
ignore_changes = [secret_data]
}
}
resource "google_secret_manager_secret" "secret_weka_username" {
secret_id = "${var.prefix}-${var.cluster_name}-username"
project = var.project_id
replication {
user_managed {
replicas {
location = var.region
}
}
}
depends_on = [google_project_service.secret_manager]
}
resource "google_secret_manager_secret_version" "user_secret_key" {
secret = google_secret_manager_secret.secret_weka_username.id
secret_data = var.weka_username
lifecycle {
ignore_changes = [secret_data]
}
}
resource "google_secret_manager_secret" "secret_token" {
count = var.get_weka_io_token != "" ? 1 : 0
project = var.project_id
secret_id = "${var.prefix}-${var.cluster_name}-token"
replication {
user_managed {
replicas {
location = var.region
}
}
}
depends_on = [google_project_service.secret_manager]
}
resource "google_secret_manager_secret_version" "token_secret_key" {
count = var.get_weka_io_token != "" ? 1 : 0
secret = google_secret_manager_secret.secret_token[0].id
secret_data = var.get_weka_io_token
lifecycle {
ignore_changes = [secret_data]
}
}