-
I am experimenting with crossplane in openstack. I created a Composition that group different components, like 1 virtual machine, 1 keypair to access the machine and one volume to mount in the machine. However I could not find a way to link the volume attachment, that needs to be created, to the volume resource and the VM resource. The volume attachment needs the vm id and the volume id, and I couldn't find a way to obtain these ids, not with patches at least, and openstack provider don't have cross-resource reference like others providers to reference by labels for example. I would like to know if there is a standard way to link the resources in a composition for openstack provider. Composition: |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi, For example we use it like this, to reference a Project id in a RoleAssignment: ---
apiVersion: identity.openstack.crossplane.io/v1alpha1
kind: ProjectV3
metadata:
name: test-project
annotations:
crossplane.io/composition-resource-name: project
spec:
forProvider:
name: test-stuff
domainId: {{ $envContext.projects.domainId | quote }}
providerConfigRef:
name: {{ .observed.composite.resource.spec.parameters.providerConfigRef.name | quote }}
---
apiVersion: identity.openstack.crossplane.io/v1alpha1
kind: RoleAssignmentV3
metadata:
name: roleassignment
annotations:
crossplane.io/composition-resource-name: roleAssignmentMember
spec:
forProvider:
projectId: {{ .observed.resources.project.resource.status.atProvider.id | quote }}
roleId: {{ .observed.composite.resource.spec.parameters.roleIdMember | quote }}
groupId: {{ .observed.composite.resource.spec.parameters.groupId | quote }}
providerConfigRef:
name: {{ .observed.composite.resource.spec.parameters.providerConfigRef.name | quote }} I can recommend checking out the examples of the go-templating functions, the setup is explained pretty good there. |
Beta Was this translation helpful? Give feedback.
Hi,
it is theoretical possible to implement the cross-resource references you mentioned. We mostly use functions for our compositions and accomplish specially your use case with the go-templating function . There you can just use any value from and for other Resources, so this is really flexible.
For example we use it like this, to reference a Project id in a RoleAssignment: