I’d like to run multiple linux commands using azurerm_virtual_machine_extension. Is there a sophisticated way to use multiple commands side by side instead of listing them in a single line? I’ve previously used it as below.
resource "azurerm_virtual_machine_extension" "run_command" {
for_each = var.vm_template
name = "${each.value.vm_name}-run_command"
virtual_machine_id = azurerm_linux_virtual_machine.vm[each.key].id
publisher = "Microsoft.Azure.Extensions"
type = "CustomScript"
type_handler_version = "2.0"
timeouts {
create = "1h" # VM 개수가 많으면 그만큼 더 오래걸림
}
settings = <<SETTINGS
{
"commandToExecute": "bash -c 'hostnamectl set-hostname --static ${each.value.hostname}'&& sleep 60 && sh /tmp/for_image.sh > /tmp/installed.log 2>&1"
}
SETTINGS
}
Is it possible to write a code by aligning it line by line without executing all the commands line like above? I need your help.