Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: dtoss 6235 create terraform module for azure event grid #87

Merged
Merged
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
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 = {}
}
5 changes: 5 additions & 0 deletions infrastructure/modules/function-app/output.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ output "name" {
value = azurerm_linux_function_app.function_app.name
}

output "function_app_endpoint_name" {
description = "The function app endpoint name."
value = var.function_app_name
}

output "id" {
description = "The id of the Linux Function App."
value = azurerm_linux_function_app.function_app.id
Expand Down
Loading