Edits per Code Review

This commit is contained in:
Tom Archer
2023-05-19 08:03:44 -07:00
parent c7bd6dc586
commit 40ac990971
4 changed files with 61 additions and 18 deletions

View File

@ -65,16 +65,6 @@ resource "azurerm_network_interface" "test" {
}
}
resource "azurerm_managed_disk" "test" {
count = 2
name = "datadisk_existing_${count.index}"
location = azurerm_resource_group.rg.location
resource_group_name = azurerm_resource_group.rg.name
storage_account_type = "Standard_LRS"
create_option = "Empty"
disk_size_gb = "1023"
}
resource "azurerm_availability_set" "avset" {
name = "avset"
location = azurerm_resource_group.rg.location
@ -88,13 +78,27 @@ resource "random_pet" "azurerm_linux_virtual_machine_name" {
prefix = "vm"
}
resource "random_password" "password" {
count = var.password == null ? 1 : 0
length = 20
special = true
min_numeric = 1
min_upper = 1
min_lower = 1
min_special = 1
}
locals {
password = try(random_password.password[0].result, var.password)
}
resource "azurerm_linux_virtual_machine" "test" {
count = 2
name = "${random_pet.azurerm_linux_virtual_machine_name.id}${count.index}"
location = azurerm_resource_group.rg.location
availability_set_id = azurerm_availability_set.avset.id
resource_group_name = azurerm_resource_group.rg.name
network_interface_ids = [element(azurerm_network_interface.test.*.id, count.index)]
network_interface_ids = [azurerm_network_interface.test[count.index].id]
size = "Standard_DS1_v2"
# Uncomment this line to delete the OS disk automatically when deleting the VM
@ -117,7 +121,25 @@ resource "azurerm_linux_virtual_machine" "test" {
}
computer_name = "hostname"
admin_username = "testadmin"
admin_password = "Password1234!"
admin_username = var.user_name
admin_password = local.password
disable_password_authentication = false
}
resource "azurerm_managed_disk" "test" {
count = 2
name = "datadisk_existing_${count.index}"
location = azurerm_resource_group.rg.location
resource_group_name = azurerm_resource_group.rg.name
storage_account_type = "Standard_LRS"
create_option = "Empty"
disk_size_gb = "1023"
}
resource "azurerm_virtual_machine_data_disk_attachment" "test" {
count = 2
managed_disk_id = azurerm_managed_disk.test[count.index].id
virtual_machine_id = azurerm_linux_virtual_machine.test[count.index].id
lun = "10"
caching = "ReadWrite"
}