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:
- 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.
- use "environment_vars" parameter in provisioners block in template pass variables build machine.
- add {{.vars}} "execute_command" parameter vars defined prior script run.
- install aws cli (part of script being passed.)
- grab instance_id of build machine meta_data via wget , assign env var.
- issue aws cli command attach volume , use env vars passed template fill in command options instance_id wget command.
- 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
Post a Comment