6

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.

1 Answers1

1

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
Frederic Henri
  • 51,761
  • 10
  • 113
  • 139
  • But i wanted to create another clone given a instance ids or a list of ids. as this has to be done for say 50 servers. as this process is not help in automation. – Vaseem Ahmed Khan Sep 09 '16 at 12:38
  • 3
    What you should do then is use the [CloudClient](https://docs.saltstack.com/en/latest/ref/clients/#salt.cloud.CloudClient) and write a python script to automate running this over all the servers that you want images of. – gtmanfred May 18 '17 at 19:42