Skip to content

GitLab Credentials Guide

Bootstrap guide for giving the platform automation scripts full access to all managed groups and projects under tierpoint/prodtech. Follows the same god-mode-then-scope-down pattern as the GitHub guide.

Script that uses this: scripts/identity/Invoke-GitLabVariableDistribution.ps1
See also: GitHub Credentials Guide — same pattern for GitHub


Prerequisites

  • Invoke-TenantIdentitySetup.ps1 must have run first. The GitLab variable distribution seeds SPN credentials (client-id and secret) for kv-demos-platform, kv-tplabs-platform, and kv-phx-platform into GitLab CI/CD variables. Those SPNs must exist and their secrets must be in the tenant Key Vaults before this script can read them.
  • Azure CLI logged in as kris@hybridsolutions.cloud with access to kv-hcs-vault-01
  • Environment loaded: . D:\git\platform\scripts\Load-HCSEnvironment.ps1

Phase 1 — God-mode bootstrap

Step 1 — Create god-mode PATs (one per account)

You have two GitLab accounts with access to tierpoint/prodtech. Create one PAT per account.

PAT 1 — KristopherjTurner personal account (gitlab.com)

Where: gitlab.com → User Settings → Access Tokens

Token name: hcs-platform-godmode-<YYYY-MM-DD>

Expiration: 90 days

Scopes — select ALL:

ScopeWhy
apiFull API access — read/write groups, projects, CI/CD variables, members
read_userRead authenticated user profile
read_apiRead-only API (subset of api, included for completeness)
read_repositoryRead repository content
write_repositoryPush to repositories
read_registryRead GitLab Container Registry
write_registryWrite to GitLab Container Registry
create_runnerRegister GitLab Runners
manage_runnerManage Runner configuration

sudo and admin_mode are only available on self-hosted GitLab instances where your account has admin rights. On gitlab.com they are not available — skip them. The api scope alone is sufficient for all group/project variable management.

Store in KV immediately:

powershell
az keyvault secret set `
  --vault-name kv-hcs-vault-01 `
  --name hcs-platform-gitlab-kjt-godmode-pat `
  --value '<paste-token-here>'

PAT 2 — kristopher.turner@tierpoint.com (gitlab.com TierPoint account)

Same process. Token name: hcs-platform-tp-godmode-<YYYY-MM-DD>

Store in KV:

powershell
az keyvault secret set `
  --vault-name kv-hcs-vault-01 `
  --name hcs-platform-gitlab-tp-godmode-pat `
  --value '<paste-token-here>'

Step 2 — Add both secrets to secret-inventory.md

Add these rows to docs/identity/secret-inventory.md:

Secret nameVaultPurposeRotationNotes
hcs-platform-gitlab-kjt-godmode-patkv-hcs-vault-01God-mode GitLab PAT — KristopherjTurner account — all scopesRevoke after Phase 2Temporary
hcs-platform-gitlab-tp-godmode-patkv-hcs-vault-01God-mode GitLab PAT — TierPoint account — all scopesRevoke after Phase 2Temporary

Tick the corresponding rows in Table C of docs/onboarding/tracker.md.


Step 3 — Seed group CI/CD variables

The script uses the TierPoint account god-mode PAT (hcs-platform-gitlab-tp-godmode-pat) by default, since that account has access to the tierpoint/prodtech group.

powershell
. D:\git\platform\scripts\Load-HCSEnvironment.ps1

# Preview first
pwsh D:\git\platform\scripts\identity\Invoke-GitLabVariableDistribution.ps1 -DryRun

# Review log output, then run live
pwsh D:\git\platform\scripts\identity\Invoke-GitLabVariableDistribution.ps1

What the script seeds:

Group-level variables (inherited by all projects under tierpoint/prodtech)

GroupVariableSource KV secretMasked
tierpoint/prodtechPLATFORM_PAThcs-platform-gitlab-tp-godmode-pat (→ replaced by hcs-platform-gitlab-tp-pat in Phase 2)Yes
tierpoint/prodtech/azurelocalAZL_KV_NAMEStatic: kv-demos-platformNo

Subgroup-level variables (per-tenant KV access for lab environment projects)

These variables let CI/CD jobs in each lab-environment subgroup authenticate to the correct tenant Key Vault to pull secrets at runtime.

GroupVariableSource KV secretSource vaultMasked
tierpoint/prodtech/azurelocal/lab-environmentsKV_SP_CLIENT_IDtpdemos-platform-automation-spn-client-idkv-demos-platformNo
tierpoint/prodtech/azurelocal/lab-environmentsKV_SP_SECRETtpdemos-platform-automation-spn-secretkv-demos-platformYes
tierpoint/prodtech/azurelocal/lab-environmentsKV_TENANT_IDStatic: 28217fed-1ba3-4974-89c0-f1423aafe640No

Note on subgroup variable scope: Where tplabs and phx projects live in different subgroups than tpdemos, set their KV_SP_CLIENT_ID / KV_SP_SECRET / KV_TENANT_ID at those subgroup paths or at the project level. Update the script's $script:GroupDefinitions array to add those group paths before running.


Phase 2 — Scoped per-account PATs (AB#23)

Create these after the god-mode bootstrap is confirmed working. Scopes: api, read_repository, write_repository only — no runner management or registry write.

Expiration: 365 days with calendar reminder to rotate.

GitLab accountKV secret name (→ kv-hcs-vault-01)
KristopherjTurner (gitlab.com personal)hcs-platform-gitlab-kjt-pat
kristopher.turner@tierpoint.comhcs-platform-gitlab-tp-pat

Store each immediately:

powershell
az keyvault secret set `
  --vault-name kv-hcs-vault-01 `
  --name hcs-platform-gitlab-tp-pat `
  --value '<paste-token>'

Add each to docs/identity/secret-inventory.md and tick the corresponding row in Table C of docs/onboarding/tracker.md.

Re-seed group variables with scoped PAT

powershell
pwsh D:\git\platform\scripts\identity\Invoke-GitLabVariableDistribution.ps1 `
  -PatKvSecretName hcs-platform-gitlab-tp-pat `
  -DryRun

pwsh D:\git\platform\scripts\identity\Invoke-GitLabVariableDistribution.ps1 `
  -PatKvSecretName hcs-platform-gitlab-tp-pat

This re-seeds PLATFORM_PAT using the scoped token, replacing the god-mode value.


Phase 3 — Revoke god-mode PATs

Only do this after the scoped PATs are confirmed in KV and PLATFORM_PAT has been re-seeded.

  1. GitLab → User Settings → Access Tokens → revoke hcs-platform-godmode-* on both accounts
  2. Remove from KV:
    powershell
    az keyvault secret delete --vault-name kv-hcs-vault-01 --name hcs-platform-gitlab-kjt-godmode-pat
    az keyvault secret delete --vault-name kv-hcs-vault-01 --name hcs-platform-gitlab-tp-godmode-pat
  3. Update secret-inventory.md — mark both rows as revoked/deleted with the date.

Copyright © Hybrid Cloud Solutions LLC — Kristopher Turner