Skip to main content
added 28 characters in body
Source Link

IfI don't know that you are using linuxcan specify ranges. On Linux, you can add a bash function such as from here.

A slight modification should work,

terraform-replace () {
    sed 's/\x1b\[[0-9;]*m//g' | grep -o '# [^( ]* ' | grep '\.' | sed " s/^# /-replace '/; s/ $/'/; "
}

Then use it like this,

terraform plan | terraform-replace | grep 'azurerm_windows_virtual_machine.vm\[[0-4]\]' | xargs -r terraform apply -auto-approve

If you are using linux, you can add a bash function such as from here.

A slight modification should work,

terraform-replace () {
    sed 's/\x1b\[[0-9;]*m//g' | grep -o '# [^( ]* ' | grep '\.' | sed " s/^# /-replace '/; s/ $/'/; "
}

Then use it like this,

terraform plan | terraform-replace | grep 'azurerm_windows_virtual_machine.vm\[[0-4]\]' | xargs -r terraform apply -auto-approve

I don't know that you can specify ranges. On Linux, you can add a bash function such as from here.

A slight modification should work,

terraform-replace () {
    sed 's/\x1b\[[0-9;]*m//g' | grep -o '# [^( ]* ' | grep '\.' | sed " s/^# /-replace '/; s/ $/'/; "
}

Then use it like this,

terraform plan | terraform-replace | grep 'azurerm_windows_virtual_machine.vm\[[0-4]\]' | xargs -r terraform apply -auto-approve
Source Link

If you are using linux, you can add a bash function such as from here.

A slight modification should work,

terraform-replace () {
    sed 's/\x1b\[[0-9;]*m//g' | grep -o '# [^( ]* ' | grep '\.' | sed " s/^# /-replace '/; s/ $/'/; "
}

Then use it like this,

terraform plan | terraform-replace | grep 'azurerm_windows_virtual_machine.vm\[[0-4]\]' | xargs -r terraform apply -auto-approve