kubernetes/kops · error
error creating EventBridge rule: %v
Error message
error creating EventBridge rule: %v
What it means
RenderAWS for EventBridgeRule calls PutRule to create or update the rule and wraps any API error with this message. It is thrown only when the rule does not yet exist (the create branch) and AWS rejects the PutRule call.
Source
Thrown at upup/pkg/fi/cloudup/awstasks/eventbridgerule.go:127
if a == nil {
var tags []eventbridgetypes.Tag
for k, v := range eb.Tags {
tags = append(tags, eventbridgetypes.Tag{
Key: aws.String(k),
Value: aws.String(v),
})
}
request := &eventbridge.PutRuleInput{
Name: eb.Name,
EventPattern: e.EventPattern,
Tags: tags,
}
_, err := t.Cloud.EventBridge().PutRule(context.TODO(), request)
if err != nil {
return fmt.Errorf("error creating EventBridge rule: %v", err)
}
}
return nil
}
type terraformEventBridgeRule struct {
Name *string `cty:"name"`
EventPattern *terraformWriter.Literal `cty:"event_pattern"`
Tags map[string]string `cty:"tags"`
}
func (_ *EventBridgeRule) RenderTerraform(t *terraform.TerraformTarget, a, e, changes *EventBridgeRule) error {
m, err := t.AddFileBytes("aws_cloudwatch_event_rule", *e.Name, "event_pattern", []byte(*e.EventPattern), false)
if err != nil {
return err
}
View on GitHub (pinned to 4c8573c808)
Solutions
- Validate the eventPattern is syntactically valid JSON and matches EventBridge pattern grammar.
- Shorten/fix the rule name (max 64 chars, only letters, digits, . - _).
- Add eventbridge:PutRule to the kOps IAM policy, or request a quota increase for rules per event bus.
- Retry on throttling; check AWS Health/events for regional incidents.
Example fix
// before
EventPattern: fi.String("{'source':['aws.ec2']}")
// after (valid JSON, double quotes)
EventPattern: fi.String("{\"source\":[\"aws.ec2\"]}") Defensive patterns
Strategy: validation
Validate before calling
// Validate EventPattern JSON before applying
import encoding/json
if err := json.Valid([]byte(fi.ValueOf(e.EventPattern))); !err {
return fmt.Errorf("invalid EventPattern JSON")
}
// Rule name check
if len(name) > 64 { return fmt.Errorf("rule name too long") } Prevention
- Lint eventPattern as JSON in cluster spec validation
- Check IAM grants eventbridge:PutRule
- Monitor rules-per-event-bus quota in the account
When it happens
Trigger: PutRule fails: invalid EventPattern JSON, rule name violating the 64-char/[.\-_A-Za-z0-9]+ pattern, eventbridge:PutRule denied, rule limit (default 300) exceeded, or throttling.
Common situations: Cluster spec with a hand-written eventPattern containing invalid JSON; IAM role missing eventbridge:PutRule; accounts that hit the EventBridge rules-per-event-bus quota.
Related errors
- error creating EventBridge target: %v
- listing targets for EventBridge rule %q: %w
- removing targets for EventBridge rule %q: %w
- deleting EventBridge rule %q: %w
- error listing Eventbridge rules: %v
AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05).
Data as JSON: /api/errors/22f719ac7157c1c7.
Report an issue: GitHub.