generated from nhs-england-tools/repository-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
66d60c0
commit 51b138b
Showing
6 changed files
with
140 additions
and
13 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
resource "azurerm_eventgrid_event_subscription" "eventgrid_event_subscription" { | ||
name = var.subscription_name | ||
scope = var.azurerm_eventgrid_id | ||
|
||
dynamic "azure_function_endpoint" { | ||
for_each = var.subscriber_function_details | ||
content { | ||
function_id = azure_function_endpoint.value.function_endpoint | ||
} | ||
} | ||
|
||
storage_blob_dead_letter_destination { | ||
storage_account_id = var.dead_letter_storage_account_id | ||
storage_blob_container_name = var.dead_letter_storage_account_container_name | ||
} | ||
|
||
# tags = var.tags | ||
} | ||
|
||
|
||
resource "azurerm_role_assignment" "eventgrid_subscription_role" { | ||
for_each = { for idx, endpoint in var.subscriber_function_details : idx => endpoint } | ||
|
||
principal_id = each.value.principal_id | ||
role_definition_name = "EventGrid Data Receiver" | ||
scope = var.azurerm_eventgrid_id | ||
} |
38 changes: 38 additions & 0 deletions
38
infrastructure/modules/event-grid-subscription/variables.tf
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
variable "subscription_name" { | ||
description = "The name of the Event Grid event subscription." | ||
type = string | ||
} | ||
|
||
variable "resource_group_name" { | ||
type = string | ||
description = "The name of the resource group in which to create the Event Grid. Changing this forces a new resource to be created." | ||
} | ||
|
||
variable "subscriber_function_details" { | ||
type = list(object({ | ||
function_endpoint = string | ||
principal_id = string | ||
})) | ||
default = [] | ||
} | ||
|
||
variable "azurerm_eventgrid_id" { | ||
description = "The azurerm Event Grid id to link to." | ||
type = string | ||
} | ||
|
||
variable "tags" { | ||
description = "A mapping of tags to assign to the Event Grid topic." | ||
type = map(string) | ||
default = {} | ||
} | ||
|
||
variable "dead_letter_storage_account_container_name" { | ||
description = "The name of storage account container for the Dead Letter queue." | ||
type = string | ||
} | ||
|
||
variable "dead_letter_storage_account_id" { | ||
description = "The name of storage account container id for the Dead Letter queue." | ||
type = string | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
resource "azurerm_eventgrid_topic" "azurerm_eventgrid" { | ||
name = var.topic_name | ||
resource_group_name = var.resource_group_name | ||
location = var.location | ||
|
||
identity { | ||
type = var.identity_type | ||
} | ||
|
||
dynamic "inbound_ip_rule" { | ||
for_each = var.inbound_ip_rules | ||
content { | ||
ip_mask = inbound_ip_rule.value["ip_mask"] | ||
action = inbound_ip_rule.value["action"] | ||
} | ||
} | ||
|
||
tags = var.tags | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
output "topic_endpoint" { | ||
description = "The event grid topic URL." | ||
value = azurerm_eventgrid_topic.azurerm_eventgrid.endpoint | ||
} | ||
|
||
output "id" { | ||
description = "The event grid topic id." | ||
value = azurerm_eventgrid_topic.azurerm_eventgrid.id | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
variable "resource_group_name" { | ||
type = string | ||
description = "The name of the resource group in which to create the Event Grid. Changing this forces a new resource to be created." | ||
} | ||
|
||
variable "location" { | ||
type = string | ||
description = "The location/region where the Event Grid is created." | ||
} | ||
|
||
variable "inbound_ip_rules" { | ||
description = "List of inbound IP rules" | ||
type = list(object({ | ||
ip_mask = string | ||
action = string | ||
})) | ||
default = [] | ||
} | ||
|
||
variable "identity_type" { | ||
type = string | ||
description = "The identity type of the Event Grid." | ||
} | ||
|
||
variable "topic_name" { | ||
description = "The name of the Event Grid topic." | ||
type = string | ||
} | ||
|
||
variable "tags" { | ||
description = "A mapping of tags to assign to the Event Grid topic." | ||
type = map(string) | ||
default = {} | ||
} |
This file contains 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