{"record":{"id":"9ea1872663d8b49d","repo":"kubernetes/kops","slug":"error-creating-routetableassociation-v","errorCode":null,"errorMessage":"error creating RouteTableAssociation: %v","messagePattern":"error creating RouteTableAssociation: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/awstasks/routetableassociation.go","lineNumber":185,"sourceCode":"\t\t\t\t\tAssociationId: a.RouteTableAssociationId,\n\t\t\t\t}\n\n\t\t\t\t_, err := t.Cloud.EC2().DisassociateRouteTable(ctx, request)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn fmt.Errorf(\"error disassociating existing RouteTable from subnet: %v\", err)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tklog.V(2).Infof(\"Creating RouteTableAssociation\")\n\t\trequest := &ec2.AssociateRouteTableInput{\n\t\t\tSubnetId:     e.Subnet.ID,\n\t\t\tRouteTableId: e.RouteTable.ID,\n\t\t}\n\n\t\tresponse, err := t.Cloud.EC2().AssociateRouteTable(ctx, request)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"error creating RouteTableAssociation: %v\", err)\n\t\t}\n\n\t\te.ID = response.AssociationId\n\t}\n\n\treturn nil // no tags\n}\n\ntype terraformRouteTableAssociation struct {\n\tSubnetID     *terraformWriter.Literal `cty:\"subnet_id\"`\n\tRouteTableID *terraformWriter.Literal `cty:\"route_table_id\"`\n}\n\nfunc (_ *RouteTableAssociation) RenderTerraform(t *terraform.TerraformTarget, a, e, changes *RouteTableAssociation) error {\n\ttf := &terraformRouteTableAssociation{\n\t\tSubnetID:     e.Subnet.TerraformLink(),\n\t\tRouteTableID: e.RouteTable.TerraformLink(),\n\t}","sourceCodeStart":167,"sourceCodeEnd":203,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/awstasks/routetableassociation.go#L167-L203","documentation":"AssociateRouteTable failed while binding the subnet to the target route table — commonly an invalid or already-deleted RouteTableId/SubnetId, or missing ec2:AssociateRouteTable permission. The AWS API detail is in the wrapped error.","triggerScenarios":"AssociateRouteTable fails with invalid subnet/route table IDs (resources deleted out-of-band), UnauthorizedOperation, InvalidParameterValue (wrong region/VPC), or throttling during RenderAWS.","commonSituations":"Subnet or route table deleted manually between planning and apply; IAM policy missing ec2:AssociateRouteTable; cross-VPC mismatch where the route table belongs to a different VPC than the subnet; region misconfiguration.","solutions":["Read the wrapped AWS error: InvalidSubnetID.NotFound/InvalidRouteTableID.NotFound means resources were deleted — re-create or fix the cluster spec","Verify route table and subnet are in the same VPC and region","Add ec2:AssociateRouteTable to the IAM role if UnauthorizedOperation","Re-run kops update after fixing"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"aws ec2 describe-subnets --subnet-ids <subnet-id>\naws ec2 describe-route-tables --route-table-ids <rt-id>  # confirm both exist and share the VPC","typeGuard":null,"tryCatchPattern":"if err != nil {\n  switch {\n  case strings.Contains(err.Error(), \"InvalidSubnetID.NotFound\"), strings.Contains(err.Error(), \"InvalidRouteTableID.NotFound\"):\n    // resource deleted out-of-band: recreate / fix spec\n  case strings.Contains(err.Error(), \"UnauthorizedOperation\"):\n    // fix IAM policy\n  }\n}","preventionTips":["Avoid deleting AWS resources kOps manages without kops delete cluster","Verify region and VPC alignment in the cluster spec","Grant ec2:AssociateRouteTable to the kOps role"],"tags":["aws","ec2","route-table","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"}