Guest User

Untitled

a guest
Jun 10th, 2018
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.22 KB | None | 0 0
  1. data "azurerm_resource_group" "image" {
  2. name = "customimage"
  3. }
  4.  
  5. data "azurerm_image" "image" {
  6. name = "myCustomImage"
  7. resource_group_name = "${data.azurerm_resource_group.image.name}"
  8. }
  9.  
  10. resource "azurerm_resource_group" "test" {
  11. name = "acctestrg"
  12. location = "West US 2"
  13. }
  14.  
  15. resource "azurerm_virtual_network" "test" {
  16. name = "acctvn"
  17. address_space = ["10.0.0.0/16"]
  18. location = "${azurerm_resource_group.test.location}"
  19. resource_group_name = "${azurerm_resource_group.test.name}"
  20. }
  21.  
  22. resource "azurerm_subnet" "test" {
  23. name = "acctsub"
  24. resource_group_name = "${azurerm_resource_group.test.name}"
  25. virtual_network_name = "${azurerm_virtual_network.test.name}"
  26. address_prefix = "10.0.2.0/24"
  27. }
  28.  
  29. resource "azurerm_network_interface" "test" {
  30. name = "acctni"
  31. location = "${azurerm_resource_group.test.location}"
  32. resource_group_name = "${azurerm_resource_group.test.name}"
  33.  
  34. ip_configuration {
  35. name = "testconfiguration1"
  36. subnet_id = "${azurerm_subnet.test.id}"
  37. private_ip_address_allocation = "dynamic"
  38. }
  39. }
  40.  
  41. resource "azurerm_managed_disk" "test" {
  42. name = "datadisk_existing"
  43. location = "${azurerm_resource_group.test.location}"
  44. resource_group_name = "${azurerm_resource_group.test.name}"
  45. storage_account_type = "Standard_LRS"
  46. create_option = "Empty"
  47. disk_size_gb = "1023"
  48. }
  49.  
  50. resource "azurerm_virtual_machine" "test" {
  51. name = "acctvm"
  52. location = "${azurerm_resource_group.test.location}"
  53. resource_group_name = "${azurerm_resource_group.test.name}"
  54. network_interface_ids = ["${azurerm_network_interface.test.id}"]
  55. vm_size = "Standard_DS1_v2"
  56.  
  57. # Uncomment this line to delete the OS disk automatically when deleting the VM
  58. # delete_os_disk_on_termination = true
  59.  
  60. # Uncomment this line to delete the data disks automatically when deleting the VM
  61. # delete_data_disks_on_termination = true
  62.  
  63. storage_image_reference {
  64. id="${data.azurerm_image.image.id}"
  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_linux_config {
  92. # disable_password_authentication = true
  93. # ssh_keys {
  94. # path = "/home/azureuser/.ssh/authorized_keys"
  95. # key_data = "ssh-rsa AAAAB3Nz{snip}hwhqT9h"
  96. # }
  97. # }
  98.  
  99. os_profile {
  100. computer_name = "hostname"
  101. admin_username = "testadmin"
  102. admin_password = "Password1234!"
  103. }
  104.  
  105. os_profile_linux_config {
  106. disable_password_authentication = false
  107. }
  108.  
  109. tags {
  110. environment = "staging"
  111. }
  112. }
Add Comment
Please, Sign In to add comment