Skip to content

Commit

Permalink
fix(lambda/function): resource is ready when function is inactive due…
Browse files Browse the repository at this point in the history
… to idle

Signed-off-by: Charel Baum (external expert on behalf of DB InfraGO AG) <[email protected]>
  • Loading branch information
Charel Baum (external expert on behalf of DB InfraGO AG) committed Jul 29, 2024
1 parent 24abbe4 commit 3c0ced8
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 3c0ced8

Please sign in to comment.