Fred Damstra před 9 roky
rodič
revize
76c05361c2
3 změnil soubory, kde provedl 29 přidání a 5 odebrání
  1. 9 4
      FindInstanceInProfile.sh
  2. 8 1
      README.md
  3. 12 0
      TestBoto.py

+ 9 - 4
FindInstanceInProfile.sh

@@ -4,11 +4,12 @@
 #  FindInstanceInAccount.sh <instanceid> <accountname>
 
 if [ $# -ne 2 ]; then
-	echo Usage: $0 "<instanceid> <profile>"
+	echo Usage: $0 "<searchstring> <profile>"
 	exit 1
 fi
 
-INSTANCEID=$1
+# TODO: Sanitize search string
+SEARCHSTRING=$1
 PROFILE=$2
 
 # Cool, grab regions dynamically
@@ -16,8 +17,12 @@ REGIONS=$(aws ec2 describe-regions --profile $PROFILE --output text --query 'Reg
 
 for region in $REGIONS; do
 	(
-	         aws ec2 describe-instances --profile $PROFILE --region $region --instance-id $INSTANCEID &> /dev/null && \
-			 echo "$INSTANCEID is in $region under profile $PROFILE"
+		 # Search by instance ID:
+	         aws ec2 describe-instances --profile $PROFILE --region $region --instance-id $SEARCHSTRING &> /dev/null && \
+			 echo "$SEARCHSTRING is in $region under profile $PROFILE"
+		 # Search by Name:
+	         aws ec2 describe-instances --profile $PROFILE --region $region --filter "Name=tag:Name,Values=$SEARCHSTRING" &> /dev/null && \
+			 echo "$SEARCHSTRING is in $region under profile $PROFILE"
 	) &
 done 2> /dev/null
 

+ 8 - 1
README.md

@@ -1,3 +1,10 @@
 # aws-scripts
 
-Scripts to make life with AWS more manageable. Some are specific to my instances.
+Scripts to make life with AWS more manageable. Some are specific to my instances.
+
+Prerequisite: boto3. To install, run:
+	sudo easy_install pip && pip install boto3
+On El Capitan, I had to run:
+	sudo -H pip install --ignore-installed six --upgrade boto3
+
+

+ 12 - 0
TestBoto.py

@@ -0,0 +1,12 @@
+#!/usr/bin/python
+# 
+# Just tests boto and default credentials
+import boto3
+
+boto3.set_stream_logger('botocore', level='DEBUG') 
+
+s3 = boto3.resource('s3')
+for bucket in s3.buckets.all():
+	print(bucket.name)
+
+