Skip to content

entrepot_gitlab_trust_policy

A GitLab trust policy lets GitLab CI/CD jobs authenticate with their id_token (no stored secrets). A job is matched to the policy when its token was issued by the named GitLab instance and every condition matches; bind roles to the policy with entrepot_role_binding (subject_type = "gitlab_policy"). Deleting a policy also deletes the role bindings that reference it.

# Trust id_tokens from protected branches of projects under platform/ on the
# GitLab instance configured as "gitlab" in the server's auth.gitlab list.
resource "entrepot_gitlab_trust_policy" "platform" {
name = "platform-protected"
description = "Protected pipelines of the platform group"
gitlab = "gitlab"
conditions = {
project_path = "platform/**"
ref_protected = "true"
}
}
# In .gitlab-ci.yml:
# id_tokens:
# ENTREPOT_TOKEN:
# aud: https://entrepot.example.com
  • conditions (Map of String) id_token claim → glob pattern; all must match. Common claims: project_path, namespace_path, ref, ref_type, ref_protected, environment, pipeline_source. * matches within a path segment, ** across segments and a|b either alternative, e.g. { project_path = "platform/**", ref_protected = "true" }.
  • gitlab (String) Name of a trusted GitLab instance from the server’s auth.gitlab configuration (listed in GET /api/v1/system/info as gitlabInstances).
  • name (String) Policy name, used as the role binding subject. Changing it forces a new policy.
  • description (String) Free-form description.
  • id (String) Same as name.

The terraform import command can be used, for example:

Terminal window
# GitLab trust policies are imported by name.
terraform import entrepot_gitlab_trust_policy.platform platform-protected

Resource documentation generated from the provider’s schema (docs/resources/gitlab_trust_policy.md in terraform-provider-entrepot).