Skip to content

Commit

Permalink
Merge pull request #2085 from crossplane-contrib/backport-2084-to-rel…
Browse files Browse the repository at this point in the history
…ease-0.49

[Backport release-0.49] fix(lambda/function): resource is ready when function is inactive due to idle
  • Loading branch information
MisterMX authored Jul 29, 2024
2 parents 24abbe4 + f85bf03 commit b9e3222
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion pkg/controller/lambda/function/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
"github.com/pkg/errors"
"k8s.io/utils/ptr"
ctrl "sigs.k8s.io/controller-runtime"

svcapitypes "github.com/crossplane-contrib/provider-aws/apis/lambda/v1beta1"
Expand Down Expand Up @@ -131,7 +132,13 @@ func postObserve(_ context.Context, cr *svcapitypes.Function, resp *svcsdk.GetFu
cr.SetConditions(xpv1.Available())
case string(svcapitypes.State_Pending):
cr.SetConditions(xpv1.Creating())
case string(svcapitypes.State_Failed), string(svcapitypes.State_Inactive):
case string(svcapitypes.State_Inactive):
if aws.StringValue(resp.Configuration.StateReasonCode) == string(svcapitypes.StateReasonCode_Idle) {
cr.SetConditions(xpv1.Available().WithMessage(ptr.Deref(resp.Configuration.StateReason, "")))
} else {
cr.SetConditions(xpv1.Unavailable().WithMessage(ptr.Deref(resp.Configuration.StateReason, "")))
}
case string(svcapitypes.State_Failed):
cr.SetConditions(xpv1.Unavailable())
}
return obs, nil
Expand Down

0 comments on commit b9e3222

Please sign in to comment.