A composition function that filters matching composed resources using CEL expressions.
Each filter:
- Matches composed resources by name using a regular expression.
- Specifies whether resources should be included using a CEL expression.
If a filter's CEL expression evaluates to true, Crossplane creates the matching composed resources.
Filters only apply to matching composed resources. The function doesn't filter composed resources that don't match a filter.
apiVersion: apiextensions.crossplane.io/v1kind: Compositionmetadata:
name: function-template-gospec:
compositeTypeRef:
apiVersion: example.crossplane.io/v1kind: NoSQLmode: Pipelinepipeline:
- step: patch-and-transformfunctionRef:
name: function-patch-and-transforminput:
apiVersion: pt.fn.crossplane.io/v1beta1kind: Resourcesresources:
- name: tablebase:
apiVersion: dynamodb.aws.upbound.io/v1beta1kind: Tablemetadata:
name: crossplane-quickstart-databasespec:
forProvider:
region: "us-east-2"writeCapacity: 1readCapacity: 1attribute:
- name: S3IDtype: ShashKey: S3ID
- name: bucketbase:
apiVersion: s3.aws.upbound.io/v1beta1kind: Bucketspec:
forProvider:
region: us-east-2
- step: filter-composed-resourcesfunctionRef:
name: function-cel-filterinput:
apiVersion: cel.fn.crossplane.io/v1beta1kind: Filtersfilters:
# Only create the bucket if the XR's spec.export field is set to "S3".
- name: bucketexpression: observed.composite.resource.spec.export == "S3"The following top-level variables are available to the CEL expression:
observeddesiredcontext
Example expressions:
observed.composite.resource.spec.widgets == 42observed.resources['bucket'].connection_details['user'] == b'admin'desired.resources['bucket'].resource.spec.widgets == 42"bucket" in desired.resources
Expressions must evaluate to true for the composed resource to be included.
See the RunFunctionRequest protobuf message for schema details. The introduction to CEL documentation shows more example expressions.