Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

amazon_import post-processor fails: architecture=arm64 has an invalid format #11970

Closed
cevich opened this issue Sep 1, 2022 · 4 comments
Closed

Comments

@cevich
Copy link

cevich commented Sep 1, 2022

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

When filing a bug, please include the following headings if possible. Any
example text in this template can be deleted.

Overview of the Issue

Importing a Fedora 37 arm64 (aarch64) image fails with an error message from AWS indicating the architecture value is invalid. Googling for the error suggests:

  • Despite the docs saying otherwise, you cannot specify an architecture with the ImportImage call (presumably this is what is being used) - in the cli this would be equivalent to aws ec2 import-image --architecture arm64.
  • What does work is the ImportSnapshot call - in the cli this would be like aws ec2 import-snapshot --disk-container Format=VHD,UserBucket="{S3Bucket=YOUR-BUCKET,S3Key=S3_OBJECT_NAME}"
  • When the status reports complete, that may be followed by a RegisterImage call - the cli equivalent of aws ec2 register-image --cli-input-json "$(<register-image.json)" (with an appropriate JSON input file specifying the snapshot ID returned by the import-snapshot output)

Ref: NixOS/nixpkgs#52779 (comment)

Reproduction Steps

I'm using a packer (JSON) template with a null builder, shell-local provisioner (download + verify + qemu-img convert the image), and a post-processor similar to what's posted in the template item below. Simply running packer build with this template, will fail a few minutes after the upload completes with:

`
==> fedora-aws-arm64: Running post-processor: artifice
==> fedora-aws-arm64 (artifice): Using these artifact files: /tmp/fedora-aws-arm64.vhdx
==> fedora-aws-arm64: Running post-processor: amazon-import
fedora-aws-arm64 (amazon-import): Uploading /tmp/fedora-aws-arm64.vhdx to s3://IMPORT-BUCKET-NAME/packer-import-1662046985.vhdx
fedora-aws-arm64 (amazon-import): Completed upload of /tmp/fedora-aws-arm64.vhdx to s3://IMPORT-BUCKET-NAME/packer-import-1662046985.vhdx
Build 'fedora-aws-arm64' errored after 3 minutes 11 seconds: 1 error(s) occurred:

  • Post-processor failed: Failed to start import from s3://IMPORT-BUCKET-NAME/packer-import-1662046985.vhdx: retry count exhausted. Last err: InvalidParameter: Parameter architecture = arm64 has an invalid format.
    status code: 400, request id: c781da9e-39d2-4df8-ba61-8d176a5cae85

==> Wait completed after 3 minutes 11 seconds

==> Some builds didn't complete successfully and had errors:
--> fedora-aws-arm64: 1 error(s) occurred:

  • Post-processor failed: Failed to start import from s3://IMPORT-BUCKET-NAME/packer-import-1662046985.vhdx: retry count exhausted. Last err: InvalidParameter: Parameter architecture = arm64 has an invalid format.
    status code: 400, request id: c781da9e-39d2-4df8-ba61-8d176a5cae85

==> Builds finished but no artifacts were created.
`

However, passing the (already uploaded) S3 object into the aws CLI results in (eventual) aws ec2 describe-import-snapshot-tasks success:

aws ec2 import-snapshot --disk-container Format=VHDX,UserBucket="{S3Bucket=IMPORT-BUCKET-NAME,S3Key=packer-import-1662046985.vhdx}"

Following that with a aws ec2 register-image --cli-input-json "$(<register-image.json)" reports success with a "ImageId": "ami-BLAHBLAH"

Packer version

1.8.0 and 1.8.3

Simplified Packer Template

  ...cut...
  "post-processors": [
    [
      {
        "type": "artifice",
        "keep_input_artifact": false,
        "files": [
          "{{user `TEMPDIR`}}/{{build_name}}.{{user `IMAGE_IMPORT_FORMAT`}}"
        ]
      },
      {
        "type": "amazon-import",
        "region": "SOMEWHERE",
        "s3_bucket_name": "IMPORT-BUCKET-NAME",
        "ami_users": [
          "1234567890"
        ],
        "ami_name": "{{build_name}}-{{user `IMG_SFX`}}",
        "boot_mode": "uefi",
        "format": "{{user `IMAGE_IMPORT_FORMAT`}}",
        "keep_input_artifact": false,
        "tags": {
          "Name": "{{build_name}}-{{user `IMG_SFX`}}",
          "arch": "x86_64",
          "release": "fedora-{{user `FEDORA_RELEASE`}}"
        }
      },
  ...cut...

Operating system and Environment details

CentOS Stream8 container, credentials specified via AWS_SHARED_CREDENTIALS_FILE env. var.

Log Fragments and crash.log files

Eleven-billion lines like:

2022/09/01 16:44:03 packer-post-processor-amazon-import plugin: status code: 400, request id: 8a9f1460-cf21-4d69-a2f6-87eebf913b43 2022/09/01 16:44:29 packer-post-processor-amazon-import plugin: Retryable error: InvalidParameter: Parameter architecture = arm64 has an invalid format.

@cevich cevich added the bug label Sep 1, 2022
@github-actions github-actions bot removed the bug label Sep 1, 2022
@cevich
Copy link
Author

cevich commented Sep 1, 2022

Hrmmm, github-actions bot, no, I think this is definitely a bug. Though, arguably it's the shoddy AWS documentation's fault.

@cevich
Copy link
Author

cevich commented Sep 1, 2022

Hmmm, my bad, probably should report this in https://github.com/hashicorp/packer-plugin-amazon...

@cevich cevich closed this as completed Sep 1, 2022
@cevich
Copy link
Author

cevich commented Sep 1, 2022

@github-actions
Copy link

github-actions bot commented Oct 2, 2022

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 2, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
@cevich and others