Initial commit: add .gitignore and README

This commit is contained in:
defiQUG
2026-02-09 21:51:46 -08:00
commit b970b4fc51
52 changed files with 3362 additions and 0 deletions

View File

@@ -0,0 +1,86 @@
# Azure Networking Module
**Purpose**: Create Azure Virtual Network with subnets and network security groups
**Status**: ✅ Complete
---
## Usage
```hcl
module "networking" {
source = "../../modules/azure/networking"
resource_group_name = "rg-example"
location = "eastus"
vnet_name = "vnet-example"
address_space = ["10.0.0.0/16"]
subnets = {
frontend = {
name = "snet-frontend"
address_prefixes = ["10.0.1.0/24"]
service_endpoints = ["Microsoft.Storage"]
}
backend = {
name = "snet-backend"
address_prefixes = ["10.0.2.0/24"]
service_endpoints = []
}
}
network_security_groups = {
frontend_nsg = {
name = "nsg-frontend"
subnet_key = "frontend"
security_rules = [
{
name = "AllowHTTP"
priority = 100
direction = "Inbound"
access = "Allow"
protocol = "Tcp"
source_port_range = "*"
destination_port_range = "80"
source_address_prefix = "*"
destination_address_prefix = "*"
}
]
}
}
tags = {
Environment = "production"
}
}
```
---
## Inputs
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|----------|
| resource_group_name | Name of the resource group | string | - | yes |
| location | Azure region | string | - | yes |
| vnet_name | Name of the virtual network | string | - | yes |
| address_space | Address space for the virtual network | list(string) | - | yes |
| subnets | Map of subnets to create | map(object) | {} | no |
| network_security_groups | Map of network security groups | map(object) | {} | no |
| tags | Tags to apply | map(string) | {} | no |
---
## Outputs
| Name | Description |
|------|-------------|
| vnet_id | Virtual network ID |
| vnet_name | Virtual network name |
| subnet_ids | Map of subnet names to IDs |
| subnet_names | Map of subnet names |
| nsg_ids | Map of NSG names to IDs |
---
**Status**: ✅ Complete - Ready for use

View File

@@ -0,0 +1,73 @@
# Azure Networking Module
# Main resources
terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "~> 3.0"
}
}
}
# Virtual Network
resource "azurerm_virtual_network" "main" {
name = var.vnet_name
address_space = var.address_space
location = var.location
resource_group_name = var.resource_group_name
tags = var.tags
lifecycle {
create_before_destroy = true
}
}
# Subnets
resource "azurerm_subnet" "subnets" {
for_each = var.subnets
name = each.value.name
resource_group_name = var.resource_group_name
virtual_network_name = azurerm_virtual_network.main.name
address_prefixes = each.value.address_prefixes
service_endpoints = each.value.service_endpoints
lifecycle {
create_before_destroy = true
}
}
# Network Security Groups
resource "azurerm_network_security_group" "nsgs" {
for_each = var.network_security_groups
name = each.value.name
location = var.location
resource_group_name = var.resource_group_name
tags = var.tags
dynamic "security_rule" {
for_each = each.value.security_rules
content {
name = security_rule.value.name
priority = security_rule.value.priority
direction = security_rule.value.direction
access = security_rule.value.access
protocol = security_rule.value.protocol
source_port_range = security_rule.value.source_port_range
destination_port_range = security_rule.value.destination_port_range
source_address_prefix = security_rule.value.source_address_prefix
destination_address_prefix = security_rule.value.destination_address_prefix
}
}
}
# Associate NSGs with subnets
resource "azurerm_subnet_network_security_group_association" "nsg_associations" {
for_each = var.network_security_groups
subnet_id = azurerm_subnet.subnets[each.value.subnet_key].id
network_security_group_id = azurerm_network_security_group.nsgs[each.key].id
}

View File

@@ -0,0 +1,27 @@
# Azure Networking Module Outputs
output "vnet_id" {
description = "Virtual network ID"
value = azurerm_virtual_network.main.id
}
output "vnet_name" {
description = "Virtual network name"
value = azurerm_virtual_network.main.name
}
output "subnet_ids" {
description = "Map of subnet names to IDs"
value = { for k, v in azurerm_subnet.subnets : k => v.id }
}
output "subnet_names" {
description = "Map of subnet names"
value = { for k, v in azurerm_subnet.subnets : k => v.name }
}
output "nsg_ids" {
description = "Map of NSG names to IDs"
value = { for k, v in azurerm_network_security_group.nsgs : k => v.id }
}

View File

@@ -0,0 +1,58 @@
# Azure Networking Module Variables
variable "resource_group_name" {
description = "Name of the resource group"
type = string
}
variable "location" {
description = "Azure region"
type = string
}
variable "vnet_name" {
description = "Name of the virtual network"
type = string
}
variable "address_space" {
description = "Address space for the virtual network"
type = list(string)
}
variable "subnets" {
description = "Map of subnets to create"
type = map(object({
name = string
address_prefixes = list(string)
service_endpoints = list(string)
}))
default = {}
}
variable "network_security_groups" {
description = "Map of network security groups to create"
type = map(object({
name = string
subnet_key = string
security_rules = list(object({
name = string
priority = number
direction = string
access = string
protocol = string
source_port_range = string
destination_port_range = string
source_address_prefix = string
destination_address_prefix = string
}))
}))
default = {}
}
variable "tags" {
description = "Tags to apply to resources"
type = map(string)
default = {}
}

View File

@@ -0,0 +1,13 @@
# Azure Networking Module - Provider Versions
terraform {
required_version = ">= 1.0"
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "~> 3.0"
}
}
}