@@ -21,7 +21,8 @@ locals {
2121}
2222
2323resource "google_service_account" "posture_auth" {
24- account_id = " sysdig-secure-posture-${ local . suffix } "
24+ # service account name cannot be longer than 30 characters
25+ account_id = " sysdig-posture-${ local . suffix } "
2526 display_name = " Sysdig Config Posture Auth Service Account"
2627 project = var. project_id
2728}
@@ -48,7 +49,7 @@ resource "google_iam_workload_identity_pool" "posture_auth_pool" {
4849resource "google_iam_workload_identity_pool_provider" "posture_auth_pool_provider" {
4950 project = var. project_id
5051 workload_identity_pool_id = google_iam_workload_identity_pool. posture_auth_pool . workload_identity_pool_id
51- workload_identity_pool_provider_id = " sysdig-secure- posture-${ local . suffix } "
52+ workload_identity_pool_provider_id = " sysdig-posture-${ local . suffix } "
5253 display_name = " Sysdigcloud config posture auth"
5354 description = " AWS identity pool provider for Sysdig Secure Data Config Posture resources"
5455 disabled = false
@@ -77,33 +78,29 @@ resource "google_project_iam_member" "cspm" {
7778}
7879
7980# attaching WIF as a member to the service account for auth
80- resource "google_service_account_iam_member" "custom_auth " {
81+ resource "google_service_account_iam_member" "custom_posture_auth " {
8182 service_account_id = google_service_account. posture_auth . name
8283 role = " roles/iam.workloadIdentityUser"
8384 member = " principalSet://iam.googleapis.com/projects/${ data . google_project . project . number } /locations/global/workloadIdentityPools/${ google_iam_workload_identity_pool . posture_auth_pool . workload_identity_pool_id } /attribute.aws_role/arn:aws:sts::${ data . sysdig_secure_trusted_cloud_identity . trusted_identity . aws_account_id } :assumed-role/${ data . sysdig_secure_trusted_cloud_identity . trusted_identity . aws_role_name } /${ var . external_id } "
8485}
8586
8687# --------------------------------------------------------------------------------------------------------------
8788# Call Sysdig Backend to add the service-principal integration for Config Posture to the Sysdig Cloud Account
88- #
89- # Note (optional): To ensure this gets called after all cloud resources are created, add
90- # explicit dependency using depends_on
9189# --------------------------------------------------------------------------------------------------------------
9290resource "sysdig_secure_cloud_auth_account_component" "google_service_principal" {
9391 account_id = var. sysdig_secure_account_id
9492 type = " COMPONENT_SERVICE_PRINCIPAL"
9593 instance = " secure-posture"
96- verion = " v0.1.0"
94+ version = " v0.1.0"
9795 service_principal_metadata = jsonencode ({
9896 gcp = {
99- service_principal = {
100- workload_identity_federation = {
101- pool_id = google_iam_workload_identity_pool.posture_auth_pool.workload_identity_pool_id
102- pool_provider_id = google_iam_workload_identity_pool_provider.posture_auth_pool_provider.workload_identity_pool_provider_id
103- project_number = data.google_project.project.number
104- }
105- email = google_service_account.posture_auth.email
97+ workload_identity_federation = {
98+ pool_id = google_iam_workload_identity_pool.posture_auth_pool.workload_identity_pool_id
99+ pool_provider_id = google_iam_workload_identity_pool_provider.posture_auth_pool_provider.workload_identity_pool_provider_id
100+ project_number = data.google_project.project.number
106101 }
102+ email = google_service_account.posture_auth.email
107103 }
108104 })
105+ depends_on = [google_service_account_iam_member . custom_posture_auth ]
109106}
0 commit comments