Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/adr/assets/ADR-003/examples/python/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
PyJWT==2.8.0
PyJWT==2.12.0
requests==2.32.4
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
resource "aws_cloudwatch_event_rule" "supplier_api_to_digital_letters" {
name = "${local.csi}-supplier-api-to-digital-letters"
description = "Supplier API events routed to Digital Letters"
event_bus_name = aws_cloudwatch_event_bus.data_plane.name

event_pattern = jsonencode({
"detail" : {
"type" : [
{ prefix = "uk.nhs.notify.supplier-api.letter.ACCEPTED" },
{ prefix = "uk.nhs.notify.supplier-api.letter.CANCELLED" },
{ prefix = "uk.nhs.notify.supplier-api.letter.DELIVERED" },
{ prefix = "uk.nhs.notify.supplier-api.letter.DISPATCHED" },
{ prefix = "uk.nhs.notify.supplier-api.letter.ENCLOSED" },
{ prefix = "uk.nhs.notify.supplier-api.letter.FAILED" },
{ prefix = "uk.nhs.notify.supplier-api.letter.FORWARDED" },
{ prefix = "uk.nhs.notify.supplier-api.letter.PENDING" },
{ prefix = "uk.nhs.notify.supplier-api.letter.PRINTED" },
{ prefix = "uk.nhs.notify.supplier-api.letter.REJECTED" },
{ prefix = "uk.nhs.notify.supplier-api.letter.RETURNED" }
]
}
})
}

resource "aws_cloudwatch_event_target" "supplier_api_to_digital_letters" {
count = var.event_target_arns["digital_letters_eventbus"] != null ? 1 : 0

rule = aws_cloudwatch_event_rule.supplier_api_to_digital_letters.name
arn = var.event_target_arns["digital_letters_eventbus"]
target_id = "supplier-api-to-digital-letters-eventbus"
event_bus_name = aws_cloudwatch_event_bus.data_plane.name
role_arn = aws_iam_role.supplier_api_to_digital_letters[0].arn
}

resource "aws_iam_role" "supplier_api_to_digital_letters" {
count = var.event_target_arns["digital_letters_eventbus"] != null ? 1 : 0

name = "eventbridge-cross-account"

assume_role_policy = jsonencode({
Version = "2012-10-17"
Statement = [{
Effect = "Allow"
Principal = {
Service = "events.amazonaws.com"
}
Action = "sts:AssumeRole"
}]
})
}

resource "aws_iam_role_policy" "supplier_api_to_digital_letters" {
count = var.event_target_arns["digital_letters_eventbus"] != null ? 1 : 0

role = aws_iam_role.supplier_api_to_digital_letters[0].id

policy = jsonencode({
Statement = [{
Effect = "Allow"
Action = "events:PutEvents"
Resource = var.event_target_arns["digital_letters_eventbus"]
}]
})
}
11 changes: 6 additions & 5 deletions infrastructure/terraform/components/events/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,12 @@ variable "event_publisher_account_ids" {
variable "event_target_arns" {
description = "A map of event target ARNs keyed by name"
type = object({
sms_nudge = string
notify_core_sns_topic = optional(string, null)
supplier_api_sns_topic = optional(string, null)
app_response = optional(string, null)
client_callbacks = optional(string, null)
sms_nudge = string
notify_core_sns_topic = optional(string, null)
supplier_api_sns_topic = optional(string, null)
app_response = optional(string, null)
client_callbacks = optional(string, null)
digital_letters_eventbus = optional(string, null)
})
}

Expand Down
Loading