Packer KVM image build issue

Hi ,

Packer is running on EKS cluster.
Raw image is stored on S3 bucket
Final image should store on S3 bucket
Raw image is qcow2 file

Need help to create kvm image out of qcow2 file stored in S3 bucket.
Tried below code, getting error:

Code:

{
“variables”: {
“ssh_passwd”: “{{env SSH_PASSWD }}”,
“aws_access_key”: “{{env AWS_ACCESS_KEY }}”,
“aws_secret_key”: “{{env AWS_SECRET_KEY }}”,
“aws_session_token”: “{{env AWS_SESSION_TOKEN }}”,
“aws_role_arn”: “{{env AWS_ROLE_ARN }}”
},

“builders”: [
{
“type”: “qemu”,
“format”: “qcow2”,
“qemu_binary”: “/usr/libexec/qemu-kvm”,
“accelerator”: “kvm”,
“disk_image”: “true”,
“use_backing_file”: “false”,
“iso_url”: “https://packer_test.s3.us-west-1.amazonaws.com/packer_image.qcow2”,
“iso_checksum”: “ced2b0b1a99361f698b063a1c02ea2ac86b2705”,
“vm_name”: “vm_name_test”,
“output_directory”: “image_output_dir”,
“communicator”: “ssh”,
“ssh_username”: “root”,
“ssh_password”: “{{ user ssh_passwd }}”,
“ssh_wait_timeout”: “20m”,
“shutdown_command”: “echo ‘{{ user ssh_passwd }}’ | sudo -S /sbin/halt -h -p”,
“headless”: true,
“memory”: “1024”,
“cpus”: 1
}

],
“provisioners”: [
{
“type”: “shell”,
“inline”: [
“aws s3 cp image_output_dir/packer_image.qcow2 s3://bucket_name/”
]
}
]
}

Error:
e[1;32mqemu: output will be in this color.e[0m

e[1;32m==> qemu: Retrieving ISOe[0m
e[1;32m==> qemu: Trying https://packer_test.s3.us-west-1.amazonaws.com/packer_image.qcow2e[0m
e[1;32m==> qemu: Trying https://packer_test.s3.us-west-1.amazonaws.com/packer_image.qcow2?checksum=sha256%ced2b0b1a99361f698b063a1c02ea2ac86b2705e[0m
e[1;32m==> qemu: Download failed bad response code: 403e[0m
e[1;31m==> qemu: error downloading ISO: [bad response code: 403]e[0m
e[1;31mBuild ‘qemu’ errored after 242 milliseconds 603 microseconds: error downloading ISO: [bad response code: 403]e[0m

==> Wait completed after 242 milliseconds 649 microseconds

==> Some builds didn’t complete successfully and had errors:
→ qemu: error downloading ISO: [bad response code: 403]

==> Builds finished but no artifacts were created.

Hey @priyapatil180, this doesn’t look like a terraform issue. The status code terraform received while downloading from https://packer_test.s3.us-west-1.amazonaws.com/packer_image.qcow2 is 403, so you should check more on why your request is denied from S3.

Mostly due to wrong IAM / auth issues. This might help : Troubleshoot 403 Access Denied errors from Amazon S3 | AWS re:Post

Thank you Tanmay. Will check with access.

Access issue has been resolved now. Getting below error, though qemu-kvm been installed.

2023/09/27 02:54:21 packer-plugin-qemu_v1.0.10_x5.0_linux_amd64 plugin: 2023/09/27 02:54:21 Started Qemu. Pid: 583
2023/09/27 02:54:21 packer-plugin-qemu_v1.0.10_x5.0_linux_amd64 plugin: 2023/09/27 02:54:21 Qemu stderr: Could not access KVM kernel module: No such file or directory
2023/09/27 02:54:21 packer-plugin-qemu_v1.0.10_x5.0_linux_amd64 plugin: 2023/09/27 02:54:21 Qemu stderr: qemu-kvm: failed to initialize kvm: No such file or directory
2023/09/27 02:54:21 packer-plugin-qemu_v1.0.10_x5.0_linux_amd64 plugin: 2023/09/27 02:54:21 failed to unlock port lockfile: close tcp 127.0.0.1:5984: use of closed network connection
2023/09/27 02:54:21 packer-plugin-qemu_v1.0.10_x5.0_linux_amd64 plugin: 2023/09/27 02:54:21 failed to unlock port lockfile: close tcp 127.0.0.1:3212: use of closed network connection

please suggest.

can anyone please update on this issue. Packer hosted on eks cluster and trying to build kvm image using qemu-kvm module.