Platform Engineering · Lesson 237

Golden Paths, Software Templates, and Platform APIs: From Tickets to Self-Service

A golden path is the supported, opinionated way to do a common job (create a service, add a database, get a preview environment), made so easy that teams choose it. It is delivered through software templates (Backstage scaffolder, cookiecutter, Copier), a developer portal that catalogues what exists, and platform APIs that provision infrastructure on request: Kubernetes custom resources backed by Crossplane compositions, a Terraform module catalogue behind a pipeline, or a portal action. This lesson follows one team asking for a new service with a database and preview environments, and shows the two ways self-service goes wrong: templates that copy-and-diverge forever, and a platform API that exposes every cloud knob.

Difficulty: Advanced · Know this first: Lesson 236, Lesson 148

What you will learn

By the end of this lesson you can work at four levels:

This page teaches it with a plain-language analogy, an animated diagram with normal and failure scenarios, a simulator, a quiz, basic, intermediate, advanced, and master checks, the expert detail ("Go deeper"), a production incident, a hands-on lab with commands and their output, and a production design exercise.

Run it as:

When it breaks, I check

One thing to remember

Where the time goes

This bar adds up minutes from the request to a running service with a database. It is a worked example, not a measurement. The platform API and upgrade hops decide whether self-service stays safe and current.

Try it: design the golden path

Pick how templates work, how much the platform API exposes, and whether previews clean themselves up. The readouts show time to a new service and the cost of rolling out a fix.

47 minto a new service with a database
1 weekto roll a fix to 140 services
$900preview cost a month

Check yourself

Three questions. No score is saved anywhere — this is just you against the material.

Basic to master

Golden paths grow in four levels: using them, building templates, building platform APIs, and keeping paths maintained across the estate.

Basic — Use the golden path

At the basic level you can create and run a service on the path.

  • The portal's templates, the catalogue entry, and the claim for a database.
  • What the path supports and what it does not.
  • Preview environments for your pull requests.

Where it breaks: copying another team's repository instead of using the template.

Try it: Basic

Your service needs something the path does not support. What do you do?

Now do it: Read your platform's list of supported options.

Intermediate — Build templates

At the intermediate level you build updatable templates.

  • Copier or Backstage scaffolder templates with the version recorded.
  • Pipeline, manifests, observability, docs, and catalog-info.yaml included.
  • Shared pieces in libraries and base images, bumped by Renovate or Dependabot.

Try it: Intermediate

Where should logging configuration live so a change reaches every service?

Now do it: Move one copied file into a shared library.

Advanced — Build platform APIs

At the advanced level you build APIs that provision infrastructure safely.

  • Crossplane composite resources and compositions, or kro, or a Terraform module catalogue behind a pipeline.
  • A narrow schema with secure defaults; versioned, tested compositions.
  • Policies on claims; status reported back to the team.

Try it: Advanced

A team needs a larger database than the API allows. What is the platform-API way?

Now do it: Add an option to one composition in a test cluster.

Master — Maintain the paths

At the master level the golden paths stay current across the whole estate.

  • Template and composition versions tracked per service; update campaigns measured.
  • Migration from tickets: routine ticket types retired one by one as self-service replaces them.
  • Deprecation of old path versions with dates and help (next lesson).

Trade-off: opinionated paths are fast and consistent, and some teams will need to leave them; make leaving visible, not punished.

Try it: Master

How do you measure the move from tickets to self-service?

Now do it: Chart routine tickets by type for the last year.

Go deeper

A platform API for a database with Crossplane: teams create a small claim; the composition (not shown) expands it into the cloud database, networking, backups, monitoring, and a connection secret. Check the Crossplane documentation for your version (v2 changes some kinds).

# what a team writes, in its own namespace
apiVersion: platform.example.org/v1alpha1
kind: PostgreSQLInstance
metadata: {name: ledger-db, namespace: payments}
spec:
  size: small                 # small | medium | large, mapped to instance classes by the platform
  version: "16"
  environment: production     # drives backups (14 days), Multi-AZ, alarms
  writeConnectionSecretToRef: {name: ledger-db-conn}
---
# the schema the platform publishes (part of a CompositeResourceDefinition)
spec:
  versions:
  - name: v1alpha1
    schema:
      openAPIV3Schema:
        properties:
          spec:
            properties:
              size: {type: string, enum: [small, medium, large]}
              version: {type: string, enum: ["15", "16"]}
              environment: {type: string, enum: [dev, staging, production]}
            required: [size, environment]

An updatable template with Copier: the answers and template version are saved in the project, so copier update (or a bot running it) can bring later template changes in, as a reviewable diff.

copier copy gh:example-org/service-template ledger-service   # asks the template's questions
cat ledger-service/.copier-answers.yml                       # _commit: v3.4, language: go, database: postgresql
cd ledger-service && copier update                           # later: pulls template v3.5 changes as a diff

Preview environments with Argo CD: an ApplicationSet with a pull-request generator creates one Application per open pull request and deletes it when the pull request closes.

One time it broke

This is a composite of a failure pattern that keeps repeating; the details are illustrative. The template that was copied 140 times.

Timeline

  • Years 1–3New services are created by copying an "example service" repository. Each copy is edited freely; nothing records where it came from.
  • Day 0A critical vulnerability is announced in the base image, and the logging pipeline needs a format change for a compliance deadline.
  • Months 1–5Platform engineers open 140 pull requests by hand. Many conflict with local edits; some sit unmerged for weeks because teams do not recognise the files.
  • Month 5The last service is patched. The example repository becomes a Copier template with recorded versions and automated update pull requests.

What changed after

Every new service records its template version, shared pieces live in base images and libraries bumped by Renovate, template updates arrive as pull requests, and a scorecard shows each service's template version.

Try it yourself, from scratch

Everything here runs on any Linux machine: your own laptop, WSL on Windows (run wsl --install in PowerShell once), or a small cloud VM. The Python needs only Python 3 and its standard library; check that you have it with python3 --version.

Before you start: A virtual environment for Python packages: python3 -m venv ~/plat && . ~/plat/bin/activate. Then pip install copier, and Git.

1. Linux commands

Type each one, read what it prints, and compare it with the note above it.

  1. Make a tiny template: a question file and one templated file, in a Git repository with a version tag.

    Reversible

    mkdir -p ~/labs/paths/template && cd ~/labs/paths/template
    git init -q
    cat > copier.yml <<'EOF'
    service_name: {type: str, help: Service name}
    language: {type: str, choices: [go, java], default: go}
    _answers_file: .copier-answers.yml
    EOF
    echo '{{ _copier_answers|to_nice_yaml -}}' > "{{_copier_conf.answers_file}}.jinja"
    printf 'service: {{ service_name }}\nlanguage: {{ language }}\nlog_format: text\n' > service.yaml.jinja
    git add -A && git commit -qm "template" && git tag v1.0

    Options: copier.yml holds the questions; files ending .jinja are rendered; the answers file records each project's answers and template version, which is what makes updates possible; the tag is the template version.

    Expect: A Git repository tagged v1.0.

    Clean up: rm -rf ~/labs/paths.

  2. Generate a service from it; the answers file records the template version.

    Read-only

    cd ~/labs/paths && copier copy --defaults --data service_name=ledger "$HOME/labs/paths/template" ledger
    cat ledger/service.yaml ledger/.copier-answers.yml

    Options: --defaults takes default answers; --data sets one; an absolute template path lets the project find its template again later.

    Expect: A service.yaml with log_format: text, and the answers file with _commit: v1.0: the template version this project came from.

  3. Improve the template (JSON logs, v1.1), then pull the change into the service as an update.

    Potentially destructive

    cd ~/labs/paths/template && sed -i "s/log_format: text/log_format: json/" service.yaml.jinja && git commit -qam "json logs" && git tag v1.1
    cd ~/labs/paths/ledger && git init -q && git add -A && git commit -qm init
    copier update --defaults
    grep log_format service.yaml

    Expect: log_format: json: the improvement reached a generated project as a reviewable change, which is how a template avoids becoming a fork.

2. Python: platform_api.py

This program is a narrow platform API for databases. A team's claim has three fields; the platform validates them against a schema and expands them into the full set of provider settings with secure defaults, so teams cannot switch off backups or turn on public access. It also compares the cost of rolling a fix to 140 services with copied templates and with updatable ones. Save it as platform_api.py, then run it.

# platform_api.py
SCHEMA = {"size": {"small", "medium", "large"}, "version": {"15", "16"}, "environment": {"dev", "staging", "production"}}
CLASS = {"small": "db.t4g.medium", "medium": "db.r7g.large", "large": "db.r7g.2xlarge"}

def compose(claim):
    extra = set(claim) - set(SCHEMA)
    if extra:
        return f"REJECTED: fields not in the platform API: {sorted(extra)} (the platform decides these)"
    for field, allowed in SCHEMA.items():
        if claim.get(field) not in allowed:
            return f"REJECTED: {field} must be one of {sorted(allowed)}"
    prod = claim["environment"] == "production"
    return {
        "engine": "postgres", "engine_version": claim["version"], "instance_class": CLASS[claim["size"]],
        "storage_encrypted": True, "publicly_accessible": False,
        "backup_retention_days": 14 if prod else 3, "multi_az": prod, "deletion_protection": prod,
        "monitoring": "enhanced", "subnet_group": f"private-{claim['environment']}",
        "tags": {"managed-by": "platform", "environment": claim["environment"]},
    }

for claim in [{"size": "small", "version": "16", "environment": "production"},
              {"size": "small", "version": "16", "environment": "production", "publicly_accessible": True, "backup_retention_days": 0},
              {"size": "huge", "version": "16", "environment": "dev"}]:
    result = compose(claim)
    print(f"claim {claim}")
    print(f"  -> {result if isinstance(result, str) else str(len(result)) + ' settings, e.g. backups ' + str(result['backup_retention_days']) + ' days, public ' + str(result['publicly_accessible'])}")
print()

SERVICES, MINUTES_PER_MANUAL_PR, REVIEW_MIN = 140, 90, 10
manual = SERVICES * MINUTES_PER_MANUAL_PR
automated = SERVICES * REVIEW_MIN
print(f"roll a fix to {SERVICES} services: copied templates about {manual / 60:.0f} engineer-hours; "
      f"update pull requests about {automated / 60:.0f} engineer-hours of review")

Run it, and you should see this output:

$ python3 platform_api.py
claim {'size': 'small', 'version': '16', 'environment': 'production'}
  -> 11 settings, e.g. backups 14 days, public False
claim {'size': 'small', 'version': '16', 'environment': 'production', 'publicly_accessible': True, 'backup_retention_days': 0}
  -> REJECTED: fields not in the platform API: ['backup_retention_days', 'publicly_accessible'] (the platform decides these)
claim {'size': 'huge', 'version': '16', 'environment': 'dev'}
  -> REJECTED: size must be one of ['large', 'medium', 'small']

roll a fix to 140 services: copied templates about 210 engineer-hours; update pull requests about 23 engineer-hours of review

3. What to notice

4. Advanced: every step as one Bash script

The same Linux steps, made into a real script you can keep and run again. It uses the Bash features a production script needs: functions (one per step), an array of step names, arguments to choose steps, a case for options, exit codes recorded for each step, and a trap that prints a summary even when you stop it with Ctrl+C. Make a folder for this lesson (mkdir -p ~/labs/golden-paths-software-templates-and-platform-apis && cd ~/labs/golden-paths-software-templates-and-platform-apis) and save this as lab.sh.

#!/usr/bin/env bash
# The Linux steps of "Golden Paths, Software Templates, and Platform APIs: From Tickets to Self-Service", as one script (save it as lab.sh).
#
#   ./lab.sh          run every step, in order
#   ./lab.sh 2 4      run only steps 2 and 4
#   ./lab.sh --list   list the steps
#
# The steps share one shell, so a later step can use what an earlier one set up (a folder,
# a variable, a container): run them all in order the first time. Your own scripts should
# start with "set -euo pipefail"; this one runs teaching commands, and some of them fail on
# purpose, so it records each step's exit code instead of stopping at the first failure.

STEPS=(
  'Make a tiny template: a question file and one templated file, in a Git repository with a version tag.'
  'Generate a service from it; the answers file records the template version.'
  'Improve the template (JSON logs, v1.1), then pull the change into the service as an update.'
)

step_1() {
mkdir -p ~/labs/paths/template && cd ~/labs/paths/template
git init -q
cat > copier.yml <<'EOF'
service_name: {type: str, help: Service name}
language: {type: str, choices: [go, java], default: go}
_answers_file: .copier-answers.yml
EOF
echo '{{ _copier_answers|to_nice_yaml -}}' > "{{_copier_conf.answers_file}}.jinja"
printf 'service: {{ service_name }}\nlanguage: {{ language }}\nlog_format: text\n' > service.yaml.jinja
git add -A && git commit -qm "template" && git tag v1.0
}

step_2() {
cd ~/labs/paths && copier copy --defaults --data service_name=ledger "$HOME/labs/paths/template" ledger
cat ledger/service.yaml ledger/.copier-answers.yml
}

step_3() {
cd ~/labs/paths/template && sed -i "s/log_format: text/log_format: json/" service.yaml.jinja && git commit -qam "json logs" && git tag v1.1
cd ~/labs/paths/ledger && git init -q && git add -A && git commit -qm init
copier update --defaults
grep log_format service.yaml
}

# print a step that has to be run by hand, instead of running it
by_hand() {
  echo "  (run this one yourself: $1)"
  sed 's/^/    /'
}

RESULTS=()
run_step() {
  local n=$1 start=$SECONDS code
  printf '\n== step %d of %d: %s\n' "$n" "${#STEPS[@]}" "${STEPS[n-1]}"
  "step_$n"
  code=$?
  RESULTS+=("step $n: exit code $code, $((SECONDS - start)) s")
}

summary() {
  echo
  echo "== summary"
  local r
  for r in "${RESULTS[@]}"; do echo "  $r"; done
}

case "${1:-}" in
  -h|--help) sed -n '2,6p' "$0"; exit 0 ;;
  --list) for i in "${!STEPS[@]}"; do echo "$((i + 1)). ${STEPS[i]}"; done; exit 0 ;;
esac

[ $# -eq 0 ] && set -- $(seq 1 "${#STEPS[@]}")
for n in "$@"; do
  if ! [[ $n =~ ^[0-9]+$ ]] || (( n < 1 || n > ${#STEPS[@]} )); then
    echo "there is no step '$n'; try --list" >&2
    exit 2
  fi
done
trap summary EXIT
trap 'echo; echo "stopped with Ctrl+C"; exit 130' INT
for n in "$@"; do run_step "$n"; done

Then make it executable and run it:

chmod +x lab.sh
./lab.sh --list     # the steps
./lab.sh            # every step, then a summary of exit codes and times
./lab.sh 2 3        # only steps 2 and 3

5. Learn the basics behind it

New to a feature used above? These W3Schools pages explain each one from zero, with examples you can run in the browser.

If you remember nothing else

Design exercise

Teams wait three weeks and file 14 tickets for a new service with a database. Design the golden path that replaces it.

Clarifying questions to ask

What does the portal offer? What do templates generate, and how do they stay updatable? What does the platform API look like, and what is behind it? Which guardrails apply? How do environments and previews work? How do you retire the old tickets?

Rough sizing

Say 25 teams, 6 new services a month, 140 existing services, two databases (PostgreSQL and Redis), and three environments plus previews.

Shape of the answer

A portal with "New service" and "Add database" golden paths; Copier templates generating repository, pipeline, manifests, observability, docs, and catalog-info.yaml, with versions recorded and update pull requests; Crossplane claims for PostgreSQL and Redis with size, version, and environment only, compositions setting encryption, backups, private networking, monitoring, and secrets; Kyverno policies on claims; Argo CD for environments and an ApplicationSet for previews with TTLs; the 14 routine ticket types retired one by one as each path goes live; a campaign to move the 140 existing services onto the template.

Trade-offs to name

Narrow APIs mean some requests need an API change, which keeps them governed; Crossplane adds a control plane to run; previews cost money that TTLs and quotas must bound; migrating 140 services is a long campaign that pays back on every future fix.

Failure modes and how to troubleshoot them

Each row is one way this system went wrong in the diagram's scenarios. The hop number is where to look first.

ScenarioWhereEffectWhat goes wrong
Copy-and-diverge templatesHop 9: UpgradesBreaks140 services were created by copying an example repository over three years.
Every knob exposedHop 4: Platform APIBreaksThe database API passes all 60 provider parameters through to teams "for flexibility". A team copies an example that sets public access on and backup retention to 0 to save cost in dev, then uses the same values in production.
Every knob exposedHop 6: GuardrailsDegradesOnly public access was checked; backup retention had no policy.

How to troubleshoot

  1. Write down the symptom and when it started: what users see, which number moved, and what changed just before (a deploy, a config change, traffic).
  2. Walk the path in order, from the first hop to the last: Request → Template → Catalogue → Platform API → Composition or module → Guardrails → Environments → Preview environments → Upgrades. The first hop whose evidence is wrong is where to dig.
  3. At that hop, run the read-only check from the diagram or the lab first; change nothing until the evidence points at a cause.
  4. Fix the smallest thing that restores service, or roll back the last change, and confirm the symptom is gone with the same check.
  5. Write down what you found and the check that would have caught it sooner, so the next person starts there.

References and review

The official documentation and standards behind this lesson. Versions and defaults change; when a command or field here differs from them, trust the official page.

Last updated . Next review due by November 2027. Found something out of date? Tell me.

Saved on this device, in this browser.
Next in this series · Lesson 238
Platform Scorecards, SLOs, Cost Allocation, and Deprecation

Once teams depend on a platform, it has to be run like the production system it is. Scorecards show each service's standing against agreed standards (owner, on-call, SLOs, template version, vulnerabilities) and nudge improvement…

Go to Lesson 238 →

Or browse the full course from the Lessons index.