Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating AWS EC2 instance image using saltstack?

Has anybody tried creating AWS AMI(image) using saltstack.

I tried using it was able to create new instance from existing AMIs but how to create image using salt-cloud?

Also attempted by using boto_ec2 but its give error that Module 'boto_ec2' is not available.

like image 356
Vaseem Ahmed Khan Avatar asked Sep 02 '16 10:09

Vaseem Ahmed Khan


1 Answers

You can do that in 2 steps:

  1. you need to take a snapshot of your volume
  2. you can create an AMI from a given snapshots

You can see all saltstack ec2 commands at https://docs.saltstack.com/en/latest/ref/clouds/all/salt.cloud.clouds.ec2.html

  1. create the snapshots : create_snapshot

    salt-cloud -f create_snapshot my-ec2-config volume_id=vol-351d8826
    salt-cloud -f create_snapshot my-ec2-config volume_id=vol-351d8826 \
    description="My Snapshot Description"
    
  2. create the AMI : register_image

This command creates an ami from a snapshot

salt-cloud -f register_image my-ec2-config ami_name=my_ami \
description="my description" root_device_name=/dev/xvda snapshot_id=snap-xxxxxxxx
like image 123
Frederic Henri Avatar answered Sep 26 '22 04:09

Frederic Henri