Terminating and EC2 instance by command line

0 votes

Is it possible to terminate all my EC2 instances at once using command line? If yes what is the command? 

Aug 9, 2018 in AWS by datageek
• 2,430 points
12 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

There is no command to terminate all instances at once. So you probably need to script it.You only need to generate a comma separated list of your instances.

This is a python script I am using:

import sys
import time
from boto.ec2.connection import EC2Connection

def main():
    conn = EC2Connection('', '')
    instances = conn.get_all_instances()
    print instances
    for reserv in instances:
        for inst in reserv.instances:
            if inst.state == u'running':
                print "Terminating instance %s" % inst
                inst.stop()

if __name__ == "__main__":
    main()

answered Aug 9, 2018 by Archana
• 4,090 points

Related Questions In AWS

0 votes
1 answer
0 votes
2 answers

How to configure Amazon EC2 command line interface?

You can use this command to create ...READ MORE

answered Feb 23 in AWS by Shashank
• 1,350 points
59 views
0 votes
1 answer
0 votes
1 answer

Stopping then starting EC2 from command line

I understand this post is 3 years ...READ MORE

answered Aug 24, 2018 in AWS by Priyaj
• 56,140 points
33 views
+3 votes
5 answers

How to move files from amazon ec2 to s3 bucket using command line

First Option sm3cmd Use s3cmd s3cmd get s3://AWS_S3_Bucket/dir/file Take a ...READ MORE

answered Aug 29, 2018 in AWS by Priyaj
• 56,140 points
1,025 views
0 votes
1 answer
+5 votes
2 answers

EC2 instance status check failed

Creating a snapshot from an EBS volume ...READ MORE

answered Mar 27, 2018 in AWS by DragonLord999
• 8,360 points
302 views
0 votes
1 answer

Create Amazon EC2 instance with API

If you are looking for a method ...READ MORE

answered Jul 20, 2018 in AWS by Archana
• 4,090 points
47 views
0 votes
1 answer

How to set up a SPF(Sender Policy Framework) for AWS EC2 instance?

Setting up a SPF record is pretty ...READ MORE

answered Aug 16, 2018 in AWS by Archana
• 4,090 points
118 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.