Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Python with boto script aws...help!

  • 23-11-2013 05:37PM
    #1
    Registered Users, Registered Users 2 Posts: 196 ✭✭


    I'm new to python and programming in general. I have been trying to write a script in python implementing the boto library to monitor instances that are running in my EC2 amazon web services account. Below is my script:
    __________________________________________________________
         import boto
         import boto.ec2
         import time
    
         key_id = "*******"
         secret_key = "********"
    
        region = boto.ec2.get_region("eu-west-1", aws_access_key_id=key_id,                                                                                  aws_secret_access_key=secret_key)
        print region
    
                                                                                                                                                                         conn =    boto.connect_ec2(aws_access_key_id=key_id,aws_secret_access_key=secret_key,region=region)
    
            reservation = conn.run_instances('<ami-a63edbd1>',key_name='*******')
    
            for inst in reservation.instances:
            if instance.state == u'running' :
            
             print "Running AWS EC2 instances"
             print"%s" % (inst.id, inst.type, region.placement, inst.launch_time)
    
    __________________________________________________________

    Any help would be much appreciated! Thanks


Comments

  • Registered Users, Registered Users 2 Posts: 7,157 ✭✭✭srsly78


    Indentation is not optional, use code tags when pasting python here.

    Like this:
       print "this stuff is inside code tags"
    


  • Registered Users, Registered Users 2 Posts: 196 ✭✭Senor Frog


    I keep getting the following error:


  • Registered Users, Registered Users 2 Posts: 7,098 ✭✭✭Talisman


    The error message tells you exactly what the problem is:

    < is <
    > is >
    reservation = conn.run_instances('<ami-a63edbd1>',key_name='*******')

    So get rid of the angle brackets in the line above.


Advertisement