Posts Tagged AWS
AWS automation script which supports “--clone” as “Launch More Like This” on web console
Posted by mcsrainbow in Linux&Unix on December 27, 2014
I just completed an automation script for AWS, it supports “--clone” function, likes the “Launch More Like This” on AWS web console, based on Python boto library.
Address:https://github.com/mcsrainbow/python-demos/blob/master/demos/awscli.py
$ ./awscli.py -h
usage: awscli.py [-h] (--create | --clone | --terminate) --region REGION [--instance_name INSTANCE_NAME] [--image_id IMAGE_ID] [--instance_type INSTANCE_TYPE] [--key_name KEY_NAME] [--security_group_ids SECURITY_GROUP_IDS] [--subnet_id SUBNET_ID] [--src_instance_name SRC_INSTANCE_NAME] [--dest_instance_name DEST_INSTANCE_NAME] [--private_ip_address PRIVATE_IP_ADDRESS] [--instance_id INSTANCE_ID] [--volume_size VOLUME_SIZE] [--volume_type {standard,io1,gp2}] [--volume_zone VOLUME_ZONE] [--volume_iops VOLUME_IOPS] [--volume_delete_on_termination] [--load_balancer_name LOAD_BALANCER_NAME] [--ignore_load_balancer] [--quick] examples: ./awscli.py --create --region us-west-1 --instance_name idc1-server2 \ --image_id ami-30f01234 --instance_type t1.micro \ --key_name idc1-keypair1 --security_group_ids sg-eaf01234f \ --subnet_id subnet-6d901234 ./awscli.py --create --region us-west-1 --instance_name idc1-server3 \ --image_id ami-30f01234 --instance_type t1.micro \ --key_name idc1-keypair1 --security_group_ids sg-eaf01234f \ --subnet_id subnet-6d901234 --volume_size 10 --volume_type gp2 \ --volume_zone us-west-1a --volume_delete_on_termination \ --load_balancer_name idc1-elb1 --private_ip_address 172.16.2.23 ./awscli.py --clone --region us-west-1 --src_instance_name idc1-server1 \ --dest_instance_name idc1-server2 ./awscli.py --clone --region us-west-1 --src_instance_name idc1-server1 \ --dest_instance_name idc1-server3 --private_ip_address 172.16.2.23 ./awscli.py --clone --region us-west-1 --src_instance_name idc1-server1 \ --dest_instance_name idc1-server3 --private_ip_address 172.16.2.23 \ --ignore_load_balancer ./awscli.py --terminate --region us-west-1 --instance_name idc1-server3 ./awscli.py --terminate --region us-west-1 --instance_id i-01234abc ./awscli.py --terminate --region us-west-1 --instance_id i-01234abc --quick ... optional arguments: -h, --help show this help message and exit --create create instance --clone clone instance --terminate terminate instance --region REGION --instance_name INSTANCE_NAME --image_id IMAGE_ID --instance_type INSTANCE_TYPE --key_name KEY_NAME --security_group_ids SECURITY_GROUP_IDS --subnet_id SUBNET_ID --src_instance_name SRC_INSTANCE_NAME --dest_instance_name DEST_INSTANCE_NAME --private_ip_address PRIVATE_IP_ADDRESS --instance_id INSTANCE_ID --volume_size VOLUME_SIZE in GiB --volume_type {standard,io1,gp2} --volume_zone VOLUME_ZONE --volume_iops VOLUME_IOPS --volume_delete_on_termination delete volumes on termination --load_balancer_name LOAD_BALANCER_NAME --ignore_load_balancer ignore load balancer setting --quick no wait on termination ... optional arguments: -h, --help show this help message and exit --create create instance --clone clone instance --terminate terminate instance --region REGION --instance_name INSTANCE_NAME --image_id IMAGE_ID --instance_type INSTANCE_TYPE --key_name KEY_NAME --security_group_ids SECURITY_GROUP_IDS --subnet_id SUBNET_ID --src_instance_name SRC_INSTANCE_NAME --dest_instance_name DEST_INSTANCE_NAME --private_ip_address PRIVATE_IP_ADDRESS --instance_id INSTANCE_ID --volume_size VOLUME_SIZE in GiB --volume_type {standard,io1,gp2} --volume_zone VOLUME_ZONE --volume_iops VOLUME_IOPS --volume_delete_on_termination delete volumes on termination --load_balancer_name LOAD_BALANCER_NAME --quick no wait on termination
$ ./awscli.py --create --region us-west-1 --instance_name idc1-server1 --image_id ami-30f01234 \
--instance_type t1.micro --key_name idc1-keypair1 --security_group_ids sg-eaf01234f \
--subnet_id subnet-6d901234 --volume_size 10 --volume_type gp2 --volume_zone us-west-1a \
--volume_delete_on_termination --load_balancer_name idc1-elb1 --private_ip_address 172.16.2.21
1. Launching instance: idc1-server1 2. Creating tag as instance name: {"Name": idc1-server1} Instance state: pending Instance state: running 3. Creating secondary volume for instance: idc1-server1 as gp2 10G Volume status: available 4. Attaching volume: vol-4ba6a54c to instance: idc1-server1 as device: /dev/sdf 5. Adding instance: idc1-server1 to ELB: idc1-elb1
$ ./awscli.py --clone --region us-west-1 --src_instance_name idc1-server1 --dest_instance_name idc1-server2
1. Launching instance: idc1-server2 2. Creating tag as instance name: {"Name": idc1-server2} Instance state: pending Instance state: running 3. Creating secondary volume for instance: idc1-server2 as gp2 10G Volume status: available 4. Attaching volume: vol-5b61635c to instance: idc1-server2 as device: /dev/sdf 5. Adding instance: idc1-server2 to ELB: idc1-elb1
$ ./awscli.py --terminate --region us-west-1 --instance_name idc1-server2
Terminating instance: idc1-server2 id: i-86976d62 Instance state: shutting-down Instance state: shutting-down Instance state: terminated
Recent Comments
pls tell me how to lock the target directory of the bbcp user?
Hi, i am trying to send out mail to office 365 and i am getting below error…
How to do the above settings for windows 7 machine and jenkins hosted on tomcat installed on the same machine??
Hey pal, who said pfSense sucks screw you!
Hey dear can we done some Project together ? i am from iran and i have some…
Upload it to Mega.nz
How can I replicate this issue.? I also faced the same problem, where all the cron entries lost. Not sure…
Hi, I am trying to integrate Jenkins with office365 and as mentioned above, (please correct me if i am…
Hi, I am trying to integrate Jenkins with office365 and as mentioned above, (please correct me if i am…
Vishal : shreyas :…