Guest User

Untitled

a guest
Feb 21st, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.91 KB | None | 0 0
  1. # create a resource group if it doesn't exist
  2. resource "azurerm_resource_group" "rg" {
  3. name = "a132rg"
  4. location = "ukwest"
  5. }
  6.  
  7. # create virtual network
  8. resource "azurerm_virtual_network" "vnet" {
  9. name = "tfvnet"
  10. address_space = ["10.0.0.0/16"]
  11. location = "ukwest"
  12. resource_group_name = "${azurerm_resource_group.rg.name}"
  13. subnet {
  14. name = "subnet1"
  15. address_prefix = "10.0.3.0/24"
  16.  
  17. }
  18. }
  19.  
  20. # create subnet
  21. resource "azurerm_subnet" "subnet" {
  22. name = "tfsub"
  23. resource_group_name = "${azurerm_resource_group.rg.name}"
  24. virtual_network_name = "${azurerm_virtual_network.vnet.name}"
  25. address_prefix = "10.0.2.0/24"
  26. #network_security_group_id = "${azurerm_network_security_group.nsg.id}"
  27. }
  28.  
  29. # create public IPs
  30. resource "azurerm_public_ip" "ip" {
  31. name = "tfip"
  32. location = "ukwest"
  33. resource_group_name = "${azurerm_resource_group.rg.name}"
  34. public_ip_address_allocation = "dynamic"
  35. domain_name_label = "a132"
  36.  
  37. tags {
  38. environment = "staging"
  39. }
  40. }
  41.  
  42. # create network interface
  43. resource "azurerm_network_interface" "ni" {
  44. name = "tfni"
  45. location = "ukwest"
  46. resource_group_name = "${azurerm_resource_group.rg.name}"
  47.  
  48. ip_configuration {
  49. name = "ipconfiguration"
  50. subnet_id = "${azurerm_subnet.subnet.id}"
  51. private_ip_address_allocation = "static"
  52. private_ip_address = "10.0.2.5"
  53. public_ip_address_id = "${azurerm_public_ip.ip.id}"
  54. }
  55. }
  56.  
  57. # create storage account
  58. resource "azurerm_storage_account" "storage" {
  59. name = "0fda935368315bd1a5f5560e"
  60. resource_group_name = "${azurerm_resource_group.rg.name}"
  61. location = "ukwest"
  62. account_replication_type = "LRS"
  63. account_tier = "Standard"
  64.  
  65. tags {
  66. environment = "staging"
  67. }
  68. }
  69.  
  70. # create storage container
  71. resource "azurerm_storage_container" "storagecont" {
  72. name = "vhd"
  73. resource_group_name = "${azurerm_resource_group.rg.name}"
  74. storage_account_name = "${azurerm_storage_account.storage.name}"
  75. container_access_type = "private"
  76. depends_on = ["azurerm_storage_account.storage"]
  77. }
  78.  
  79.  
  80.  
  81. # create virtual machine
  82. resource "azurerm_virtual_machine" "vm" {
  83. name = "a132vm"
  84. location = "ukwest"
  85. resource_group_name = "${azurerm_resource_group.rg.name}"
  86. network_interface_ids = ["${azurerm_network_interface.ni.id}"]
  87. vm_size = "Standard_A6"
  88.  
  89. storage_image_reference {
  90. publisher = "Canonical"
  91. offer = "UbuntuServer"
  92. sku = "16.04-LTS"
  93. version = "latest"
  94. }
  95.  
  96. storage_os_disk {
  97. name = "myosdisk"
  98. vhd_uri = "${azurerm_storage_account.storage.primary_blob_endpoint}${azurerm_storage_container.storagecont.name}/myosdisk.vhd"
  99. caching = "ReadWrite"
  100. create_option = "FromImage"
  101. }
  102.  
  103. os_profile {
  104. computer_name = "a132"
  105. admin_username = "****"
  106.  
  107. admin_password = "*************"
  108.  
  109. }
  110. os_profile_linux_config {
  111. disable_password_authentication = false
  112. }
  113.  
  114. }
Add Comment
Please, Sign In to add comment