I want to provision a Azure VM (Windows) in terraform, with a package installation of python, pip, java JDK, and more with IIS software deployment. All this installation should be done by commands or scripts. these scripts should work with a config file where I can give variable or parameters for PowerShell arguments, config file is in repository.
After some research I got 3 ways to move ahead with my provisioning.
- Custom data attribute in VM resource block.
- Azure VM extension resource block.(Custom Script)
- Provisioner block in VM resource. I want to choose one of these, but I am confused which will be better for my situation to handle error, exceptions and complete installation.
Choosing parameters:
- Error handling (logs generation to debug)
- Successful installation with config file
- secure data in script file. Can someone suggest me what should I use and how, which will be more suitable??
To install Python, pip, and Java JDK on the
VM
, you can run a script using theCustomScriptExtension
extension. To deploy software toIIS
, you can use theWebDeployExtension
extension.Save the
PowerShell script
to an Azure blob and copy its URL. Then, paste the URL in thefileUris
section.Here is the
PowerShell Script
to installPython, pip, and Java JDK on the VM
.Script.ps1
Terraform Script
Terraform Apply:
Reference: azurerm_virtual_machine_extension