Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
Checking mergeability… Don’t worry, you can still create the pull request.
  • 2 commits
  • 2 files changed
  • 0 commit comments
  • 1 contributor
Showing with 12 additions and 8 deletions.
  1. +11 −7 bin/ec2-host
  2. +1 −1 bin/ec2-ssh
View
18 bin/ec2-host
@@ -6,25 +6,26 @@ import getopt
from sys import stderr
-import boto
+import boto, boto.ec2
_ec2 = None
def short_usage():
- print >>stderr, """Usage: ec2-host [-k KEY] [-s SECRET] [NAME]
+ print >>stderr, """Usage: ec2-host [-k KEY] [-s SECRET] [-r REGION] [NAME]
ec2-host django8 => ec2-53-19-113-121.compute-1.amazonaws.com
Try `ssh-distillery --help' for more information."""
def full_usage():
- print >>stderr, """Usage: ec2-host [-k KEY] [-s SECRET] [NAME]
+ print >>stderr, """Usage: ec2-host [-k KEY] [-s SECRET] [-r REGION] [NAME]
Prints server host name.
--help display this help and exit
-k, --aws-key KEY Amazon EC2 Key, defaults to ENV[AWS_ACCESS_KEY_ID]
- -s, --aws-secret SECRET Amazon EC2 Secret, defaults to ENV[AWS_SECRET_ACCESS_KEY]"""
+ -s, --aws-secret SECRET Amazon EC2 Secret, defaults to ENV[AWS_SECRET_ACCESS_KEY]
+ -r, --region REGION Amazon EC2 Region, defaults to ENV[EC2_REGION] or otherwise us-east-1"""
def list_instances():
@@ -62,8 +63,8 @@ def ec2_instances(**kwargs):
def main(argv):
try:
- opts, args = getopt.getopt(argv, "hLk:s:",
- ["help", "aws-key", "aws-secret"])
+ opts, args = getopt.getopt(argv, "hLk:s:r:",
+ ["help", "aws-key", "aws-secret", "region"])
except getopt.GetoptError, err:
print >>sys.stderr, err
short_usage()
@@ -71,6 +72,7 @@ def main(argv):
aws_key = os.environ.get("AWS_ACCESS_KEY_ID")
aws_secret = os.environ.get("AWS_SECRET_ACCESS_KEY")
+ region = os.environ.get("EC2_REGION", 'us-east-1')
for opt, arg in opts:
if opt in ("-h", "--help"):
@@ -80,6 +82,8 @@ def main(argv):
aws_key = arg
elif opt in("-s", "--aws-secret"):
aws_secret = arg
+ elif opt in("-r", "--region"):
+ region = arg
if not aws_key or not aws_secret:
if not aws_key:
@@ -96,7 +100,7 @@ def main(argv):
sys.exit(2)
global _ec2
- _ec2 = boto.connect_ec2(aws_key, aws_secret)
+ _ec2 = boto.ec2.connect_to_region(region, aws_access_key_id=aws_key, aws_secret_access_key=aws_secret)
argc = len(args)
if argc == 0:
View
2 bin/ec2-ssh
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
#/ Usage: ec2-ssh <instance-name>
#/ Open ssh connection to EC2 instance where tag:Name=<instance-name>
#/ For list of instance, run ec2-host without any paramteres

No commit comments for this range

Something went wrong with that request. Please try again.