> ## 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_repos data source

> Lists Kosli repos matching filters such as name, namespace, VCS provider and tags. Use the returned IDs with the kosli_repo_tags resource to tag repos.

Lists Kosli [repos](https://docs.kosli.com/tutorials/repositories.md) matching the given filters. Kosli records a repo when an attestation or trail references it. Use the returned `id` values with the [`kosli_repo_tags` resource](https://docs.kosli.com/terraform-reference/resources/repo_tags) to tag repos. To fetch a single repo, use the [`kosli_repo` data source](https://docs.kosli.com/terraform-reference/data-sources/repo).

> [!NOTE]
>
> Data sources are read at plan time. A repo that Kosli first records later in the same pipeline is missing from `repos` until the next plan. No match returns an empty list, not an error.

## Example usage

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

# All repos whose name contains "service", on a self-hosted GitLab
data "kosli_repos" "services" {
  search       = "service"
  vcs_provider = "gitlab"
  vcs_instance = "gitlab.acme.com"
}

# Repos owned by the platform or payments team that have a tier tag with any value
data "kosli_repos" "tiered" {
  tag_filter {
    key    = "team"
    values = ["platform", "payments"]
  }
  tag_filter {
    key = "tier"
  }
}

output "service_repo_ids" {
  description = "Internal IDs of the matching repos, for use with kosli_repo_tags"
  value       = data.kosli_repos.services.repos[*].id
}

output "tiered_repo_names" {
  description = "Names of the tiered repos owned by the platform or payments team"
  value       = data.kosli_repos.tiered.repos[*].name
}
```

## Schema

### Optional

* `name` (String) Return only repos with exactly this name, for example `acme/platform/api`. Conflicts with `search`.
* `namespace` (String) Return only repos nested anywhere under this `/`-separated namespace, for example `acme/platform`.
* `search` (String) Return only repos whose name contains this string (case-insensitive). Conflicts with `name`.
* `tag_filter` (Block List) Return only repos with a matching tag. Repos must match every `tag_filter` block. See the nested schema below.
* `vcs_instance` (String) Return only repos on this VCS host, for example `gitlab.company.com`.
* `vcs_provider` (String) Return only repos hosted by this VCS provider, for example `github`, `gitlab`, `bitbucket` or `azure-devops`.

### Read-only

* `repos` (Attributes List) The matching repos, sorted by name and then by `id`. Empty when no repo matches. See the nested schema below.

### Nested schema for `tag_filter`

Required:

* `key` (String) Tag key the repo must have.

Optional:

* `values` (List of String) Values the tag may have; a repo matches if its tag has any of them. Omit to match the key with any value.

### Nested schema for `repos`

Read-only:

* `id` (String) Internal Kosli ID of the repo. Use it as `repo_id` on `kosli_repo_tags`.
* `name` (String) Full name of the repo, including its namespace. Names can repeat across VCS providers.
* `tags` (Map of String) Key-value pairs tagging the repo.
* `url` (String) URL of the repo.
* `vcs_instance` (String) VCS host of the repo. Null when Kosli could not determine it.
* `vcs_provider` (String) VCS provider of the repo. Null when Kosli could not determine it.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.