EventBridge Rule
π¦ Overviewβ
This Terraform module provisions a flexible Amazon EventBridge rule, supporting both schedule-based and pattern-based triggers.
Itβs ideal for automating workflows, triggering Lambda functions, or routing events between decoupled systems.
β Key Featuresβ
- Creates a named EventBridge rule
- Supports schedule expressions or event pattern matching
- Integrates with custom or default event buses
- Enables cross-service automation and event handling
πΌ Use Casesβ
- Running backups or batch jobs on a schedule
- Triggering Lambda or Step Functions based on custom events
- Routing events across microservices using event patterns
- Building decoupled systems with domain-specific event buses
π₯ Input Variablesβ
| Name | Type | Description |
|---|---|---|
region | string | AWS region where the rule will be deployed |
rule_name | string | Name of the EventBridge rule |
event_bus_name | string | Name of the associated event bus |
schedule_expression | string | (Optional) Schedule expression (e.g., rate(1 day)) |
event_pattern | string | (Optional) Event pattern in JSON string format |
target_arn | string | ARN of the target resource to invoke (e.g., Lambda function) |
environment | string | Tag to specify the deployment environment (e.g., prod, staging) |
π€ Outputsβ
| Name | Description |
|---|---|
eventbridge_rule_name | The name of the created EventBridge rule |
eventbridge_rule_arn | The ARN of the created rule |
event_bus_name | The event bus the rule is associated with |
π Deployment Readinessβ
- β Compatible with Terraform 1.0+
- β Tested with AWS provider 5.x
- π§ͺ Requires at least one of:
schedule_expressionorevent_pattern
π οΈ Example Usageβ
module "eventbridge_rule" {
source = "git::ssh://git@github.com/archiphire/aws-level-1-modules.git//developer-utilities/eventbridge-rule?ref=v1.0.0"
region = "us-east-1"
rule_name = "trigger-backup"
event_bus_name = "my-custom-bus"
schedule_expression = "rate(1 day)"
target_arn = "arn:aws:lambda:us-east-1:123456789012:function:my-backup-fn"
environment = "prod"
}
terraform init
terraform plan
terraform apply
or
tofu init
tofu plan
tofu apply
π§Ή Cleanup Optionsβ
For testing:
terraform destroy
or
tofu destroy
For production:
Manually delete the rule via the AWS Console or CLI to avoid interrupting any linked workflows or targets.
π‘οΈ Notesβ
This is a Level 1 event-driven module that enables both time-based and pattern-based automation. To build more complete systems, pair with additional modules for event buses, Lambda functions, Step Functions, or SNS topics.
π Deployment Package Noticeβ
This module is part of the Level 1 AWS License Tier. To access the full deployment package and source code, subscribe to Archiphire.