-
-
Save IPvPho/ab3ddb2c47645d9678212100b67a63fe to your computer and use it in GitHub Desktop.
TF Examples
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
provider "azurerm" { | |
features {} | |
} | |
resource "azurerm_resource_group" "rgs" { | |
for_each = var.rgs | |
name = each.value["name"] | |
location = each.value["location"] | |
tags = lookup(each.value, "tags", null) | |
} | |
resource "azurerm_virtual_network" "vnets" { | |
for_each = var.vnets | |
name = each.value["name"] | |
location = each.value["location"] | |
resource_group_name = each.value["resource_group_name"] | |
address_space = each.value["address_space"] | |
dns_servers = lookup(each.value, "dns_servers", null) | |
dynamic "subnet" { | |
for_each = each.value["subnets"] | |
content { | |
name = subnet.value["name"] | |
address_prefix = subnet.value["address_prefix"] | |
security_group = lookup(subnet.value, "security_group", null) | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rgs = { | |
rg_one = { | |
name = "rg-tf-test-chriran-1" | |
location = "eastus" | |
tags = { | |
ApplicationName = "ACETECHWEEK" | |
AppTypeRole = "DC" | |
DataProtection = "NotProtected" | |
DRTier = "None" | |
Environment = "ATS" | |
Location = "USE1Z" | |
NotificationContact = "[email protected]" | |
ProductCostCenter = "ATS" | |
ResourceType = "Data" | |
SupportResponseSLA = "None" | |
WorkloadType = "ADEnvironment" | |
Owner = "Chris Randall" | |
} | |
} | |
rg_two = { | |
name = "rg-tf-test-chriran-2" | |
location = "eastus" | |
tags = { | |
ApplicationName = "ACETECHWEEK" | |
AppTypeRole = "DC" | |
DataProtection = "NotProtected" | |
DRTier = "None" | |
Environment = "ATS" | |
Location = "USE1Z" | |
NotificationContact = "[email protected]" | |
ProductCostCenter = "ATS" | |
ResourceType = "Data" | |
SupportResponseSLA = "None" | |
WorkloadType = "ADEnvironment" | |
Owner = "Chris Randall" | |
} | |
} | |
} | |
vnets = { | |
vnet_alpha = { | |
name = "vnet-alpha" | |
location = "eastus" | |
resource_group_name = "rg-tf-test-chriran-1" | |
address_space = ["10.0.0.0/16"] | |
subnets = { | |
subnet_one = { | |
name = "subnet1" | |
address_prefix = "10.0.1.0/24" | |
} | |
subnet_two = { | |
name = "subnet2" | |
address_prefix = "10.0.2.0/24" | |
} | |
subnet_three = { | |
name = "subnet3" | |
address_prefix = "10.0.3.0/24" | |
} | |
} | |
} | |
vnet_bravo = { | |
name = "vnet-bravo" | |
location = "eastus" | |
resource_group_name = "rg-tf-test-chriran-2" | |
address_space = ["10.0.0.0/16"] | |
subnets = { | |
subnet_one = { | |
name = "subnet1" | |
address_prefix = "10.0.1.0/24" | |
} | |
subnet_two = { | |
name = "subnet2" | |
address_prefix = "10.0.2.0/24" | |
} | |
subnet_three = { | |
name = "subnet3" | |
address_prefix = "10.0.3.0/24" | |
} | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
variable "rgs" { | |
description = "Data values for our resource group creation" | |
} | |
variable "vnets" { | |
description = "Data values for virtual network creation" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment