-
Notifications
You must be signed in to change notification settings - Fork 29
/
main.tf
76 lines (63 loc) · 2.11 KB
/
main.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
module "container-server" {
source = "../.."
domain = "app.${var.domain}"
email = var.email
container = {
image = "nginxdemos/hello"
}
}
resource "azurerm_resource_group" "app" {
name = var.base_resource_name
location = var.location
}
resource "azurerm_linux_virtual_machine" "app" {
name = "container-server"
resource_group_name = azurerm_resource_group.app.name
location = azurerm_resource_group.app.location
size = "Standard_F2"
admin_username = "adminuser"
custom_data = base64encode(module.container-server.cloud_config)
network_interface_ids = [
azurerm_network_interface.app.id,
]
os_disk {
caching = "ReadWrite"
storage_account_type = "Standard_LRS"
}
source_image_reference {
publisher = "Canonical"
offer = "UbuntuServer"
sku = "18.04-LTS"
version = "latest"
}
}
resource "azurerm_network_interface" "app" {
name = "${var.base_resource_name}-nic"
location = var.location
resource_group_name = azurerm_resource_group.app.name
ip_configuration {
name = var.base_resource_name
subnet_id = azurerm_subnet.app.id
private_ip_address_allocation = "Dynamic"
public_ip_address_id = azurerm_public_ip.app.id
}
}
resource "azurerm_public_ip" "app" {
name = "${var.base_resource_name}-vmpubip"
location = var.location
resource_group_name = azurerm_resource_group.app.name
allocation_method = "Static"
domain_name_label = var.base_resource_name
}
resource "azurerm_virtual_network" "app" {
name = var.base_resource_name
location = var.location
resource_group_name = azurerm_resource_group.app.name
address_space = ["10.0.0.0/8"]
}
resource "azurerm_subnet" "app" {
name = var.base_resource_name
resource_group_name = azurerm_resource_group.app.name
virtual_network_name = azurerm_virtual_network.app.name
address_prefix = cidrsubnet(azurerm_virtual_network.app.address_space[0], 16, 1)
}