Skip to main content

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​

NameTypeDescription
regionstringAWS region where the rule will be deployed
rule_namestringName of the EventBridge rule
event_bus_namestringName of the associated event bus
schedule_expressionstring(Optional) Schedule expression (e.g., rate(1 day))
event_patternstring(Optional) Event pattern in JSON string format
target_arnstringARN of the target resource to invoke (e.g., Lambda function)
environmentstringTag to specify the deployment environment (e.g., prod, staging)

πŸ“€ Outputs​

NameDescription
eventbridge_rule_nameThe name of the created EventBridge rule
eventbridge_rule_arnThe ARN of the created rule
event_bus_nameThe 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_expression or event_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.