Skip to content

Commit ac72133

Browse files
Create terraform-linuxvm
1 parent 678621a commit ac72133

File tree

1 file changed

+83
-0
lines changed

1 file changed

+83
-0
lines changed

.vscode/terraform-linuxvm

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
terraform {
2+
required_providers {
3+
azurerm = {
4+
source = "hashicorp/azurerm"
5+
version = "~>2.0"
6+
}
7+
}
8+
}
9+
10+
provider "azurerm" {
11+
features {}
12+
13+
# put credentials below this
14+
15+
}
16+
17+
# create a resource group
18+
resource "azurerm_resource_group" "main" {
19+
name = "rg1"
20+
location = "south india"
21+
}
22+
23+
resource "azurerm_virtual_network" "main" {
24+
name = "vn1"
25+
location = azurerm_resource_group.main.location
26+
resource_group_name = azurerm_resource_group.main.name
27+
address_space = ["10.0.0.0/18"]
28+
}
29+
resource "azurerm_subnet" "main" {
30+
name = "subnet1"
31+
virtual_network_name = azurerm_virtual_network.main.name
32+
resource_group_name = azurerm_resource_group.main.name
33+
address_prefixes = ["10.0.0.0/24"]
34+
}
35+
resource "azurerm_public_ip" "main" {
36+
name = "publicip1"
37+
location = azurerm_resource_group.main.location
38+
resource_group_name = azurerm_resource_group.main.name
39+
allocation_method = "Dynamic"
40+
}
41+
resource "azurerm_network_interface" "main" {
42+
name = "netface1"
43+
location = azurerm_resource_group.main.location
44+
resource_group_name = azurerm_resource_group.main.name
45+
ip_configuration {
46+
name = "internal"
47+
subnet_id = azurerm_subnet.main.id
48+
private_ip_address_allocation = "Dynamic"
49+
public_ip_address_id = azurerm_public_ip.main.id
50+
}
51+
52+
}
53+
54+
55+
56+
resource "azurerm_virtual_machine" "main" {
57+
name = "azurevm1"
58+
location = azurerm_resource_group.main.location
59+
resource_group_name = azurerm_resource_group.main.name
60+
network_interface_ids = [azurerm_network_interface.main.id]
61+
vm_size = "Standard_B1s"
62+
os_profile {
63+
computer_name = "shreya"
64+
admin_username = "shreya"
65+
admin_password = "Shreya123"
66+
}
67+
storage_image_reference {
68+
publisher = "Canonical"
69+
offer = "UbuntuServer"
70+
sku = "16.04-LTS"
71+
version = "latest"
72+
}
73+
storage_os_disk {
74+
name = "mydisk1"
75+
caching = "ReadWrite"
76+
create_option = "FromImage"
77+
managed_disk_type = "Standard_LRS"
78+
}
79+
os_profile_linux_config {
80+
disable_password_authentication = false
81+
}
82+
83+
}

0 commit comments

Comments
 (0)