This repository was archived by the owner on Mar 21, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgcp-compute-keys.tf
66 lines (55 loc) · 2.27 KB
/
gcp-compute-keys.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
# Main Project
resource "google_kms_key_ring" "disks_global_1" {
name = "foundations-disks-1"
location = "global"
depends_on = [
google_project_service.cloudkms
]
}
# Note: the Terraform service account must be given the Cloud KMS Admin role or another role with
# the cloudkms.keyRings.setIamPolicy permission, such as the Security Admin role, so that it can
# manage the roles for GCP's own service accounts. You can manually do this from the IAM & Admin
# console.
resource "google_kms_key_ring_iam_member" "disks_global_1_service_tf" {
key_ring_id = google_kms_key_ring.disks_global_1.id
role = "roles/cloudkms.cryptoKeyEncrypterDecrypter"
member = "serviceAccount:service-${google_project.foundations.number}@compute-system.iam.gserviceaccount.com"
}
resource "google_kms_crypto_key" "disk_global_1_1" {
name = "foundations-disk-1-1"
key_ring = google_kms_key_ring.disks_global_1.id
purpose = "ENCRYPT_DECRYPT"
rotation_period = "7770000s"
lifecycle {
prevent_destroy = true
}
}
# Planktoscope Project
resource "google_kms_key_ring" "disks_planktoscope_global_1" {
provider = google.planktoscope
name = "foundations-disks-1"
location = "global"
depends_on = [
google_project_service.cloudkms
]
}
# Note: the Terraform service account must be given the Cloud KMS Admin role or another role with
# the cloudkms.keyRings.setIamPolicy permission, such as the Security Admin role, so that it can
# manage the roles for GCP's own service accounts. You can manually do this from the IAM & Admin
# console.
resource "google_kms_key_ring_iam_member" "disks_planktoscope_global_1_service_tf" {
provider = google.planktoscope
key_ring_id = google_kms_key_ring.disks_planktoscope_global_1.id
role = "roles/cloudkms.cryptoKeyEncrypterDecrypter"
member = "serviceAccount:service-${google_project.foundations_planktoscope.number}@compute-system.iam.gserviceaccount.com"
}
resource "google_kms_crypto_key" "disk_planktoscope_global_1_1" {
provider = google.planktoscope
name = "foundations-disk-1-1"
key_ring = google_kms_key_ring.disks_planktoscope_global_1.id
purpose = "ENCRYPT_DECRYPT"
rotation_period = "7770000s"
lifecycle {
prevent_destroy = true
}
}