Skip to content

README recommends 3 distinct EventBridge rules but only 1 is needed #415

@gabegorelick

Description

@gabegorelick

For queue processor mode, the README mentions creating three EventBridge rules, with a target for each:

$ aws events put-rule \
  --name MyK8sASGTermRule \
  --event-pattern "{\"source\":[\"aws.autoscaling\"],\"detail-type\":[\"EC2 Instance-terminate Lifecycle Action\"]}"

$ aws events put-targets --rule MyK8sASGTermRule \
  --targets "Id"="1","Arn"="arn:aws:sqs:us-east-1:123456789012:MyK8sTermQueue"

$ aws events put-rule \
  --name MyK8sSpotTermRule \
  --event-pattern "{\"source\": [\"aws.ec2\"],\"detail-type\": [\"EC2 Spot Instance Interruption Warning\"]}"

$ aws events put-targets --rule MyK8sSpotTermRule \
  --targets "Id"="1","Arn"="arn:aws:sqs:us-east-1:123456789012:MyK8sTermQueue"

$ aws events put-rule \
  --name MyK8sRebalanceRule \
  --event-pattern "{\"source\": [\"aws.ec2\"],\"detail-type\": [\"EC2 Instance Rebalance Recommendation\"]}"

$ aws events put-targets --rule MyK8sRebalanceRule \
  --targets "Id"="1","Arn"="arn:aws:sqs:us-east-1:123456789012:MyK8sTermQueue"

However, the section heading ("Create an Amazon EventBridge Rule") and body copy ("Here is the AWS CLI command to create an Amazon EventBridge rule") are singular. I'm pretty sure a single rule with multiple sources and detail-types would work just fine [1], and it would be simpler to set up.

Example:

$ aws events put-rule \
  --name MyK8sNodeTerminationHandlerRule \
  --event-pattern '{"source":["aws.autoscaling","aws.ec2"],"detail-type":["EC2 Instance-terminate Lifecycle Action","EC2 Spot Instance Interruption Warning","EC2 Instance Rebalance Recommendation"]}"'

$ aws events put-targets --rule MyK8sNodeTerminationHandlerRule \
  --targets "Id"="1","Arn"="arn:aws:sqs:us-east-1:123456789012:MyK8sTermQueue"

[1] Values are OR-ed together: https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-event-patterns.html.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Priority: LowThis issue will not be seen by most users. The issue is a very specific use case or corner casegood first issueGood for newcomers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions