{"record":{"id":"cd836a414fa642d6","repo":"kubernetes/kops","slug":"missing-vpc-task-from-target-group-v-v","errorCode":null,"errorMessage":"Missing VPC task from target group:\n%v\n%v","messagePattern":"Missing VPC task from target group:\n(.+?)\n(.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/awstasks/targetgroup.go","lineNumber":473,"sourceCode":"\tHealthCheck           terraformTargetGroupHealthCheck `cty:\"health_check\"`\n}\n\ntype terraformTargetGroupHealthCheck struct {\n\tInterval           int32                   `cty:\"interval\"`\n\tHealthyThreshold   int32                   `cty:\"healthy_threshold\"`\n\tUnhealthyThreshold int32                   `cty:\"unhealthy_threshold\"`\n\tProtocol           elbv2types.ProtocolEnum `cty:\"protocol\"`\n\tPath               *string                 `cty:\"path\"`\n}\n\nfunc (_ *TargetGroup) RenderTerraform(t *terraform.TerraformTarget, a, e, changes *TargetGroup) error {\n\tshared := fi.ValueOf(e.Shared)\n\tif shared {\n\t\treturn nil\n\t}\n\n\tif e.VPC == nil {\n\t\treturn fmt.Errorf(\"Missing VPC task from target group:\\n%v\\n%v\", e, e.VPC)\n\t}\n\n\ttf := &terraformTargetGroup{\n\t\tName:     *e.Name,\n\t\tPort:     *e.Port,\n\t\tProtocol: e.Protocol,\n\t\tVPCID:    e.VPC.TerraformLink(),\n\t\tTags:     e.Tags,\n\t\tHealthCheck: terraformTargetGroupHealthCheck{\n\t\t\tInterval:           *e.Interval,\n\t\t\tHealthyThreshold:   *e.HealthyThreshold,\n\t\t\tUnhealthyThreshold: *e.UnhealthyThreshold,\n\t\t\tProtocol:           e.HealthCheckProtocol,\n\t\t\tPath:               e.HealthCheckPath,\n\t\t},\n\t}\n\n\tfor attr, val := range e.Attributes {","sourceCodeStart":455,"sourceCodeEnd":491,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/awstasks/targetgroup.go#L455-L491","documentation":"RenderTerraform for a TargetGroup requires the VPC task reference to emit the terraform resource, and returns this error when e.VPC is nil. (Note the message prints %v twice for e and e.VPC, so the second value is always <nil> — a known cosmetic wart.) For shared target groups it returns early, so only managed target groups hit this.","triggerScenarios":"Running `kops update cluster --target=terraform` where the TargetGroup task was constructed without its VPC field populated — typically a wiring bug or a spec where the load balancer has no VPC association.","commonSituations":"Custom code or patched kOps building TargetGroup tasks manually without setting VPC; spec/feature changes that dropped the VPC assignment during task building; using terraform output on a cluster whose NLB spec is incomplete.","solutions":["Ensure the task-building code sets TargetGroup.VPC from the cluster's VPC task","Regenerate the cluster spec with the stock kOps version for your release","If shared (existing) target group, set Shared=true so the terraform path is skipped"],"exampleFix":"// before (task building)\ntg := &awstasks.TargetGroup{Name: name, Port: &port}\n// after\ntg := &awstasks.TargetGroup{Name: name, Port: &port, VPC: vpcTask}","handlingStrategy":"validation","validationCode":"// before terraform target\nif e.VPC == nil && !fi.ValueOf(e.Shared) {\n  return errors.New(\"target group has no VPC task; set VPC or mark Shared\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always wire VPC into TargetGroup tasks when building them","Run `kops update cluster --target=terraform` early in CI to catch missing refs","Use stock kOps task-building code","Set Shared=true only for genuinely existing target groups"],"tags":["terraform","target-group","vpc","missing-task"],"backgroundTag":"missing-task-reference","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"}