{"record":{"id":"aa4ac5c15a3bd58e","repo":"kubernetes/kops","slug":"spotinst-failed-to-create-launch-spec-v","errorCode":null,"errorMessage":"spotinst: failed to create launch spec: %v","messagePattern":"spotinst: failed to create launch spec: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/spotinsttasks/launch_spec.go","lineNumber":589,"sourceCode":"\t{\n\t\tif e.InstanceMetadataOptions != nil {\n\t\t\topt := new(aws.LaunchspecInstanceMetadataOptions)\n\t\t\topt.SetHTTPPutResponseHopLimit(new(int(fi.ValueOf(e.InstanceMetadataOptions.HTTPPutResponseHopLimit))))\n\t\t\topt.SetHTTPTokens(new(fi.ValueOf(e.InstanceMetadataOptions.HTTPTokens)))\n\t\t\tspec.SetLaunchspecInstanceMetadataOptions(opt)\n\t\t}\n\t}\n\n\t// Wrap the raw object as a LaunchSpec.\n\tsp, err := spotinst.NewLaunchSpec(cloud.ProviderID(), spec)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Create a new LaunchSpec.\n\t_, err = cloud.Spotinst().LaunchSpec().Create(context.Background(), sp)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"spotinst: failed to create launch spec: %v\", err)\n\t}\n\n\treturn nil\n}\n\nfunc (_ *LaunchSpec) update(cloud awsup.AWSCloud, a, e, changes *LaunchSpec) error {\n\tklog.V(2).Infof(\"Updating Launch Spec for Ocean %q\", *a.Ocean.Name)\n\n\tocean, err := a.Ocean.find(cloud.Spotinst().Ocean())\n\tif err != nil {\n\t\tklog.Errorf(\"Unable to resolve Ocean %q, error: %v\", *a.Ocean.Name, err)\n\t\treturn err\n\t}\n\n\tactual, err := e.find(cloud.Spotinst().LaunchSpec(), *ocean.ID)\n\tif err != nil {\n\t\tklog.Errorf(\"Unable to resolve Launch Spec %q, error: %v\", *e.Name, err)\n\t\treturn err","sourceCodeStart":571,"sourceCodeEnd":607,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/spotinsttasks/launch_spec.go#L571-L607","documentation":"create calls the Spotinst LaunchSpec Create API and wraps any API error with this message. The launch spec (one instance group's configuration under an Ocean) could not be created on the Spotinst side.","triggerScenarios":"During createOrUpdate, cloud.Spotinst().LaunchSpec().Create(ctx, sp) returns a non-nil error (validation failure, quota, auth, duplicate name).","commonSituations":"Invalid instance type or subnet referenced in the spec; Spotinst account limits exceeded; duplicate launch spec name; Spotinst token lacks permissions.","solutions":["Read the wrapped %v detail for the underlying Spotinst API reason","Validate the instance group spec (subnets, instance types, IAM profile) in the cluster spec","Check Spotinst account quota/permissions in the console","Verify SPOTINST_TOKEN and SPOTINST_ACCOUNT are correct"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if sp == nil || fi.ValueOf(sp.Name) == \"\" {\n    return errors.New(\"launch spec must have a name before create\")\n}\nif len(subnetIDs) == 0 {\n    return errors.New(\"launch spec requires at least one subnet\")\n}","typeGuard":null,"tryCatchPattern":"if _, err := svc.Create(ctx, sp); err != nil {\n    var cerrs client.Errors\n    if errors.As(err, &cerrs) {\n        for _, ce := range cerrs {\n            if strings.Contains(ce.Message, \"already exists\") {\n                // fall back to find-and-update path\n            }\n        }\n    }\n    return fmt.Errorf(\"spotinst: failed to create launch spec: %w\", err)\n}","preventionTips":["Validate instance types and subnets against the Ocean region before apply","Check Spotinst account quotas when adding many groups","Ensure the launch spec name is unique within the Ocean","Keep Spotinst tokens scoped with write permissions"],"tags":["spotinst","launch-spec","api-error","create"],"backgroundTag":"spotinst-api-error","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"}