Skip to main content
Fetches an existing Kosli Rego policy and the files of one of its versions. Without version, it reads the policy’s current version: the highest-numbered valid version, which is the one an evaluation runs.

Example usage

Which version is read

Without version, the data source reads the policy’s current version: the highest-numbered valid version, which is the one an evaluation runs. A newer version that is pending, rejected or failed is not the current version. A policy with no valid version yet is an error. The error names the newest version, which you can then read by number. With version, the data source reads that version whatever its status. status says whether it is pending, valid, rejected or failed, and entrypoint and params_schema are null unless it is valid. name, description, created_at and created_by belong to the policy, not to a version, so they are the same for every version.

Archived policies

Destroying a kosli_rego_policy archives the policy. By default, the data source reads only an active policy and reports an archived one as an error. Set archived = true to read an archived policy.

Read-only access

Data sources provide read-only access. To publish or change a Rego policy, use the kosli_rego_policy resource.

Schema

Required

  • identifier (String) The identifier of the policy to query. Kosli compares identifiers without regard to case.

Optional

  • archived (Boolean) Whether the policy is expected to be archived. Deleting a kosli_rego_policy archives it, so by default only an active policy is read and an archived one is an error. Set to true to read an archived policy; an active one is then an error.
  • version (Number) The version to read. Any version can be read, whatever its status. When unset, the current version is read and its number is returned here.

Read-only

  • comment (String) Why the version was published.
  • created_at (String) RFC3339 UTC timestamp of when the policy was created.
  • created_by (String) Display name of the user who created the policy.
  • description (String) The description of the policy. Null when it has none.
  • digest (String) Digest of the version’s files, as sha256: and a hex digest. A decision made with the version cites this value.
  • entrypoint (String) Policy package Kosli found as the entrypoint. Null unless the version is valid.
  • files (Map of String) The version’s Rego bundle, as a map of each file’s relative path to its source.
  • input_schema (String) Shape of the input the version is written against, such as trail or trails.
  • name (String) Human-readable display name of the policy.
  • params_schema (String) JSON Schema, as a JSON string, that the version declares for its params. Null when it declares none or is not valid.
  • status (String) Validation status of the version: pending, valid, rejected or failed. Always valid when version is unset.
Last modified on November 27, 2026