Created
May 1, 2023 01:37
-
-
Save kaidokert/dc310780b2661557b55633bae61d9ae9 to your computer and use it in GitHub Desktop.
Azure Free VMs terraform snippet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create Windows VM | |
resource "azurerm_windows_virtual_machine" "windows_vm" { | |
size = "Standard_B1s" | |
name = "${var.prefix}-windows-vm" | |
resource_group_name = azurerm_resource_group.main.name | |
location = azurerm_resource_group.main.location | |
admin_username = "${var.adminname}" | |
admin_password = "${var.adminpwd}" | |
network_interface_ids = [ | |
azurerm_network_interface.windows_nic.id, | |
] | |
source_image_reference { | |
publisher = "MicrosoftWindowsServer" | |
offer = "WindowsServer" | |
sku = "2022-datacenter-azure-edition" | |
version = "latest" | |
} | |
os_disk { | |
storage_account_type = "Standard_LRS" | |
caching = "ReadWrite" | |
} | |
} | |
# Create Linux VM | |
resource "azurerm_linux_virtual_machine" "linux_vm" { | |
size = "Standard_B1s" | |
name = "${var.prefix}-ubuntuvm" | |
location = azurerm_resource_group.main.location | |
resource_group_name = azurerm_resource_group.main.name | |
network_interface_ids = [azurerm_network_interface.linux_nic.id] | |
os_disk { | |
caching = "ReadWrite" | |
storage_account_type = "Standard_LRS" | |
} | |
source_image_reference { | |
publisher = "Canonical" | |
offer = "0001-com-ubuntu-server-jammy" | |
sku = "22_04-lts-gen2" | |
version = "latest" | |
} | |
computer_name = "ubuntuvm" | |
admin_username = "${var.adminname}" | |
disable_password_authentication = true | |
admin_ssh_key { | |
username = "${var.adminname}" | |
public_key = tls_private_key.gen_ssh.public_key_openssh | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment