← Back to Docs
Recipe

Recipe: AWS EventBridge rule writer

Programmatically create and manage EventBridge rules that route AWS events to Meridian pipelines.

Prerequisites

  • AWS CLI v2 configured with appropriate IAM permissions
  • Meridian API key with events:write scope
  • Target bus ARN from your Meridian dashboard

Step 1 — Define the rule pattern

Create a JSON event pattern that filters the AWS service events you want to capture. Meridian supports the standard EventBridge pattern syntax.

{
  "source": ["aws.ec2"],
  "detail-type": [
    "EC2 Instance State-change Notification"
  ],
  "detail": {
    "state": ["terminated"]
  }
}

Step 2 — Create the rule

Use the AWS CLI to create the rule, specifying your Meridian event bus as the target.

aws events put-rule \
  --name meridian-ec2-terminated \
  --event-pattern file://pattern.json \
  --state ENABLED

Step 3 — Add the Meridian target

Attach your Meridian pipeline endpoint as the rule target. Replace the bus ARN and API key placeholder.

aws events put-targets \
  --rule meridian-ec2-terminated \
  --targets "Id"="meridian-pipeline","Arn"="arn:aws:events:..." \
  --event-bus-name default

Verification

Trigger a matching event and check the Meridian dashboard for ingestion. Events typically appear within 2–5 seconds.

Need help? Browse the full docs or reach out on Discord.