crossplane-runtime
crossplane-runtime copied to clipboard
Cross-resource references to handle multiple types
What problem are you facing?
There are fields in some resources that could be fulfilled by different types, i.e. ARN of Instance or NetworkInterface or LoadBalancer could be given. However, cross-resource resolver always works with a singe hard-coded type so you have to use composition to patch those fields.
How could Crossplane help solve your problem?
We could either solve this via generic patching or implement https://github.com/crossplane/crossplane-runtime/issues/341 and have per-type resolver logic in the code so that we don't have to ask for fieldpaths, transforms etc.
When creating an Opsgenie Escalation the recipient type can be either user, team or schedule, but Crossplane only supports a single cross-resource reference per "block", in this case rules.recipient.
Below is an example on how it could look like with multi cross-resource reference.
...
spec:
forProvider:
name: Escalation Name
rules:
- recipient:
- type: user
userIdRef:
name: user-name
- type: team
teamIdRef:
name: team-name
- type: schedule
scheduleIdRef:
name: schedule-name
Terraform example.
resource "opsgenie_escalation" "test" {
name = "genieescalation-%s"
description = "test"
owner_team_id = "${opsgenie_team.test.id}"
rules {
condition = "if-not-acked"
notify_type = "default"
delay = 1
recipient {
type = "user"
id = "${opsgenie_user.test.id}"
}
recipient {
type = "team"
id = "${opsgenie_team.test.id}"
}
recipient {
type = "schedule"
id = "${opsgenie_schedule.test.id}"
}
}
https://registry.terraform.io/providers/opsgenie/opsgenie/latest/docs/resources/escalation
the same we have in provider-pagerduty
rule:
- escalationDelayInMinutes: 10
target:
- id: ${pagerduty_user.example.id}
type: user_reference
- id: ${pagerduty_user.example2.id}
type: user_reference
in official-provider upbound/provider-aws we can see the same
https://marketplace.upbound.io/providers/upbound/provider-aws-directconnect/v0.36.0/resources/directconnect.aws.upbound.io/GatewayAssociation/v1beta1#doc:spec-forProvider-associatedGatewayId
associatedGatewayId is possible to match multiple resource types
today its only possible to select / reference one resource type https://marketplace.upbound.io/providers/upbound/provider-aws-directconnect/v0.36.0/resources/directconnect.aws.upbound.io/GatewayAssociation/v1beta1#doc:spec-forProvider-associatedGatewayIdRef
Crossplane does not currently have enough maintainers to address every issue and pull request. This issue has been automatically marked as stale because it has had no activity in the last 90 days. It will be closed in 14 days if no further activity occurs. Leaving a comment starting with /fresh will mark this issue as not stale.