Initial commit: add .gitignore and README
This commit is contained in:
96
terraform/examples/networking-example/main.tf
Normal file
96
terraform/examples/networking-example/main.tf
Normal file
@@ -0,0 +1,96 @@
|
||||
# Example: Using Azure Networking Module
|
||||
|
||||
terraform {
|
||||
required_version = ">= 1.0"
|
||||
|
||||
required_providers {
|
||||
azurerm = {
|
||||
source = "hashicorp/azurerm"
|
||||
version = "~> 3.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
provider "azurerm" {
|
||||
features {}
|
||||
}
|
||||
|
||||
# Resource Group
|
||||
resource "azurerm_resource_group" "example" {
|
||||
name = "rg-example"
|
||||
location = "eastus"
|
||||
}
|
||||
|
||||
# Networking Module
|
||||
module "networking" {
|
||||
source = "../../modules/azure/networking"
|
||||
|
||||
resource_group_name = azurerm_resource_group.example.name
|
||||
location = azurerm_resource_group.example.location
|
||||
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 = []
|
||||
}
|
||||
database = {
|
||||
name = "snet-database"
|
||||
address_prefixes = ["10.0.3.0/24"]
|
||||
service_endpoints = ["Microsoft.Sql"]
|
||||
}
|
||||
}
|
||||
|
||||
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 = "*"
|
||||
},
|
||||
{
|
||||
name = "AllowHTTPS"
|
||||
priority = 110
|
||||
direction = "Inbound"
|
||||
access = "Allow"
|
||||
protocol = "Tcp"
|
||||
source_port_range = "*"
|
||||
destination_port_range = "443"
|
||||
source_address_prefix = "*"
|
||||
destination_address_prefix = "*"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
tags = {
|
||||
Environment = "example"
|
||||
ManagedBy = "Terraform"
|
||||
}
|
||||
}
|
||||
|
||||
# Outputs
|
||||
output "vnet_id" {
|
||||
value = module.networking.vnet_id
|
||||
}
|
||||
|
||||
output "subnet_ids" {
|
||||
value = module.networking.subnet_ids
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user