Skip to content

Commit

Permalink
Adding networking & refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
anssihakanen committed Apr 22, 2024
1 parent 01a3994 commit 1f62871
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 0 deletions.
1 change: 1 addition & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ module "container" {
location = var.location
prefix = var.prefix
env = var.env
subnet = module.network.compute_subnet_id
}

module "monitoring" {
Expand Down
5 changes: 5 additions & 0 deletions modules/Container/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ resource "azurerm_container_group" "container_group" {
resource_group_name = var.rg
os_type = "Linux"
ip_address_type = "Public"
subnet_ids = toset([var.subnet])


container {
Expand All @@ -20,5 +21,9 @@ resource "azurerm_container_group" "container_group" {
port = 80
protocol = "TCP"
}
ports {
port = 3310
protocol = "TCP"
}
}
}
4 changes: 4 additions & 0 deletions modules/Container/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,8 @@ variable "prefix" {

variable "env" {
type = string
}

variable "subnet" {
type = string
}
1 change: 1 addition & 0 deletions modules/Database/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ resource "azurerm_mssql_server" "sql_server" {
name = "dbs-${var.prefix}-${var.env}-001"
resource_group_name = var.rg
location = var.location
tags = var.tags
version = "12.0"
administrator_login = data.azurerm_key_vault_secret.dbuser.value
administrator_login_password = data.azurerm_key_vault_secret.dbpass.value
Expand Down
4 changes: 4 additions & 0 deletions modules/Monitoring/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@ output "instrumentation_key" {

output "app_id" {
value = azurerm_application_insights.application_insights.app_id
}

output "log_analytics_workspace_id" {
value = azurerm_log_analytics_workspace.log_analytics_workspace.id
}
19 changes: 19 additions & 0 deletions modules/Network/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,23 @@ resource "azurerm_subnet" "backend" {
resource_group_name = var.rg
virtual_network_name = azurerm_virtual_network.vnet1.name
address_prefixes = ["10.100.3.0/24"]
}

resource "azurerm_private_dns_zone" "zones" {
for_each = var.private_dns_zones

name = each.value
resource_group_name = var.rg
tags = var.tags
}

# Private DNS Zone links to VNET
resource "azurerm_private_dns_zone_virtual_network_link" "zone_links" {
for_each = azurerm_private_dns_zone.zones

name = "${each.value.name}-link"
resource_group_name = var.rg
private_dns_zone_name = each.value.name
virtual_network_id = azurerm_virtual_network.vnet1.id
tags = var.tags
}
12 changes: 12 additions & 0 deletions modules/Network/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,16 @@ variable "prefix" {

variable "env" {
type = string
}

variable "private_dns_zones" {
type = map(string)
default = {
blob_zone = "privatelink.blob.core.windows.net"
file_zone = "privatelink.file.core.windows.net"
eventgrid_zone = "privatelink.eventgrid.azure.net"
functionapp_zone = "privatelink.azurewebsites.net"
container_zone = "privatelink.aci.azure.net"
sql_zone = "privatelink.database.windows.net"
}
}
Binary file modified plan.out
Binary file not shown.

0 comments on commit 1f62871

Please sign in to comment.