Skip to content

Commit

Permalink
moved modules in
Browse files Browse the repository at this point in the history
  • Loading branch information
mrlockstar committed Dec 20, 2024
1 parent 760d900 commit b79ba4f
Show file tree
Hide file tree
Showing 5 changed files with 127 additions and 0 deletions.
27 changes: 27 additions & 0 deletions infrastructure/modules/event-grid-subscription/main.tf
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 infrastructure/modules/event-grid-subscription/variables.tf
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
}
19 changes: 19 additions & 0 deletions infrastructure/modules/event-grid-topic/main.tf
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
}
9 changes: 9 additions & 0 deletions infrastructure/modules/event-grid-topic/output.tf
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
}
34 changes: 34 additions & 0 deletions infrastructure/modules/event-grid-topic/variables.tf
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 = {}
}

0 comments on commit b79ba4f

Please sign in to comment.