1

When I'm running sudo packer2 build -debug template.json

with this code:

{
"variables": {
  "profile": "aws",
  "region": "eu-west-1"
},
"builders": [{
  "type": "amazon-chroot",
  "profile": "{{user `profile`}}",
  "region": "{{user `region`}}",
  "source_ami_filter": {
    "filters": {
      "virtualization-type": "hvm",
      "name": "xxx-hvm-*",
      "root-device-type": "ebs"
      },
    "owners": ["xxxx"],
    "most_recent": true
  },
  "ami_name": "muchos-datos-{{timestamp}}",
  "ami_description": "Muchos-Datos server",
  "root_volume_type": "gp2"
}],
"provisioners": [{
  "type": "shell",
  "inline": [
    "sleep 30",
    "yum install python3"
  ]
}]
  }

I have message:

Debug mode enabled. Builds will not be parallelized.
amazon-chroot output will be in this color.

==> amazon-chroot: Prevalidating AMI Name: muchos-datos-1575543569
==> amazon-chroot: Pausing after run of step 'StepPreValidate'. Press enter to continue. 
==> amazon-chroot: Gathering information about this EC2 instance...
==> amazon-chroot: Pausing after run of step 'StepInstanceInfo'. Press enter to continue. 
    amazon-chroot: Found Image ID: ami-06e79ab2b05283afe
==> amazon-chroot: Pausing after run of step 'StepSourceAMIInfo'. Press enter to continue. 
==> amazon-chroot: Checking the root device on source AMI...
==> amazon-chroot: Pausing after run of step 'StepCheckRootDevice'. Press enter to continue. 
==> amazon-chroot: Pausing after run of step 'StepFlock'. Press enter to continue. 
==> amazon-chroot: Pausing after run of step 'StepPrepareDevice'. Press enter to continue. 
==> amazon-chroot: Creating the root volume...
==> amazon-chroot: Error creating root volume: InvalidSnapshot.NotFound: Snapshot does not exist
==> amazon-chroot:      status code: 400, request id: 5d470db2-fe0d-4179-80db-ae36c90e32ed
==> amazon-chroot: Pausing before cleanup of step 'StepPrepareDevice'. Press enter to continue.

I tried with different AMI and packer works.

Working AMI:

    Block Devices
   /dev/xvda=snap-05d661e44b5d7433e:2:true:standard

Problematic AMI:

Block Devices
   /dev/xvda=snap-0c65d8a351a04777e:8:true:gp2

I added option "root_volume_type": "gp2" but it didn't help. What's important I can create working instance using this "Problematic AMI".

4
  • Could you explain why you run packer as sudo? I thought that only packer existed. Is packer2 an alias?
    – 030
    Dec 5 '19 at 15:52
  • I tried with sudo to avoid mounting issues. Without sudo it works the same. packer2 it's only alias to packer. btw version of packer is: 1.4.5
    – dymbol
    Dec 9 '19 at 9:04
  • Just curious. What was the reason for creating a packer2 alias?
    – 030
    Dec 9 '19 at 9:17
  • It's related with different versions of packer. Older version is aliased packer and version 1.4.5 is packer2.
    – dymbol
    Dec 9 '19 at 11:08