-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvnet_with_subnets.tf
52 lines (45 loc) · 1.61 KB
/
vnet_with_subnets.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# Task :
# 1) Create a virtual network using terraform and create a single CIDR block in it 172.33.0.0/16
# 2) Create 3 Subnets, one each for DMZ, Data and Compute.
#Provider
provider "azurerm" {
features {}
}
# Resource Group
resource "azurerm_resource_group" "myrg" {
name = "myResourceGroup"
location = "East Asia"
}
# Vitural network
resource "azurerm_virtual_network" "myvnet" {
name = "myvnet"
address_space = ["172.33.0.0/16"]
location = azurerm_resource_group.myrg.location
resource_group_name = azurerm_resource_group.myrg.name
}
# Output the Vnet
output "vnet_id" {
value = azurerm_virtual_network.myvnet.id
}
# Subnet DMZ
resource "azurerm_subnet" "dmz" {
name = "dmz"
resource_group_name = azurerm_resource_group.myrg.name
virtual_network_name = azurerm_virtual_network.myvnet.name
address_prefixes = ["172.33.0.0/18"] # dmz with a /18 prefix
depends_on = [azurerm_virtual_network.myvnet]
}
resource "azurerm_subnet" "data" {
name = "data"
resource_group_name = azurerm_resource_group.myrg.name
virtual_network_name = azurerm_virtual_network.myvnet.name
address_prefixes = ["172.33.64.0/18"] # data with a /18 prefix
depends_on = [azurerm_virtual_network.myvnet]
}
resource "azurerm_subnet" "compute" {
name = "compute"
resource_group_name = azurerm_resource_group.myrg.name
virtual_network_name = azurerm_virtual_network.myvnet.name
address_prefixes = ["172.33.128.0/18"] # compute with a /18 prefix
depends_on = [azurerm_virtual_network.myvnet]
}