> ## Documentation Index
> Fetch the complete documentation index at: https://docs.kosli.com/llms.txt
> Use this file to discover all available pages before exploring further.

# kosli_service_account data source

> Fetches details of an existing Kosli service account. Use this data source to reference service accounts and access metadata such as the privilege, creator, and creation timestamp.

Fetches details of an existing Kosli service account. Use this data source to reference service accounts and access metadata such as the privilege, creator, and creation timestamp.

Use this data source to:

* Reference an existing service account managed outside Terraform
* Read the granted privilege, creating user, and creation timestamp
* Build conditional logic based on service account metadata

## Example usage

```terraform theme={"theme":"dracula","languages":{"custom":["/languages/rego.json"]}}
terraform {
  required_providers {
    kosli = {
      source = "kosli-dev/kosli"
    }
  }
}

# Create a service account
resource "kosli_service_account" "ci" {
  name        = "ci-pipeline"
  description = "CI/CD pipeline service account"
  privilege   = "member"
}

# Look up the service account via data source
data "kosli_service_account" "ci" {
  name = kosli_service_account.ci.name
}

# Reference service account metadata
output "ci_privilege" {
  description = "Privilege (role) of the CI service account"
  value       = data.kosli_service_account.ci.privilege
}

output "ci_created_at" {
  description = "RFC3339 UTC timestamp of when the service account was created"
  value       = data.kosli_service_account.ci.created_at
}
```

## Read-only access

Data sources provide read-only access to service account metadata. To create or modify service accounts, use the [`kosli_service_account` resource](/terraform-reference/resources/service_account). To manage API keys, use the [`kosli_service_account_api_key` resource](/terraform-reference/resources/service_account_api_key).

## Schema

### Required

* `name` (String) The name of the service account to query.

### Read-only

* `created_at` (String) RFC3339 UTC timestamp of when the service account was created.
* `creating_user_id` (String) Identifier of the user who created the service account.
* `description` (String) The description of the service account.
* `display_name` (String) The display name of the service account.
* `for_webhook` (Boolean) Whether the service account was created for webhook usage.
* `privilege` (String) The privilege (role) of the service account within the organization (`admin`, `member`, `snapshotter`, or `reader`).
