Git Product home page Git Product logo

/usr/bin/python2.7

written by Ego Joseph on 29/09/2021 for Alfred and Victoria

specify AWS keys

import boto.ec2 import sys

specify AWS keys

auth = {"aws_access_key_id": "<key_id>", "aws_secret_access_key": "<access_key>"}

def main(): # read arguments from the command line and # check whether at least two elements were entered if len(sys.argv) < 2: print "Usage: python aws.py {start|stop}\n" sys.exit(0) else: action = sys.argv[1]

if action == "start":
startInstance()
elif action == "stop":
	stopInstance()
else:
	print "Usage: python aws.py {start|stop}\n"

def startInstance(): print "Starting the instance..."

# change "eu-west-1" region if different
try:
    ec2 = boto.ec2.connect_to_region("eu-west-1", **auth)

except Exception, e1:
    error1 = "Error1: %s" % str(e1)
    print(error1)
    sys.exit(0)

# change instance ID appropriately  
try:
     ec2.start_instances(instance_ids="i-12345678")

except Exception, e2:
    error2 = "Error2: %s" % str(e2)
    print(error2)
    sys.exit(0)

def stopInstance(): print "Stopping the instance..."

try:
    ec2 = boto.ec2.connect_to_region("eu-west-1", **auth)

except Exception, e1:
    error1 = "Error1: %s" % str(e1)
    print(error1)
    sys.exit(0)

try:
     ec2.stop_instances(instance_ids="i-12345678")

except Exception, e2:
    error2 = "Error2: %s" % str(e2)
    print(error2)
    sys.exit(0)

if name == 'main': main()

Ego Joseph Oborakpororo's Projects

easyedit icon easyedit

An Easy-to-use Knowledge Editing Framework for LLMs.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.