Hey, I am currently using Packer with the hyper-v build to produce a base rocky-9 image along with the compression post-process to produce a .zip of the artifact. I am then trying to use this .zip as the source for my VHD in Terraform but I am constantly met with errors. any help will be appreciated
The zip should be extracted into the directory portion of the path
Actual Behavior
i get the following error
Get-VHD : 'D:\hyper-v\rocky' is not an existing virtual hard disk file.
At C:\Users\chaz_\AppData\Local\Temp\shell-terraform-2XmLLK3GNqwEEu8LpuuzZlX20jw.ps1:7 char:15
+ $vhdObject = Get-VHD -path $path | %{ @{
+ ~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Get-VHD], VirtualizationException
+ FullyQualifiedErrorId : InvalidParameter,Microsoft.Vhd.PowerShell.Cmdlets.GetVHD
╷
│ Error: run command operation returned code=1
│ stderr:
│
│ stdOut:
│ Get-VHD : 'D:\hyper-v\rocky' is not an existing virtual hard disk file.
│ At C:\Users\chaz_\AppData\Local\Temp\shell-terraform-2XmLLK3GNqwEEu8LpuuzZlX20jw.ps1:7 char:15
│ + $vhdObject = Get-VHD -path $path | %{ @{
│ + ~~~~~~~~~~~~~~~~~~~
│ + CategoryInfo : InvalidArgument: (:) [Get-VHD], VirtualizationException
│ + FullyQualifiedErrorId : InvalidParameter,Microsoft.Vhd.PowerShell.Cmdlets.GetVHD
│
│ with hyperv_vhd.base-os,
│ on main.tf line 25, in resource "hyperv_vhd" "base-os":
│ 25: resource "hyperv_vhd" "base-os" {
│
╵
Steps to Reproduce
terraform apply
Important Factoids
1) i had to modify the packer compress output as it seems to place the Virtual Hard Disk and Virtual Machine inside another folder within the zip, my modification was simply moving these folders to the root otherwise nothing extracts correct. Maybe this could be a feature request to make it inline with Packer?
Packer Compressed output
Modified Output
2) with the modified zip I am able to see the extracted Virtual Hard Disk folder in the correct path but then it seems to fail accessing the directory as if it is the VHDX file. if I add a filename to the end of the path D:\\hyper-v\\rocky\\rocky-linux-9.vhdx it does not seem to extract it correctly and instead, the .vhdx file is just a direct copy of everything inside the zip i.e. both the Virtual Hard Disk and Virtual Machine folders
With "D:\\hyper-v\\rocky\\" as the path
With "D:\\hyper-v\\rocky\\rocky-linux-9.vhdx" as the path
Hey, I am currently using Packer with the hyper-v build to produce a base rocky-9 image along with the compression post-process to produce a .zip of the artifact. I am then trying to use this .zip as the source for my VHD in Terraform but I am constantly met with errors. any help will be appreciated
Terraform Version
Terraform v1.5.7 on linux_amd64
Affected Resource(s)
Terraform Configuration Files
Expected Behavior
The zip should be extracted into the directory portion of the path
Actual Behavior
i get the following error
Steps to Reproduce
terraform apply
Important Factoids
1) i had to modify the packer compress output as it seems to place the
Virtual Hard Disk
andVirtual Machine
inside another folder within the zip, my modification was simply moving these folders to the root otherwise nothing extracts correct. Maybe this could be a feature request to make it inline with Packer?Packer Compressed output
Modified Output
2) with the modified zip I am able to see the extracted Virtual Hard Disk folder in the correct path but then it seems to fail accessing the directory as if it is the VHDX file. if I add a filename to the end of the path
D:\\hyper-v\\rocky\\rocky-linux-9.vhdx
it does not seem to extract it correctly and instead, the.vhdx
file is just a direct copy of everything inside the zip i.e. both theVirtual Hard Disk
andVirtual Machine
foldersWith
"D:\\hyper-v\\rocky\\"
as the pathWith
"D:\\hyper-v\\rocky\\rocky-linux-9.vhdx"
as the path