Skip to content

Commit 6ea0ce9

Browse files
committed
Modify tiles_tlog for TesseraCT
Update tiles_tlog to accomodate minor differences in TesseraCT from rekor-tiles: - Add resources to manage secrets in Secret Manager instead of KMS - The private key secret version needs to be uploaded out of band - Make URL map paths configurable - When updating for rekor-tiles, operator needs to be aware that http_write_path, grpc_write_path, http_read_path, and http_read_rewrite_path need to be set to appropriate values for rekor-tiles - Rename some resources so they do not collide if rekor-tiles and TesseraCT happen to have the same shard name - Make gRPC load balancer routes optional Signed-off-by: Colleen Murphy <[email protected]>
1 parent 5a81aec commit 6ea0ce9

File tree

4 files changed

+107
-14
lines changed

4 files changed

+107
-14
lines changed

gcp/modules/tiles_tlog/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ resource "google_project_service" "service" {
2424
"spanner.googleapis.com", // For Spanner database. roles/spanner.admin
2525
"storage.googleapis.com", // For GCS bucket. roles/storage.admin
2626
"cloudkms.googleapis.com", // For KMS keyring and crypto key. roles/cloudkms.admin
27+
"secretmanager.googleapis.com", // For Secret manager if log is using Secret Manager instead of KMS. roles/secretmanager.admin
2728
])
2829
project = var.project_id
2930
service = each.key

gcp/modules/tiles_tlog/network.tf

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ resource "google_compute_firewall" "backend_service_health_check" {
5656
target_tags = [local.cluster_network_tag]
5757
allow {
5858
protocol = "tcp"
59-
ports = [var.http_service_port, var.grpc_service_port]
59+
ports = var.network_endpoint_group_grpc_name_suffix == "" ? [var.http_service_port] : [var.http_service_port, var.grpc_service_port]
6060
}
6161
}
6262

@@ -81,7 +81,7 @@ resource "google_compute_health_check" "http_health_check" {
8181
}
8282

8383
resource "google_compute_health_check" "grpc_health_check" {
84-
count = var.freeze_shard ? 0 : 1
84+
count = var.freeze_shard || var.network_endpoint_group_grpc_name_suffix == "" ? 0 : 1
8585
name = "${var.shard_name}-${var.dns_subdomain_name}-grpc-health-check"
8686
project = var.project_id
8787

@@ -108,7 +108,7 @@ data "google_compute_network_endpoint_group" "k8s_http_neg" {
108108
}
109109

110110
data "google_compute_network_endpoint_group" "k8s_grpc_neg" {
111-
for_each = var.freeze_shard ? [] : toset(var.network_endpoint_group_zones)
111+
for_each = var.freeze_shard || var.network_endpoint_group_grpc_name_suffix == "" ? [] : toset(var.network_endpoint_group_zones)
112112

113113
name = "${var.shard_name}-${var.network_endpoint_group_grpc_name_suffix}"
114114
project = var.project_id
@@ -117,7 +117,7 @@ data "google_compute_network_endpoint_group" "k8s_grpc_neg" {
117117

118118
resource "google_compute_security_policy" "k8s_http_grpc_security_policy" {
119119
count = var.freeze_shard ? 0 : 1
120-
name = "${var.shard_name}-k8s-http-grpc-security-policy"
120+
name = "${var.shard_name}-${var.dns_subdomain_name}-k8s-http-grpc-security-policy"
121121
project = var.project_id
122122
type = "CLOUD_ARMOR"
123123

@@ -213,7 +213,7 @@ resource "google_compute_backend_service" "k8s_http_backend_service" {
213213
}
214214

215215
resource "google_compute_backend_service" "k8s_grpc_backend_service" {
216-
count = var.freeze_shard ? 0 : 1
216+
count = var.freeze_shard || var.network_endpoint_group_grpc_name_suffix == "" ? 0 : 1
217217
name = "${var.shard_name}-${var.dns_subdomain_name}-k8s-grpc-neg-backend-service"
218218
project = var.project_id
219219

@@ -245,7 +245,7 @@ resource "google_compute_backend_service" "k8s_grpc_backend_service" {
245245
}
246246

247247
resource "google_compute_security_policy" "bucket_security_policy" {
248-
name = "${var.shard_name}-bucket-security-policy"
248+
name = "${var.shard_name}-${var.dns_subdomain_name}-bucket-security-policy"
249249
project = var.project_id
250250
type = "CLOUD_ARMOR_EDGE"
251251

@@ -263,7 +263,7 @@ resource "google_compute_security_policy" "bucket_security_policy" {
263263
}
264264

265265
resource "google_compute_backend_bucket" "tessera_backend_bucket" {
266-
name = "${var.shard_name}-${var.bucket_name_suffix}"
266+
name = "${var.shard_name}-${var.dns_subdomain_name}-${var.bucket_name_suffix}"
267267
project = var.project_id
268268

269269
depends_on = [google_storage_bucket.tessera_store, google_compute_security_policy.bucket_security_policy]
@@ -307,33 +307,36 @@ resource "google_compute_url_map" "url_map" {
307307
priority = 1
308308
service = google_compute_backend_service.k8s_http_backend_service[0].id
309309
match_rules {
310-
full_path_match = "/api/v2/log/entries"
310+
path_template_match = var.http_write_path
311311
}
312312
match_rules {
313313
full_path_match = "/healthz"
314314
}
315315
}
316316
}
317317
dynamic "route_rules" {
318-
for_each = var.lb_backend_turndown ? [] : [1]
318+
for_each = var.lb_backend_turndown || var.grpc_write_path == "" ? [] : [1]
319319

320320
content {
321321
priority = 2
322322
service = google_compute_backend_service.k8s_grpc_backend_service[0].id
323323
match_rules {
324-
full_path_match = "/dev.sigstore.rekor.v2.Rekor/CreateEntry"
324+
path_template_match = var.grpc_write_path
325325
}
326326
}
327327
}
328328
route_rules {
329329
priority = 3
330330
service = google_compute_backend_bucket.tessera_backend_bucket.id
331331
match_rules {
332-
path_template_match = "/api/v2/{path=**}"
332+
path_template_match = var.http_read_path
333333
}
334-
route_action {
335-
url_rewrite {
336-
path_template_rewrite = "/{path}"
334+
dynamic "route_action" {
335+
for_each = var.http_read_rewrite_path == "" ? [] : [1]
336+
content {
337+
url_rewrite {
338+
path_template_rewrite = var.http_read_rewrite_path
339+
}
337340
}
338341
}
339342
}

gcp/modules/tiles_tlog/secret.tf

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/**
2+
* Copyright 2025 The Sigstore Authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
resource "google_secret_manager_secret" "private-key" {
18+
count = var.enable_secrets ? 1 : 0
19+
project = var.project_id
20+
21+
secret_id = "${var.shard_name}-${var.dns_subdomain_name}-private"
22+
23+
replication {
24+
auto {}
25+
}
26+
depends_on = [google_project_service.service]
27+
}
28+
29+
resource "google_secret_manager_secret" "public-key" {
30+
count = var.enable_secrets ? 1 : 0
31+
project = var.project_id
32+
33+
secret_id = "${var.shard_name}-${var.dns_subdomain_name}-public"
34+
35+
replication {
36+
auto {}
37+
}
38+
depends_on = [google_project_service.service]
39+
}
40+
41+
resource "google_secret_manager_secret_version" "public-key" {
42+
count = var.enable_secrets ? 1 : 0
43+
project = var.project_id
44+
45+
secret = google_secret_manager_secret.public-key[count.index].id
46+
secret_data = var.tlog_public_key
47+
}
48+
49+
resource "google_project_iam_member" "secret-getter" {
50+
count = var.enable_secrets ? 1 : 0
51+
project = var.project_id
52+
role = "roles/secretmanager.secretAccessor"
53+
member = local.workload_iam_member_id
54+
}

gcp/modules/tiles_tlog/variables.tf

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,28 @@ variable "service_health_check_path" {
186186
default = "/healthz"
187187
}
188188

189+
variable "http_write_path" {
190+
description = "the template or full path to match for HTTP log write requests"
191+
type = string
192+
}
193+
194+
variable "grpc_write_path" {
195+
description = "the template or full path to match for gRPC log write requests"
196+
type = string
197+
default = ""
198+
}
199+
200+
variable "http_read_path" {
201+
description = "the template or full path for the patch to match for HTTP log read requests"
202+
type = string
203+
}
204+
205+
variable "http_read_rewrite_path" {
206+
description = "the template for the path to rewrite read requests to"
207+
type = string
208+
default = ""
209+
}
210+
189211
variable "cluster_network_tag" {
190212
type = string
191213
description = "GKE cluster network tag for firewall"
@@ -200,6 +222,7 @@ variable "network_endpoint_group_http_name_suffix" {
200222
variable "network_endpoint_group_grpc_name_suffix" {
201223
type = string
202224
description = "suffix of the name of the network endpoint group that will be created for the gRPC service by the tiles Kubernetes service"
225+
default = ""
203226
}
204227

205228
variable "network_endpoint_group_zones" {
@@ -247,3 +270,15 @@ variable "monitoring_role_id" {
247270
description = "name of the project role for managing metrics - role must include permissions `monitoring.metricDescriptors.create`"
248271
type = string
249272
}
273+
274+
variable "enable_secrets" {
275+
description = "whether to use GCP Secret Manager for the transparency log's public and private keys"
276+
type = bool
277+
default = false
278+
}
279+
280+
variable "tlog_public_key" {
281+
description = "the value of the transparency log public key to be uploaded to Secret Manager. The private key must be uploaded manually."
282+
type = string
283+
default = ""
284+
}

0 commit comments

Comments
 (0)