Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions sysdig/data_source_sysdig_current_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
},
}
}
Expand All @@ -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)
Comment thread
airadier marked this conversation as resolved.
} else {
_ = d.Set("customer_id", nil)
_ = d.Set("customer_name", nil)
_ = d.Set("customer_external_id", nil)
}
Comment thread
tembleking marked this conversation as resolved.

return nil
}
3 changes: 3 additions & 0 deletions sysdig/data_source_sysdig_current_user_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
),
Comment thread
tembleking marked this conversation as resolved.
},
},
Comment thread
airadier marked this conversation as resolved.
})
Expand Down
21 changes: 14 additions & 7 deletions sysdig/internal/client/v2/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
8 changes: 7 additions & 1 deletion website/docs/d/current_user.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
* `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.
6 changes: 4 additions & 2 deletions website/docs/d/secure_tenant_external_id.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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.

Loading