Skip to content

Commit 4abc7b2

Browse files
haresh-sureshjose-pablo-camacho
authored andcommitted
fix role naming & version metadata
1 parent 5581c6a commit 4abc7b2

File tree

3 files changed

+23
-47
lines changed

3 files changed

+23
-47
lines changed

modules/config-posture/main.tf

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ locals {
2121
}
2222

2323
resource "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" {
4849
resource "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
#--------------------------------------------------------------------------------------------------------------
9290
resource "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
}

modules/onboarding/main.tf

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ locals {
2121
}
2222

2323
resource "google_service_account" "onboarding_auth" {
24-
account_id = "sysdig-secure-onboarding-${local.suffix}"
24+
# service account name cannot be longer than 30 characters
25+
account_id = "sysdig-onboarding-${local.suffix}"
2526
display_name = "Sysdig Onboarding Auth Service Account"
2627
project = var.project_id
2728
}
@@ -42,13 +43,13 @@ resource "google_service_account_iam_binding" "onboarding_auth_binding" {
4243

4344
resource "google_iam_workload_identity_pool" "onboarding_auth_pool" {
4445
project = var.project_id
45-
workload_identity_pool_id = "sysdig-secure-onboarding-${local.suffix}"
46+
workload_identity_pool_id = "sysdig-onboarding-${local.suffix}"
4647
}
4748

4849
resource "google_iam_workload_identity_pool_provider" "onboarding_auth_pool_provider" {
4950
project = var.project_id
5051
workload_identity_pool_id = google_iam_workload_identity_pool.onboarding_auth_pool.workload_identity_pool_id
51-
workload_identity_pool_provider_id = "sysdig-secure-onboarding-${local.suffix}"
52+
workload_identity_pool_provider_id = "sysdig-onboarding-${local.suffix}"
5253
display_name = "Sysdigcloud onboarding auth"
5354
description = "AWS identity pool provider for Sysdig Secure Data Onboarding resources"
5455
disabled = false
@@ -77,7 +78,7 @@ resource "google_project_iam_member" "browser" {
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_onboarding_auth" {
8182
service_account_id = google_service_account.onboarding_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.onboarding_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}"
@@ -101,19 +102,17 @@ resource "sysdig_secure_cloud_auth_account" "google_account" {
101102
version = "v0.1.0"
102103
service_principal_metadata = jsonencode({
103104
gcp = {
104-
service_principal = {
105-
workload_identity_federation = {
106-
pool_id = google_iam_workload_identity_pool.onboarding_auth_pool.workload_identity_pool_id
107-
pool_provider_id = google_iam_workload_identity_pool_provider.onboarding_auth_pool_provider.workload_identity_pool_provider_id
108-
project_number = data.google_project.project.number
109-
}
110-
email = google_service_account.onboarding_auth.email
105+
workload_identity_federation = {
106+
pool_id = google_iam_workload_identity_pool.onboarding_auth_pool.workload_identity_pool_id
107+
pool_provider_id = google_iam_workload_identity_pool_provider.onboarding_auth_pool_provider.workload_identity_pool_provider_id
108+
project_number = data.google_project.project.number
111109
}
110+
email = google_service_account.onboarding_auth.email
112111
}
113112
})
114113
}
115114

116-
depends_on = [google_service_account_iam_member.custom_auth]
115+
depends_on = [google_service_account_iam_member.custom_onboarding_auth]
117116

118117
lifecycle {
119118
ignore_changes = [

modules/onboarding/outputs.tf

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,9 @@
1-
output "workload_identity_pool_id" {
2-
value = google_iam_workload_identity_pool.onboarding_auth_pool.workload_identity_pool_id
3-
description = "Id of Workload Identity Pool for authenticating to GCP to access data onboarding resources"
4-
}
5-
6-
output "workload_identity_pool_provider_id" {
7-
value = google_iam_workload_identity_pool_provider.onboarding_auth_pool_provider.workload_identity_pool_provider_id
8-
description = "Id of Workload Identity Pool Provider for authenticating to GCP to access data onboarding resources"
9-
}
10-
11-
output "workload_identity_project_number" {
12-
value = data.google_project.project.number
13-
description = "GCP project number"
14-
}
15-
16-
output "service_account_email" {
17-
value = google_service_account.onboarding_auth.email
18-
description = "email of the Service Account created"
19-
}
20-
211
output "project_id" {
222
value = var.project_id
233
description = "Project ID in which secure-for-cloud onboarding resources are created. For organizational installs it is the Management Project ID selected during install"
244
}
255

26-
output "sysdig_secure_project_id" {
6+
output "sysdig_secure_account_id" {
277
value = sysdig_secure_cloud_auth_account.google_account.id
288
description = "ID of the Sysdig Cloud Account created"
299
}

0 commit comments

Comments
 (0)