-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.tf
More file actions
100 lines (87 loc) · 3.12 KB
/
main.tf
File metadata and controls
100 lines (87 loc) · 3.12 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# We strongly recommend using the required_providers block to set the
# Azure Provider source and version being used
terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "=3.0.0"
}
}
}
# Configure the Microsoft Azure Provider
provider "azurerm" {
features {}
subscription_id = "9cf7d5a5-d86d-42c7-a771-9552939ab171"
client_id = "9beac7cd-60c5-485a-a3c9-8e5786f0267f"
client_secret = "XA28Q~XYh~ionXOSDMMAj_LXewG3W4GWC1uebdBg"
tenant_id = "6a1fb993-1866-44b7-ae78-883af9b9ad42"
}
resource "azurerm_resource_group" "rg1" {
name = "${var.rgname}"
location = "${var.location}"
}
resource "azurerm_virtual_network" "vnet1" {
name = "${var.prefix}-1"
location = azurerm_resource_group.rg1.location
resource_group_name = azurerm_resource_group.rg1.name
address_space = ["${var.vnet_cidr_prefix}"]
}
resource "azurerm_subnet" "subnet1" {
name = "${var.prefix}-10"
resource_group_name = azurerm_resource_group.rg1.name
virtual_network_name = azurerm_virtual_network.vnet1.name
address_prefixes = ["${var.subnet1_cidr_prefix}"]
}
resource "azurerm_network_security_group" "nsg1" {
name = "${var.prefix}-nsg1"
location = azurerm_resource_group.rg1.location
resource_group_name = azurerm_resource_group.rg1.name
}
resource "azurerm_network_security_rule" "nsr1" {
name = "practice6"
priority = 100
direction = "Outbound"
access = "Allow"
protocol = "Tcp"
source_port_range = "*"
destination_port_range = "*"
source_address_prefix = "*"
destination_address_prefix = "*"
resource_group_name = azurerm_resource_group.rg1.name
network_security_group_name = azurerm_network_security_group.nsg1.name
}
resource "azurerm_subnet_network_security_group_association" "nsga1" {
subnet_id = azurerm_subnet.subnet1.id
network_security_group_id = azurerm_network_security_group.nsg1.id
}
resource "azurerm_network_interface" "ni1" {
name = "${var.prefix}-ninter"
location = azurerm_resource_group.rg1.location
resource_group_name = azurerm_resource_group.rg1.name
ip_configuration {
name = "internal"
subnet_id = azurerm_subnet.subnet1.id
private_ip_address_allocation = "Dynamic"
}
}
resource "azurerm_windows_virtual_machine" "wvm1" {
name = "${var.prefix}-vmac"
resource_group_name = azurerm_resource_group.rg1.name
location = azurerm_resource_group.rg1.location
size = "Standard_F2"
admin_username = "adminuser"
admin_password = "P@$$w0rd1234!"
network_interface_ids = [
azurerm_network_interface.ni1.id,
]
os_disk {
caching = "ReadWrite"
storage_account_type = "Standard_LRS"
}
source_image_reference {
publisher = "MicrosoftWindowsServer"
offer = "WindowsServer"
sku = "2016-Datacenter"
version = "latest"
}
}