Skip to content

jmapro/terraform-azurerm-compute

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Deploys 1+ Virtual Machines to your provided VNet

This Terraform module deploys Virtual Machines in Azure with the following characteristics:

  • Ability to specify a simple string to get the latest marketplace image using var.vm_os_simple
  • All VMs use managed disks
  • Network Security Group (NSG) created and only if var.remote_port specified, then remote access rule created and opens this port to all nics
  • VM nics attached to a single virtual network subnet of your choice (new or existing) via var.vnet_subnet_id.
  • Public IP is created and attached only to the first VM's nic. Once into this VM, connection can be make to the other vms using the private ip on the VNet.

Usage

Provisions 2 Windows 2016 Datacenter Server VMs using vm_os_simple to a new VNet and opens up port 3389 for RDP access:

module "mycompute" {
  source = "Azure/compute/azurerm"
  resource_group_name = "mycompute"
  location = "East US 2"
  admin_password = "ComplxP@ssw0rd!"
  vm_os_simple = "WindowsServer"
  public_ip_dns = "mywinsrv252"
  remote_port = "3389"
  nb_instances = 2
  vnet_subnet_id = "${module.network.vnet_subnets[0]}"
}

module "network" {
  source = "Azure/network/azurerm"
  location = "East US 2"
  resource_group_name = "mycompute"
}

output "vm_public_name"{
  value = "${module.mycompute.public_ip_dns_name}"
}

output "vm_public_ip" {
  value = "${module.mycompute.public_ip_address}"
}

output "vm_private_ips" {
  value = "${module.mycompute.network_interface_private_ip}"
}

Provisions 2 Ubuntu 14.04 Server VMs using vm_os_publisher, vm_os_offer and vm_os_sku to a new VNet and opens up port 22 for SSH access with ~/.ssh/id_rsa.pub :

module "mycompute2" { 
    source              = "Azure/compute/azurerm"
    resource_group_name = "mycompute2"
    location            = "westus"
    public_ip_dns       = "myubuntuservers225"
    remote_port         = "22"
    nb_instances        = 2
    vm_os_publisher     = "Canonical"
    vm_os_offer         = "UbuntuServer"
    vm_os_sku           = "14.04.2-LTS"
    vnet_subnet_id      = "${module.network.vnet_subnets[0]}"
    tags                = {
                            environment = "dev"
                            costcenter  = "it"
                          }
}
  module "network" {
    source 		= "Azure/network/azurerm"
    location 		= "westus"
    resource_group_name = "mycompute2"
}

Authors

Originally created by David Tesar

License

MIT

About

Terraform Azure RM Compute Module

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • HCL 100.0%