This commit is contained in:
Sam
2025-09-26 10:47:35 +00:00
parent 8496c9de14
commit 59060033d3
3 changed files with 52 additions and 6 deletions
+16 -1
View File
@@ -8,5 +8,20 @@ terraform {
} }
provider "azurerm" { provider "azurerm" {
# Configuration options 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"
}
+14
View File
@@ -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]
}
+20 -3
View File
@@ -1,5 +1,10 @@
variable "vnet_name" {
description = "Name of the Virtual Network"
type = string
}
variable "resource_group_name" { variable "resource_group_name" {
description = "Name of the resource group" description = "Resource Group to create resources in"
type = string type = string
} }
@@ -9,11 +14,23 @@ variable "location" {
} }
variable "address_space" { variable "address_space" {
description = "CIDR for the Virtual Network" description = "CIDR blocks for the VNet"
type = list(string) type = list(string)
} }
variable "subnets" { variable "subnets" {
description = "Map of subnet names and CIDRs" description = "Map of subnet names to CIDR blocks"
type = map(string) type = map(string)
} }
variable "environment" {
description = "Environment tag (dev/prod)"
type = string
default = "dev"
}
variable "project" {
description = "Project tag"
type = string
default = "TerraformBootcamp"
}