Advertisement
Guest User

Untitled

a guest
Feb 28th, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.24 KB | None | 0 0
  1. terraform init
  2. terraform apply -no-color -auto-approve
  3. terraform destroy -force
  4.  
  5. # Configure the Microsoft Azure Provider
  6. provider "azurerm" {
  7. subscription_id = "xxxxx"
  8. client_id = "xxxxx"
  9. client_secret = "xxxxx"
  10. tenant_id = "xxxxx"
  11. }
  12.  
  13. # Locate the existing custom/golden image
  14. data "azurerm_image" "search" {
  15. name = "AZLXSPTDEVOPS01_Image"
  16. resource_group_name = "RG-EASTUS-SPT-PLATFORM"
  17. }
  18.  
  19. output "image_id" {
  20. value = "/subscriptions/xxxxxxx/resourceGroups/RG-EASTUS-SPT-PLATFORM/providers/Microsoft.Compute/images/AZLXSPTDEVOPS01_Image"
  21. }
  22.  
  23. # Create a Resource Group for the new Virtual Machine.
  24. resource "azurerm_resource_group" "main" {
  25. name = "RG-PF-TEST"
  26. location = "eastus"
  27. }
  28.  
  29. # Create a Subnet within the Virtual Network
  30. resource "azurerm_subnet" "internal" {
  31. name = "SNET-IN"
  32. virtual_network_name = "VNET-PFSENSE-TEST"
  33. resource_group_name = "${azurerm_resource_group.main.name}"
  34. address_prefix = "192.168.2.0/24"
  35. }
  36.  
  37. # Create a Network Security Group with some rules
  38. resource "azurerm_network_security_group" "main" {
  39. name = "RG-Dev-NSG"
  40. location = "${azurerm_resource_group.main.location}"
  41. resource_group_name = "${azurerm_resource_group.main.name}"
  42.  
  43. security_rule {
  44. name = "allow_SSH"
  45. description = "Allow SSH access"
  46. priority = 100
  47. direction = "Inbound"
  48. access = "Allow"
  49. protocol = "Tcp"
  50. source_port_range = "*"
  51. destination_port_range = "22"
  52. source_address_prefix = "*"
  53. destination_address_prefix = "*"
  54. }
  55. }
  56.  
  57. # Create a network interface for VMs and attach the PIP and the NSG
  58. resource "azurerm_network_interface" "main" {
  59. name = "NIC-Dev"
  60. location = "${azurerm_resource_group.main.location}"
  61. resource_group_name = "${azurerm_resource_group.main.name}"
  62. network_security_group_id = "${azurerm_network_security_group.main.id}"
  63.  
  64. ip_configuration {
  65. name = "primary"
  66. subnet_id = "${azurerm_subnet.internal.id}"
  67. private_ip_address_allocation = "static"
  68. private_ip_address = "192.168.2.6"
  69. }
  70. }
  71.  
  72. # Create a new Virtual Machine based on the Golden Image
  73. resource "azurerm_virtual_machine" "vm" {
  74. name = "AZLXSPTDEVOPS01"
  75. location = "${azurerm_resource_group.main.location}"
  76. resource_group_name = "${azurerm_resource_group.main.name}"
  77. network_interface_ids = ["${azurerm_network_interface.main.id}"]
  78. vm_size = "Standard_DS12_v2"
  79. delete_os_disk_on_termination = true
  80. delete_data_disks_on_termination = true
  81.  
  82. storage_image_reference {
  83. id = "${data.azurerm_image.search.id}"
  84. }
  85.  
  86. storage_os_disk {
  87. name = "AZLXSPTDEVOPS01-OS"
  88. caching = "ReadWrite"
  89. create_option = "FromImage"
  90. managed_disk_type = "Standard_LRS"
  91. }
  92.  
  93. os_profile {
  94. computer_name = "APPVM"
  95. admin_username = "devopsadmin"
  96. admin_password = "admin#2019"
  97. }
  98.  
  99. os_profile_linux_config {
  100. disable_password_authentication = false
  101. }
  102. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement