spec.size: small on an XR become spec.forProvider.instanceClass: db.t3.micro on an AWS RDS resource? Crossplane functions implement this mapping and conditional logic.
In this lesson we will:
- Explain why compositions need programmable logic.
- Describe the pipeline architecture used by function-based compositions.
- Master the Patch-and-Transform function: its structure, configuration, patch types, and transforms.
- Trace a complete patch-with-transform example end-to-end.
db.t3.micro, always us-east-1, always 20 GB) is not a real platform. Real self-service platforms accept simple, intent-oriented inputs like size: small, environment: prod, and name: orders, and then translate those into provider-specific configuration.
Typical runtime mappings:
small→db.t3.micro(AWS) ordb-f1-micro(GCP)name: orders+environment: prod→orders-prodfor unique resource namesenvironment: prod→ 3 replicas;dev→ 1 replica
- Render base resources (templates).
- Apply patches and transforms to move and convert data.
- Optionally run custom logic (filters, readiness checks, additional transforms).


pt.fn.crossplane.io/v1beta1 and kind Resources. The top-level resources array lists each composed resource: a name, a base template for the managed resource, and a list of patches (with optional transforms) to apply.
Example pipeline step (YAML):
input that tells it which resources to create and which patches / transforms to apply. Patch-and-Transform is the most common function because it enables declarative, composition-friendly mapping.
Patch types
Patch-and-Transform supports copying data in both directions and from environment configs. The most common patch types:
Example: basic FromCompositeFieldPath
Focus on
FromCompositeFieldPath and CombineFromComposite first — these cover the majority of practical composition needs.
Examples
String format transform:
spec.size) to a provider instance class:
- Developer submits an XR with
spec.size: small. - A
FromCompositeFieldPathpatch readsspec.size. - A
maptransform mapssmall→db.t3.micro. - The mapped value is written to the composed resource at
spec.forProvider.instanceClass.
FromCompositeFieldPath + map transform pattern is the bread-and-butter of Crossplane compositions. Mastering it enables most practical platform workflows.
Summary
- Use pipeline-mode functions for programmable mappings in compositions.
- Patch-and-Transform (
apiVersion: pt.fn.crossplane.io/v1beta1,kind: Resources) is the primary, declarative function for most use cases. - Focus first on
FromCompositeFieldPathandCombineFromCompositepatches. - Use
stringandmaptransforms for name formatting and mapping developer-friendly values to provider-specific configuration. - Reserve GoTemplating, KCL, or custom functions for cases where Patch-and-Transform is not expressive enough.

- Crossplane Composition Functions (official docs)
- Crossplane Composition Overview
- Kubernetes documentation: Kubernetes Concepts