0 votes
1 view
in DevOps and Agile by (30k points)

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

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

Also attempted by using boto_ec2 but it gives an error that Module 'boto_ec2' is not available.

1 Answer

0 votes
by (51.2k points)

To create an ec2 instance image using saltstack just follow the steps 

you need to take a snapshot of your volume

you can create an AMI from a given snapshots

For commands of saltstack refer: https://docs.saltstack.com/en/latest/ref/clouds/all/salt.cloud.clouds.ec2.html

For creating snapshot follow the commands 

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"

To create an AMI use this 

create the AMI: register_image

salt-cloud -f register_image my-ec2-config ami_name=my_ami \

description="my description" root_device_name=/dev/xvda snapshot_id=snap-xxxxxxxx

Hope this will help to create ec2 instances using saltstack

If you need to automate this creation process

Refer: https://docs.saltstack.com/en/latest/ref/clients/#salt.cloud.CloudClient

And write a python script to automate this process of creating AMI in your servers.

Welcome to Intellipaat Community. Get your technical queries answered by top developers !