| Server IP : 52.9.100.119 / Your IP : 216.73.216.207 Web Server : Apache/2.4.61 (Amazon) OpenSSL/1.0.2k-fips PHP/7.3.30 Phusion_Passenger/5.1.5 System : Linux ip-172-31-9-35 4.14.355-196.618.amzn1.x86_64 #1 SMP Mon Apr 7 17:09:50 UTC 2025 x86_64 User : root ( 0) PHP Version : 7.3.30 Disable Function : exec,passthru,shell_exec,system,popen,proc_open MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /usr/bin/ |
Upload File : |
#!/usr/bin/python2.7
import sys
from optparse import OptionParser
import boto
from boto.ec2 import regions
def kill_instance(region, ids):
"""Kill an instances given it's instance IDs"""
# Connect the region
ec2 = boto.connect_ec2(region=region)
for instance_id in ids:
print("Stopping instance: %s" % instance_id)
ec2.terminate_instances([instance_id])
if __name__ == "__main__":
parser = OptionParser(usage="kill_instance [-r] id [id ...]")
parser.add_option("-r", "--region", help="Region (default us-east-1)", dest="region", default="us-east-1")
(options, args) = parser.parse_args()
if not args:
parser.print_help()
sys.exit(1)
for r in regions():
if r.name == options.region:
region = r
break
else:
print("Region %s not found." % options.region)
sys.exit(1)
kill_instance(region, args)