Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- variable "location" { default = "South Central US" }
- variable "vm_size" { default = "Standard_A0" }
- variable "name" { default = "temp" }
- variable "username" { }
- variable "password" { }
- variable "scripts_address" { }
- variable "scripts_connect" { }
- resource "azurerm_resource_group" "temp" {
- name = "${var.name}"
- location = "${var.location}"
- }
- # Networking - simple virtual network
- resource "azurerm_virtual_network" "temp" {
- name = "${var.name}"
- address_space = ["10.0.0.0/24"]
- location = "${var.location}"
- resource_group_name = "${azurerm_resource_group.temp.name}"
- }
- resource "azurerm_subnet" "temp" {
- name = "${var.name}"
- resource_group_name = "${azurerm_resource_group.temp.name}"
- virtual_network_name = "${azurerm_virtual_network.temp.name}"
- address_prefix = "10.0.0.0/24"
- }
- resource "azurerm_public_ip" "temp" {
- name = "${var.name}"
- location = "${var.location}"
- resource_group_name = "${azurerm_resource_group.temp.name}"
- public_ip_address_allocation = "static"
- }
- resource "azurerm_network_interface" "temp" {
- name = "${var.name}"
- location = "${var.location}"
- resource_group_name = "${azurerm_resource_group.temp.name}"
- ip_configuration
- {
- name = "${var.name}"
- subnet_id = "${azurerm_subnet.temp.id}"
- private_ip_address_allocation = "dynamic"
- public_ip_address_id = "${azurerm_public_ip.temp.id}"
- }
- }
- # Storage account + one disk for VM
- resource "azurerm_storage_account" "temp" {
- name = "${var.name}12345"
- resource_group_name = "${azurerm_resource_group.temp.name}"
- location = "${var.location}"
- account_type = "Standard_LRS"
- }
- resource "azurerm_storage_container" "temp" {
- name = "vhds"
- resource_group_name = "${azurerm_resource_group.temp.name}"
- storage_account_name = "${azurerm_storage_account.temp.name}"
- container_access_type = "private"
- }
- # VM
- resource "azurerm_virtual_machine" "temp"
- {
- name = "${var.name}"
- location = "${var.location}"
- resource_group_name = "${azurerm_resource_group.temp.name}"
- network_interface_ids = ["${azurerm_network_interface.temp.id}"]
- vm_size = "${var.vm_size}"
- storage_image_reference {
- publisher = "Canonical"
- offer = "UbuntuServer"
- sku = "16.04.0-LTS"
- version = "latest"
- }
- storage_os_disk {
- name = "${var.name}_os"
- vhd_uri = "${azurerm_storage_account.temp.primary_blob_endpoint}${azurerm_storage_container.temp.name}/${var.name}_os.vhd"
- caching = "ReadWrite"
- create_option = "FromImage"
- }
- delete_os_disk_on_termination = true
- os_profile {
- computer_name = "${var.name}"
- admin_username = "${var.username}"
- admin_password = "${var.password}"
- }
- os_profile_linux_config {
- disable_password_authentication = false
- }
- provisioner "remote-exec" {
- connection {
- type = "ssh"
- user = "${var.username}"
- password = "${var.password}"
- host = "${azurerm_public_ip.temp.ip_address}"
- }
- inline = [
- "sudo apt-get update",
- "sudo apt-get upgrade -y"
- ]
- }
- }
- output "ip" {
- value = "${azurerm_public_ip.temp.ip_address}"
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement