Last active
June 5, 2025 11:54
-
-
Save sergiojoker11/57c701fc4f0ef7da76e6d93cdd8a732e to your computer and use it in GitHub Desktop.
Example of usage: Stripe Event Bridge Webhook using customm Event bus + fanout to SQS using EventBridge rules
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
locals { | |
streams_to_return = ["all-events"] | |
} | |
module "stripe_webhook" { | |
source = "./modules/stripe-event-bridge-webhook" | |
environment = var.environment | |
aws_region = var.aws_region | |
api_version = var.stripe_api_version | |
stripe_admin_api_key = var.stripe_admin_api_key | |
stripe_webhook_events = [ | |
"customer.subscription.created", | |
"customer.subscription.updated", | |
"customer.subscription.deleted", | |
"invoice.payment_succeeded", | |
"invoice.payment_failed", | |
"checkout.session.completed" | |
] | |
streams_to_return = toset(local.streams_to_return) | |
} | |
resource "aws_cloudwatch_event_target" "all_events" { | |
for_each = module.stripe_webhook.stripe_event_rules | |
rule = each.value.event_bus_rule_name | |
event_bus_name = each.value.event_bus_name | |
target_id = each.key | |
arn = module.stripe_webhook_queue.sqs_queue_arn | |
sqs_target { | |
message_group_id = "stripe-events-${each.key}" | |
} | |
} | |
module "stripe_webhook_queue" { | |
source = "./modules/sqs" | |
queue_name = "stripe-webhook-${var.environment}" | |
sender_arns = toset([ | |
module.stripe_webhook.stripe_event_rules[local.streams_to_return[0]].event_bus_rule_arn | |
]) | |
receiver_arn = "lambda consuming events" # TODO | |
tags = local.common_tags | |
redrive_policy = { | |
max_receive_count = 2 | |
dead_letter_target_arn = aws_sqs_queue.global_dlq_unprocessable_sqs.arn | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage of this module
Notes: