{"record":{"id":"101b57a0b7851617","repo":"kubernetes/kops","slug":"error-creating-autoscalinggroup-s","errorCode":null,"errorMessage":"error creating AutoScalingGroup: %s","messagePattern":"error creating AutoScalingGroup: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/awstasks/autoscalinggroup.go","lineNumber":431,"sourceCode":"\t\t\t}\n\t\t} else if e.LaunchTemplate != nil {\n\t\t\trequest.LaunchTemplate = &autoscalingtypes.LaunchTemplateSpecification{\n\t\t\t\tLaunchTemplateId: e.LaunchTemplate.ID,\n\t\t\t\tVersion:          aws.String(\"$Latest\"),\n\t\t\t}\n\t\t} else {\n\t\t\treturn fmt.Errorf(\"could not find one of launch template or mixed instances policy\")\n\t\t}\n\n\t\t// @step: attempt to create the autoscaling group for us\n\t\tif _, err := t.Cloud.Autoscaling().CreateAutoScalingGroup(ctx, request); err != nil {\n\t\t\tcode := awsup.AWSErrorCode(err)\n\t\t\tmessage := awsup.AWSErrorMessage(err)\n\t\t\tif code == \"ValidationError\" && strings.Contains(message, \"Invalid IAM Instance Profile name\") {\n\t\t\t\tklog.V(4).Infof(\"error creating AutoscalingGroup: %s\", message)\n\t\t\t\treturn fi.NewTryAgainLaterError(\"waiting for the IAM Instance Profile to be propagated\")\n\t\t\t}\n\t\t\treturn fmt.Errorf(\"error creating AutoScalingGroup: %s\", message)\n\t\t}\n\n\t\t// @step: attempt to enable the metrics for us\n\t\tif _, err := t.Cloud.Autoscaling().EnableMetricsCollection(ctx, &autoscaling.EnableMetricsCollectionInput{\n\t\t\tAutoScalingGroupName: e.Name,\n\t\t\tGranularity:          e.Granularity,\n\t\t\tMetrics:              e.Metrics,\n\t\t}); err != nil {\n\t\t\treturn fmt.Errorf(\"error enabling metrics collection for AutoscalingGroup: %v\", err)\n\t\t}\n\n\t\tif len(*e.SuspendProcesses) > 0 {\n\t\t\tprocessQuery := &autoscaling.SuspendProcessesInput{}\n\t\t\tprocessQuery.AutoScalingGroupName = e.Name\n\t\t\tprocessQuery.ScalingProcesses = *e.SuspendProcesses\n\n\t\t\tif _, err := t.Cloud.Autoscaling().SuspendProcesses(ctx, processQuery); err != nil {\n\t\t\t\treturn fmt.Errorf(\"error suspending processes: %v\", err)","sourceCodeStart":413,"sourceCodeEnd":449,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/awstasks/autoscalinggroup.go#L413-L449","documentation":"CreateAutoScalingGroup API call failed; kOps wraps the AWS error message. One special case is recognized first: 'Invalid IAM Instance Profile name' is converted to a TryAgainLaterError so apply retries while IAM propagation completes.","triggerScenarios":"CreateAutoScalingGroup returns an error — most commonly a newly created instance profile not yet propagated to IAM, invalid VPC-subzone/min-size parameters (ValidationError), or the ASG name already existing in another state.","commonSituations":"First apply right after IAM role creation; typos in subnets/zones; ASG limits exceeded in the region.","solutions":["If the message says 'Invalid IAM Instance Profile name', just re-run apply after ~30s — IAM needs time to propagate (kOps will retry automatically)","Check the embedded AWS message for the real cause (ValidationErrors name the offending field)","Verify subnets, min/max size, and that no ASG with the same name exists","Check service quotas for AutoScaling groups in the region"],"exampleFix":"// before: immediate hard failure\nreturn fmt.Errorf(\"error creating AutoScalingGroup: %s\", message)\n// after (what kOps does for IAM propagation)\nif code == \"ValidationError\" && strings.Contains(message, \"Invalid IAM Instance Profile name\") {\n\treturn fi.NewTryAgainLaterError(\"waiting for the IAM Instance Profile to be propagated\")\n}","handlingStrategy":"retry","validationCode":"aws iam get-instance-profile --instance-profile-name nodes-instance-profile-<cluster> # exists?\naws autoscaling create-auto-scaling-group --generate-cli-skeleton # validate fields before apply","typeGuard":null,"tryCatchPattern":"retryuntil(30*time.Second, func() error {\n  if err := applyCluster(); err != nil &&\n     strings.Contains(err.Error(), \"Invalid IAM Instance Profile name\") {\n    return ErrRetry // IAM propagation lag\n  }\n  return err\n})","preventionTips":["After fresh IAM role/profile creation, wait ~1 minute before first apply","Pre-create IAM instance profiles before cluster bring-up in CI","Read the wrapped AWS message to distinguish propagation lag from real validation errors"],"tags":["aws","autoscaling","iam","api-error"],"backgroundTag":"iam-instance-profile-propagation","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"}