Skip to content

Commit

Permalink
Refactor Virtualnetwork (#1481)
Browse files Browse the repository at this point in the history
Co-authored-by: Automatic Update <[email protected]>
  • Loading branch information
sveinpj and Automatic Update authored Oct 24, 2024
1 parent 2c5abbf commit 69d607d
Show file tree
Hide file tree
Showing 48 changed files with 422 additions and 996 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ resource "azurerm_public_ip_prefix" "publicipprefix" {
tags = {
IaC = "terraform"
}
lifecycle {
prevent_destroy = true
}
}

resource "azurerm_public_ip" "this" {
Expand Down
33 changes: 0 additions & 33 deletions terraform/subscriptions/modules/networksecuritygroup/main.tf

This file was deleted.

This file was deleted.

19 changes: 0 additions & 19 deletions terraform/subscriptions/modules/networksecuritygroup/variables.tf

This file was deleted.

21 changes: 11 additions & 10 deletions terraform/subscriptions/modules/redis_cache/main.tf
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
resource "azurerm_redis_cache" "this" {
for_each = toset(["qa", "prod"])
name = "${var.name}-${each.key}"
location = var.location
resource_group_name = var.rg_name
capacity = 1
family = "C"
sku_name = var.sku_name
minimum_tls_version = "1.2"
for_each = toset(["qa", "prod"])
name = "${var.name}-${each.key}"
location = var.location
resource_group_name = var.rg_name
capacity = 1
family = "C"
sku_name = var.sku_name
minimum_tls_version = "1.2"
public_network_access_enabled = false
redis_configuration {
maxmemory_reserved = 125
maxmemory_delta = 125
maxfragmentationmemory_reserved = 125

data_persistence_authentication_method = "SAS"
maxmemory_policy = "volatile-lru"
# data_persistence_authentication_method = "SAS"
maxmemory_policy = "volatile-lru"
}
}
12 changes: 1 addition & 11 deletions terraform/subscriptions/s940/c2/clusters/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ module "config" {
}

module "resourcegroups" {
for_each = toset(var.resource_groups)
source = "../../../modules/resourcegroups"
name = each.value
name = module.config.cluster_resource_group
location = module.config.location
}

Expand Down Expand Up @@ -147,15 +146,6 @@ module "radix_id_velero_mi" {
}
}

module "nsg" {
source = "../../../modules/networksecuritygroup"
for_each = local.flattened_clusters
networksecuritygroupname = "nsg-${each.key}"
location = each.value.location
resource_group_name = each.value.resource_group_name
destination_address_prefix = each.value.destination_address_prefix
}

output "radix_id_aks_mi_id" {
value = module.radix_id_aks_mi.data.id
}
Expand Down
31 changes: 0 additions & 31 deletions terraform/subscriptions/s940/c2/clusters/variables.tf
Original file line number Diff line number Diff line change
@@ -1,31 +0,0 @@
locals {
flattened_clusters = {
for key, value in var.clusters : key => {
name = key
resource_group_name = value.resource_group_name
location = value.location
destination_address_prefix = value.destination_address_prefix
}
}
}

variable "resource_groups" {
type = list(string)
default = ["clusters-c2"]
}

variable "clusters" {
type = map(object({
resource_group_name = optional(string, "clusters")
location = optional(string, "northeurope")
destination_address_prefix = string
}))
default = {
# weekly-52 = {
# destination_address_prefix = "20.223.40.149"
# }
# weekly-01 = {
# destination_address_prefix = "20.223.40.148"
# }
}
}
60 changes: 60 additions & 0 deletions terraform/subscriptions/s940/c2/common/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,66 @@ module "config" {
source = "../../../modules/config"
}

###Migrated from 'Virtualnetwork' start

module "vnet_resourcegroup" {
source = "../../../modules/resourcegroups"
name = module.config.vnet_resource_group
location = module.config.location
}

module "azurerm_virtual_network" {
source = "../../../modules/virtualnetwork"
location = module.config.location
enviroment = module.config.environment
vnet_resource_group = module.vnet_resourcegroup.data.name
private_dns_zones = tolist(module.config.private_dns_zones_names)
depends_on = [module.vnet_resourcegroup]

}

module "azurerm_public_ip_prefix_ingress" {
source = "../../../modules/network_publicipprefix"
location = module.config.location
resource_group_name = var.resource_groups_common_temporary #TODO
publicipprefixname = "ippre-ingress-radix-aks-${module.config.environment}-prod-001" #TODO
pipprefix = "ingress-radix-aks"
pippostfix = "prod"
enviroment = module.config.environment
prefix_length = 29
publicipcounter = 8
# zones = ["1", "2", "3"]
}

module "azurerm_public_ip_prefix_egress" {
source = "../../../modules/network_publicipprefix"
location = module.config.location
resource_group_name = var.resource_groups_common_temporary #TODO
publicipprefixname = "ippre-egress-radix-aks-${module.config.environment}-prod-001" #TODO
pipprefix = "egress-radix-aks"
pippostfix = "prod"
enviroment = module.config.environment
prefix_length = 29
publicipcounter = 8
}

output "vnet_hub_id" {
value = module.azurerm_virtual_network.data.vnet_hub.id
}

output "vnet_subnet_id" {
value = module.azurerm_virtual_network.data.vnet_subnet.id
}

output "public_ip_prefix_ids" {
value = {
egress_id = module.azurerm_public_ip_prefix_egress.data.id
ingress_id = module.azurerm_public_ip_prefix_ingress.data.id
}
}

###Migrated from 'Virtualnetwork' end

module "resourcegroups" {
source = "../../../modules/resourcegroups"
name = module.config.common_resource_group
Expand Down
5 changes: 5 additions & 0 deletions terraform/subscriptions/s940/c2/common/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,9 @@ variable "storageaccounts" {
lifecyclepolicy = true
}
}
}

variable "resource_groups_common_temporary" {
type = string
default = "common-westeurope"
}
45 changes: 0 additions & 45 deletions terraform/subscriptions/s940/c2/virtualnetwork/.terraform.lock.hcl

This file was deleted.

28 changes: 0 additions & 28 deletions terraform/subscriptions/s940/c2/virtualnetwork/backend.tf

This file was deleted.

58 changes: 0 additions & 58 deletions terraform/subscriptions/s940/c2/virtualnetwork/main.tf

This file was deleted.

9 changes: 0 additions & 9 deletions terraform/subscriptions/s940/c2/virtualnetwork/variables.tf

This file was deleted.

3 changes: 1 addition & 2 deletions terraform/subscriptions/s940/extmon/clusters/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ module "config" {
}

module "resourcegroups" {
for_each = toset(var.resource_groups)
source = "../../../modules/resourcegroups"
name = each.value
name = module.config.cluster_resource_group
location = module.config.location
}

Expand Down
Loading

0 comments on commit 69d607d

Please sign in to comment.