Skip to content
This repository was archived by the owner on Mar 30, 2026. It is now read-only.

Commit efbc70d

Browse files
committed
feat: Update Terraform configuration to manage GitHub secrets and bump dependencies
1 parent 6c31539 commit efbc70d

File tree

3 files changed

+51
-17
lines changed

3 files changed

+51
-17
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,14 @@ repos:
2424
- configs/.secrets.baseline
2525

2626
- repo: https://github.com/antonbabenko/pre-commit-terraform
27-
rev: v1.99.5
27+
rev: v1.105.0
2828
hooks:
2929
- id: terraform_fmt
3030
- id: terraform_validate
3131
- id: terraform_tflint
3232
- id: terraform_trivy
33-
args:
34-
- --args=--config=configs/trivy.yaml
3533
- repo: https://github.com/bridgecrewio/checkov.git
36-
rev: 3.2.457
34+
rev: 3.2.510
3735
hooks:
3836
- id: checkov
3937
args: [--config-file, ./configs/checkov.yml]

infra/terraform/main.tf

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,3 +165,39 @@ resource "google_cloud_run_service_iam_member" "gateway_invoker" {
165165
member = "serviceAccount:service-${data.google_project.project.number}@gcp-sa-apigateway.iam.gserviceaccount.com"
166166
depends_on = [google_cloud_run_v2_service.app, google_api_gateway_gateway.webhook]
167167
}
168+
169+
# https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/secret_manager_secret
170+
resource "google_secret_manager_secret" "github_private_key" {
171+
project = var.project_id
172+
secret_id = "github-private-key"
173+
replication {
174+
user_managed {
175+
replicas {
176+
location = var.region
177+
}
178+
}
179+
}
180+
}
181+
182+
resource "google_secret_manager_secret_version" "github_private_key" {
183+
secret = google_secret_manager_secret.github_private_key.id
184+
secret_data = var.github_private_key
185+
}
186+
187+
# https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/secret_manager_secret
188+
resource "google_secret_manager_secret" "github_webhook_secret" {
189+
project = var.project_id
190+
secret_id = "github-webhook-secret"
191+
replication {
192+
user_managed {
193+
replicas {
194+
location = var.region
195+
}
196+
}
197+
}
198+
}
199+
200+
resource "google_secret_manager_secret_version" "github_webhook_secret" {
201+
secret = google_secret_manager_secret.github_webhook_secret.id
202+
secret_data = var.github_webhook_secret
203+
}

infra/terraform/variables.tf

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,6 @@ variable "github_app_id" {
3232
description = "GitHub App ID"
3333
}
3434

35-
variable "github_private_key" {
36-
type = string
37-
description = "GitHub App private key (PEM contents; use \\n for newlines)"
38-
sensitive = true
39-
}
40-
41-
variable "github_webhook_secret" {
42-
type = string
43-
description = "GitHub webhook secret"
44-
sensitive = true
45-
}
46-
4735
variable "github_accepted_events" {
4836
type = string
4937
description = "Optional comma-separated events allowlist"
@@ -53,10 +41,22 @@ variable "github_accepted_events" {
5341
variable "services" {
5442
type = list(string)
5543
description = "Additional GCP services to enable"
56-
default = ["run.googleapis.com", "artifactregistry.googleapis.com", "iam.googleapis.com", "apigateway.googleapis.com"]
44+
default = ["run.googleapis.com", "artifactregistry.googleapis.com", "iam.googleapis.com", "apigateway.googleapis.com", "secretmanager.googleapis.com"]
5745
}
5846

5947
variable "kms_key_resource_name" {
6048
description = "The resource name of the KMS crypto key used for state encryption. This should be in the format: projects/{project}/locations/{location}/keyRings/{keyRing}/cryptoKeys/{cryptoKey}"
6149
type = string
6250
}
51+
52+
variable "github_webhook_secret" {
53+
description = "GitHub webhook secret for securing webhook payloads"
54+
type = string
55+
sensitive = true
56+
}
57+
58+
variable "github_private_key" {
59+
description = "GitHub App private key (PEM format, with \\n for newlines)"
60+
type = string
61+
sensitive = true
62+
}

0 commit comments

Comments
 (0)