Skip to content

Commit f26768d

Browse files
committed
Fixing gcp onboarding on gcp regions
1 parent 76e9fe9 commit f26768d

File tree

1 file changed

+42
-0
lines changed
  • modules/vm-workload-scanning

1 file changed

+42
-0
lines changed

modules/vm-workload-scanning/main.tf

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
#-----------------------------------------------------------------------------------------
2+
# Fetch the data sources
3+
#-----------------------------------------------------------------------------------------
4+
data "sysdig_secure_agentless_scanning_assets" "assets" {}
5+
16
locals {
27
suffix = random_id.suffix.hex
38
}
@@ -54,6 +59,8 @@ resource "google_iam_workload_identity_pool" "agentless" {
5459
}
5560

5661
resource "google_iam_workload_identity_pool_provider" "agentless" {
62+
count = data.sysdig_secure_agentless_scanning_assets.assets.backend == "aws" ? 1 : 0
63+
5764
project = var.project_id
5865
workload_identity_pool_id = google_iam_workload_identity_pool.agentless.workload_identity_pool_id
5966
workload_identity_pool_provider_id = "sysdig-wl-${local.suffix}"
@@ -76,11 +83,42 @@ resource "google_iam_workload_identity_pool_provider" "agentless" {
7683
}
7784

7885
resource "google_service_account_iam_member" "controller_binding" {
86+
count = data.sysdig_secure_agentless_scanning_assets.assets.backend == "aws" ? 1 : 0
87+
7988
service_account_id = google_service_account.controller.name
8089
role = "roles/iam.workloadIdentityUser"
8190
member = "principalSet://iam.googleapis.com/${google_iam_workload_identity_pool.agentless.name}/attribute.aws_account/${data.sysdig_secure_trusted_cloud_identity.trusted_identity.aws_account_id}"
8291
}
8392

93+
resource "google_iam_workload_identity_pool_provider" "agentless_gcp" {
94+
count = data.sysdig_secure_agentless_scanning_assets.assets.backend == "gcp" ? 1 : 0
95+
96+
workload_identity_pool_id = google_iam_workload_identity_pool.agentless.workload_identity_pool_id
97+
workload_identity_pool_provider_id = "sysdig-ws-${local.suffix}-gcp"
98+
display_name = "Sysdig Agentless Workload Controller"
99+
description = "GCP identity pool provider for Sysdig Secure Agentless Workload Scanning"
100+
disabled = false
101+
102+
attribute_condition = "google.subject == \"${data.sysdig_secure_agentless_scanning_assets.assets.backend.cloudId}\""
103+
104+
attribute_mapping = {
105+
"google.subject" = "assertion.sub"
106+
"attribute.sa_id" = "assertion.sub"
107+
}
108+
109+
oidc {
110+
issuer_uri = "https://accounts.google.com"
111+
}
112+
}
113+
114+
resource "google_service_account_iam_member" "controller_binding_gcp" {
115+
count = data.sysdig_secure_agentless_scanning_assets.assets.backend == "gcp" ? 1 : 0
116+
117+
service_account_id = google_service_account.controller.name
118+
role = "roles/iam.workloadIdentityUser"
119+
member = "principalSet://iam.googleapis.com/${google_iam_workload_identity_pool.agentless.name}/attribute.sa_id/${data.sysdig_secure_agentless_scanning_assets.assets.backend.cloudId}"
120+
}
121+
84122

85123
#--------------------------------------------------------------------------------------------------------------
86124
# Call Sysdig Backend to add the service-principal integration for VM Workload Scanning to the Sysdig Cloud Account
@@ -105,6 +143,10 @@ resource "sysdig_secure_cloud_auth_account_component" "google_service_principal"
105143
google_project_iam_custom_role.controller,
106144
google_project_iam_binding.controller_binding,
107145
google_iam_workload_identity_pool.agentless,
146+
google_iam_workload_identity_pool_provider.agentless,
147+
google_iam_workload_identity_pool_provider.agentless_gcp,
148+
google_service_account_iam_member.controller_binding,
149+
google_service_account_iam_member.controller_binding_gcp,
108150
google_organization_iam_member.controller,
109151
]
110152
}

0 commit comments

Comments
 (0)