close

參考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)

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 slinbody 的頭像
    slinbody

    495884965

    slinbody 發表在 痞客邦 留言(0) 人氣()