amazon web services - attach ebs volume with packer during build time -


i'm not sure if right way go i'm looking shorten build time of image packer. 1 of steps required copy 10gb of data , make part of image. i'm using shell provisioner sftp in image. takes long time. instead have data in ebs volume can attached @ build time. since mounted block device in amazon's own network transfer faster sftp.

i tried searching around such method in packer there's not out there. i'm going try , see if can use ami_block_device_mappings optional parameter in amazon-ebs builder attach ebs volume.

if there better method i'm not aware of please let me know. thanks.

so looks shell provisioner way go..for now. shell provisioner seems catch things :). have parameter in amazon-ebs builder @ point though. "attach_ebs_volume" instance. anyway, here's how did it:

  1. add aws info (ebs_volume, instance_id etc..) variables secion of template. pull access , secret key env it's not spelled out in template rest define in template now.
  2. use "environment_vars" parameter in provisioners block in template pass variables build machine.
  3. add {{.vars}} "execute_command" parameter vars defined prior script run.
  4. install aws cli (part of script being passed.)
  5. grab instance_id of build machine meta_data via wget , assign env var.
  6. issue aws cli command attach volume , use env vars passed template fill in command options instance_id wget command.
  7. mount normal (have sleep few seconds before mounting, takes little time attach. otherwise won't see , mount fail.)

done.

if has more elegant way... please share.

thanks.


Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

visual studio 2010 - Connect to informix database windows form application -

android - Associate same looper with different threads -