Skip to content

Commit

Permalink
Add support for KMS
Browse files Browse the repository at this point in the history
  • Loading branch information
AlCutter committed Aug 20, 2024
1 parent 4470171 commit fb0b06e
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
1 change: 1 addition & 0 deletions deployment/live/gcp/example-gcp/ci/terragrunt.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ inputs = merge(
include.root.locals,
{
example_gcp_docker_image = "us-central1-docker.pkg.dev/trillian-tessera/docker-prod/example-gcp:latest"
log_origin = "example-gcp"
}
)
27 changes: 26 additions & 1 deletion deployment/modules/gcp/example-gcp/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,35 @@ module "gcs" {
project_id = var.project_id
}

##
## Resources
##

# Enable Cloud Run API
resource "google_project_service" "cloudrun_api" {
service = "run.googleapis.com"
disable_on_destroy = false
}
resource "google_project_service" "cloudkms_googleapis_com" {
service = "cloudkms.googleapis.com"
}

##
## KMS for log signing
##
resource "google_kms_key_ring" "log_signer" {
location = var.location
name = var.base_name
}

resource "google_kms_crypto_key" "log_signer" {
key_ring = google_kms_key_ring.log_signer.id
name = "log_signer"
purpose = "ASYMMETRIC_SIGN"
version_template {
algorithm = "EC_SIGN_ED25519"
}
}

###
### Set up Cloud Run service
Expand Down Expand Up @@ -71,7 +95,8 @@ resource "google_cloud_run_v2_service" "default" {
"--spanner=${module.gcs.log_spanner_db.id}",
"--project=${var.project_id}",
"--listen=:8080",
"--signer=./testgcp.sec",
"--kms_key=${google_kms_crypto_key.log_signer.id}",
"--origin=${var.log_origin}",
]
ports {
container_port = 8080
Expand Down
5 changes: 5 additions & 0 deletions deployment/modules/gcp/example-gcp/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,8 @@ variable "example_gcp_docker_image" {
description = "The full image URL (path & tag) for the example-gcp Docker image to deploy"
type = string
}

variable "log_origin" {
description = "The origin string for the example log"
type = string
}

0 comments on commit fb0b06e

Please sign in to comment.