Packer Azure Windows Image
Example of how to create and deploy Azure Windows VM with preinstalled chocolatey and other software
To install Packer
choco install packer -y
Packer commands
packer init windows-server2019-v1.pkr.hcl
packer validate -var-file="windows.variables.json" windows-server2019-v1.pkr.hcl
packer build -var-file="windows.variables.json" windows-server2019-v1.pkr.hcl
Pre-commit configuration
- Install python3 via windows store
pip install --upgrade pip
pip install pre-commit
- Update PATH variable
pre-commit install
Install terraform docs
choco install terraform-docs
Install tflint
choco install tflint
Documentation
- https://github.com/antonbabenko/pre-commit-terraform
- https://github.com/kolosovpetro/AzureTerraformBackend
- https://github.com/terraform-docs/terraform-docs
- https://terraform-docs.io/user-guide/installation/
- https://pre-commit.com/
Storage account configuration file
storage_account_name = "storage_account_name"
container_name = "container_name"
key = "terraform.tfstate"
sas_token = "sas_token"
Deploy storage account for terraform state
Module documentation
Requirements
Name | Version |
---|---|
azurerm | =3.71.0 |
Providers
Name | Version |
---|---|
azurerm | 3.71.0 |
Modules
Name | Source | Version |
---|---|---|
custom_script_extension | ./modules/custom-script-extension | n/a |
key_vault | ./modules/keyvault | n/a |
key_vault_secrets | ./modules/keyvault-secrets | n/a |
keyvault_access_policy | ./modules/keyvault-access-policy | n/a |
network | ./modules/network | n/a |
storage | ./modules/storage | n/a |
virtual_machine | ./modules/vm | n/a |
Resources
Name | Type |
---|---|
azurerm_resource_group.public | resource |
azurerm_client_config.current | data source |
Inputs
Name | Description | Type | Default | Required |
---|---|---|---|---|
azure-client-id | n/a | string |
n/a | yes |
azure-client-secret | n/a | string |
n/a | yes |
azure-region | n/a | string |
n/a | yes |
azure-resource-group | n/a | string |
n/a | yes |
azure-subscription-id | n/a | string |
n/a | yes |
azure-tenant-id | n/a | string |
n/a | yes |
custom_script_extension_enabled | Specifies whether the extension should be enabled or disabled. | bool |
n/a | yes |
image-name | n/a | string |
n/a | yes |
image_resource_group_name | Specifies the name of the resource group that contains the image to use to create the virtual machine. | string |
n/a | yes |
os_profile_admin_password | Specifies the password of the administrator account. | string |
n/a | yes |
os_profile_admin_username | Specifies the name of the administrator account. | string |
n/a | yes |
prefix | Resources name prefix | string |
n/a | yes |
resource_group_location | Location of the resource group. | string |
n/a | yes |
storage_account_replication | Specifies the replication type for this storage account. | string |
n/a | yes |
storage_account_tier | Specifies the tier to use for this storage account. | string |
n/a | yes |
storage_image_reference_offer | Specifies the offer of the platform image or marketplace image used to create the virtual machine. | string |
n/a | yes |
storage_image_reference_publisher | The publisher of the image used to create the virtual machine. | string |
n/a | yes |
storage_image_reference_sku | Specifies the SKU of the platform image or marketplace image used to create the virtual machine. | string |
n/a | yes |
storage_image_reference_version | Specifies the version of the platform image or marketplace image used to create the virtual machine. | string |
n/a | yes |
storage_os_disk_caching | Specifies the caching requirements for the OS disk. | string |
n/a | yes |
storage_os_disk_create_option | Specifies how the virtual machine should be created. | string |
n/a | yes |
storage_os_disk_managed_disk_type | Specifies the storage account type for the managed disk. | string |
n/a | yes |
vm-size | n/a | string |
n/a | yes |
vm_size | The size of the virtual machine. | string |
n/a | yes |
Outputs
Name | Description |
---|---|
public_ip | n/a |
username | n/a |