Skip to content

data-platform-hq/terraform-azurerm-linux-vm

Repository files navigation

Azure linux vm Terraform module

Terraform module for creation Azure linux vm

Usage

# Prerequisite resources

data "azurerm_resource_group" "example" {
  name                = "example"
}

data "azurerm_subnet" "example" {
  name                 = "example"
  virtual_network_name = "production"
  resource_group_name  = data.azurerm_resource_group.example.name
}

resource "tls_private_key" "example" {
  algorithm   = "RSA"
  ecdsa_curve = 2048
}

module "linux_virtual_machine" {
  source   = "data-platform-hq/linux-vm/azurerm"
  version  = "~> 1.0"

  project        = var.project
  env            = var.env
  resource_group = data.azurerm_resource_group.example.name
  location       = var.location
  subnet_id      = data.azurerm_subnet.example.id
  
  admin_ssh_key = {
    username   = "userexample"
    public_key = tls_private_key.example.public_key_openssh
  }
}

Requirements

Name Version
terraform >=1.0.0
azurerm >= 4.0.1

Providers

Name Version
azurerm >= 4.0.1

Modules

No modules.

Resources

Name Type
azurerm_linux_virtual_machine.this resource
azurerm_network_interface.this resource
azurerm_public_ip.this resource

Inputs

Name Description Type Default Required
admin_ssh_key Objects to configure ssh key reference for virtual machine
object({
username = optional(string, "adminuser")
public_key = optional(string)
})
n/a yes
custom_network_interface_name Specifies the name of the virtual machine interface name resource string null no
custom_public_ip_name Specifies the name of the public ip name name resource string null no
custom_virtual_machine_name Specifies the name of the virtual machine name resource string null no
env Environment name string n/a yes
identity_enabled Boolean flag than enables creation of System Assigned identity to VM bool false no
location Azure location string n/a yes
network_interface_private_ip_address_allocation The allocation method used for the Private IP Address. string "Dynamic" no
os_disk Objects to configure os disk reference for virtual machine
object({
caching = string
storage_account_type = string
})
{
"caching": "ReadWrite",
"storage_account_type": "Standard_LRS"
}
no
password_access_enabled Boolean flag that enables access using password bool false no
project Project name string n/a yes
public_ip_allocation_method Defines the allocation method for this IP address. Possible values are Static or Dynamic string "Static" no
public_ip_enabled Boolean flag to enable Public Ip address creation and assignment to Virtual Machine bool true no
resource_group The name of the resource group string n/a yes
source_image_reference Objects to configure source image reference for virtual machine
object({
publisher = string
offer = string
sku = string
version = string
})
{
"offer": "0001-com-ubuntu-server-focal",
"publisher": "Canonical",
"sku": "20_04-lts",
"version": "latest"
}
no
subnet_id The ID of the Subnet where this Network Interface should be located in. string n/a yes
suffix Optional suffix that would be added to the end of resources names. It is recommended to use dash at the beginning of variable (e.x., '-example') string "" no
tags Resource tags map(any) {} no
vm_admin_password The password of the local administrator used for the Virtual Machine. string null no
vm_admin_username The username of the local administrator used for the Virtual Machine. string "adminuser" no
vm_size The SKU which should be used for this Virtual Machine. string "Standard_F2" no

Outputs

Name Description
id The ID of the Linux Virtual Machine
identity linux virtual machine Identities list
private_ip Linux Virtual Machine private IP address
public_ip Linux Virtual Machine public IP address

License

Apache 2 Licensed. For more information please see LICENSE