crossplane-contrib / provider-pagerduty

Apache License 2.0
13 stars 13 forks source link

Unable to reference schedule in Policy resource #35

Open asafhm opened 8 months ago

asafhm commented 8 months ago

What happened?

Following the docs, I tried setting up my policy resource with a schedule resource using the terraform ${pagerduty_schedule.example.id} syntax but the following error is shown in the policy events:

Warning CannotObserveExternalResource 20s (x17 over 16m) managed/escalation.pagerduty.crossplane.io/v1alpha1, kind=policy cannot run refresh: refresh failed: Reference to undeclared resource: A managed resource "pagerduty_schedule" "example" has not been declared in the root module.

How can we reproduce it?

I tried using the following code:

apiVersion: schedule.pagerduty.crossplane.io/v1alpha1
kind: Schedule
metadata:
  name: example
  labels:
    schedule: example
  annotations:
    crossplane.io/external-name: xxx # redacted
spec:
  managementPolicies: ["Observe"]
  forProvider: {}
---
apiVersion: escalation.pagerduty.crossplane.io/v1alpha1
kind: Policy
metadata:
  labels:
    escalation-policy: example
  name: example
spec:
  forProvider:
    name: example Escalation Policy
    description: Managed by Crossplane
    numLoops: 2
    teamSelector:
      matchLabels:
        team: example-team
    rule:
      - escalationDelayInMinutes: 10
        target:
          - id: ${pagerduty_schedule.example.id}
            type: schedule_reference

I made sure the schedule managed resource is populated with real data from the external resource, including its id.

What environment did it happen in?

Crossplane version: v1.15.0 Provider version: v0.6.1

Kubernetes: GKE 1.28

haarchri commented 8 months ago

You need to add a real id

asafhm commented 8 months ago

I see... I assume it's related to https://github.com/crossplane-contrib/provider-pagerduty/issues/10