-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgcp-storage-keys.tf
142 lines (119 loc) · 4.86 KB
/
gcp-storage-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
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# Main Project
data "google_storage_project_service_account" "default" {
depends_on = [
google_project_service.iam
]
}
resource "google_kms_key_ring" "buckets_global_1" {
name = "foundations-buckets-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" "buckets_global_1_service_tf" {
key_ring_id = google_kms_key_ring.buckets_global_1.id
role = "roles/cloudkms.cryptoKeyEncrypterDecrypter"
member = "serviceAccount:${data.google_storage_project_service_account.default.email_address}"
}
resource "google_kms_crypto_key" "bucket_global_1_1" {
name = "foundations-bucket-1-1"
key_ring = google_kms_key_ring.buckets_global_1.id
purpose = "ENCRYPT_DECRYPT"
rotation_period = "7770000s"
lifecycle {
prevent_destroy = true
}
}
resource "google_kms_key_ring" "buckets_us_west1_1" {
name = "foundations-buckets-us-west1-1"
location = "us-west1"
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" "buckets_us_west1_1_service_tf" {
key_ring_id = google_kms_key_ring.buckets_us_west1_1.id
role = "roles/cloudkms.cryptoKeyEncrypterDecrypter"
member = "serviceAccount:${data.google_storage_project_service_account.default.email_address}"
}
resource "google_kms_crypto_key" "bucket_us_west1_1_1" {
name = "foundations-bucket-us_west1-1-1"
key_ring = google_kms_key_ring.buckets_us_west1_1.id
purpose = "ENCRYPT_DECRYPT"
rotation_period = "7770000s"
lifecycle {
prevent_destroy = true
}
}
# Planktoscope Project
data "google_storage_project_service_account" "default_planktoscope" {
provider = google.planktoscope
depends_on = [
google_project_service.iam_planktoscope
]
}
resource "google_kms_key_ring" "buckets_planktoscope_global_1" {
provider = google.planktoscope
name = "foundations-buckets-1"
location = "global"
depends_on = [
google_project_service.cloudkms_planktoscope
]
}
# 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" "buckets_planktoscope_global_1_service_tf" {
provider = google.planktoscope
key_ring_id = google_kms_key_ring.buckets_planktoscope_global_1.id
role = "roles/cloudkms.cryptoKeyEncrypterDecrypter"
member = "serviceAccount:${data.google_storage_project_service_account.default_planktoscope.email_address}"
}
resource "google_kms_crypto_key" "bucket_planktoscope_global_1_1" {
provider = google.planktoscope
name = "foundations-bucket-1-1"
key_ring = google_kms_key_ring.buckets_planktoscope_global_1.id
purpose = "ENCRYPT_DECRYPT"
rotation_period = "7770000s"
lifecycle {
prevent_destroy = true
}
}
resource "google_kms_key_ring" "buckets_planktoscope_us_west1_1" {
provider = google.planktoscope
name = "foundations-buckets-us-west1-1"
location = "us-west1"
depends_on = [
google_project_service.cloudkms_planktoscope
]
}
# 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" "buckets_planktoscope_us_west1_1_service_tf" {
provider = google.planktoscope
key_ring_id = google_kms_key_ring.buckets_planktoscope_us_west1_1.id
role = "roles/cloudkms.cryptoKeyEncrypterDecrypter"
member = "serviceAccount:${data.google_storage_project_service_account.default_planktoscope.email_address}"
}
resource "google_kms_crypto_key" "bucket_planktoscope_us_west1_1_1" {
provider = google.planktoscope
name = "foundations-bucket-us_west1-1-1"
key_ring = google_kms_key_ring.buckets_planktoscope_us_west1_1.id
purpose = "ENCRYPT_DECRYPT"
rotation_period = "7770000s"
lifecycle {
prevent_destroy = true
}
}