diff --git a/ops/terraform/locals.tf b/ops/terraform/locals.tf index 6fc1c396..d42f56af 100644 --- a/ops/terraform/locals.tf +++ b/ops/terraform/locals.tf @@ -7,43 +7,49 @@ locals { dev = { dev = { vnetcidr = "10.0.0.0/16" - websubnetcidr = "10.0.1.0/24" + appsubnetcidr = "10.0.1.0/24" + websubnetcidr = "10.0.2.0/24" lbsubnetcidr = "10.0.2.0/24" } } dev2 = { dev2 = { vnetcidr = "10.2.0.0/16" - websubnetcidr = "10.2.1.0/24" - lbsubnetcidr = "10.2.2.0/24" + appsubnetcidr = "10.2.1.0/24" + websubnetcidr = "10.2.2.0/24" + lbsubnetcidr = "10.2.3.0/24" } } dev3 = { dev3 = { vnetcidr = "10.3.0.0/16" - websubnetcidr = "10.3.1.0/24" - lbsubnetcidr = "10.3.2.0/24" + appsubnetcidr = "10.3.1.0/24" + websubnetcidr = "10.3.2.0/24" + lbsubnetcidr = "10.3.3.0/24" } } dev4 = { dev4 = { vnetcidr = "10.4.0.0/16" - websubnetcidr = "10.4.1.0/24" - lbsubnetcidr = "10.4.2.0/24" + appsubnetcidr = "10.4.1.0/24" + websubnetcidr = "10.4.2.0/24" + lbsubnetcidr = "10.4.3.0/24" } } dev5 = { dev5 = { vnetcidr = "10.5.0.0/16" - websubnetcidr = "10.5.1.0/24" - lbsubnetcidr = "10.5.2.0/24" + appsubnetcidr = "10.5.1.0/24" + websubnetcidr = "10.5.2.0/24" + lbsubnetcidr = "10.5.3.0/24" } } dev6 = { dev6 = { vnetcidr = "10.6.0.0/16" - websubnetcidr = "10.6.1.0/24" - lbsubnetcidr = "10.6.2.0/24" + appsubnetcidr = "10.6.1.0/24" + websubnetcidr = "10.6.2.0/24" + lbsubnetcidr = "10.6.3.0/24" } } } \ No newline at end of file diff --git a/ops/terraform/main.tf b/ops/terraform/main.tf index b0d7ca19..a01d3c83 100644 --- a/ops/terraform/main.tf +++ b/ops/terraform/main.tf @@ -8,6 +8,22 @@ locals { } } +output "workspace" { + value = "${terraform.workspace}" +} + +output "vnetcidr" { + value = "${local.workspace["vnetcidr"]}" +} + +output "websubnetcidr" { + value = "${local.workspace["websubnetcidr"]}" +} + +output "lbsubnetcidr" { + value = "${local.workspace["lbsubnetcidr"]}" +} + ########## ## 02-network ########## @@ -19,6 +35,7 @@ module "networking" { vnetcidr = local.workspace["vnetcidr"] websubnetcidr = local.workspace["websubnetcidr"] lbsubnetcidr = local.workspace["lbsubnetcidr"] + appsubnetcidr = local.workspace["appsubnetcidr"] env = local.environment } @@ -32,6 +49,7 @@ module "securitygroup" { location = data.azurerm_resource_group.rg.location resource_group = data.azurerm_resource_group.rg.name web_subnet_id = module.networking.websubnet_id + app_subnet_id = module.networking.appsubnet_id # db_subnet_id = module.networking.dbsubnet_id lb_subnet_id = module.networking.lbsubnet_id env = local.environment diff --git a/ops/terraform/modules/app_gateway/main.tf b/ops/terraform/modules/app_gateway/main.tf index 1f8e1637..ce2a5a15 100644 --- a/ops/terraform/modules/app_gateway/main.tf +++ b/ops/terraform/modules/app_gateway/main.tf @@ -159,7 +159,7 @@ resource "azurerm_application_gateway" "load_balancer" { path_rule { name = "api" - paths = ["/*", "/"] + paths = ["/api/*", "/api"] backend_address_pool_name = local.backend_address_pool_name_api backend_http_settings_name = local.http_setting_name_api // this is the default, why would we set it again? diff --git a/ops/terraform/modules/network/main.tf b/ops/terraform/modules/network/main.tf index 56cd44dc..4abef522 100644 --- a/ops/terraform/modules/network/main.tf +++ b/ops/terraform/modules/network/main.tf @@ -14,21 +14,21 @@ resource "azurerm_subnet" "web-subnet" { depends_on = [azurerm_virtual_network.vnet] } -# resource "azurerm_subnet" "app-subnet" { -# name = "${var.name}-app-subnet-${var.env}" -# virtual_network_name = azurerm_virtual_network.vnet.name -# resource_group_name = var.resource_group -# address_prefixes = [var.appsubnetcidr] +resource "azurerm_subnet" "app-subnet" { + name = "${var.name}-app-subnet-${var.env}" + virtual_network_name = azurerm_virtual_network.vnet.name + resource_group_name = var.resource_group + address_prefixes = [var.appsubnetcidr] -# delegation { -# name = "delegation" + delegation { + name = "delegation" -# service_delegation { -# name = "Microsoft.ContainerInstance/containerGroups" -# actions = ["Microsoft.Network/virtualNetworks/subnets/action"] -# } -# } -# } + service_delegation { + name = "Microsoft.ContainerInstance/containerGroups" + actions = ["Microsoft.Network/virtualNetworks/subnets/action"] + } + } +} resource "azurerm_subnet" "lb-subnet" { name = "${var.name}-lb-subnet-${var.env}" diff --git a/ops/terraform/modules/network/outputs.tf b/ops/terraform/modules/network/outputs.tf index f3e6da98..c04deb55 100644 --- a/ops/terraform/modules/network/outputs.tf +++ b/ops/terraform/modules/network/outputs.tf @@ -8,6 +8,11 @@ output "websubnet_id" { description = "Id of websubnet in the network" } +output "appsubnet_id" { + value = azurerm_subnet.app-subnet.id + description = "Id of appsubnet in the network" +} + # output "dbsubnet_id" { # value = azurerm_subnet.db-subnet.id # description = "Id of dbsubnet in the network" diff --git a/ops/terraform/modules/network/variables.tf b/ops/terraform/modules/network/variables.tf index 301bbef4..d7648952 100644 --- a/ops/terraform/modules/network/variables.tf +++ b/ops/terraform/modules/network/variables.tf @@ -3,6 +3,7 @@ variable "name" {} variable "location" {} variable "vnetcidr" {} variable "websubnetcidr" {} +variable "appsubnetcidr" {} variable "lbsubnetcidr" {} # variable "dbsubnetcidr" {} variable "env" {} \ No newline at end of file diff --git a/ops/terraform/modules/security/variables.tf b/ops/terraform/modules/security/variables.tf index 9c62eaba..295e8e03 100644 --- a/ops/terraform/modules/security/variables.tf +++ b/ops/terraform/modules/security/variables.tf @@ -3,5 +3,6 @@ variable "name" {} variable "env" {} variable "resource_group" {} variable "web_subnet_id" {} +variable "app_subnet_id" {} # variable "db_subnet_id" {} variable "lb_subnet_id" {} \ No newline at end of file