Amazon import-image task stuck on "updating" when platform is not specified
OlaSegha opened this issue · comments
Overview of the Issue
The post-processor amazon-import (import-image-task) gets stuck in "updating" because the platform is not provided.
The AWS EC2 equivalent of this process provides an optional --platform
flag which is not available in the packer-plugin-amazon
plugin.
Reproduction Steps
post-processor "amazon-import" {
access_key = var.aws_access_key
secret_key = var.aws_access_secret_id
token = var.aws_session_token
region = var.region
s3_bucket_name = var.s3_bucket_name
format = "vmdk"
keep_input_artifact = true
ami_name = "packer-demo-${formatdate("YYYY-MM-DD'T'hh-mm-ssZ", timestamp())}"
role_name = var.role_name
ami_encrypt = var.ami_encrypt
ami_kms_key = var.ami_kms_key
ami_users = var.ami_users
ami_ou_arns = var.ami_ou_arns
boot_mode = var.boot_mode
license_type = var.license_type
}
Result
{
"Architecture": "x86_64",
"Encrypted": true,
"ImportTaskId": "import-ami-03cf3969904860ae8",
"KmsKeyId": "XXXXXXXXXXXXXXXXXXXXX",
"LicenseType": "BYOL",
"Progress": "27",
"SnapshotDetails": [
{
"DeviceName": "/dev/sde",
"DiskImageSize": 9525806592.0,
"Format": "VMDK",
"Status": "completed",
"UserBucket": {
"S3Bucket": "XXXXXXXXXXXXXXXXXXXXX",
"S3Key": "packer-import-1699295410.vmdk"
}
}
],
"Status": "active",
"StatusMessage": "updating",
"Tags": [],
"BootMode": "uefi"
},
Which eventually gets deleted.
Plugin and Packer version
Packer v1.9.4
amazon = {
version = ">=1.2.7"
source = "github.com/hashicorp/amazon"
}
Operating system and Environment details
NAME="Ubuntu"
VERSION="20.04.6 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.6 LTS"
VERSION_ID="20.04"
Log Fragments and crash.log files
vsphere-iso.windows (amazon-import): Completed upload of /home/user/cicd-base-windows10-template/artifacts//windows-10-2H1-pro-main-2023-11-10T01-49-06Z.vmdk to s3://XXXXXXXXXXXXX/packer-import-1699580946.vmdk
vsphere-iso.windows (amazon-import): Setting license type to 'BYOL'
vsphere-iso.windows (amazon-import): Started import of s3://XXXXXXXXXXXX/packer-import-1699580946.vmdk, task id import-ami-0b0d543bf1549c983
vsphere-iso.windows (amazon-import): Waiting for task import-ami-0b0d543bf1549c983 to complete (may take a while)
{
"Architecture": "x86_64",
"Encrypted": true,
"ImportTaskId": " import-ami-0b0d543bf1549c983",
"KmsKeyId": "XXXXXXXXXXXXXXXXXXX",
"LicenseType": "BYOL",
"Progress": "27",
"SnapshotDetails": [
{
"DeviceName": "/dev/sde",
"DiskImageSize": 9525806592.0,
"Format": "VMDK",
"Status": "completed",
"UserBucket": {
"S3Bucket": "XXXXXXXXXXXXXXXXXX",
"S3Key": "packer-import-1699580946.vmdk"
}
}
],
"Status": "active",
"StatusMessage": "updating",
"Tags": [],
"BootMode": "uefi"
}
Alternatively I have tested the AWS CLI Command that does the same thing
post-processor "shell-local" {
inline = [ <<EOF
aws ec2 import-image --role-name "${var.role_name}" \
--description ${local.vm_name_description} \
--license-type BYOL \
--disk-containers Format=vmdk,UserBucket="{S3Bucket=${var.s3_bucket_name},S3Key=${local.vm_name_description}.vmdk}"
EOF
]
}
and got the same results. But setting platform in the CLI command works.
post-processor "shell-local" {
inline = [ <<EOF
aws ec2 import-image --role-name "${var.role_name}" \
--description ${local.vm_name_description} \
--platform windows \
--license-type BYOL \
--disk-containers Format=vmdk,UserBucket="{S3Bucket=${var.s3_bucket_name},S3Key=${local.vm_name_description}.vmdk}"
EOF
]
}
Hi @OlaSegha,
This looks coherent with what's described in the AWS docs for EFI builds here, which seems to be your case. In this case Platform
must be specified as either Windows
or Linux
in order for the import to be successful.
The work needed here is not extensive it seems, I'll see to have a PR open for that this week.
Thanks for reporting this!