Skip to content

armgit / AiSOC

Public Imported from GitHub
0

Open-source AI Security Operations Center: alert fusion, LLM-agent triage, MITRE ATT&CK investigation, and a replayable decision ledger for every agent step. Self-hostable, runs with no API keys, MIT licensed. Ships an MCP server for Claude, Cursor and Continue.

fix(infra/gcp): drop sensitive-var taint from terraform for_each and … (#243)

Asin sayed alif51ee46547e5
diff --git a/infra/terraform/gcp/cloud_run.tf b/infra/terraform/gcp/cloud_run.tf
index 743f2158e..9f4bff50f 100644
--- a/infra/terraform/gcp/cloud_run.tf
+++ b/infra/terraform/gcp/cloud_run.tf
@@ -152,12 +152,15 @@ resource "google_cloud_run_v2_service" "api" {
}
dynamic "env" {
- for_each = var.openai_api_key == "" ? [] : [1]
+ # Iterate over the count-driven secret resource (0 or 1 element) so the
+ # for_each collection is derived from resource state, not the sensitive
+ # var.openai_api_key. Sensitive values are rejected as for_each args.
+ for_each = google_secret_manager_secret.openai_api_key
content {
name = "OPENAI_API_KEY"
value_source {
secret_key_ref {
- secret = google_secret_manager_secret.openai_api_key[0].secret_id
+ secret = env.value.secret_id
version = "latest"
}
}
diff --git a/infra/terraform/gcp/iam.tf b/infra/terraform/gcp/iam.tf
index 37c35dbfa..d55024620 100644
--- a/infra/terraform/gcp/iam.tf
+++ b/infra/terraform/gcp/iam.tf
@@ -73,13 +73,15 @@ resource "google_project_iam_member" "runtime_shared" {
# bundle that talks to the API over HTTP — it doesn't need DB or vault keys.
locals {
- api_secrets = compact([
- google_secret_manager_secret.postgres_password.id,
- google_secret_manager_secret.secret_key.id,
- google_secret_manager_secret.credential_key.id,
- google_secret_manager_secret.redis_auth.id,
- var.openai_api_key == "" ? "" : google_secret_manager_secret.openai_api_key[0].id,
- ])
+ api_secrets = concat(
+ [
+ google_secret_manager_secret.postgres_password.id,
+ google_secret_manager_secret.secret_key.id,
+ google_secret_manager_secret.credential_key.id,
+ google_secret_manager_secret.redis_auth.id,
+ ],
+ google_secret_manager_secret.openai_api_key[*].id,
+ )
ingest_secrets = [
google_secret_manager_secret.postgres_password.id,
diff --git a/infra/terraform/gcp/outputs.tf b/infra/terraform/gcp/outputs.tf
index ffe1fa0c5..df8ef6434 100644
--- a/infra/terraform/gcp/outputs.tf
+++ b/infra/terraform/gcp/outputs.tf
@@ -109,5 +109,9 @@ output "secret_redis_auth_id" {
output "secret_openai_api_key_id" {
description = "Secret Manager ID for the OpenAI API key (null when not provisioned)."
- value = var.openai_api_key == "" ? null : google_secret_manager_secret.openai_api_key[0].secret_id
+ value = nonsensitive(
+ length(google_secret_manager_secret.openai_api_key) == 0
+ ? null
+ : google_secret_manager_secret.openai_api_key[0].secret_id
+ )
}