參考1
On Ubuntu
If U use python3 instead of python
#sudo apt-get install python3-pip
#pip3 install boto
#vi ~/.boto
-----------------------------------------
[Credentials]
aws_access_key_id = <Your Key Id>
aws_secret_access_key = <Your Secret Key>
-----------------------------------------
#vi aws.py
----------------------------------------
#!/usr/bin/python3
import boto.ec2
conn = boto.ec2.connect_to_region('ap-southeast-1')
print(conn.get_all_reservations())
-----------------------------------------
#stop instance:i-8xxxx
a=['i-8xxxx']
print(conn.stop_instances(a))
#start instance:i-8xxxx
a=['i-8xxxx']
print(conn.start_instances(a))
#get instance: i-3686d661 state
#get_only_instances回傳boto.ec2.instance.Instance的list
#而boto.ec2.instance.Instance有state的屬性
print(conn.get_only_instances('i-3686d661')[0].state)
- Dec 02 Tue 2014 13:40
boto module of Python3
close
全站熱搜
留言列表