Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/patkoch/terraform_virtual_machine_windows
Deployment of a Windows virtual machine on Azure using Terraform
https://github.com/patkoch/terraform_virtual_machine_windows
azure hashicorp-terraform infrastructure-as-code terraform virtual-machine vs-code
Last synced: about 1 month ago
JSON representation
Deployment of a Windows virtual machine on Azure using Terraform
- Host: GitHub
- URL: https://github.com/patkoch/terraform_virtual_machine_windows
- Owner: patkoch
- Created: 2021-12-30T17:40:23.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-12-29T23:32:54.000Z (about 1 year ago)
- Last Synced: 2024-11-02T22:22:40.655Z (3 months ago)
- Topics: azure, hashicorp-terraform, infrastructure-as-code, terraform, virtual-machine, vs-code
- Language: HCL
- Homepage: https://www.patrickkoch.dev/posts/post_12/
- Size: 340 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Deployment of a Windows virtual machine on Azure using Terraform
This is the manual for the provisioning of a Windows virtual machine on Azure using Terraform.
# Prerequisites
Despite of having an *Azure* subscription, install following:
- [Azure CLI](https://learn.microsoft.com/en-us/cli/azure/install-azure-cli)
- [Terraform](https://developer.hashicorp.com/terraform/downloads)# Sources for the Terraform configuration
I'd like to refer to following to links, which I've used for for that example:
[Hashicorp - azurerm - Windows Virtual Machine](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/windows_virtual_machine)
[Hashicorp - azurerm - public ip](https://registry.terraform.io/providers/hashicorp/azurerm/2.55.0/docs/resources/public_ip)
# Deploy and destroy the Windows virtual machine with Terraform
I recommend to conduct all commands in VS Code using a new Terminal.
## Login in to Azure
Run following command to start the login to *Azure*:
```
az login
```A new browser session pops up, use the login credentials of your account:
After that, switch back to VS Code, you should see logs similar in the picture shown below:
You can prove whether you are using the right subscription using the following command:
```
az account show
```
This shows you the current subscription:## Deploy the virtual machine
The first *Terraform* command is the "init" command:
```
terraform init
```
The logs in the picture below show a successful execution of the command:As next, run the "format" command, to ensure that all files of your configuration stick to specific language style conventions:
```
terraform fmt
```After that, ensure that your *Terraform* coniguration is valid by executing:
```
terraform validate
```Create now a *Terraform* plan file, by running:
```
terraform plan -out tfplan
```
This creates a file named "tfplan" in your directory:Finally, the command can be executed for deploying the virtual machine on *Azure* - it uses the *Terraform* plan named "tfplan" as an argument:
```
terraform apply "tfplan"
```The deployment was successful if following log message appears:
Prove the deployment of the virtual machine in the *Azure* portal:
## Destroy the virtual machine
The virtual machine can be destroyed using the following command:
```
terraform destroy
```# References
https://developer.hashicorp.com/terraform/tutorials/azure-get-started/azure-build
https://developer.hashicorp.com/terraform/cli/commands