diff --git a/environments/dev/main.tf b/environments/dev/main.tf index 91b3812..f31cce2 100644 --- a/environments/dev/main.tf +++ b/environments/dev/main.tf @@ -8,5 +8,20 @@ terraform { } provider "azurerm" { - # Configuration options -} \ No newline at end of file + features{} + subscription_id = "4b2d6154-f4c5-4854-be82-12dfc82d4d23" +} + +module "network" { + source = "../../modules/network" + vnet_name = "dev-vnet" + resource_group_name = "dev-rg" + location = "UK South" + address_space = ["10.0.0.0/16"] + subnets = { public = "10.0.1.0/24", private = "10.0.2.0/24" } + environment = "dev" + project = "TerraformBootcamp" +} + + + diff --git a/modules/network/main.tf b/modules/network/main.tf index e69de29..34d6ebb 100644 --- a/modules/network/main.tf +++ b/modules/network/main.tf @@ -0,0 +1,14 @@ +resource "azurerm_virtual_network" "main" { + name = var.vnet_name + resource_group_name = var.resource_group_name + location = var.location + address_space = var.address_space +} + +resource "azurerm_subnet" "subnets" { + for_each = var.subnets + name = each.key + resource_group_name = var.resource_group_name + virtual_network_name = azurerm_virtual_network.main.name + address_prefixes = [each.value] +} diff --git a/modules/network/variables.tf b/modules/network/variables.tf index 67bd549..5c89eab 100644 --- a/modules/network/variables.tf +++ b/modules/network/variables.tf @@ -1,5 +1,10 @@ +variable "vnet_name" { + description = "Name of the Virtual Network" + type = string +} + variable "resource_group_name" { - description = "Name of the resource group" + description = "Resource Group to create resources in" type = string } @@ -9,11 +14,23 @@ variable "location" { } variable "address_space" { - description = "CIDR for the Virtual Network" + description = "CIDR blocks for the VNet" type = list(string) } variable "subnets" { - description = "Map of subnet names and CIDRs" + description = "Map of subnet names to CIDR blocks" type = map(string) -} \ No newline at end of file +} + +variable "environment" { + description = "Environment tag (dev/prod)" + type = string + default = "dev" +} + +variable "project" { + description = "Project tag" + type = string + default = "TerraformBootcamp" +}