โšก
Zero to Platform Architect2026
Phase 7: DevEx & Platform IDPs
Phase 7: DevEx & Platform IDPsโฑ๏ธ 8 min readโšก Staff SRE Standard
๐ŸŽฏ Operations Test Bank →

Lesson 3: TechDocs Architecture & Phase 7 Hands-On Lab Solutions

This module details Spotify Backstageโ€™s TechDocs (Docs-Like-Code) publishing pipeline and provides complete solutions for the Phase 7 Job-Essential Exercises.


๐Ÿ“š TechDocs Architecture: The Docs-Like-Code Philosophy

Traditional enterprise documentation fails because it lives in static wikis (Confluence, Notion) disconnected from source code. When developers refactor an API, they forget to update the wiki, and documentation rots.

TechDocs enforces Docs-Like-Code:

  1. Documentation lives as Markdown inside a /docs directory inside the serviceโ€™s own Git repository.
  2. Every time a Pull Request merges to main, a CI/CD job compiles the markdown using mkdocs and uploads the static HTML bundle to an enterprise AWS S3 bucket.
  3. Backstage fetches and displays the documentation natively inside the componentโ€™s catalog page. Documentation stays synchronized with every code commit!
sequenceDiagram
    autonumber
    actor Dev as ๐Ÿ‘ฉโ€๐Ÿ’ป Developer (Edits docs/api.md)
    participant Git as ๐Ÿ™ GitHub Enterprise
    participant CI as ๐Ÿค– GitHub Actions (TechDocs Builder)
    participant S3 as ๐Ÿชฃ AWS S3 (TechDocs Storage)
    participant BS as ๐Ÿ–ฅ๏ธ Spotify Backstage UI

    Dev->>Git: git push origin main
    Git->>CI: Triggers .github/workflows/techdocs.yml
    CI->>CI: techdocs-cli generate (Runs MkDocs build)
    CI->>S3: techdocs-cli publish (Uploads to s3://corp-techdocs/default/component/orders/)
    Dev->>BS: Opens "Docs" tab on Order Service
    BS->>S3: Fetches HTML bundle
    BS-->>Dev: Renders interactive TechDocs with search! โœ…

๐Ÿ› ๏ธ Lab 1: The Catalog Definition Challenge

Objective

Author an enterprise catalog-info.yaml declaring an OrderManagementService Component that exposes an OrderAPI, depends on an external CustomerDatabase Resource, and binds to an on-call team.

apiVersion: backstage.io/v1alpha1
kind: Component
metadata:
  name: order-management-service
  description: "Processes customer orders and manages payment transitions"
  annotations:
    github.com/project-slug: "corp/order-management"
    backstage.io/techdocs-ref: "dir:."
    pagerduty.com/integration-key: "pd-order-mgmt-key"
    datadog.com/service-name: "order-management"
spec:
  type: service
  lifecycle: production
  owner: group:checkout-squad
  system: ecommerce-core
  providesApis:
    - order-api-v1
  dependsOn:
    - resource:default/customer-postgres-db
---
apiVersion: backstage.io/v1alpha1
kind: API
metadata:
  name: order-api-v1
  description: "REST API for order creation and status checks"
spec:
  type: openapi
  lifecycle: production
  owner: group:checkout-squad
  system: ecommerce-core
  definition: |
    openapi: "3.0.0"
    info:
      title: Order API
      version: "1.0.0"
    paths:
      /orders:
        get:
          summary: List orders
          responses:
            '200':
              description: OK
---
apiVersion: backstage.io/v1alpha1
kind: Resource
metadata:
  name: customer-postgres-db
  description: "AWS RDS PostgreSQL Multi-AZ Cluster"
spec:
  type: database
  owner: group:platform-team
  system: ecommerce-core

๐Ÿ› ๏ธ Lab 2: The Golden Path Scaffolder Challenge

Objective

Create an end-to-end Backstage Software Template (template.yaml) that prompts for a project name, renders a skeleton repository, creates a private GitHub repository, and commits an initial GitOps ArgoCD manifest.

apiVersion: scaffolder.backstage.io/v1beta3
kind: Template
metadata:
  name: python-microservice-template
  title: Production-Ready Python Service
  description: "Scaffold a Python service with Dockerfile, CI, and ArgoCD registration"
spec:
  owner: group:platform-team
  type: service

  parameters:
    - title: Microservice Metadata
      required: [app_name, owner_group]
      properties:
        app_name:
          type: string
          title: Service Identifier
          description: Lowercase alphanumeric name (e.g. inventory-service)
        owner_group:
          type: string
          title: Owning Squad
          ui:field: OwnerPicker

  steps:
    - id: template
      name: Render Template Files
      action: fetch:template
      input:
        url: ./skeleton
        values:
          app_name: ${{ parameters.app_name }}
          owner: ${{ parameters.owner_group }}

    - id: publish
      name: Publish to GitHub
      action: publish:github
      input:
        allowedHosts: ['github.com']
        description: 'Provisioned via Platform Golden Path'
        repoUrl: github.com?owner=my-enterprise-org&repo=${{ parameters.app_name }}
        defaultBranch: main
        repoVisibility: private

    - id: register
      name: Register in Backstage Catalog
      action: catalog:register
      input:
        repoContentsUrl: ${{ steps.publish.output.repoContentsUrl }}
        catalogInfoPath: '/catalog-info.yaml'

๐Ÿ› ๏ธ Lab 3: The TechDocs Integration Challenge

Objective

Configure a microservice repository with a mkdocs.yml file and GitHub Actions workflow to build and publish TechDocs to an AWS S3 bucket.

1. mkdocs.yml in Microservice Root

site_name: Order Management Service Documentation
plugins:
  - techdocs-core
nav:
  - Overview: index.md
  - Architecture: architecture.md
  - API Reference: api.md

2. .github/workflows/techdocs.yml

name: Publish TechDocs to S3

on:
  push:
    branches: [main]
    paths:
      - 'docs/**'
      - 'mkdocs.yml'

jobs:
  publish:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with: { node-version: 18 }
      - uses: actions/setup-python@v5
        with: { python-version: '3.11' }

      - name: Install TechDocs CLI & MkDocs
        run: |
          pip install mkdocs-techdocs-core
          npm install -g @techdocs/cli

      - name: Generate TechDocs Static Site
        run: techdocs-cli generate --no-docker

      - name: Configure AWS Credentials via OIDC
        uses: aws-actions/configure-aws-credentials@v4
        with:
          role-to-assume: arn:aws:iam::123456789012:role/TechDocsPublisherRole
          aws-region: us-east-1

      - name: Publish to S3 Bucket
        run: |
          techdocs-cli publish \
            --publisher-type awsS3 \
            --storage-name corp-backstage-techdocs-storage \
            --entity default/Component/order-management-service

๐Ÿงญ Step-by-Step Operational Playbook: Deploying the Production TechDocs CI/CD Publisher Pipeline

In production, Backstage should never run mkdocs build inside the Backstage backend container (runIn: local), as that consumes massive CPU/RAM and creates a security risk. Follow this step-by-step playbook to implement the Recommended CI/CD External Object Storage Architecture:

Step 1: Provision the Encrypted Cloud Storage Bucket (AWS S3 / GCS)

  1. Plain-English Goal: Create a dedicated S3 bucket (corp-backstage-techdocs-storage) to store pre-compiled static HTML documentation for all microservices.
  2. Action:
    aws s3api create-bucket --bucket corp-backstage-techdocs-storage --region us-east-1
    aws s3api put-public-access-block --bucket corp-backstage-techdocs-storage \
      --public-access-block-configuration BlockPublicAcls=true,IgnorePublicAcls=true,BlockPublicPolicy=true,RestrictPublicBuckets=true

Step 2: Configure Backstage to Read Pre-Built Docs (builder: external)

  1. Plain-English Goal: Tell Backstage in app-config.yaml that CI/CD builds the docs (builder: external) and Backstage only needs read-only access to S3 (publisher.type: awsS3).
  2. Action: Bind an IRSA read-only role to the backstage-backend ServiceAccount.

Step 3: Add techdocs-cli generate and publish to GitHub Actions CI

  1. Plain-English Goal: Whenever a developer updates docs/index.md in their microservice repo, GitHub Actions compiles the Markdown into HTML and uploads it to S3 under default/component/<service-name>/.
  2. Action:
    npx @techdocs/cli generate --no-docker --source-dir . --output-dir ./site
    npx @techdocs/cli publish --publisher-type awsS3 --storage-name corp-backstage-techdocs-storage --entity default/Component/payment-service --directory ./site

Step 4: Verify Live Rendering & Search Indexing in Backstage

  1. Plain-English Goal: Open https://backstage.corp.internal/docs/default/component/payment-service and verify that the static HTML and Mermaid diagrams load from S3 in under 100ms.

๐Ÿšจ Real-World Troubleshooting & Tricky Production Scenarios

Scenario 1: TechDocs Blank iFrame & S3 CORS Preflight Rejection

  • Symptom: Developers navigate to a serviceโ€™s โ€œDocsโ€ tab in the Backstage portal. The UI displays an empty grey box or Failed to load documentation. The browser developer console reports: Cross-Origin Request Blocked (CORS Missing Allow Origin).
  • Under-the-Hood Root Cause: Backstage UI renders documentation inside an iframe or fetches HTML/JS bundles directly from the S3 storage bucket. If the AWS S3 bucket lacks an explicit CORS configuration permitting GET and HEAD from the Backstage frontend domain (https://portal.corp.internal), browsers block the asset download.
  • Triage & Remediation:
    // Apply this CORS policy to the TechDocs S3 bucket:
    [
      {
        "AllowedHeaders": ["*"],
        "AllowedMethods": ["GET", "HEAD"],
        "AllowedOrigins": ["https://portal.corp.internal"],
        "ExposeHeaders": ["ETag"],
        "MaxAgeSeconds": 3000
      }
    ]

Scenario 2: Scaffolder Pipeline Partial Failure Leaving Orphaned Repositories

  • Symptom: A developer executes a โ€œCreate Microserviceโ€ template. Step 2 (publish:github) succeeds, creating repo-alpha on GitHub. However, Step 3 (catalog:register) fails due to a network timeout. The developer retries, but the template now fails with Repository already exists!
  • Under-the-Hood Root Cause: The template lacked compensating rollback actions (Saga Pattern). Distributed provisioning operations are not atomic transactions; if downstream steps fail, previously created external resources remain orphaned.
  • Triage & Fix:
    # Configure custom errorHandler or compensating steps in template.yaml
    steps:
      - id: publish
        action: publish:github
        # ...
      - id: register
        action: catalog:register
        # ...
    # Architectural Standard: Implement an idempotent scaffolder plugin that checks
    # for existing repositories or tags them with a 'pending-provision' lifecycle label.

๐Ÿ“ Staff Architect & SRE Interview Scenarios

โ“ Question 1: Out-of-Band vs CI-Driven TechDocs Architecture

Question: Backstage supports two build modes for TechDocs: โ€œLocal/Backendโ€ (the Backstage backend pod builds docs using Python/MkDocs on-the-fly) and โ€œExternal/CIโ€ (built in GitHub Actions/GitLab CI and uploaded to S3/GCS). Why is the โ€œLocalโ€ build pattern considered an anti-pattern in enterprise production?

Answer:

  1. Security Vulnerabilities: Running MkDocs locally on the Backstage backend pod requires installing Python, Node.js, and Docker inside the Backstage container, dramatically increasing the container attack surface. Developers could submit arbitrary Python plugins in their mkdocs.yml executing arbitrary code within the Backstage podโ€™s security context.
  2. Resource Exhaustion & Scalability: Building documentation for 5,000 repositories on-demand spikes backend pod CPU and memory to 100%, causing OOMKilled crashes for all portal users.
  3. The Enterprise Standard: The External/CI pattern decouples documentation compilation into the repositoryโ€™s native CI runner. The Backstage backend acts strictly as a static file reader from S3, consuming zero build resources and achieving infinite horizontal read scalability.
โ“ Question 2: Golden Path Governance vs Developer Freedom

Question: If the platform team mandates all microservices use Backstage Software Templates, how do you prevent developers from bypassing the portal and creating rogue repositories directly in GitHub or AWS?

Answer: Enforce policy guardrails at the cloud and identity boundary rather than relying on human compliance:

  1. GitHub Organization Permissions: Restrict repository creation rights so that standard developers have Member permissions without repository creation privileges. Only the Backstage GitHub App bot possesses the repository:write permission.
  2. Cloud Account SCPs: Disallow direct IAM role assumption from arbitrary GitHub repositories using strict OIDC trust conditions (repo:my-org/golden-path-*).
  3. Result: Developers are physically unable to deploy or provision cloud resources unless their repository was generated through the authenticated Backstage Golden Path pipeline.