Skip to content

Instantly share code, notes, and snippets.

@alexjeen
Created June 27, 2023 16:10
Show Gist options
  • Save alexjeen/799c90704ef955f1906d1ada6a69699d to your computer and use it in GitHub Desktop.
Save alexjeen/799c90704ef955f1906d1ada6a69699d to your computer and use it in GitHub Desktop.
Using the EventBridge modules multiple times
variable "env_level" {
description = "Environment level"
default = "dev"
}
module "eventbridge_price" {
source = "terraform-aws-modules/eventbridge/aws"
create_bus = false
create_connections = true
create_api_destinations = true
attach_api_destination_policy = true
rules = {
"test_room_price_${var.env_level}" = {
description = "Trigger test room price cron"
schedule_expression = "cron(20 4 * * ? *)"
enabled = true
event_pattern = null
}
}
targets = {
"test_room_price_${var.env_level}" = [
{
name = "send-request-to-test-room-price-${var.env_level}"
destination = "test_room_price_${var.env_level}"
attach_role_arn = true
}
]
}
connections = {
"test_room_price_${var.env_level}" = {
authorization_type = "API_KEY"
auth_parameters = {
api_key = {
key = "Authorization"
value = "Bearer testtoken"
}
}
}
}
api_destinations = {
"test_room_price_${var.env_level}" = {
description = "my test room price endpoint"
invocation_endpoint = "https://example.com/generate_cts/*"
http_method = "POST"
invocation_rate_limit_per_second = 10
}
}
}
module "eventbridge_details" {
source = "terraform-aws-modules/eventbridge/aws"
create_bus = false
create_connections = true
create_api_destinations = true
attach_api_destination_policy = true
rules = {
"test_room_details_${var.env_level}" = {
description = "Trigger test room details cron"
schedule_expression = "cron(50 3 * * ? *)"
enabled = true
event_pattern = null
}
}
targets = {
"test_room_details_${var.env_level}" = [
{
name = "send-request-to-test-room-details-${var.env_level}"
destination = "test_room_details_${var.env_level}"
attach_role_arn = true
}
]
}
connections = {
"test_room_details_${var.env_level}" = {
authorization_type = "API_KEY"
auth_parameters = {
api_key = {
key = "Authorization"
value = "Bearer testtoken"
}
}
}
}
api_destinations = {
"test_room_details_${var.env_level}" = {
description = "XXX"
invocation_endpoint = "http://example.com/generate_cts/*"
http_method = "POST"
invocation_rate_limit_per_second = 10
}
}
}
@sany2k8
Copy link

sany2k8 commented Jul 1, 2023

I really appreciate your effort, sir. Thanks a lot 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment