Guest User

Untitled

a guest
Dec 14th, 2017
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.82 KB | None | 0 0
  1. provider "azurerm" {
  2. subscription_id = ""
  3. tenant_id = ""
  4. }
  5.  
  6. resource "azurerm_resource_group" "test" {
  7. name = "acctestrg"
  8. location = "koreasouth"
  9. }
  10.  
  11. resource "azurerm_virtual_network" "test" {
  12. name = "acctvn"
  13. address_space = ["10.0.0.0/16"]
  14. location = "koreasouth"
  15. resource_group_name = "${azurerm_resource_group.test.name}"
  16. }
  17.  
  18. resource "azurerm_subnet" "test" {
  19. name = "acctsub"
  20. resource_group_name = "${azurerm_resource_group.test.name}"
  21. virtual_network_name = "${azurerm_virtual_network.test.name}"
  22. address_prefix = "10.0.2.0/24"
  23. }
  24.  
  25. resource "azurerm_network_interface" "test" {
  26. name = "acctni"
  27. location = "koreasouth"
  28. resource_group_name = "${azurerm_resource_group.test.name}"
  29.  
  30. ip_configuration {
  31. name = "testconfiguration1"
  32. subnet_id = "${azurerm_subnet.test.id}"
  33. private_ip_address_allocation = "dynamic"
  34. }
  35.  
  36. }
  37.  
  38. resource "azurerm_managed_disk" "test" {
  39. name = "datadisk_existing"
  40. location = "koreasouth"
  41. resource_group_name = "${azurerm_resource_group.test.name}"
  42. storage_account_type = "Standard_LRS"
  43. create_option = "Empty"
  44. disk_size_gb = "1023"
  45. }
  46.  
  47. resource "azurerm_virtual_machine" "test" {
  48. name = "acctvm"
  49. location = "koreasouth"
  50. resource_group_name = "${azurerm_resource_group.test.name}"
  51. network_interface_ids = ["${azurerm_network_interface.test.id}"]
  52. vm_size = "Standard_DS1_v2"
  53.  
  54. # Uncomment this line to delete the OS disk automatically when deleting the VM
  55. # delete_os_disk_on_termination = true
  56.  
  57. # Uncomment this line to delete the data disks automatically when deleting the VM
  58. # delete_data_disks_on_termination = true
  59.  
  60. storage_image_reference {
  61. publisher = "Canonical"
  62. offer = "UbuntuServer"
  63. sku = "16.04-LTS"
  64. version = "latest"
  65. }
  66.  
  67. storage_os_disk {
  68. name = "myosdisk1"
  69. caching = "ReadWrite"
  70. create_option = "FromImage"
  71. managed_disk_type = "Standard_LRS"
  72. }
  73.  
  74. # Optional data disks
  75. storage_data_disk {
  76. name = "datadisk_new"
  77. managed_disk_type = "Standard_LRS"
  78. create_option = "Empty"
  79. lun = 0
  80. disk_size_gb = "1023"
  81. }
  82.  
  83. storage_data_disk {
  84. name = "${azurerm_managed_disk.test.name}"
  85. managed_disk_id = "${azurerm_managed_disk.test.id}"
  86. create_option = "Attach"
  87. lun = 1
  88. disk_size_gb = "${azurerm_managed_disk.test.disk_size_gb}"
  89. }
  90.  
  91. os_profile {
  92. computer_name = "hostname"
  93. admin_username = "testadmin"
  94. admin_password = "Password1234!"
  95. }
  96.  
  97. os_profile_linux_config {
  98. disable_password_authentication = false
  99. }
  100.  
  101. tags {
  102. environment = "staging"
  103. }
  104. }
Add Comment
Please, Sign In to add comment