My use-case is like this:
Create a ebs backed ec2 instance which has an additional ebs volume attached that some software will be configured on during provisioning. I wish to create an AMI of this config.
So I started out by specifying no provisioners and this field in the builders object:
[{ "type": "amazon-ebs",
"access_key": BLAH BLAH,
"secret_key": "bluh bluh,
"region": "us-east-1",
"source_ami": "ami-77fcbc1e",
"instance_type": "t1.micro",
"ssh_username": "ubuntu",
"ami_name": "packer-tries-{{timestamp}}",
"ami_block_device_mappings" : [{
"device_name" : "/dev/sdf1", <<<<
"volume_size" : 20 <<<<
}]
If I create an ec2 instance from the resulting ami, I can run the following operation on it:
volpath="/dev/xvdf1" # Ubuntu maps /dev/sdf1 -> /dev/xvdf1
mountpoint="/vol"
sudo mkfs.ext4 $volpath
sudo mkdir -m 000 $mountpoint
echo "$volpath $mountpoint auto noatime 0 0" | sudo tee -a /etc/fstab
sudo mount $mountpoint
So I added the above to a script and wrote a builder:
"provisioners": [
{
"type": "shell",
"scripts" : [
"scripts/setup.sh"
]
}
]
Now while this script executes during the provisioning phase on the temporary ec2 instance I get a device not found error:
$ packer build template.json
amazon-ebs output will be in this color.
==> amazon-ebs: Creating temporary keypair for this instance...
==> amazon-ebs: Creating temporary security group for this instance...
==> amazon-ebs: Authorizing SSH access on the temporary security group...
==> amazon-ebs: Launching a source AWS instance...
==> amazon-ebs: Waiting for instance (i-312f8953) to become ready...
==> amazon-ebs: Waiting for SSH to become available...
==> amazon-ebs: Connected to SSH!
==> amazon-ebs: Provisioning with shell script: scripts/setup.sh
amazon-ebs: mke2fs 1.42.5 (29-Jul-2012)
amazon-ebs: Could not stat /dev/xvdf1 --- No such file or directory
amazon-ebs:
amazon-ebs: The device apparently does not exist; did you specify it correctly?
amazon-ebs: /dev/xvdf1 /vol auto noatime 0 0
amazon-ebs: mount: special device /dev/xvdf1 does not exist
What is wrong? Should I be using the amazon-chroot to get this to work?
Thanks in advance for any pointers!