Skip to main content
Fetches details of an existing Kosli policy. Use this data source to reference existing policies and access metadata such as the policy content, description, and latest version number.

Example usage

terraform {
  required_providers {
    kosli = {
      source = "kosli-dev/kosli"
    }
  }
}

# Query an existing policy
data "kosli_policy" "production" {
  name = "prod-requirements"
}

output "policy_latest_version" {
  description = "Latest version number of the policy"
  value       = data.kosli_policy.production.latest_version
}

output "policy_content" {
  description = "YAML content of the latest policy version"
  value       = data.kosli_policy.production.content
}

Schema

Required

  • name (String) The name of the policy to query.

Read-only

  • content (String) YAML content of the latest policy version. Null if the policy has no versions.
  • created_at (Number) Unix timestamp of when the policy was first created.
  • description (String) Description of the policy.
  • latest_version (Number) The version number of the latest policy version. Null if the policy has no versions.
Last modified on March 26, 2026