hashicorp / packer-plugin-amazon

Packer plugin for Amazon AMI Builder
https://www.packer.io/docs/builders/amazon
Mozilla Public License 2.0
76 stars 112 forks source link

Parallel build of AMIs fails consistently #276

Open hc-github-team-packer opened 2 years ago

hc-github-team-packer commented 2 years ago

This issue was originally opened by @diaasami in https://github.com/hashicorp/packer/issues/11976 and has been migrated to this repository. The original issue description is below.


Community Note

Overview of the Issue

When building multiple amazon AMIs, one of them always fails with ResourceNotReady: exceeded wait attempts. Adding aws_polling block doesn't help, I tried up to a combined wait of up to 3 hours. Running the same packer config with parallel builds disabled (-parallel-builds=1) succeeds without even aws_polling block.

Reproduction Steps

Steps to reproduce this issue

  1. Save the file below as aws-ubuntu.pkr.hcl in an arbitrary new folder.
  2. Run packer build . in the same folder

Notes:

Packer version

Packer v1.8.3

Simplified Packer Template

source "amazon-ebs" "ubuntu" {
  ami_name     = "learn-packer-linux-aws"
  region       = "us-east-1"
  ssh_username = "ubuntu"

  # Remove previous image before making the new one.
  force_deregister      = true
  force_delete_snapshot = true
}

build {
  source "amazon-ebs.ubuntu" {
    name          = "test-packer-x86"
    instance_type = "t2.micro"

    source_ami_filter {
      filters = {
        name                = "ubuntu/images/*ubuntu-xenial-16.04-amd64-server-*"
        root-device-type    = "ebs"
        virtualization-type = "hvm"
      }
      most_recent = true
      owners      = ["099720109477"]
    }
  }

  source "amazon-ebs.ubuntu" {
    name          = "test-packer-aarch64"
    instance_type = "c6g.large"

    source_ami_filter {
      filters = {
        name                = "ubuntu/images/*ubuntu-xenial-16.04-arm64-server-*"
        root-device-type    = "ebs"
        virtualization-type = "hvm"
      }
      most_recent = true
      owners      = ["099720109477"]
    }
  }
}

Operating system and Environment details

Fedora 35, x86_64