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
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.
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.
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.
Three questions. No score is saved anywhere — this is just you against the material.
Golden paths grow in four levels: using them, building templates, building platform APIs, and keeping paths maintained across the estate.
At the basic level you can create and run a service on the path.
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.
At the intermediate level you build updatable templates.
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.
At the advanced level you build APIs that provision infrastructure safely.
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.
At the master level the golden paths stay current across the whole estate.
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.
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.
This is a composite of a failure pattern that keeps repeating; the details are illustrative. The template that was copied 140 times.
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.
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.
Type each one, read what it prints, and compare it with the note above it.
Make a tiny template: a question file and one templated file, in a Git repository with a version tag.
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.0Generate a service from it; the answers file records the template version.
cd ~/labs/paths && copier copy --defaults --data service_name=ledger "$HOME/labs/paths/template" ledger cat ledger/service.yaml ledger/.copier-answers.yml
Improve the template (JSON logs, v1.1), then pull the change into the service as an update.
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
platform_api.pyThis 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
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
New to a feature used above? These W3Schools pages explain each one from zero, with examples you can run in the browser.
grep, sed, mkdir, cat, echo, cd, Pipes, Redirection, If...Else, Here documents.Teams wait three weeks and file 14 tickets for a new service with a database. Design the golden path that replaces it.
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?
Say 25 teams, 6 new services a month, 140 existing services, two databases (PostgreSQL and Redis), and three environments plus previews.
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.
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.
Each row is one way this system went wrong in the diagram's scenarios. The hop number is where to look first.
| Scenario | Where | Effect | What goes wrong |
|---|---|---|---|
| Copy-and-diverge templates | Hop 9: Upgrades | Breaks | 140 services were created by copying an example repository over three years. |
| Every knob exposed | Hop 4: Platform API | Breaks | The 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 exposed | Hop 6: Guardrails | Degrades | Only public access was checked; backup retention had no policy. |
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.