{"record":{"id":"d383fc21440ccfe1","repo":"kubernetes/kops","slug":"error-listing-eventbridge-rules-v","errorCode":null,"errorMessage":"error listing Eventbridge rules: %v","messagePattern":"error listing Eventbridge rules: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/resources/aws/eventbridge.go","lineNumber":98,"sourceCode":"\treturn nil\n}\n\nfunc ListEventBridgeRules(cloud fi.Cloud, vpcID, clusterName string) ([]*resources.Resource, error) {\n\tctx := context.TODO()\n\tc := cloud.(awsup.AWSCloud)\n\n\tklog.V(2).Infof(\"Listing EventBridge rules\")\n\tclusterNamePrefix := awsup.GetClusterName40(clusterName)\n\n\t// rule names start with the cluster name so that we can search for them\n\trequest := &eventbridge.ListRulesInput{\n\t\tEventBusName: nil,\n\t\tLimit:        nil,\n\t\tNamePrefix:   aws.String(clusterNamePrefix),\n\t}\n\tresponse, err := c.EventBridge().ListRules(ctx, request)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error listing Eventbridge rules: %v\", err)\n\t}\n\tif response == nil || len(response.Rules) == 0 {\n\t\treturn nil, nil\n\t}\n\n\tvar resourceTrackers []*resources.Resource\n\n\tfor _, rule := range response.Rules {\n\t\tresourceTracker := &resources.Resource{\n\t\t\tName:    *rule.Name,\n\t\t\tID:      *rule.Name,\n\t\t\tType:    TypeEventBridgeRule,\n\t\t\tDeleter: EventBridgeRuleDeleter,\n\t\t\tDumper:  DumpEventBridgeRule,\n\t\t\tObj:     rule,\n\t\t}\n\n\t\tresourceTrackers = append(resourceTrackers, resourceTracker)","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/pkg/resources/aws/eventbridge.go#L80-L116","documentation":"ListEventBridgeRules in pkg/resources/aws/eventbridge.go enumerates EventBridge rules whose names start with the cluster-name prefix (used by `kops delete cluster` to find cluster-owned rules). This error wraps any failure returned by the EventBridge ListRules API call. It means the lookup of cluster rules could not be completed, so cluster deletion cannot inventory EventBridge resources.","triggerScenarios":"Any non-nil error from c.EventBridge().ListRules with EventBusName=nil and NamePrefix=<clusterNamePrefix>: missing/invalid AWS credentials, wrong region on the cloud client, throttling (ThrottlingException), AccessDeniedException from restrictive IAM, invalid NamePrefix (>64 chars) producing ValidationException, or network/API outages.","commonSituations":"Expired or absent AWS session during `kops delete cluster`; IAM policy without events:ListRules; misconfigured KOPS_REGION/AWS_REGION; the 40-char cluster prefix (GetClusterName40) exceeding EventBridge rule-name limits; transient throttling on accounts with many rules.","solutions":["Verify AWS credentials and region used to build the AWSCloud client (aws sts get-caller-identity in the target region).","Check IAM policy grants events:ListRules on the account/default event bus.","Retry on throttling; add backoff or reduce concurrent describe calls in the same deletion run.","Ensure the cluster name (and thus GetClusterName40 prefix) is a valid EventBridge rule-name prefix (<=64 chars, valid pattern)."],"exampleFix":"// before\nresponse, err := c.EventBridge().ListRules(ctx, request)\n// after\nresponse, err := c.EventBridge().ListRules(ctx, request)\nif err != nil {\n    var terr *types.ThrottlingException\n    if errors.As(err, &terr) {\n        // retry with backoff\n    }\n    return nil, fmt.Errorf(\"error listing Eventbridge rules: %w\", err)\n}","handlingStrategy":"try-catch","validationCode":"// Go: preflight before deletion run\nsess, err := config.LoadDefaultConfig(ctx)\nif err != nil { return fmt.Errorf(\"no AWS config: %w\", err) }\nif _, err := sts.NewFromConfig(sess).GetCallerIdentity(ctx, &sts.GetCallerIdentityInput{}); err != nil {\n    return fmt.Errorf(\"invalid AWS credentials: %w\", err)\n}\nif len(clusterNamePrefix) > 64 {\n    return fmt.Errorf(\"cluster prefix %q too long for EventBridge rule name\", clusterNamePrefix)\n}","typeGuard":"func isEventBridgeListErr(err error) (retryable bool, ok bool) {\n    if err == nil { return false, false }\n    var rerr *types.ThrottlingException\n    if errors.As(err, &rerr) { return true, true }\n    var aerr *types.AccessDeniedException\n    if errors.As(err, &aerr) { return false, true }\n    return false, true\n}","tryCatchPattern":"rules, err := ListEventBridgeRules(cloud, vpcID, clusterName)\nif err != nil {\n    klog.Warningf(\"EventBridge listing failed, continuing deletion: %v\", err)\n    rules = nil // fallback: proceed without EventBridge cleanup\n}","preventionTips":["Run `kops toolbox dump` or aws events list-rules manually first to verify permissions.","Use dedicated IAM profiles with events:ListRules for cleanup operations.","Keep cluster names within the 40-char GetClusterName40 budget to avoid rule-name validation issues.","Set AWS_REGION/KOPS_REGION explicitly in CI environments."],"tags":["aws","eventbridge","list-rules","cluster-deletion"],"backgroundTag":"aws-api-list-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"}