diff --git a/apis/elbv2/manualv1alpha1/target.go b/apis/elbv2/manualv1alpha1/target.go index 42ce068e9c..1bef462a40 100644 --- a/apis/elbv2/manualv1alpha1/target.go +++ b/apis/elbv2/manualv1alpha1/target.go @@ -185,7 +185,7 @@ type TargetObservation struct { TargetHealth *TargetHealth `json:"targetHealth,omitempty"` } -// GetState returns TargetHealth.State if it is not nil, otherwise an empty +// GetState returns s.TargetHealth.State if it is not nil, otherwise an empty // string. func (s *TargetObservation) GetState() string { if s.TargetHealth != nil && s.TargetHealth.State != nil { @@ -194,6 +194,15 @@ func (s *TargetObservation) GetState() string { return "" } +// GetReason returns s.TargetHealth.Reason if it is not nil, otherwise an empty +// string. +func (s *TargetObservation) GetReason() string { + if s.TargetHealth != nil && s.TargetHealth.Reason != nil { + return *s.TargetHealth.Reason + } + return "" +} + // TargetStatus defines the observed state of a // Target type TargetStatus struct { diff --git a/pkg/controller/elbv2/target/controller.go b/pkg/controller/elbv2/target/controller.go index e2adc3e2c0..01694acbd1 100644 --- a/pkg/controller/elbv2/target/controller.go +++ b/pkg/controller/elbv2/target/controller.go @@ -130,7 +130,7 @@ func (e *external) Observe(ctx context.Context, mg resource.Managed) (managed.Ex } return managed.ExternalObservation{ - ResourceExists: true, + ResourceExists: cr.Status.AtProvider.GetReason() != string(types.TargetHealthReasonEnumNotRegistered), ResourceUpToDate: true, // Targets cannot be updated }, nil }