From a0111661067225a2c8817217583e4b4df554fd88 Mon Sep 17 00:00:00 2001 From: Alvaro Iradier Date: Fri, 6 Feb 2026 16:06:03 +0100 Subject: [PATCH 1/6] feat(current-user): expose customer info in sysdig_current_user data source Add customer_id, customer_name, and customer_external_id computed attributes to the sysdig_current_user data source, sourced from the user's customer object in the API response. Clarify documentation for sysdig_secure_tenant_external_id to distinguish the cloud onboarding external ID from the customer-level external ID. Co-Authored-By: Claude Opus 4.6 --- sysdig/data_source_sysdig_current_user.go | 18 ++++++++++++++++ .../data_source_sysdig_current_user_test.go | 5 +++++ sysdig/internal/client/v2/model.go | 21 ++++++++++++------- website/docs/d/current_user.md | 8 ++++++- website/docs/d/secure_tenant_external_id.md | 6 ++++-- 5 files changed, 48 insertions(+), 10 deletions(-) diff --git a/sysdig/data_source_sysdig_current_user.go b/sysdig/data_source_sysdig_current_user.go index 38f0cf889..37c90c62d 100644 --- a/sysdig/data_source_sysdig_current_user.go +++ b/sysdig/data_source_sysdig_current_user.go @@ -36,6 +36,18 @@ func dataSourceSysdigCurrentUser() *schema.Resource { Type: schema.TypeString, Computed: true, }, + "customer_id": { + Type: schema.TypeInt, + Computed: true, + }, + "customer_name": { + Type: schema.TypeString, + Computed: true, + }, + "customer_external_id": { + Type: schema.TypeString, + Computed: true, + }, }, } } @@ -58,5 +70,11 @@ func dataSourceSysdigCurrentUserRead(ctx context.Context, d *schema.ResourceData _ = d.Set("last_name", user.LastName) _ = d.Set("system_role", user.SystemRole) + if user.Customer != nil { + _ = d.Set("customer_id", user.Customer.ID) + _ = d.Set("customer_name", user.Customer.Name) + _ = d.Set("customer_external_id", user.Customer.ExternalID) + } + return nil } diff --git a/sysdig/data_source_sysdig_current_user_test.go b/sysdig/data_source_sysdig_current_user_test.go index c89aa7847..207c33f0d 100644 --- a/sysdig/data_source_sysdig_current_user_test.go +++ b/sysdig/data_source_sysdig_current_user_test.go @@ -22,6 +22,11 @@ func TestAccCurrentUser(t *testing.T) { Steps: []resource.TestStep{ { Config: getCurrentUser(), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttrSet("data.sysdig_current_user.me", "customer_id"), + resource.TestCheckResourceAttrSet("data.sysdig_current_user.me", "customer_name"), + resource.TestCheckResourceAttrSet("data.sysdig_current_user.me", "customer_external_id"), + ), }, }, }) diff --git a/sysdig/internal/client/v2/model.go b/sysdig/internal/client/v2/model.go index 3d131f217..0305b98fc 100644 --- a/sysdig/internal/client/v2/model.go +++ b/sysdig/internal/client/v2/model.go @@ -86,14 +86,21 @@ type teamWrapper struct { Team Team `json:"team"` } +type Customer struct { + ID int `json:"id,omitempty"` + Name string `json:"name,omitempty"` + ExternalID string `json:"externalId,omitempty"` +} + type User struct { - ID int `json:"id,omitempty"` - Version int `json:"version,omitempty"` - SystemRole string `json:"systemRole,omitempty"` - Email string `json:"username"` - FirstName string `json:"firstName,omitempty"` - LastName string `json:"lastName,omitempty"` - CurrentTeam *int `json:"currentTeam"` + ID int `json:"id,omitempty"` + Version int `json:"version,omitempty"` + SystemRole string `json:"systemRole,omitempty"` + Email string `json:"username"` + FirstName string `json:"firstName,omitempty"` + LastName string `json:"lastName,omitempty"` + CurrentTeam *int `json:"currentTeam"` + Customer *Customer `json:"customer,omitempty"` } type userWrapper struct { diff --git a/website/docs/d/current_user.md b/website/docs/d/current_user.md index 38a1a32d4..c57776611 100644 --- a/website/docs/d/current_user.md +++ b/website/docs/d/current_user.md @@ -31,4 +31,10 @@ In addition to all arguments above, the following attributes are exported: * `last_name` - The user's last name. -* `system_role` - The user's system role. \ No newline at end of file +* `system_role` - The user's system role. + +* `customer_id` - The ID of the customer (account) the user belongs to, as shown in [Customer ID, Name, and External ID](https://docs.sysdig.com/en/administration/find-your-customer-id-and-name/). + +* `customer_name` - The name of the customer (account) the user belongs to, as shown in [Customer ID, Name, and External ID](https://docs.sysdig.com/en/administration/find-your-customer-id-and-name/). + +* `customer_external_id` - The Customer External ID as shown in [Customer ID, Name, and External ID](https://docs.sysdig.com/en/administration/find-your-customer-id-and-name/). \ No newline at end of file diff --git a/website/docs/d/secure_tenant_external_id.md b/website/docs/d/secure_tenant_external_id.md index 8dbd62724..240adecc9 100644 --- a/website/docs/d/secure_tenant_external_id.md +++ b/website/docs/d/secure_tenant_external_id.md @@ -8,7 +8,9 @@ description: |- # Data Source: sysdig_secure_tenant_external_id -Retrieves information about the Sysdig Secure Tenant External ID +Retrieves the **cloud onboarding** external ID for the Sysdig Secure tenant. This ID is used when configuring trusted relationships for cloud account onboarding (e.g., AWS IAM role trust policies). + +~> **Note:** This is *not* the Customer External ID shown in [Customer ID, Name, and External ID](https://docs.sysdig.com/en/administration/find-your-customer-id-and-name/). For the customer-level external ID, use [`sysdig_current_user`](current_user.md) and its `customer_external_id` attribute instead. -> **Note:** Sysdig Terraform Provider is under rapid development at this point. If you experience any issue or discrepancy while using it, please make sure you have the latest version. If the issue persists, or you have a Feature Request to support an additional set of resources, please open a [new issue](https://github.com/sysdiglabs/terraform-provider-sysdig/issues/new) in the GitHub repository. @@ -24,5 +26,5 @@ data "sysdig_secure_tenant_external_id" "external_id" {} In addition to all arguments above, the following attributes are exported: -* `external_id` - String identifier for external id value +* `external_id` - The cloud onboarding external ID for the Sysdig Secure tenant. From 0979df1d8ba1449b0f6601b3baa545a2cf922dfe Mon Sep 17 00:00:00 2001 From: Alvaro Iradier Date: Fri, 6 Feb 2026 16:36:42 +0100 Subject: [PATCH 2/6] Update sysdig/data_source_sysdig_current_user.go Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- sysdig/data_source_sysdig_current_user.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sysdig/data_source_sysdig_current_user.go b/sysdig/data_source_sysdig_current_user.go index 37c90c62d..0f99e36b2 100644 --- a/sysdig/data_source_sysdig_current_user.go +++ b/sysdig/data_source_sysdig_current_user.go @@ -74,6 +74,10 @@ func dataSourceSysdigCurrentUserRead(ctx context.Context, d *schema.ResourceData _ = d.Set("customer_id", user.Customer.ID) _ = d.Set("customer_name", user.Customer.Name) _ = d.Set("customer_external_id", user.Customer.ExternalID) + } else { + _ = d.Set("customer_id", 0) + _ = d.Set("customer_name", "") + _ = d.Set("customer_external_id", "") } return nil From 31b3db7b7d130513af3fc227c61a6c7207604b75 Mon Sep 17 00:00:00 2001 From: Alvaro Iradier Date: Fri, 6 Feb 2026 17:20:09 +0100 Subject: [PATCH 3/6] Update sysdig/data_source_sysdig_current_user.go Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- sysdig/data_source_sysdig_current_user.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sysdig/data_source_sysdig_current_user.go b/sysdig/data_source_sysdig_current_user.go index 0f99e36b2..3b0e3a639 100644 --- a/sysdig/data_source_sysdig_current_user.go +++ b/sysdig/data_source_sysdig_current_user.go @@ -75,9 +75,9 @@ func dataSourceSysdigCurrentUserRead(ctx context.Context, d *schema.ResourceData _ = d.Set("customer_name", user.Customer.Name) _ = d.Set("customer_external_id", user.Customer.ExternalID) } else { - _ = d.Set("customer_id", 0) - _ = d.Set("customer_name", "") - _ = d.Set("customer_external_id", "") + _ = d.Set("customer_id", nil) + _ = d.Set("customer_name", nil) + _ = d.Set("customer_external_id", nil) } return nil From 4191da9c1fd6757b5da995f1786d0cd29d913b87 Mon Sep 17 00:00:00 2001 From: Alvaro Iradier Date: Fri, 6 Feb 2026 17:24:34 +0100 Subject: [PATCH 4/6] fix(test): only assert customer_id is set in current user test customer_name and customer_external_id may be empty depending on the account/environment, making TestCheckResourceAttrSet brittle. The customer_id check alone is sufficient to verify the customer object mapping works correctly. Co-Authored-By: Claude Opus 4.6 --- sysdig/data_source_sysdig_current_user_test.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/sysdig/data_source_sysdig_current_user_test.go b/sysdig/data_source_sysdig_current_user_test.go index 207c33f0d..4a5648db9 100644 --- a/sysdig/data_source_sysdig_current_user_test.go +++ b/sysdig/data_source_sysdig_current_user_test.go @@ -24,8 +24,6 @@ func TestAccCurrentUser(t *testing.T) { Config: getCurrentUser(), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttrSet("data.sysdig_current_user.me", "customer_id"), - resource.TestCheckResourceAttrSet("data.sysdig_current_user.me", "customer_name"), - resource.TestCheckResourceAttrSet("data.sysdig_current_user.me", "customer_external_id"), ), }, }, From dc18e9fe6097f3f30f7f212ae98e7c311b06a561 Mon Sep 17 00:00:00 2001 From: Alvaro Iradier Date: Mon, 9 Feb 2026 10:47:56 +0100 Subject: [PATCH 5/6] Document that external ID is only available for admin users --- website/docs/d/current_user.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/d/current_user.md b/website/docs/d/current_user.md index c57776611..d400c1cbf 100644 --- a/website/docs/d/current_user.md +++ b/website/docs/d/current_user.md @@ -37,4 +37,4 @@ In addition to all arguments above, the following attributes are exported: * `customer_name` - The name of the customer (account) the user belongs to, as shown in [Customer ID, Name, and External ID](https://docs.sysdig.com/en/administration/find-your-customer-id-and-name/). -* `customer_external_id` - The Customer External ID as shown in [Customer ID, Name, and External ID](https://docs.sysdig.com/en/administration/find-your-customer-id-and-name/). \ No newline at end of file +* `customer_external_id` - The Customer External ID as shown in [Customer ID, Name, and External ID](https://docs.sysdig.com/en/administration/find-your-customer-id-and-name/). Only available for users with the Admin role; empty for non-admin users. \ No newline at end of file From e52d17484afcde9baf8b8cb99780beb8aafa6d74 Mon Sep 17 00:00:00 2001 From: Alvaro Iradier Date: Mon, 9 Feb 2026 14:01:05 +0100 Subject: [PATCH 6/6] docs: capitalize Tenant in secure_tenant_external_id docs Co-Authored-By: Claude Opus 4.6 --- website/docs/d/secure_tenant_external_id.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/website/docs/d/secure_tenant_external_id.md b/website/docs/d/secure_tenant_external_id.md index 240adecc9..e0ba9b487 100644 --- a/website/docs/d/secure_tenant_external_id.md +++ b/website/docs/d/secure_tenant_external_id.md @@ -8,7 +8,7 @@ description: |- # Data Source: sysdig_secure_tenant_external_id -Retrieves the **cloud onboarding** external ID for the Sysdig Secure tenant. This ID is used when configuring trusted relationships for cloud account onboarding (e.g., AWS IAM role trust policies). +Retrieves the **cloud onboarding** external ID for the Sysdig Secure Tenant. This ID is used when configuring trusted relationships for cloud account onboarding (e.g., AWS IAM role trust policies). ~> **Note:** This is *not* the Customer External ID shown in [Customer ID, Name, and External ID](https://docs.sysdig.com/en/administration/find-your-customer-id-and-name/). For the customer-level external ID, use [`sysdig_current_user`](current_user.md) and its `customer_external_id` attribute instead. @@ -26,5 +26,5 @@ data "sysdig_secure_tenant_external_id" "external_id" {} In addition to all arguments above, the following attributes are exported: -* `external_id` - The cloud onboarding external ID for the Sysdig Secure tenant. +* `external_id` - The cloud onboarding external ID for the Sysdig Secure Tenant.