1+ # References:
2+ # https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/virtual_network
3+ # https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/subnet
4+ # https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/public_ip
5+ # https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/network_interface
6+ # https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/linux_virtual_machine
7+
8+ resource "azurerm_virtual_network" "vn" {
9+ name = " tim-demo-network"
10+ address_space = [" 10.0.0.0/16" ]
11+ location = azurerm_resource_group. rg . location
12+ resource_group_name = azurerm_resource_group. rg . name
13+ }
14+
15+ resource "azurerm_subnet" "sn" {
16+ name = " internal"
17+ resource_group_name = azurerm_resource_group. rg . name
18+ virtual_network_name = azurerm_virtual_network. vn . name
19+ address_prefixes = [" 10.0.2.0/24" ]
20+ }
21+
22+ resource "azurerm_public_ip" "pip" {
23+ name = " tim-demo-pip"
24+ resource_group_name = azurerm_resource_group. rg . name
25+ location = azurerm_resource_group. rg . location
26+ allocation_method = " Dynamic"
27+ }
28+
29+ resource "azurerm_network_interface" "ni" {
30+ name = " tim-demo-nic"
31+ location = azurerm_resource_group. rg . location
32+ resource_group_name = azurerm_resource_group. rg . name
33+
34+ ip_configuration {
35+ name = " internal"
36+ subnet_id = azurerm_subnet. sn . id
37+ private_ip_address_allocation = " Dynamic"
38+
39+ public_ip_address_id = azurerm_public_ip. pip . id
40+ }
41+ }
42+
43+ resource "azurerm_linux_virtual_machine" "vm" {
44+ name = " tim-demo-vm"
45+ resource_group_name = azurerm_resource_group. rg . name
46+ location = azurerm_resource_group. rg . location
47+ size = " Standard_F2"
48+ admin_username = " adminuser"
49+ network_interface_ids = [
50+ azurerm_network_interface . ni . id ,
51+ ]
52+
53+ admin_ssh_key {
54+ username = " adminuser"
55+ public_key = file (" C:/Users/tim_hall/Dropbox/cloud/Azure/id_rsa.pub" )
56+ }
57+
58+ os_disk {
59+ caching = " ReadWrite"
60+ storage_account_type = " Standard_LRS"
61+ }
62+
63+ source_image_reference {
64+ publisher = " Canonical"
65+ offer = " 0001-com-ubuntu-server-focal"
66+ sku = " 20_04-lts"
67+ version = " latest"
68+ }
69+ }
0 commit comments