Crossplane Composition Functions Prompt
Author Crossplane composition functions (pipeline mode with KCL, Go templating, or Python) to generate composed resources dynamically — replacing brittle patch-and-transform with testable, conditional logic.
- Target user
- Platform teams building Crossplane control planes
- Difficulty
- Advanced
- Tools
- Claude, ChatGPT
The prompt
You are a platform engineer who has migrated Crossplane Compositions from native patch-and-transform to function pipelines and never looked back. You think in terms of an observed/desired state pipeline, not a pile of patches. I will provide: - My XRD (composite resource definition) and the API I want to expose - The managed resources I need to compose (across one or more providers) - The dynamic behavior patch-and-transform can't express cleanly (loops, conditionals, computed counts) - My preferred function language (KCL, Go templating, or Python) and Crossplane version Your job: 1. **Pipeline design** — lay out the Composition in `mode: Pipeline` with ordered function steps. Explain that each function receives the observed state and the desired state accumulated so far, and returns an updated desired state — and why ordering matters. 2. **Pick the function(s)** — recommend function-kcl, function-go-templating, function-patch-and-transform, function-auto-ready, or function-sequencer for each concern, and justify the split (e.g. generation in KCL, readiness via auto-ready). 3. **Generate composed resources** — write the function logic that emits managed resources from XR fields, including loops (N subnets from a list), conditionals (create a NAT gateway only if requested), and computed names. 4. **Connection details & status** — show how to surface connection secrets and write back computed status to the XR. 5. **Readiness** — set readiness correctly so the XR only goes Ready when its composed resources truly are; avoid the trap of an XR reporting Ready prematurely. 6. **Testing** — use `crossplane render` (or `function-test`) with example XRs and golden outputs in CI; cover the conditional and loop branches. 7. **Migration** — convert an existing patch-and-transform Composition step by step, keeping the rendered output identical until you intentionally change behavior. Output as: (a) the Pipeline Composition YAML, (b) the function source (KCL/Go/Python) with comments, (c) example XRs + expected rendered output, (d) a `crossplane render` CI test, (e) a patch-and-transform → functions migration checklist. Bias toward: testable rendering, correct readiness, and small composable function steps.
Run this prompt with AI
Test it, get an AI-improved version, or compare models — live in the Prompt Workspace. No copy-paste.
Related prompts
-
Crossplane Managed Resource Import & Observe-Only Prompt
Bring existing brownfield cloud resources under Crossplane management using the crossplane.io/external-name annotation and observe-only policies, without recreating or mutating live infrastructure.
-
Crossplane v2 Namespaced XR Migration Prompt
Plan the migration from Crossplane v1 cluster-scoped composite resources and claims to v2 namespaced XRs, updating XRDs, compositions, and RBAC without orphaning managed resources.
-
Crossplane Composition Testing with uptest Prompt
Build a render-and-test workflow for Crossplane Compositions so XR changes are validated against expected managed resources before they reach a cluster.
-
Crossplane Providers & XRD API Design Prompt
Design Crossplane CompositeResourceDefinitions (XRDs) and provider configs that expose a clean, opinionated self-service platform API to app teams — abstracting cloud resources behind claims.
More Infrastructure as Code prompts & error guides
Browse every Infrastructure as Code prompt and troubleshooting guide in one place.
Reading prompts? Get all 500 in one free PDF
500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.
- 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
- Instant PDF download — yours free, forever
- Plus one practical AI-workflow email a week (no spam)
Single opt-in · unsubscribe anytime · no spam.