@@ -36,7 +36,7 @@ import (
3636// DescribeLifecycleHooks returns the lifecycle hooks for the given AutoScalingGroup after retrieving them from the AWS API.
3737func (s * Service ) DescribeLifecycleHooks (asgName string ) ([]* expinfrav1.AWSLifecycleHook , error ) {
3838 input := & autoscaling.DescribeLifecycleHooksInput {
39- AutoScalingGroupName : aws . String (asgName ),
39+ AutoScalingGroupName : ptr . To (asgName ),
4040 }
4141
4242 out , err := s .ASGClient .DescribeLifecycleHooksWithContext (context .TODO (), input )
@@ -54,25 +54,21 @@ func (s *Service) DescribeLifecycleHooks(asgName string) ([]*expinfrav1.AWSLifec
5454
5555func getPutLifecycleHookInput (asgName string , hook * expinfrav1.AWSLifecycleHook ) (ret * autoscaling.PutLifecycleHookInput ) {
5656 ret = & autoscaling.PutLifecycleHookInput {
57- AutoScalingGroupName : aws . String (asgName ),
58- LifecycleHookName : aws . String (hook .Name ),
59- LifecycleTransition : aws . String (hook .LifecycleTransition .String ()),
57+ AutoScalingGroupName : ptr . To (asgName ),
58+ LifecycleHookName : ptr . To (hook .Name ),
59+ LifecycleTransition : ptr . To (hook .LifecycleTransition .String ()),
6060
6161 // Optional
6262 RoleARN : hook .RoleARN ,
6363 NotificationTargetARN : hook .NotificationTargetARN ,
6464 NotificationMetadata : hook .NotificationMetadata ,
6565 }
6666
67- // Optional parameters
68- if hook .DefaultResult != nil {
69- ret .DefaultResult = aws .String (hook .DefaultResult .String ())
70- }
71-
72- if hook .HeartbeatTimeout != nil {
73- timeoutSeconds := hook .HeartbeatTimeout .Duration .Seconds ()
74- ret .HeartbeatTimeout = aws .Int64 (int64 (timeoutSeconds ))
75- }
67+ // For optional fields in the manifest, still fill in the AWS request parameters so any drifted lifecycle hook
68+ // settings are reconciled to the desired state on update. Using AWS default values here.
69+ ret .DefaultResult = ptr .To (ptr .Deref (hook .DefaultResult , expinfrav1 .LifecycleHookDefaultResultAbandon ).String ())
70+ timeoutSeconds := ptr .Deref (hook .HeartbeatTimeout , metav1.Duration {Duration : 3600 * time .Second }).Duration .Seconds ()
71+ ret .HeartbeatTimeout = aws .Int64 (int64 (timeoutSeconds ))
7672
7773 return
7874}
@@ -102,8 +98,8 @@ func (s *Service) UpdateLifecycleHook(ctx context.Context, asgName string, hook
10298// DeleteLifecycleHook deletes a lifecycle hook for the given AutoScalingGroup.
10399func (s * Service ) DeleteLifecycleHook (ctx context.Context , asgName string , hook * expinfrav1.AWSLifecycleHook ) error {
104100 input := & autoscaling.DeleteLifecycleHookInput {
105- AutoScalingGroupName : aws . String (asgName ),
106- LifecycleHookName : aws . String (hook .Name ),
101+ AutoScalingGroupName : ptr . To (asgName ),
102+ LifecycleHookName : ptr . To (hook .Name ),
107103 }
108104
109105 if _ , err := s .ASGClient .DeleteLifecycleHookWithContext (ctx , input ); err != nil {
@@ -134,8 +130,8 @@ func (s *Service) SDKToLifecycleHook(hook *autoscaling.LifecycleHook) *expinfrav
134130func getLifecycleHookSpecificationList (lifecycleHooks []expinfrav1.AWSLifecycleHook ) (ret []* autoscaling.LifecycleHookSpecification ) {
135131 for _ , hook := range lifecycleHooks {
136132 spec := & autoscaling.LifecycleHookSpecification {
137- LifecycleHookName : aws . String (hook .Name ),
138- LifecycleTransition : aws . String (hook .LifecycleTransition .String ()),
133+ LifecycleHookName : ptr . To (hook .Name ),
134+ LifecycleTransition : ptr . To (hook .LifecycleTransition .String ()),
139135
140136 // Optional
141137 RoleARN : hook .RoleARN ,
@@ -145,7 +141,7 @@ func getLifecycleHookSpecificationList(lifecycleHooks []expinfrav1.AWSLifecycleH
145141
146142 // Optional parameters
147143 if hook .DefaultResult != nil {
148- spec .DefaultResult = aws . String (hook .DefaultResult .String ())
144+ spec .DefaultResult = ptr . To (hook .DefaultResult .String ())
149145 }
150146
151147 if hook .HeartbeatTimeout != nil {
0 commit comments