> ## 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_repo_tags resource

> Manages the tags of a Kosli repo by its internal ID. Use it with the kosli_repo and kosli_repos data sources to tag existing repos from Terraform.

Manages the tags of a Kosli [repo](https://docs.kosli.com/tutorials/repositories.md). Kosli records a repo when an attestation or trail references it, so this resource tags an existing repo and never creates or deletes one. Use the [`kosli_repos` data source](https://docs.kosli.com/terraform-reference/data-sources/repos) or the [`kosli_repo` data source](https://docs.kosli.com/terraform-reference/data-sources/repo) to find repo IDs.

> [!WARNING]
>
> `tags` is authoritative: it manages every tag on the repo. Tags added outside Terraform, in the Kosli UI or with `kosli tag repo`, show as drift and are removed on the next apply. Destroying the resource removes all of the repo's tags.

> [!WARNING]
>
> Declare at most one `kosli_repo_tags` per repo. Two resources for the same repo remove each other's tags.

> [!NOTE]
>
> `kosli_repos` is read at plan time. A repo that Kosli first records later in the same pipeline isn't visible until the next plan, so it isn't tagged until then.

## Example usage

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

# Find every GitHub repo under the acme/platform namespace
data "kosli_repos" "platform" {
  namespace    = "acme/platform"
  vcs_provider = "github"
}

# Tag each of them. Key on the repo ID: names can repeat across VCS providers.
resource "kosli_repo_tags" "platform" {
  for_each = { for r in data.kosli_repos.platform.repos : r.id => r }

  repo_id = each.key
  tags = {
    team = "platform"
    tier = "1"
  }
}

# Tag a single repo found by its name
data "kosli_repo" "billing" {
  name         = "acme/payments/billing"
  vcs_provider = "github"
}

resource "kosli_repo_tags" "billing" {
  repo_id = data.kosli_repo.billing.id
  tags = {
    team = "payments"
  }
}
```

## Import

Repo tags can be imported using the repo's internal ID:

```shell theme={"theme":"dracula","languages":{"custom":["/languages/rego.json"]}}
# Import by the repo's internal ID, shown by `kosli get repo`
terraform import kosli_repo_tags.billing 6f1c2a9e-3b7d-4c55-9e0a-1d2f3b4c5d6e
```

## Schema

### Required

* `repo_id` (String) Internal Kosli ID of the repo, as returned by the `kosli_repos` data source or `kosli get repo`. Repo names repeat across VCS providers, so tags are keyed by ID. Changing this forces a new resource.
* `tags` (Map of String) Key-value pairs to tag the repo with. These replace every existing tag on the repo; `{}` removes them all.


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