Skip to content
DevOps AI ToolKit
Newsletter
All prompts
AI for Infrastructure as Code Difficulty: Advanced ClaudeChatGPTCursor

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.

Target user
Platform engineers shipping Crossplane control planes and XRDs
Difficulty
Advanced
Tools
Claude, ChatGPT, Cursor

The prompt

You are a senior platform engineer who runs a Crossplane control plane and refuses to merge a
Composition change that hasn't been rendered and tested first.

I will provide:
- A Composition (and its CompositionFunction pipeline if used) plus the XRD it satisfies.
- An example claim/XR that a consumer would submit.
- The managed resources I expect it to produce ([RDS INSTANCE / GCP BUCKET / VPC] etc.).

Your job:

1. **Set up render tests** — use `crossplane render` (with the function pipeline) to produce the
   composed resources offline, and write golden-file assertions so a diff in output fails the test.
2. **Validate patch-and-transform logic** — for each field that flows from the claim to a managed
   resource, add a fixture proving the transform (e.g. region mapping, name templating) is correct.
3. **Cover the missing-input case** — assert that omitting a required claim field fails XRD schema
   validation with a clear message, not a silently-defaulted resource.
4. **Add uptest e2e (optional)** — sketch an `uptest` manifest that applies the claim to a kind/test
   cluster, waits for `Ready`, and tears it down, for the cases that need a real reconcile.
5. **Guard against drift in defaults** — flag any field defaulted inside the Composition that should
   instead be required, so consumers can't accidentally inherit a wrong value.
6. **Pin versions** — note the Crossplane and provider/function versions the tests assume.

Output as: (a) the render-based test setup and golden files, (b) a fixture table mapping claim inputs
to expected managed-resource fields, (c) the optional uptest manifest, (d) a list of risky defaults.

Do not apply anything to a real cluster in the render tests. Keep `crossplane render` offline; only the
optional uptest stage touches a disposable kind cluster.

Why this prompt works

Crossplane Compositions are deceptively risky: a one-character change to a patch path can repoint an entire fleet of managed resources, and because the reconcile happens asynchronously in a live control plane, the blast radius is real cloud infrastructure. Most teams test Compositions by applying a claim and eyeballing whether the right resources appear — slow, non-repeatable, and impossible to gate in CI. This prompt pushes the work upstream to crossplane render, which evaluates the Composition and its function pipeline offline and emits the composed resources as YAML you can assert against with golden files.

The fixture table mapping claim inputs to expected managed-resource fields is the high-value artifact. Patch-and-transform pipelines accumulate region maps, name templates, and conditional patches that nobody can hold in their head; encoding each as a fixture turns the Composition’s contract into something a reviewer can verify line by line. The instruction to assert on missing-required-input behavior catches the most common production incident — a consumer omits a field, the Composition silently defaults it, and a resource lands in the wrong region or with the wrong size.

Keeping crossplane render offline and quarantining uptest to a disposable kind cluster is the load-bearing safety constraint, because the difference between a render test and an e2e test is the difference between zero cloud spend and accidentally provisioning a database. The prompt also flags Composition-level defaults that should really be required XRD fields, which is the most common source of “it worked in test but consumers got the wrong value.” Combine with the Crossplane Composition design prompt and Composition Functions prompt, and browse the IaC category for more control-plane tooling.

Related prompts

Newsletter

Free: the DevOps AI Incident-Triage Cheat Sheet

Subscribe and we’ll send you the one-page cheat sheet — plus weekly AI prompts, automation ideas, and tool reviews for infrastructure engineers. One email a week. No spam, unsubscribe anytime.

  • AI Incident-Triage Cheat Sheet (PDF)
  • Access to 2,104 DevOps AI prompts
  • One practical workflow email per week