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

Failed to copy AMI to multiple regions #12779

Closed
megablend opened this issue Jan 9, 2024 · 2 comments
Closed

Failed to copy AMI to multiple regions #12779

megablend opened this issue Jan 9, 2024 · 2 comments
Labels

Comments

@megablend
Copy link

Overview of the Issue

Creating AMI with multiple regions fail with below error:

==> Sample Build (Ubuntu 20.04) 2024-01-09-1819-23.3.0-98-55.amazon-ebs.connector-ami: Deregistering the AMI and deleting associated snapshots because of cancellation, or error...
==> Sample Build (Ubuntu 20.04) 2024-01-09-1819-23.3.0-98-55.amazon-ebs.connector-ami: Provisioning step had errors: Running the cleanup provisioner, if present...
==> Sample Build (Ubuntu 20.04) 2024-01-09-1819-23.3.0-98-55.amazon-ebs.connector-ami: Terminating the source AWS instance...
==> Sample Build (Ubuntu 20.04) 2024-01-09-1819-23.3.0-98-55.amazon-ebs.connector-ami: Cleaning up any extra volumes...
==> Sample Build (Ubuntu 20.04) 2024-01-09-1819-23.3.0-98-55.amazon-ebs.connector-ami: No volumes to clean up, skipping
==> Sample Build (Ubuntu 20.04) 2024-01-09-1819-23.3.0-98-55.amazon-ebs.connector-ami: Deleting temporary keypair...
2024/01/09 13:38:11 [INFO] (telemetry) ending amazon-ebs.connector-ami

* Error waiting for AMI (ami-07bbe6f7e88aa7b90) in region (us-east-1): Failed with ResourceNotReady error, which can have a variety of causes. For help troubleshooting, check our docs: https://www.packer.io/docs/builders/amazon.html#resourcenotready-error
original error: ResourceNotReady: failed waiting for successful resource state
==> Wait completed after 18 minutes 18 seconds
2024/01/09 13:38:11 machine readable: error-count []string{"1"}
==> Some builds didn't complete successfully and had errors:
Build 'Sample Build (Ubuntu 20.04) 2024-01-09-1819-23.3.0-98-55.amazon-ebs.connector-ami' errored after 18 minutes 18 seconds: 1 error(s) occurred:
2024/01/09 13:38:11 machine readable: Sample Build (Ubuntu 20.04) 2024-01-09-1819-23.3.0-98-55.amazon-ebs.connector-ami,error []string{"1 error(s) occurred:\n\n* Error waiting for AMI (ami-07bbe6f7e88aa7b90) in region (us-east-1): Failed with ResourceNotReady error, which can have a variety of causes. For help troubleshooting, check our docs: https://www.packer.io/docs/builders/amazon.html#resourcenotready-error\noriginal error: ResourceNotReady: failed waiting for successful resource state"}


* Error waiting for AMI (ami-07bbe6f7e88aa7b90) in region (us-east-1): Failed with ResourceNotReady error, which can have a variety of causes. For help troubleshooting, check our docs: https://www.packer.io/docs/builders/amazon.html#resourcenotready-error
original error: ResourceNotReady: failed waiting for successful resource state
==> Builds finished but no artifacts were created.
2024/01/09 13:38:11 [INFO] (telemetry) Finalizing.
* Error waiting for AMI (ami-07bbe6f7e88aa7b90) in region (us-east-1): Failed with ResourceNotReady error, which can have a variety of causes. For help troubleshooting, check our docs: https://www.packer.io/docs/builders/amazon.html#resourcenotready-error
original error: ResourceNotReady: failed waiting for successful resource state

Note: I created a KMS key with multi region support with the hope that it will work across regions. I added all the required permissions for KMS and it works for the build region and not the other regions.

Reproduction Steps

Here is a sample template I used

encrypt_boot         = true
  kms_key_id           = var.volume_encryption_key
  region_kms_key_ids   = {for _region in var.regions : _region => var.volume_encryption_key}
  ami_regions          = var.regions
  vpc_id               = var.vpc_id
  security_group_id    = var.security_group_id
  subnet_id            = var.subnet_id
  ena_support          = true
  iam_instance_profile = var.iam_instance_profile

  launch_block_device_mappings {
    device_name           = "/dev/sda1"
    volume_size           = 20
    volume_type           = "gp3"
    kms_key_id            = var.volume_encryption_key
    encrypted             = true
    delete_on_termination = true
  }

Steps to reproduce this issue

Packer version

From packer version

Packer v1.9.4

Your version of Packer is out of date! The latest version
is 1.10.0. You can update by downloading from www.packer.io/downloads
@megablend megablend added the bug label Jan 9, 2024
@megablend
Copy link
Author

megablend commented Jan 20, 2024

Turns out the solution was mostly using a multi-region KMS and replicating the key to the desired regions, using a single-region key will result to this error.

Copy link

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 Feb 20, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

1 participant