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 66d60c0 commit 51b138b
Show file tree
Hide file tree
Showing 6 changed files with 140 additions and 13 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 = {}
}
26 changes: 13 additions & 13 deletions infrastructure/modules/sql-server/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -68,26 +68,26 @@ module "private_endpoint_sql_server" {
/* --------------------------------------------------------------------------------------------------
SQL Server Diagnostic Settings
-------------------------------------------------------------------------------------------------- */
# module "diagnostic_setting_sql_server" {
module "diagnostic_setting_sql_server" {

# source = "../diagnostic-settings"
source = "../diagnostic-settings"

# name = "${var.name}-sql-server-diagnotic-setting"
# target_resource_id = "${azurerm_mssql_server.azure_sql_server.id}/databases/master"
# log_analytics_workspace_id = var.log_analytics_workspace_id
# enabled_log = var.monitor_diagnostic_setting_sql_server_enabled_logs
# metric = var.monitor_diagnostic_setting_sql_server_metrics
# }
name = "${var.name}-sql-server-diagnotic-setting"
target_resource_id = "${azurerm_mssql_server.azure_sql_server.id}/databases/master"
log_analytics_workspace_id = var.log_analytics_workspace_id
enabled_log = var.monitor_diagnostic_setting_sql_server_enabled_logs
metric = var.monitor_diagnostic_setting_sql_server_metrics
}

/* --------------------------------------------------------------------------------------------------
# SQL Server Extended Auditing Policy
# -------------------------------------------------------------------------------------------------- */
# resource "azurerm_mssql_server_extended_auditing_policy" "azure_sql_server" {
resource "azurerm_mssql_server_extended_auditing_policy" "azure_sql_server" {

# server_id = azurerm_mssql_server.azure_sql_server.id
# log_monitoring_enabled = var.log_monitoring_enabled
# retention_in_days = var.auditing_policy_retention_in_days
# }
server_id = azurerm_mssql_server.azure_sql_server.id
log_monitoring_enabled = var.log_monitoring_enabled
retention_in_days = var.auditing_policy_retention_in_days
}

/* --------------------------------------------------------------------------------------------------
Security Alert Policy for SQL Server
Expand Down

0 comments on commit 51b138b

Please sign in to comment.