diff --git a/cmd/tesseract/gcp/generate_key/main.go b/cmd/tesseract/gcp/generate_key/main.go index 890b0222a..cb8619dd3 100644 --- a/cmd/tesseract/gcp/generate_key/main.go +++ b/cmd/tesseract/gcp/generate_key/main.go @@ -76,11 +76,11 @@ func main() { sec, pub = genEd25519KeypairNote() } - pubKName := fmt.Sprintf("%s-%s-public", *keyUsage, resourceFromOrigin(*origin)) + pubKName := fmt.Sprintf("%s-%s-public", resourceFromOrigin(*origin), *keyUsage) if err := createSecret(ctx, *projectID, client, pubKName, pub); err != nil { exit("Failed to create secret %q: %v", pubKName, err) } - secKName := fmt.Sprintf("%s-%s-secret", *keyUsage, resourceFromOrigin(*origin)) + secKName := fmt.Sprintf("%s-%s-secret", resourceFromOrigin(*origin), *keyUsage) if err := createSecret(ctx, *projectID, client, secKName, sec); err != nil { exit("Failed to create secret %q: %v", secKName, err) } diff --git a/deployment/live/gcp/static-ct-ci/logs/ci/terragrunt.hcl b/deployment/live/gcp/static-ct-ci/logs/ci/terragrunt.hcl index 42e945e19..c437bc2a4 100644 --- a/deployment/live/gcp/static-ct-ci/logs/ci/terragrunt.hcl +++ b/deployment/live/gcp/static-ct-ci/logs/ci/terragrunt.hcl @@ -3,14 +3,15 @@ terraform { } locals { - env = "ci" - docker_env = local.env - base_name = "${local.env}-conformance" - origin_suffix = ".ct.transparency.dev" - log_public_key_suffix = "-ecdsa-p256-public-key" # Legacy key name pattern. - log_private_key_suffix = "-ecdsa-p256-private-key" # Legacy key name pattern. - server_docker_image = "${include.root.locals.location}-docker.pkg.dev/${include.root.locals.project_id}/docker-${local.env}/conformance-gcp:latest" - ephemeral = true + env = "ci" + docker_env = local.env + base_name = "${local.env}-conformance" + origin = "${local.base_name}.ct.transparency.dev" + safe_origin = replace("${local.origin}", "/[^-a-zA-Z0-9]/", "-") + log_public_key_secret_name = "projects/223810646869/secrets/${local.safe_origin}-log-public/versions/1" + log_private_key_secret_name = "projects/223810646869/secrets/${local.safe_origin}-log-secret/versions/1" + server_docker_image = "${include.root.locals.location}-docker.pkg.dev/${include.root.locals.project_id}/docker-${local.env}/conformance-gcp:latest" + ephemeral = true } include "root" { diff --git a/deployment/live/gcp/static-ct-staging/logs/arche2025h1/terragrunt.hcl b/deployment/live/gcp/static-ct-staging/logs/arche2025h1/terragrunt.hcl index 351032ae7..43197dcb4 100644 --- a/deployment/live/gcp/static-ct-staging/logs/arche2025h1/terragrunt.hcl +++ b/deployment/live/gcp/static-ct-staging/logs/arche2025h1/terragrunt.hcl @@ -6,7 +6,7 @@ locals { env = include.root.locals.env docker_env = local.env base_name = include.root.locals.base_name - origin_suffix = include.root.locals.origin_suffix + origin = "${local.base_name}${include.root.locals.origin_suffix}" not_after_start = "2025-01-01T00:00:00Z" not_after_limit = "2025-07-01T00:00:00Z" server_docker_image = "${include.root.locals.location}-docker.pkg.dev/${include.root.locals.project_id}/docker-${local.env}/tesseract-gcp:${include.root.locals.docker_container_tag}" diff --git a/deployment/live/gcp/static-ct-staging/logs/arche2025h2/terragrunt.hcl b/deployment/live/gcp/static-ct-staging/logs/arche2025h2/terragrunt.hcl index ecbc42623..13b4dc3cc 100644 --- a/deployment/live/gcp/static-ct-staging/logs/arche2025h2/terragrunt.hcl +++ b/deployment/live/gcp/static-ct-staging/logs/arche2025h2/terragrunt.hcl @@ -6,7 +6,7 @@ locals { env = include.root.locals.env docker_env = local.env base_name = include.root.locals.base_name - origin_suffix = include.root.locals.origin_suffix + origin = "${local.base_name}${include.root.locals.origin_suffix}" not_after_start = "2025-07-01T00:00:00Z" not_after_limit = "2026-01-01T00:00:00Z" server_docker_image = "${include.root.locals.location}-docker.pkg.dev/${include.root.locals.project_id}/docker-${local.env}/tesseract-gcp:${include.root.locals.docker_container_tag}" diff --git a/deployment/live/gcp/static-ct-staging/logs/arche2026h1/terragrunt.hcl b/deployment/live/gcp/static-ct-staging/logs/arche2026h1/terragrunt.hcl index ab984866c..1c6d4e929 100644 --- a/deployment/live/gcp/static-ct-staging/logs/arche2026h1/terragrunt.hcl +++ b/deployment/live/gcp/static-ct-staging/logs/arche2026h1/terragrunt.hcl @@ -6,7 +6,7 @@ locals { env = include.root.locals.env docker_env = local.env base_name = include.root.locals.base_name - origin_suffix = include.root.locals.origin_suffix + origin = "${local.base_name}${include.root.locals.origin_suffix}" not_after_start = "2026-01-01T00:00:00Z" not_after_limit = "2026-07-01T00:00:00Z" server_docker_image = "${include.root.locals.location}-docker.pkg.dev/${include.root.locals.project_id}/docker-${local.env}/tesseract-gcp:${include.root.locals.docker_container_tag}" diff --git a/deployment/modules/gcp/cloudbuild/conformance/main.tf b/deployment/modules/gcp/cloudbuild/conformance/main.tf index b0293670b..1cfab63ee 100644 --- a/deployment/modules/gcp/cloudbuild/conformance/main.tf +++ b/deployment/modules/gcp/cloudbuild/conformance/main.tf @@ -24,6 +24,8 @@ locals { cloudbuild_service_account = "cloudbuild-${var.env}-sa@${var.project_id}.iam.gserviceaccount.com" artifact_repo = "${var.location}-docker.pkg.dev/${var.project_id}/${module.artifactregistry.docker.name}" conformance_gcp_docker_image = "${local.artifact_repo}/conformance-gcp" + origin = "${var.env}-conformance.ct.transparency.dev" # Must match the origin in the deplyment/gcp/static-ct-ci/logs/ci/terragrunt.hcl file. + safe_origin = replace("${local.origin}", "/[^-a-zA-Z0-9]/", "-") } resource "google_project_service" "cloudbuild_api" { @@ -72,7 +74,7 @@ resource "google_cloudbuild_trigger" "build_trigger" { ] } - ## Destroy any pre-existing infrastructure. + ## Clean-up: Destroy any pre-existing infrastructure. ## This might happen if a previous cloud build failed for some reason. step { id = "preclean_env" @@ -90,6 +92,32 @@ resource "google_cloudbuild_trigger" "build_trigger" { wait_for = ["prepare_terragrunt_opentofu_container"] } + ## Clean-up: Destroy test log keys. + ## This might happen if a previous cloud build failed for some reason. + step { + id = "preclean_destroy_test_keys" + name = "gcr.io/cloud-builders/gcloud" + script = < /workspace/conformance_url terragrunt --terragrunt-no-color output --raw tesseract_bucket_name -no-color > /workspace/conformance_bucket_name - terragrunt --terragrunt-no-color output --raw ecdsa_p256_public_key_data -no-color > /workspace/conformance_log_public_key.pem EOT dir = var.log_terragrunt env = [ @@ -193,10 +220,10 @@ resource "google_cloudbuild_trigger" "build_trigger" { base64 -w 0 /workspace/conformance_log_public_key.der > /workspace/conformance_log_public_key retry -t 5 -d 15 --until=success go run ./internal/hammer \ - --origin="ci-static-ct-ci" \ + --origin="${local.origin}" \ --log_public_key="$(cat /workspace/conformance_log_public_key)" \ --log_url="https://storage.googleapis.com/$(cat /workspace/conformance_bucket_name)/" \ - --write_log_url="$(cat /workspace/conformance_url)/ci-static-ct-ci" \ + --write_log_url="$(cat /workspace/conformance_url)/${local.origin}" \ -v=1 \ --show_ui=false \ --bearer_token="$(cat /workspace/cb_access)" \ @@ -210,7 +237,7 @@ resource "google_cloudbuild_trigger" "build_trigger" { wait_for = ["bearer_token"] } - ## Destroy the terragrunt config. + ## Clean-up: Destroy the terragrunt config. ## This will tear down the conformance infrastructure we brought up ## above. step { @@ -229,12 +256,27 @@ resource "google_cloudbuild_trigger" "build_trigger" { wait_for = ["ct_hammer"] } + ## Clean-up: Destroy test log keys. + ## Remove test-log keys. + step { + id = "postclean_destroy_test_keys" + name = "gcr.io/cloud-builders/gcloud" + script = <