72 lines
2.3 KiB
HCL
72 lines
2.3 KiB
HCL
# provider "azurerm" {
|
|
# subscription_id = "REPLACE-WITH-YOUR-SUBSCRIPTION-ID"
|
|
# client_id = "REPLACE-WITH-YOUR-CLIENT-ID"
|
|
# client_secret = "REPLACE-WITH-YOUR-CLIENT-SECRET"
|
|
# tenant_id = "REPLACE-WITH-YOUR-TENANT-ID"
|
|
# }
|
|
|
|
resource "azurerm_resource_group" "rg" {
|
|
name = "${var.resource_group}"
|
|
location = "${var.location}"
|
|
}
|
|
|
|
resource "azurerm_public_ip" "pip" {
|
|
name = "PublicIp"
|
|
location = "${var.location}"
|
|
resource_group_name = "${azurerm_resource_group.rg.name}"
|
|
public_ip_address_allocation = "Dynamic"
|
|
domain_name_label = "${var.hostname}"
|
|
}
|
|
|
|
resource "azurerm_network_interface" "nic" {
|
|
name = "nic"
|
|
location = "${var.location}"
|
|
resource_group_name = "${azurerm_resource_group.rg.name}"
|
|
|
|
ip_configuration {
|
|
name = "ipconfig"
|
|
subnet_id = "${var.existing_subnet_id}"
|
|
private_ip_address_allocation = "Dynamic"
|
|
public_ip_address_id = "${azurerm_public_ip.pip.id}"
|
|
}
|
|
}
|
|
|
|
resource "azurerm_storage_account" "stor" {
|
|
name = "${var.hostname}"
|
|
resource_group_name = "${azurerm_resource_group.rg.name}"
|
|
location = "${var.location}"
|
|
account_type = "${var.storage_account_type}"
|
|
}
|
|
|
|
resource "azurerm_virtual_machine" "vm" {
|
|
name = "${var.hostname}"
|
|
location = "${var.location}"
|
|
resource_group_name = "${azurerm_resource_group.rg.name}"
|
|
vm_size = "${var.vm_size}"
|
|
network_interface_ids = ["${azurerm_network_interface.nic.id}"]
|
|
|
|
storage_os_disk {
|
|
name = "${var.hostname}osdisk1"
|
|
image_uri = "${var.os_disk_vhd_uri}"
|
|
vhd_uri = "https://${var.existing_storage_acct}.blob.core.windows.net/${var.existing_vnet_resource_group}-vhds/${var.hostname}osdisk.vhd"
|
|
os_type = "${var.os_type}"
|
|
caching = "ReadWrite"
|
|
create_option = "FromImage"
|
|
}
|
|
|
|
os_profile {
|
|
computer_name = "${var.hostname}"
|
|
admin_username = "${var.admin_username}"
|
|
admin_password = "${var.admin_password}"
|
|
}
|
|
|
|
os_profile_linux_config {
|
|
disable_password_authentication = false
|
|
}
|
|
|
|
boot_diagnostics {
|
|
enabled = true
|
|
storage_uri = "${azurerm_storage_account.stor.primary_blob_endpoint}"
|
|
}
|
|
}
|