{"record":{"id":"1dd35d5a58f9229e","repo":"kubernetes/kops","slug":"error-listing-asg-lifecycle-hooks-v","errorCode":null,"errorMessage":"error listing ASG Lifecycle Hooks: %v","messagePattern":"error listing ASG Lifecycle Hooks: (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/awstasks/autoscalinglifecyclehook.go","lineNumber":68,"sourceCode":"\nvar _ fi.CompareWithID = (*AutoscalingLifecycleHook)(nil)\n\nfunc (h *AutoscalingLifecycleHook) CompareWithID() *string {\n\treturn h.Name\n}\n\nfunc (h *AutoscalingLifecycleHook) Find(c *fi.CloudupContext) (*AutoscalingLifecycleHook, error) {\n\tctx := c.Context()\n\tcloud := awsup.GetCloud(c)\n\n\trequest := &autoscaling.DescribeLifecycleHooksInput{\n\t\tAutoScalingGroupName: h.AutoscalingGroup.Name,\n\t\tLifecycleHookNames:   []string{aws.ToString(h.GetHookName())},\n\t}\n\n\tresponse, err := cloud.Autoscaling().DescribeLifecycleHooks(ctx, request)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error listing ASG Lifecycle Hooks: %v\", err)\n\t}\n\tif response == nil || len(response.LifecycleHooks) == 0 {\n\t\tif !fi.ValueOf(h.Enabled) {\n\t\t\treturn h, nil\n\t\t}\n\n\t\treturn nil, nil\n\t}\n\tif len(response.LifecycleHooks) > 1 {\n\t\treturn nil, fmt.Errorf(\"found multiple ASG Lifecycle Hooks with the same name\")\n\t}\n\n\thook := response.LifecycleHooks[0]\n\tactual := &AutoscalingLifecycleHook{\n\t\tID:                  h.Name,\n\t\tName:                h.Name,\n\t\tHookName:            h.HookName,\n\t\tLifecycle:           h.Lifecycle,","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/awstasks/autoscalinglifecyclehook.go#L50-L86","documentation":"Wraps any AWS SDK error returned when calling DescribeLifecycleHooks for an Auto Scaling Group lifecycle hook task. kOps calls this during Find to reconcile the desired hook with actual AWS state; if the AWS API call itself fails, the underlying error is wrapped and returned.","triggerScenarios":"The Autoscaling().DescribeLifecycleHooks(ctx, request) call fails: IAM permissions missing (autoscaling:DescribeLifecycleHooks), invalid/unavailable AutoScalingGroupName, throttling, or network/endpoint issues.","commonSituations":"Clusters created before the lifecycle-hook task existed with restricted IAM policies; hooks referencing an ASG name that no longer exists or was renamed; transient AWS API throttling during reconcile.","solutions":["Check the wrapped AWS error in the message for the root cause (access denied, throttling, not found)","Verify the IAM policy used by the kOps controller grants autoscaling:DescribeLifecycleHooks on the ASG","Confirm the AutoscalingGroup name in the task actually exists in the target region/account","Retry if the wrapped error is throttling or a transient network failure"],"exampleFix":"// before: IAM policy missing describe\n{\"Effect\":\"Deny\",\"Action\":\"autoscaling:*\",\"Resource\":\"*\"}\n// after: allow the needed call\n{\"Effect\":\"Allow\",\"Action\":[\"autoscaling:DescribeLifecycleHooks\"],\"Resource\":\"*\"}","handlingStrategy":"try-catch","validationCode":"// verify IAM + ASG existence before apply\nconst asg = await autoscaling.describeAutoScalingGroups({AutoScalingGroupNames:[asgName]}).promise();\nif (!asg.AutoScalingGroups.length) throw new Error(`ASG ${asgName} not found`);","typeGuard":"function isAwsErr(err) { return err instanceof Error && 'code' in err; }","tryCatchPattern":"try {\n  await findLifecycleHook(ctx, hook);\n} catch (err) {\n  if (awsup.AWSErrorCode(err) === 'Throttling') return retryWithBackoff();\n  throw new Error(`error listing ASG Lifecycle Hooks: ${err.message}`);\n}","preventionTips":["Ensure autoscaling:DescribeLifecycleHooks is in the kOps IAM policy","Verify ASG names exist in the target region before applying","Watch for repeated Throttling codes on large fleets and add backoff"],"tags":["aws","autoscaling","lifecycle-hook","api-error"],"backgroundTag":"aws-api-call-failed","analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T07:17:12.445Z"}