Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(routing-key): enable routing key generation in a deterministic way #44

Merged
merged 5 commits into from
Oct 18, 2024
12 changes: 8 additions & 4 deletions modules/integrations/pub-sub/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,16 @@ data "sysdig_secure_tenant_external_id" "external_id" {}

data "sysdig_secure_cloud_ingestion_assets" "assets" {}

data "sysdig_current_user" "user" {}
#-----------------------------------------------------------------------------------------
# These locals indicate the suffix to create unique name for resources
#-----------------------------------------------------------------------------------------
locals {
suffix = var.suffix == null ? random_id.suffix[0].hex : var.suffix
role_name = "SysdigIngestionAuthRole"
suffix = var.suffix == null ? random_id.suffix[0].hex : var.suffix
role_name = "SysdigIngestionAuthRole"
key_name = "${var.project_id}-${data.sysdig_current_user.user.id}"
routing_key = uuidv5("oid", local.key_name)
jose-pablo-camacho marked this conversation as resolved.
Show resolved Hide resolved
ingestion_url = "${regex("^(.*)/[^/]+$", data.sysdig_secure_cloud_ingestion_assets.assets.gcp_metadata.ingestionURL)[0]}/${local.routing_key}"
jose-pablo-camacho marked this conversation as resolved.
Show resolved Hide resolved
}


Expand Down Expand Up @@ -143,7 +147,7 @@ resource "google_pubsub_subscription" "ingestion_topic_push_subscription" {
project = var.project_id

push_config {
push_endpoint = data.sysdig_secure_cloud_ingestion_assets.assets.gcp_metadata.ingestionURL
push_endpoint = local.ingestion_url
attributes = {
x-goog-version = "v1"
}
Expand Down Expand Up @@ -256,7 +260,7 @@ resource "sysdig_secure_cloud_auth_account_component" "gcp_pubsub_datasource" {
sink_name = var.is_organizational ? google_logging_organization_sink.ingestion_sink[0].name : google_logging_project_sink.ingestion_sink[0].name
push_subscription_name = google_pubsub_subscription.ingestion_topic_push_subscription.name
push_endpoint = google_pubsub_subscription.ingestion_topic_push_subscription.push_config[0].push_endpoint
routing_key = data.sysdig_secure_cloud_ingestion_assets.assets.gcp_routing_key
routing_key = local.routing_key
}
service_principal = {
workload_identity_federation = {
Expand Down
Loading