github.com/swisspost/terratest@v0.0.0-20230214120104-7ec6de2e1ae0/examples/terraform-aws-ec2-windows-example/packer/build.pkr.hcl (about) 1 variable "instance_type" { 2 type = string 3 description = "The EC2 instance size / type to launch" 4 } 5 6 variable "region" { 7 type = string 8 description = "The AWS region to deploy the Windows instance into" 9 } 10 11 12 data "amazon-ami" "windows_server_2016" { 13 filters = { 14 name = "Windows_Server-2016-English-Full-Base-*" 15 root-device-type = "ebs" 16 virtualization-type = "hvm" 17 } 18 most_recent = true 19 owners = ["801119661308"] 20 region = var.region 21 } 22 23 locals { 24 build_version = "${legacy_isotime("2006.01.02.150405")}" 25 } 26 27 source "amazon-ebs" "windows_server_2016" { 28 ami_name = "WIN2016-CUSTOM-${local.build_version}" 29 associate_public_ip_address = true 30 communicator = "winrm" 31 instance_type = var.instance_type 32 region = var.region 33 source_ami = "${data.amazon-ami.windows_server_2016.id}" 34 user_data_file = "${path.root}/scripts/bootstrap_windows.txt" 35 winrm_timeout = "15m" 36 winrm_password = "SuperS3cr3t!!!!" 37 winrm_username = "Administrator" 38 39 } 40 41 build { 42 sources = ["source.amazon-ebs.windows_server_2016"] 43 44 # Install Chocolatey package manager, then install any Chocolatey packages defined in scripts/install_packages.ps1 45 provisioner "powershell" { 46 scripts = ["${path.root}/scripts/install_chocolatey.ps1", "${path.root}/scripts/install_packages.ps1"] 47 } 48 49 provisioner "windows-restart" { 50 restart_timeout = "35m" 51 } 52 }