diff --git a/sysdig/data_source_sysdig_current_user.go b/sysdig/data_source_sysdig_current_user.go index 38f0cf88..3b0e3a63 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,15 @@ 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) + } else { + _ = d.Set("customer_id", nil) + _ = d.Set("customer_name", nil) + _ = d.Set("customer_external_id", nil) + } + return nil } diff --git a/sysdig/data_source_sysdig_current_user_test.go b/sysdig/data_source_sysdig_current_user_test.go index c89aa784..4a5648db 100644 --- a/sysdig/data_source_sysdig_current_user_test.go +++ b/sysdig/data_source_sysdig_current_user_test.go @@ -22,6 +22,9 @@ func TestAccCurrentUser(t *testing.T) { Steps: []resource.TestStep{ { Config: getCurrentUser(), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttrSet("data.sysdig_current_user.me", "customer_id"), + ), }, }, }) diff --git a/sysdig/internal/client/v2/model.go b/sysdig/internal/client/v2/model.go index 3d131f21..0305b98f 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 38a1a32d..d400c1cb 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/). Only available for users with the Admin role; empty for non-admin users. \ 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 8dbd6272..e0ba9b48 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.