Skip to content

Commit 2885ccc

Browse files
haresh-sureshjose-pablo-camacho
authored andcommitted
use external_id datasource
1 parent e9a212d commit 2885ccc

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

modules/config-posture/main.tf

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ data "sysdig_secure_trusted_cloud_identity" "trusted_identity" {
66
cloud_provider = "gcp"
77
}
88

9+
data "sysdig_secure_tenant_external_id" "external_id" {}
10+
911
data "google_project" "project" {
1012
project_id = var.project_id
1113
}
@@ -54,7 +56,7 @@ resource "google_iam_workload_identity_pool_provider" "posture_auth_pool_provide
5456
description = "AWS identity pool provider for Sysdig Secure Data Config Posture resources"
5557
disabled = false
5658

57-
attribute_condition = "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}\""
59+
attribute_condition = "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}/${data.sysdig_secure_tenant_external_id.external_id.external_id}\""
5860

5961
attribute_mapping = {
6062
"google.subject" = "assertion.arn",
@@ -81,7 +83,7 @@ resource "google_project_iam_member" "cspm" {
8183
resource "google_service_account_iam_member" "custom_posture_auth" {
8284
service_account_id = google_service_account.posture_auth.name
8385
role = "roles/iam.workloadIdentityUser"
84-
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}"
86+
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}/${data.sysdig_secure_tenant_external_id.external_id.external_id}"
8587
}
8688

8789
#--------------------------------------------------------------------------------------------------------------

modules/onboarding/main.tf

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ data "sysdig_secure_trusted_cloud_identity" "trusted_identity" {
66
cloud_provider = "gcp"
77
}
88

9+
data "sysdig_secure_tenant_external_id" "external_id" {}
10+
911
data "google_project" "project" {
1012
project_id = var.project_id
1113
}
@@ -54,7 +56,7 @@ resource "google_iam_workload_identity_pool_provider" "onboarding_auth_pool_prov
5456
description = "AWS identity pool provider for Sysdig Secure Data Onboarding resources"
5557
disabled = false
5658

57-
attribute_condition = "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}\""
59+
attribute_condition = "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}/${data.sysdig_secure_tenant_external_id.external_id.external_id}\""
5860

5961
attribute_mapping = {
6062
"google.subject" = "assertion.arn",
@@ -81,7 +83,7 @@ resource "google_project_iam_member" "browser" {
8183
resource "google_service_account_iam_member" "custom_onboarding_auth" {
8284
service_account_id = google_service_account.onboarding_auth.name
8385
role = "roles/iam.workloadIdentityUser"
84-
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}"
86+
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}/${data.sysdig_secure_tenant_external_id.external_id.external_id}"
8587
}
8688

8789
#---------------------------------------------------------------------------------------------

test/examples/modular_organization/onboarding_with_posture.tf

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,13 @@ provider "sysdig" {
2020
module "onboarding" {
2121
source = "../../../modules/onboarding"
2222
project_id = "org-child-project-3"
23-
external_id = "25ef0d887bc7a2b30089a025618e1c62"
2423
is_organizational = true
2524
organization_domain = "draios.com"
2625
}
2726

2827
module "config-posture" {
2928
source = "../../../modules/config-posture"
3029
project_id = module.onboarding.project_id
31-
external_id = "25ef0d887bc7a2b30089a025618e1c62"
3230
is_organizational = module.onboarding.is_organizational
3331
organization_domain = module.onboarding.organization_domain
3432
sysdig_secure_account_id = module.onboarding.sysdig_secure_account_id

test/examples/modular_single_project/onboarding_with_posture.tf

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,11 @@ provider "sysdig" {
2020
module "onboarding" {
2121
source = "../../../modules/onboarding"
2222
project_id = "org-child-project-3"
23-
external_id = "25ef0d887bc7a2b30089a025618e1c62"
2423
}
2524

2625
module "config-posture" {
2726
source = "../../../modules/config-posture"
2827
project_id = "org-child-project-3"
29-
external_id = "25ef0d887bc7a2b30089a025618e1c62"
3028
sysdig_secure_account_id = module.onboarding.sysdig_secure_account_id
3129
}
3230

0 commit comments

Comments
 (0)