{"record":{"id":"50af1d9d2b9a3b74","repo":"kubernetes/kops","slug":"found-multiple-asg-lifecycle-hooks-with-the-same-n","errorCode":null,"errorMessage":"found multiple ASG Lifecycle Hooks with the same name","messagePattern":"found multiple ASG Lifecycle Hooks with the same name","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/awstasks/autoscalinglifecyclehook.go","lineNumber":78,"sourceCode":"\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,\n\t\tAutoscalingGroup:    h.AutoscalingGroup,\n\t\tDefaultResult:       hook.DefaultResult,\n\t\tHeartbeatTimeout:    hook.HeartbeatTimeout,\n\t\tLifecycleTransition: hook.LifecycleTransition,\n\t\tEnabled:             new(true),\n\t}\n\n\treturn actual, nil\n}\n","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/awstasks/autoscalinglifecyclehook.go#L60-L96","documentation":"Thrown when DescribeLifecycleHooks returns more than one hook matching the task's single hook name for the ASG. The Find method expects at most one hook per (ASG, hook name) pair and refuses to guess which to reconcile.","triggerScenarios":"More than one lifecycle hook with the same name exists on the same Auto Scaling Group — possible if hooks were created out-of-band (console, Terraform, other tooling) or a prior creation partially duplicated.","commonSituations":"Manual AWS console edits; duplicate infrastructure applied by two IaC tools; state drift after a failed kOps apply left a stale hook.","solutions":["List the ASG lifecycle hooks in the AWS console/CLI (aws autoscaling describe-lifecycle-hooks)","Delete the duplicate hook so only one remains with the expected name","Re-run kops apply/update to reconcile cleanly","Audit other IaC tooling managing the same ASG to avoid recreating duplicates"],"exampleFix":"// before: duplicates present\naws autoscaling put-lifecycle-hook --lifecycle-hook-name Foo ...\naws autoscaling put-lifecycle-hook --lifecycle-hook-name Foo ...  # duplicate\n// after: remove the duplicate\naws autoscaling delete-lifecycle-hook --auto-scaling-group-name myasg --lifecycle-hook-name Foo","handlingStrategy":"validation","validationCode":"aws autoscaling describe-lifecycle-hooks --auto-scaling-group-name $ASG \\\n  --query \"LifecycleHooks[?LifecycleHookName=='$HOOK'] | length(@)\"\n# must output 1 (or 0) before applying","typeGuard":null,"tryCatchPattern":"catch (err) {\n  if (String(err).includes('found multiple ASG Lifecycle Hooks')) {\n    // remediate duplicates out-of-band, then retry\n  }\n  throw err;\n}","preventionTips":["Manage lifecycle hooks through a single IaC tool","Never create hooks manually in the console for kOps-managed ASGs","Audit hooks after failed/partial applies"],"tags":["aws","autoscaling","lifecycle-hook","duplicate-resource"],"backgroundTag":"duplicate-resource-found","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"}