- Notifications
You must be signed in to change notification settings - Fork926
chore(examples/templates/azure-windows): remove dependency onaz
CLI#16039
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -31,5 +31,34 @@ This template provisions the following resources: | ||
This means, when the workspace restarts, any tools or files outside of the data directory are not persisted. To pre-bake tools into the workspace (e.g. `python3`), modify the VM image, or use a [startup script](https://registry.terraform.io/providers/coder/coder/latest/docs/resources/script). | ||
>[!NOTE] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Can we render these within Coder? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Good thinking, will check! | ||
> This template is designed to be a starting point! Edit the Terraform to extend the template to support your use case. | ||
### Persistent VM | ||
> [!IMPORTANT] | ||
> This approach requires the [`az` CLI](https://learn.microsoft.com/en-us/cli/azure/install-azure-cli#install) to be present in the PATH of your Coder Provisioner. | ||
> You will have to do this installation manually as it is not included in our official images. | ||
It is possible to make the VM persistent (instead of ephemeral) by removing the `count` attribute in the `azurerm_windows_virtual_machine` resource block as well as adding the following snippet: | ||
```hcl | ||
# Stop the VM | ||
resource "null_resource" "stop_vm" { | ||
count = data.coder_workspace.me.transition == "stop" ? 1 : 0 | ||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. count = data.coder_workspave.me.start_count There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. @matifali I'm not sure though, the issue is that if we use it for stopping, then it will look something like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more.
| ||
depends_on = [azurerm_windows_virtual_machine.main] | ||
provisioner "local-exec" { | ||
# Use deallocate so the VM is not charged | ||
command = "az vm deallocate --ids ${azurerm_windows_virtual_machine.main.id}" | ||
} | ||
} | ||
# Start the VM | ||
resource "null_resource" "start" { | ||
count = data.coder_workspace.me.transition == "start" ? 1 : 0 | ||
depends_on = [azurerm_windows_virtual_machine.main] | ||
provisioner "local-exec" { | ||
command = "az vm start --ids ${azurerm_windows_virtual_machine.main.id}" | ||
} | ||
} | ||
``` |
Uh oh!
There was an error while loading.Please reload this page.