-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Trying the changes made by sclausson from extenda. https://github.com/extenda/aws-helper-scripts
- Loading branch information
Showing
2 changed files
with
46 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,21 @@ | ||
# Exit the script if any command returns an error | ||
#set -e | ||
|
||
# Check that Amazon EC2 API Tools are installed. | ||
if ! type ec2-version >/dev/null 2>&1; then | ||
echo "Error: Cannot find Amazon EC2 API Tools please install from http://s3.amazonaws.com/ec2-downloads/ec2-api-tools.zip" | ||
echo " and ensure the directory is in the servers path variable." | ||
# Check that Amazon AWS CLI is installed. | ||
aws --version >/dev/null 2>&1 | ||
if [ ! $? -eq 0 ] ; then | ||
echo "Error: Cannot find Amazon AWS CLI please see http://docs.aws.amazon.com/cli/latest/userguide/installing.html for installation information" | ||
echo | ||
exit 1 | ||
fi | ||
|
||
CURL_META_DATA="curl --retry 3 --silent --show-error --fail -L http://169.254.169.254/2011-01-01" | ||
CURL_META_DATA="curl --retry 3 --silent --show-error --fail -L http://169.254.169.254/latest" | ||
|
||
INSTANCE_ID=$($CURL_META_DATA/meta-data/instance-id) | ||
REGION=$($CURL_META_DATA/dynamic/instance-identity/document|grep region|awk -F\" '{print $4}') | ||
AVAILABILITY_ZONE=$($CURL_META_DATA/meta-data/placement/availability-zone) | ||
IP=$($CURL_META_DATA/meta-data/public-ipv4) | ||
PUBLIC_IP=$($CURL_META_DATA/meta-data/public-ipv4) | ||
PRIVATE_IP=$($CURL_META_DATA/meta-data/local-ipv4) | ||
|
||
echo "Setting AWS CLI Region to $REGION" | ||
$(aws configure set region $REGION) |