<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
    <channel>
        <title>Platform-Engineering on zharif.my</title>
        <link>https://zharif.my/categories/platform-engineering/</link>
        <description>Recent content in Platform-Engineering on zharif.my</description>
        <generator>Hugo -- gohugo.io</generator>
        <language>en-us</language>
        <lastBuildDate>Wed, 22 Apr 2026 00:00:00 +0000</lastBuildDate><atom:link href="https://zharif.my/categories/platform-engineering/index.xml" rel="self" type="application/rss+xml" /><item>
        <title>GitHub Organization as Code with Terraform</title>
        <link>https://zharif.my/posts/github-management-plane/</link>
        <pubDate>Wed, 22 Apr 2026 00:00:00 +0000</pubDate>
        
        <guid>https://zharif.my/posts/github-management-plane/</guid>
        <description>&lt;img src="https://images.unsplash.com/photo-1556075798-4825dfaaf498?w=800&amp;h=400&amp;fit=crop" alt="Featured image of post GitHub Organization as Code with Terraform" /&gt;&lt;h2 id=&#34;why-this-matters&#34;&gt;Why This Matters
&lt;/h2&gt;&lt;p&gt;If you&amp;rsquo;ve ever tried to explain to your team that &amp;ldquo;we can&amp;rsquo;t create a new repo right now, I&amp;rsquo;m at dinner,&amp;rdquo; you understand why GitHub management should be code. Every infrastructure change in my homelab goes through code review — including how we manage GitHub itself.&lt;/p&gt;
&lt;p&gt;The problem: GitHub&amp;rsquo;s web UI is fine for 3 repos, painful for 30+. You can&amp;rsquo;t track who changed what, can&amp;rsquo;t enforce naming conventions, and can&amp;rsquo;t ensure consistency across repositories.&lt;/p&gt;
&lt;p&gt;The solution: treat your GitHub organization like database infrastructure. Define everything in YAML, let Terraform handle the drift, and sleep better at night.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Scale&lt;/strong&gt;: This setup manages 40+ repositories across my organization with full configuration, teams, secrets, and custom properties.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;All Terraform resources support &lt;code&gt;lifecycle { create_before_destroy = true }&lt;/code&gt; for zero-downtime deployments.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2 id=&#34;architecture&#34;&gt;Architecture
&lt;/h2&gt;&lt;p&gt;The &lt;code&gt;github-management-plane&lt;/code&gt; repository manages my GitHub organization through Terraform — the same configuration-driven pattern as my homelab infrastructure:&lt;/p&gt;
&lt;pre class=&#34;mermaid&#34;&gt;
  graph TB
    G[github-management-plane]
    R[Repository Module]
    S[Secrets/Variables Module]
    O[Organization Custom Properties]
    
    G --&amp;gt; R
    G --&amp;gt; S
    G --&amp;gt; O
    
    Repos[&amp;#34;All Repositories&amp;#34;]
    Vars[&amp;#34;Actions Variables&amp;#34;]
    Secs[&amp;#34;Actions Secrets&amp;#34;]
    
    Repos --&amp;gt; tf-infra-homelab[&amp;#34;tf-infra-homelab&amp;#34;]
    Repos --&amp;gt; tf-module-proxmox-talos[&amp;#34;tf-module-proxmox-talos&amp;#34;]
    Repos --&amp;gt; applications-homelab[&amp;#34;applications-homelab&amp;#34;]
    Repos --&amp;gt; ...[&amp;#34;24+ repositories&amp;#34;]
&lt;/pre&gt;

&lt;h2 id=&#34;what-this-module-does&#34;&gt;What This Module Does
&lt;/h2&gt;&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Repository management&lt;/strong&gt; — create and configure all repositories via YAML&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Team management&lt;/strong&gt; — define teams and members&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Organization custom properties&lt;/strong&gt; — classify repositories&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Actions secrets/variables&lt;/strong&gt; — manage organization-wide secrets&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Issue labels&lt;/strong&gt; — standardize labels across repositories&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;quick-start&#34;&gt;Quick Start
&lt;/h2&gt;&lt;pre class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-hcl&#34;&gt;module &amp;#34;repositories&amp;#34; {
  source   = &amp;#34;./modules/repository&amp;#34;
  for_each = local.filtered_repo_configurations
  
  configuration = each.value
  organization  = var.github_organization
}&lt;/code&gt;&lt;/pre&gt;&lt;hr&gt;
&lt;h2 id=&#34;repository-management&#34;&gt;Repository Management
&lt;/h2&gt;&lt;p&gt;All repositories are defined as YAML configurations:&lt;/p&gt;
&lt;pre class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-yaml&#34;&gt;# configurations/repository/tf-infra-homelab.yaml
name: tf-infra-homelab
description: A terraform infrastructure repository for managing my homelab environment
enabled: true
archived: false
visibility: private
type: terraform-infrastructure

topics:
  - homelab
  - proxmox

enabled_features:
  vulnerability_alerts: true
  issues: true
  wiki: false
  projects: false
  discussions: false&lt;/code&gt;&lt;/pre&gt;&lt;h3 id=&#34;repository-types&#34;&gt;Repository Types
&lt;/h3&gt;&lt;p&gt;The module supports different repository types with defaults:&lt;/p&gt;
&lt;pre class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-hcl&#34;&gt;locals {
  repository_types = {
    terraform-infrastructure = {
      license_template = &amp;#34;mit&amp;#34;
      auto_init       = true
      topics        = [&amp;#34;terraform&amp;#34;, &amp;#34;homelab&amp;#34;]
    }
    terraform-module = {
      license_template = &amp;#34;mit&amp;#34;
      auto_init       = true
      topics         = [&amp;#34;terraform&amp;#34;, &amp;#34;proxmox&amp;#34;]
    }
    python-docker-application = {
      license_template = &amp;#34;mit&amp;#34;
      auto_init       = true
      topics         = [&amp;#34;python&amp;#34;, &amp;#34;docker&amp;#34;]
    }
    generic = {
      auto_init = true
    }
  }
}&lt;/code&gt;&lt;/pre&gt;&lt;h3 id=&#34;repository-resource&#34;&gt;Repository Resource
&lt;/h3&gt;&lt;pre class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-hcl&#34;&gt;resource &amp;#34;github_repository&amp;#34; &amp;#34;this&amp;#34; {
  name        = var.configuration.name
  description = var.configuration.description
  visibility  = var.configuration.visibility
  
  allow_rebase_merge    = true
  allow_squash_merge  = true
  delete_branch_on_merge = true
  
  vulnerability_alerts = var.configuration.enabled_features.vulnerability_alerts
  has_discussions     = var.configuration.enabled_features.discussions
  has_issues         = var.configuration.enabled_features.issues
  has_projects       = var.configuration.enabled_features.projects
  has_wiki           = var.configuration.enabled_features.wiki
}&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;organization-custom-properties&#34;&gt;Organization Custom Properties
&lt;/h2&gt;&lt;p&gt;Custom properties allow classification and filtering:&lt;/p&gt;
&lt;pre class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-hcl&#34;&gt;locals {
  organization_custom_properties = {
    &amp;#34;can-be-public&amp;#34; = {
      description   = &amp;#34;To indicate whether the repository can be made public&amp;#34;
      value_type  = &amp;#34;single_select&amp;#34;
      required   = true
      allowed_values = [&amp;#34;true&amp;#34;, &amp;#34;false&amp;#34;]
      default_value = &amp;#34;false&amp;#34;
    }
    
    &amp;#34;managed-by&amp;#34; = {
      description = &amp;#34;To identify who manages the repository&amp;#34;
      value_type = &amp;#34;single_select&amp;#34;
      required = true
      allowed_values = [
        &amp;#34;github-management-plane&amp;#34;,
        &amp;#34;manual-management&amp;#34;,
      ]
      default_value = &amp;#34;manual-management&amp;#34;
    }
    
    &amp;#34;repository-type&amp;#34; = {
      description = &amp;#34;To indicate the type of repository&amp;#34;
      value_type = &amp;#34;single_select&amp;#34;
      required = true
      allowed_values = [
        &amp;#34;generic&amp;#34;,
        &amp;#34;repository-template&amp;#34;,
        &amp;#34;golang-linux-package&amp;#34;,
        &amp;#34;golang-docker-application&amp;#34;,
        &amp;#34;python-docker-application&amp;#34;,
        &amp;#34;python-package&amp;#34;,
        &amp;#34;terraform-infrastructure&amp;#34;,
        &amp;#34;terraform-module&amp;#34;,
      ]
    }
  }
}&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Apply them:&lt;/p&gt;
&lt;pre class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-hcl&#34;&gt;resource &amp;#34;github_organization_custom_properties&amp;#34; &amp;#34;managed_properties&amp;#34; {
  for_each   = local.organization_custom_properties
  
  property_name = each.key
  value_type  = each.value.value_type
  required   = each.value.required
  description = each.value.description
  default_value = each.value.default_value
  allowed_values = each.value.allowed_values
}&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;secrets-and-variables&#34;&gt;Secrets and Variables
&lt;/h2&gt;&lt;p&gt;Actions secrets and variables are managed through Bitwarden:&lt;/p&gt;
&lt;pre class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-yaml&#34;&gt;# configurations/secrets_variables/global.yaml
variables:
  - name: RUNNER
    value: self-hosted
    visibility: all

secrets:
  - name: BWS_ACCESS_TOKEN
    is_manual: true
    visibility: private&lt;/code&gt;&lt;/pre&gt;&lt;h3 id=&#34;variable-resource&#34;&gt;Variable Resource
&lt;/h3&gt;&lt;pre class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-hcl&#34;&gt;resource &amp;#34;github_actions_organization_variable&amp;#34; &amp;#34;managed_variables&amp;#34; {
  for_each = { for v in var.configuration.variables : v.name =&amp;gt; v }
  
  variable_name = each.value.name
  visibility   = each.value.visibility
  value        = each.value.value
}&lt;/code&gt;&lt;/pre&gt;&lt;h3 id=&#34;secret-resource&#34;&gt;Secret Resource
&lt;/h3&gt;&lt;p&gt;For secrets, two patterns:&lt;/p&gt;
&lt;pre class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-hcl&#34;&gt;# Manual secrets (value set outside Terraform)
resource &amp;#34;github_actions_organization_secret&amp;#34; &amp;#34;managed_secrets_manual&amp;#34; {
  for_each = { for v in var.configuration.secrets : v.name =&amp;gt; v if v.is_manual }
  
  secret_name = each.value.name
  visibility = each.value.visibility
  plaintext_value = &amp;#34;NONE&amp;#34;
}

# Synced secrets (from Bitwarden)
resource &amp;#34;github_actions_organization_secret&amp;#34; &amp;#34;managed_secrets_sync&amp;#34; {
  for_each = { for v in var.configuration.secrets : v.name =&amp;gt; v if !v.is_manual }
  
  secret_name     = each.value.name
  visibility     = each.value.visibility
  plaintext_value = data.bitwarden-secrets_secret.secrets[each.value.name].value
}&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Get secrets from Bitwarden:&lt;/p&gt;
&lt;pre class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-hcl&#34;&gt;data &amp;#34;bitwarden-secrets_secret&amp;#34; &amp;#34;secrets&amp;#34; {
  for_each = { for v in local.all_secrets : v.name =&amp;gt; v if !v.is_manual }
  id      = each.value.bw_secret_id
}&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;team-management&#34;&gt;Team Management
&lt;/h2&gt;&lt;p&gt;Teams are defined in the main module:&lt;/p&gt;
&lt;pre class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-hcl&#34;&gt;resource &amp;#34;github_team&amp;#34; &amp;#34;organization_administrators&amp;#34; {
  name        = &amp;#34;organization-administrators&amp;#34;
  description = &amp;#34;Team with administrative access to the organization&amp;#34;
  privacy     = &amp;#34;closed&amp;#34;
}

resource &amp;#34;github_team_members&amp;#34; &amp;#34;organization_administrators_members&amp;#34; {
  team_id = github_team.organization_administrators.id
  
  members = {
    &amp;#34;your-username&amp;#34; = {
      role = &amp;#34;maintainer&amp;#34;
    }
  }
}&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;issue-labels&#34;&gt;Issue Labels
&lt;/h2&gt;&lt;p&gt;Labels are standardized across repositories:&lt;/p&gt;
&lt;pre class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-hcl&#34;&gt;locals {
  shared_labels = {
    &amp;#34;bug&amp;#34; = {
      color   = &amp;#34;d73a4a&amp;#34;
      description = &amp;#34;Bug report&amp;#34;
    }
    &amp;#34;enhancement&amp;#34; = {
      color   = &amp;#34;a2eeef&amp;#34;
      description = &amp;#34;New feature&amp;#34;
    }
    &amp;#34;documentation&amp;#34; = {
      color   = &amp;#34;0075ca&amp;#34;
      description = &amp;#34;Documentation improvements&amp;#34;
    }
  }
}

resource &amp;#34;github_issue_labels&amp;#34; &amp;#34;this&amp;#34; {
  repository = var.configuration.name
  
  label = merge(
    local.shared_labels,
    try(var.configuration.labels, {})
  )
}&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;my-repository-configuration&#34;&gt;My Repository Configuration
&lt;/h2&gt;&lt;p&gt;Here&amp;rsquo;s the list of repositories managed:&lt;/p&gt;
&lt;pre class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-txt&#34;&gt;configurations/repository/
├── tf-infra-homelab.yaml          # Homelab infrastructure
├── tf-infra-github-management-plane.yaml  # GitHub management
├── tf-module-proxmox-lxc.yaml    # LXC module
├── tf-module-proxmox-vm.yaml    # VM module
├── tf-module-proxmox-talos.yaml  # Talos module
├── tf-module-proxmox-docker.yaml # Docker module
├── applications-homelab.yaml   # Kustomize apps
├── cf-worker-terraform-registry.yaml  # TF registry worker
├── cf-worker-apt-repository.yaml   # APT repository worker
├── template-terraform-basic.yaml   # Module template
├── template-cloudflare-worker-python.yaml  # Worker template
└── ... (24 total)&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Each is just a YAML file — adding a new repository is adding a file.&lt;/p&gt;
&lt;h2 id=&#34;configuration-structure&#34;&gt;Configuration Structure
&lt;/h2&gt;&lt;pre class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-txt&#34;&gt;github-management-plane/
├── configurations/
│   ├── repository/           # Repository definitions
│   ├── secrets_variables/   # Actions secrets/variables
│   └── rulesets/           # Branch protection (future)
├── modules/
│   ├── repository/         # Repository module
│   ├── secrets_variables/  # Secrets module
│   └── organization/        # Org properties module
├── main.tf                 # Orchestration
├── locals.tf              # Configuration loading
└── providers.tf          # Provider setup&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;This mirrors the homelab infrastructure structure.&lt;/p&gt;
&lt;h2 id=&#34;outputs&#34;&gt;Outputs
&lt;/h2&gt;&lt;p&gt;The module doesn&amp;rsquo;t have specific outputs since it manages the organization passively.&lt;/p&gt;
&lt;h2 id=&#34;whats-next&#34;&gt;What&amp;rsquo;s Next
&lt;/h2&gt;&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Branch protection rulesets&lt;/strong&gt; — via rulesets API (when Terraform provider supports it)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Repository invitations&lt;/strong&gt; — managing outside collaborators&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Security advisories&lt;/strong&gt; — automated security scanning&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;what-most-people-get-wrong&#34;&gt;What Most People Get Wrong
&lt;/h2&gt;&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;&amp;ldquo;GitHub Terraform is just for repos&amp;rdquo;&lt;/strong&gt; — It&amp;rsquo;s org-wide: teams, custom properties, secrets, variables. The whole thing.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;&amp;ldquo;One Terraform run is enough&amp;rdquo;&lt;/strong&gt; — Git rate limits apply. Use &lt;code&gt;ratenode&lt;/code&gt; provider or caching.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;&amp;ldquo;Manual changes are fine if you revert&amp;rdquo;&lt;/strong&gt; — Terraform drift will catch you. Enable &lt;code&gt;logento&lt;/code&gt; or run &lt;code&gt;terraform refresh&lt;/code&gt; regularly.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;when-to-use--when-not-to-use&#34;&gt;When to Use / When NOT to Use
&lt;/h2&gt;&lt;table&gt;
  &lt;thead&gt;
      &lt;tr&gt;
          &lt;th&gt;Use GitHub Management Plane&lt;/th&gt;
          &lt;th&gt;Do it manually&lt;/th&gt;
      &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
      &lt;tr&gt;
          &lt;td&gt;20+ repositories&lt;/td&gt;
          &lt;td&gt;1-5 repos&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;Team collaboration&lt;/td&gt;
          &lt;td&gt;Personal projects&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;Audit requirements&lt;/td&gt;
          &lt;td&gt;Quick experiments&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;Secret/variable management&lt;/td&gt;
          &lt;td&gt;Ad-hoc scripts only&lt;/td&gt;
      &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;This makes GitHub management declarative — every change goes through code review.&lt;/p&gt;
</description>
        </item>
        <item>
        <title>Self-Service Infrastructure with Backstage</title>
        <link>https://zharif.my/posts/backstage-homelab/</link>
        <pubDate>Sat, 18 Apr 2026 00:00:00 +0000</pubDate>
        
        <guid>https://zharif.my/posts/backstage-homelab/</guid>
        <description>&lt;img src="https://images.unsplash.com/photo-1551288049-bebda4e38f71?w=800&amp;h=400&amp;fit=crop" alt="Featured image of post Self-Service Infrastructure with Backstage" /&gt;&lt;h2 id=&#34;why-self-service-matters&#34;&gt;Why Self-Service Matters
&lt;/h2&gt;&lt;p&gt;In my homelab, I was the bottleneck. Every new Kubernetes cluster meant:&lt;/p&gt;
&lt;pre class=&#34;mermaid&#34;&gt;
  flowchart LR
    A[Create YAML] --&amp;gt; B[Find free IPs]
    B --&amp;gt; C[Configure node sizes]
    C --&amp;gt; D[Manually create Backstage catalog entries]
    D --&amp;gt; E[Open PR]
    E --&amp;gt; F[Wait for review]
&lt;/pre&gt;

&lt;p&gt;That&amp;rsquo;s 6 steps where 4 could be automated.&lt;/p&gt;
&lt;p&gt;The insight: infrastructure already defined as YAML. Backstage should consume that same YAML and generate its own catalog entries.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Real-world constraint&lt;/strong&gt;: I deploy clusters infrequently (quarterly?), so I forget the steps. The templated approach ensures consistency whether I do this once a month or once a year.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;This post covers the Backstage integration for homelab infrastructure. See the architecture overview for how it fits in the broader platform.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2 id=&#34;two-integration-points&#34;&gt;Two Integration Points
&lt;/h2&gt;&lt;p&gt;Backstage integrates with the homelab infrastructure in two ways:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Resource Catalog&lt;/strong&gt; — auto-generated entities from infrastructure YAML configurations&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Software Templates&lt;/strong&gt; — scaffolder templates for self-service provisioning&lt;/li&gt;
&lt;/ol&gt;
&lt;pre class=&#34;mermaid&#34;&gt;
  graph LR
    subgraph &amp;#34;Configuration&amp;#34;
        C[configurations/*.yaml]
    end
    
    subgraph &amp;#34;Generation&amp;#34;
        G[generate_backstage_catalog.py]
    end
    
    subgraph &amp;#34;Backstage&amp;#34;
        R[Resource Catalog]
        T[Software Templates]
    end
    
    C --&amp;gt; G
    G --&amp;gt; R
    G --&amp;gt; T
&lt;/pre&gt;

&lt;h2 id=&#34;auto-generated-catalog&#34;&gt;Auto-Generated Catalog
&lt;/h2&gt;&lt;p&gt;Running &lt;code&gt;make backstage-catalog&lt;/code&gt; generates Backstage Resource entities from configurations:&lt;/p&gt;
&lt;pre class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;make backstage-catalog
# ✓ kubernetes--prod-k8s.yaml (prod-k8s, disabled)
# ✓ kubernetes--dev-k8s.yaml (dev-k8s, disabled)
# ✓ docker--prod-docker-lxc.yaml (prod-docker-lxc, disabled)
# ✓ docker--dev-docker-lxc.yaml (dev-docker-lxc, enabled)&lt;/code&gt;&lt;/pre&gt;&lt;h3 id=&#34;generated-entity-example&#34;&gt;Generated Entity Example
&lt;/h3&gt;&lt;p&gt;Each generated YAML file is a Backstage Resource:&lt;/p&gt;
&lt;pre class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-yaml&#34;&gt;# backstage/catalog/kubernetes--prod-k8s.yaml
apiVersion: backstage.io/v1alpha1
kind: Resource
metadata:
  name: prod-k8s
  description: Talos kubernetes cluster configuration for production environment
  annotations:
    github.com/project-slug: your-org/your-infra-repo
    homelab.dev/configuration-file: configurations/kubernetes/prod-k8s.yaml
    homelab.dev/resource-type: kubernetes
    homelab.dev/schema-file: configuration_schemas/kubernetes.schema.yaml
    backstage.io/techdocs-entity: component:terraform-module-kubernetes
    homelab.dev/cluster-name: prod-k8s
    homelab.dev/talos-version: v1.12.4
    homelab.dev/kubernetes-version: v1.35.0
    homelab.dev/vip-address: 192.168.62.20
  labels:
    homelab.dev/enabled: &amp;#39;false&amp;#39;
    homelab.dev/environment: prod
    homelab.dev/control-plane-count: &amp;#39;3&amp;#39;
    homelab.dev/worker-count: &amp;#39;3&amp;#39;
    homelab.dev/size-control_plane-cpu: &amp;#39;4&amp;#39;
    homelab.dev/size-control_plane-memory: &amp;#39;8192&amp;#39;
    homelab.dev/size-worker-cpu: &amp;#39;10&amp;#39;
    homelab.dev/size-worker-memory: &amp;#39;49152&amp;#39;
  tags:
    - disabled
    - kubernetes
    - prod
    - proxmox
    - talos
spec:
  type: kubernetes-cluster
  lifecycle: experimental
  owner: group:default/homelab-admins
  system: tf-infra-homelab
  dependsOn:
    - component:default/terraform-module-kubernetes&lt;/code&gt;&lt;/pre&gt;&lt;h3 id=&#34;docker-cluster-entity&#34;&gt;Docker Cluster Entity
&lt;/h3&gt;&lt;pre class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-yaml&#34;&gt;# backstage/catalog/docker--prod-docker-lxc.yaml
apiVersion: backstage.io/v1alpha1
kind: Resource
metadata:
  name: prod-docker-lxc
  description: Docker configuration on lxc for production environment
  annotations:
    github.com/project-slug: your-org/your-infra-repo
    homelab.dev/configuration-file: configurations/docker/prod-docker-lxc.yaml
    homelab.dev/resource-type: docker
    homelab.dev/cluster-name: prod-docker-lxc
    homelab.dev/cluster-type: lxc
    homelab.dev/vip-address: 192.168.61.20
  labels:
    homelab.dev/enabled: &amp;#39;false&amp;#39;
    homelab.dev/environment: prod
    homelab.dev/worker-count: &amp;#39;3&amp;#39;
    homelab.dev/size-medium-cpu: &amp;#39;8&amp;#39;
    homelab.dev/size-medium-memory: &amp;#39;32768&amp;#39;
  tags:
    - disabled
    - docker
    - lxc
    - prod
    - proxmox
spec:
  type: docker-cluster
  lifecycle: experimental
  owner: group:default/homelab-admins
  system: tf-infra-homelab
  dependsOn:
    - component:default/terraform-module-docker&lt;/code&gt;&lt;/pre&gt;&lt;h3 id=&#34;metadata-extraction&#34;&gt;Metadata Extraction
&lt;/h3&gt;&lt;p&gt;The generation script extracts key metadata from configurations:&lt;/p&gt;
&lt;pre class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-python&#34;&gt;# scripts/generate_backstage_catalog.py

def extract_kubernetes_metadata(config: dict) -&amp;gt; dict:
    &amp;#34;&amp;#34;&amp;#34;Extract catalog-relevant metadata from a Kubernetes configuration.&amp;#34;&amp;#34;&amp;#34;
    annotations = {}
    labels = {}
    
    cluster = config.get(&amp;#34;cluster&amp;#34;, {})
    annotations[&amp;#34;homelab.dev/cluster-name&amp;#34;] = cluster.get(&amp;#34;name&amp;#34;, &amp;#34;&amp;#34;)
    
    talos = cluster.get(&amp;#34;talos&amp;#34;, {}) or {}
    annotations[&amp;#34;homelab.dev/talos-version&amp;#34;] = talos.get(&amp;#34;version&amp;#34;, &amp;#34;&amp;#34;)
    annotations[&amp;#34;homelab.dev/kubernetes-version&amp;#34;] = cluster.get(&amp;#34;kubernetes_version&amp;#34;, &amp;#34;&amp;#34;)
    
    cp_nodes = config.get(&amp;#34;control_plane_nodes&amp;#34;, {}).get(&amp;#34;nodes&amp;#34;, [])
    worker_nodes = config.get(&amp;#34;worker_nodes&amp;#34;, {}).get(&amp;#34;nodes&amp;#34;, [])
    labels[&amp;#34;homelab.dev/control-plane-count&amp;#34;] = str(len(cp_nodes))
    labels[&amp;#34;homelab.dev/worker-count&amp;#34;] = str(len(worker_nodes))
    
    cp_vip = config.get(&amp;#34;control_plane_nodes&amp;#34;, {}).get(&amp;#34;vip&amp;#34;, {})
    if cp_vip and cp_vip.get(&amp;#34;enabled&amp;#34;):
        annotations[&amp;#34;homelab.dev/vip-address&amp;#34;] = cp_vip.get(&amp;#34;address&amp;#34;, &amp;#34;&amp;#34;)
    
    sizes = config.get(&amp;#34;node_size_configuration&amp;#34;, {})
    for size_name, size_spec in sizes.items():
        labels[f&amp;#34;homelab.dev/size-{size_name}-cpu&amp;#34;] = str(size_spec.get(&amp;#34;cpu&amp;#34;, &amp;#34;&amp;#34;))
        labels[f&amp;#34;homelab.dev/size-{size_name}-memory&amp;#34;] = str(size_spec.get(&amp;#34;memory&amp;#34;, &amp;#34;&amp;#34;))
    
    return {&amp;#34;annotations&amp;#34;: annotations, &amp;#34;labels&amp;#34;: labels}&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;This enables filtering in Backstage:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;homelab.dev/environment=prod&lt;/code&gt; — production clusters&lt;/li&gt;
&lt;li&gt;&lt;code&gt;homelab.dev/enabled=true&lt;/code&gt; — currently deployed&lt;/li&gt;
&lt;li&gt;&lt;code&gt;homelab.dev/size-worker-memory=49152&lt;/code&gt; — large workers&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;catalog-info-definition&#34;&gt;Catalog-Info Definition
&lt;/h2&gt;&lt;p&gt;The root &lt;code&gt;catalog-info.yaml&lt;/code&gt; defines the domain, system, and components:&lt;/p&gt;
&lt;pre class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-yaml&#34;&gt;# Domain: homelab
apiVersion: backstage.io/v1alpha1
kind: Domain
metadata:
  name: homelab
  description: Self-hosted homelab infrastructure managed with Terraform and Proxmox
  annotations:
    backstage.io/techdocs-ref: dir:.
    github.com/project-slug: your-org/your-infra-repo
spec:
  owner: group:default/homelab-admins

---
# System: tf-infra-homelab
apiVersion: backstage.io/v1alpha1
kind: System
metadata:
  name: tf-infra-homelab
  description: Terraform-managed homelab infrastructure provisioning system
spec:
  owner: group:default/homelab-admins
  domain: homelab

---
# Component: terraform-module-kubernetes
apiVersion: backstage.io/v1alpha1
kind: Component
metadata:
  name: terraform-module-kubernetes
  description: Terraform module for provisioning Kubernetes (Talos) clusters on Proxmox
spec:
  type: terraform-module
  lifecycle: production
  owner: group:default/homelab-admins
  system: tf-infra-homelab

---
# Location: discovers auto-generated resources
apiVersion: backstage.io/v1alpha1
kind: Location
metadata:
  name: tf-infra-homelab-resources
spec:
  targets:
    - ./backstage/catalog/*.yaml&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;software-templates&#34;&gt;Software Templates
&lt;/h2&gt;&lt;p&gt;The Backstage scaffolder templates enable self-service provisioning:&lt;/p&gt;
&lt;h3 id=&#34;kubernetes-template&#34;&gt;Kubernetes Template
&lt;/h3&gt;&lt;pre class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-yaml&#34;&gt;# backstage/templates/kubernetes/template.yaml
apiVersion: scaffolder.backstage.io/v1beta3
kind: Template
metadata:
  name: provision-kubernetes-cluster
  title: Provision Kubernetes Cluster
  description: Create a new Talos-based Kubernetes cluster configuration on Proxmox
  tags:
    - terraform
    - kubernetes
    - talos
    - proxmox
    - homelab
spec:
  owner: group:default/homelab-admins
  type: infrastructure
  system: tf-infra-homelab&lt;/code&gt;&lt;/pre&gt;&lt;h3 id=&#34;template-parameters&#34;&gt;Template Parameters
&lt;/h3&gt;&lt;p&gt;The template accepts parameters for cluster configuration:&lt;/p&gt;
&lt;pre class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-yaml&#34;&gt;parameters:
  - title: Cluster Identity
    required:
      - name
      - environment
    properties:
      name:
        title: Cluster Name
        type: string
        pattern: &amp;#34;^[a-z][a-z0-9-]&amp;#43;$&amp;#34;
      environment:
        title: Environment
        type: string
        enum:
          - dev
          - staging
          - prod

  - title: Cluster Configuration
    properties:
      talos_version:
        title: Talos Version
        type: string
        default: v1.12.4
      kubernetes_version:
        title: Kubernetes Version
        type: string
        default: v1.35.0
      disable_default_cni:
        title: Disable Default CNI
        type: boolean
        default: true

  - title: Control Plane Nodes
    properties:
      cp_count:
        title: Number of Control Plane Nodes
        type: integer
        minimum: 1
        maximum: 5
        default: 3
      cp_cpu:
        title: CPU Cores per CP Node
        type: integer
        default: 4
      cp_memory:
        title: Memory per CP Node (MB)
        type: integer
        default: 8192

  - title: Worker Nodes
    properties:
      worker_count:
        title: Number of Workers
        type: integer
        default: 3
      worker_cpu:
        title: CPU Cores per Worker
        type: integer
        default: 8
      worker_memory:
        title: Memory per Worker (MB)
        type: integer
        default: 16384&lt;/code&gt;&lt;/pre&gt;&lt;h3 id=&#34;template-steps&#34;&gt;Template Steps
&lt;/h3&gt;&lt;p&gt;Each template has three steps:&lt;/p&gt;
&lt;pre class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-yaml&#34;&gt;steps:
  - id: generate
    name: Generate Configuration
    action: fetch:template
    input:
      url: ./skeleton/kubernetes
      targetPath: configurations/kubernetes
      values:
        name: ${{ parameters.name }}
        talos_version: ${{ parameters.talos_version }}
        cp_count: ${{ parameters.cp_count }}

  - id: generate-catalog
    name: Generate Backstage Catalog Entry
    action: fetch:template
    input:
      url: ./skeleton/backstage/catalog
      targetPath: backstage/catalog

  - id: publish
    name: Open Pull Request
    action: publish:github:pull-request
    input:
      repoUrl: github.com?repo=tf-infra-homelab&amp;amp;owner=your-org
      title: &amp;#34;feat: provision Kubernetes cluster ${{ parameters.name }}&amp;#34;&lt;/code&gt;&lt;/pre&gt;&lt;h3 id=&#34;user-flow&#34;&gt;User Flow
&lt;/h3&gt;&lt;p&gt;In Backstage, users:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Choose template&lt;/strong&gt; — &amp;ldquo;Provision Kubernetes Cluster&amp;rdquo;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Fill parameters&lt;/strong&gt; — name, environment, node sizes&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Submit&lt;/strong&gt; — opens a PR automatically&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Review&lt;/strong&gt; — maintainers approve the PR&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Apply&lt;/strong&gt; — Terraform provisions the cluster&lt;/li&gt;
&lt;/ol&gt;
&lt;pre class=&#34;mermaid&#34;&gt;
  sequenceDiagram
    participant User
    participant BS as Backstage
    participant GH as GitHub
    participant TF as Terraform
    participant PVE as Proxmox
    participant Talos
    participant Flux
    
    User-&amp;gt;&amp;gt;BS: Create new cluster (fill form)
    BS-&amp;gt;&amp;gt;GH: Open PR with config files
    Maintainer-&amp;gt;&amp;gt;GH: Review and approve PR
    GH-&amp;gt;&amp;gt;TF: Merge triggers apply
    TF-&amp;gt;&amp;gt;PVE: Provision VMs
    PVE-&amp;gt;&amp;gt;Talos: Bootstrap cluster
    Talos-&amp;gt;&amp;gt;Flux: Install GitOps
&lt;/pre&gt;

&lt;h2 id=&#34;generation-script&#34;&gt;Generation Script
&lt;/h2&gt;&lt;p&gt;The full script in &lt;code&gt;scripts/generate_backstage_catalog.py&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-python&#34;&gt;#!/usr/bin/env python3
&amp;#34;&amp;#34;&amp;#34;Generate Backstage catalog Resource entities from configuration YAML files.&amp;#34;&amp;#34;&amp;#34;

import yaml
from pathlib import Path

REPO_ROOT = Path(__file__).resolve().parent.parent

def load_yaml(path: Path) -&amp;gt; dict:
    return yaml.safe_load(path.read_text()) or {}

def build_resource_entity(resource_type, environment_name, config):
    &amp;#34;&amp;#34;&amp;#34;Build a Backstage Resource entity from configuration.&amp;#34;&amp;#34;&amp;#34;
    entity = {
        &amp;#34;apiVersion&amp;#34;: &amp;#34;backstage.io/v1alpha1&amp;#34;,
        &amp;#34;kind&amp;#34;: &amp;#34;Resource&amp;#34;,
        &amp;#34;metadata&amp;#34;: {
            &amp;#34;name&amp;#34;: config.get(&amp;#34;name&amp;#34;, environment_name),
            &amp;#34;description&amp;#34;: config.get(&amp;#34;description&amp;#34;, &amp;#34;&amp;#34;),
            &amp;#34;annotations&amp;#34;: {...},
            &amp;#34;labels&amp;#34;: {...},
        },
        &amp;#34;spec&amp;#34;: {
            &amp;#34;type&amp;#34;: RESOURCE_TYPE_META[resource_type][&amp;#34;backstage_type&amp;#34;],
            &amp;#34;lifecycle&amp;#34;: &amp;#34;experimental&amp;#34;,
            &amp;#34;owner&amp;#34;: &amp;#34;group:default/homelab-admins&amp;#34;,
            &amp;#34;system&amp;#34;: &amp;#34;tf-infra-homelab&amp;#34;,
        },
    }
    return entity

def main():
    for config_file in (REPO_ROOT / &amp;#34;configurations&amp;#34;).rglob(&amp;#34;*.yaml&amp;#34;):
        config = load_yaml(config_file)
        entity = build_resource_entity(...)
        output_file.write_text(yaml.dump(entity))&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Run via Makefile:&lt;/p&gt;
&lt;pre class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-makefile&#34;&gt;backstage-catalog:
  python3 scripts/generate_backstage_catalog.py&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;filtering-in-backstage&#34;&gt;Filtering in Backstage
&lt;/h2&gt;&lt;p&gt;With the generated metadata, users can filter in Backstage:&lt;/p&gt;
&lt;table&gt;
  &lt;thead&gt;
      &lt;tr&gt;
          &lt;th&gt;Filter&lt;/th&gt;
          &lt;th&gt;Use Case&lt;/th&gt;
      &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;code&gt;homelab.dev/environment=prod&lt;/code&gt;&lt;/td&gt;
          &lt;td&gt;Production clusters&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;code&gt;homelab.dev/enabled=true&lt;/code&gt;&lt;/td&gt;
          &lt;td&gt;Currently deployed&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;code&gt;homelab.dev/control-plane-count=3&lt;/code&gt;&lt;/td&gt;
          &lt;td&gt;Full quorum&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;code&gt;homelab.dev/size-worker-memory&amp;gt;=16384&lt;/code&gt;&lt;/td&gt;
          &lt;td&gt;Large workers&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;code&gt;homelab.dev/talos-version=v1.12.*&lt;/code&gt;&lt;/td&gt;
          &lt;td&gt;Specific Talos version&lt;/td&gt;
      &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;
&lt;h2 id=&#34;what-most-people-get-wrong&#34;&gt;What Most People Get Wrong
&lt;/h2&gt;&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;&amp;ldquo;Backstage is only for Kubernetes&amp;rdquo;&lt;/strong&gt; — It catalogs anything. My LXC, VMs, Docker clusters all have Backstage entries.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;&amp;ldquo;Templates replace code review&amp;rdquo;&lt;/strong&gt; — My templates generate PRs. Human review still happens. Self-service ≠ unattended.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;&amp;ldquo;Catalog must be perfect at launch&amp;rdquo;&lt;/strong&gt; — Start simple. The YAML-to-catalog pipeline can always regenerate.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;when-to-use--when-not-to-use&#34;&gt;When to Use / When NOT to Use
&lt;/h2&gt;&lt;table&gt;
  &lt;thead&gt;
      &lt;tr&gt;
          &lt;th&gt;Use Backstage&lt;/th&gt;
          &lt;th&gt;Use direct Terraform&lt;/th&gt;
      &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
      &lt;tr&gt;
          &lt;td&gt;Team self-service&lt;/td&gt;
          &lt;td&gt;Single admin&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;10+ resources&lt;/td&gt;
          &lt;td&gt;&amp;lt;5 resources&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;Need catalog UI&lt;/td&gt;
          &lt;td&gt;CLI is enough&lt;/td&gt;
      &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;
&lt;h2 id=&#34;whats-next&#34;&gt;What&amp;rsquo;s Next
&lt;/h2&gt;&lt;p&gt;Current areas of exploration:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;More templates&lt;/strong&gt; — VM and LXC provisioning templates&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Approval workflows&lt;/strong&gt; — notification to maintainers&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Status tracking&lt;/strong&gt; — integration with Terraform Cloud state&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The Backstage integration makes infrastructure self-serviceable while maintaining code review.&lt;/p&gt;
</description>
        </item>
        
    </channel>
</rss>
