Skip to content

Commit

Permalink
Externalise instance type
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielThomas committed Oct 28, 2016
1 parent 4c8c083 commit fe5cb90
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions ec2gaming-instance.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
source "$(dirname "$0")/ec2gaming.header"

# Verify that the gaming stane actually exists (and that there's only one)
INSTANCES=$(aws ec2 describe-instances --filters Name=instance-state-code,Values=16 Name=instance-type,Values=g2.2xlarge)
INSTANCES=$(aws ec2 describe-instances --filters Name=instance-state-code,Values=16 Name=instance-type,Values="$INSTANCE_TYPE")
if [ "$(echo "$INSTANCES" | jq '.Reservations | length')" -ne "1" ]; then
>&2 echo "didn't find an instance or there wasn't exactly one g2.2xlarge instance"
>&2 echo "didn't find an instance or there wasn't exactly one $INSTANCE_TYPE instance"
exit 1
fi
echo "$INSTANCES" | jq --raw-output '.Reservations[0].Instances[0].InstanceId'
2 changes: 1 addition & 1 deletion ec2gaming-price.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env bash
source "$(dirname "$0")/ec2gaming.header"

aws ec2 describe-spot-price-history --instance-types g2.2xlarge --product-descriptions "Windows" --start-time `date +%s` | jq --raw-output '.SpotPriceHistory|=sort_by(.SpotPrice)|first(.SpotPriceHistory[].SpotPrice), first(.SpotPriceHistory[].AvailabilityZone)'
aws ec2 describe-spot-price-history --instance-types "$INSTANCE_TYPE" --product-descriptions "Windows" --start-time `date +%s` | jq --raw-output '.SpotPriceHistory|=sort_by(.SpotPrice)|first(.SpotPriceHistory[].SpotPrice), first(.SpotPriceHistory[].AvailabilityZone)'
4 changes: 2 additions & 2 deletions ec2gaming-start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ source "$(dirname "$0")/ec2gaming.header"

BOOTSTRAP=0

echo -n "Getting lowest g2.2xlarge bid... "
echo -n "Getting lowest $INSTANCE_TYPE bid... "
PRICE_AND_ZONE=($(./ec2gaming-price.sh))
PRICE=${PRICE_AND_ZONE[0]}
ZONE=${PRICE_AND_ZONE[1]}
Expand Down Expand Up @@ -44,7 +44,7 @@ SPOT_INSTANCE_ID=$(aws ec2 request-spot-instances --spot-price "$FINAL_SPOT_PRIC
{
\"SecurityGroupIds\": [\"$EC2_SECURITY_GROUP_ID\"],
\"ImageId\": \"$AMI_ID\",
\"InstanceType\": \"g2.2xlarge\",
\"InstanceType\": \"$INSTANCE_TYPE\",
\"Placement\": {
\"AvailabilityZone\": \"$ZONE\"
}
Expand Down
1 change: 1 addition & 0 deletions ec2gaming.cfg
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
INSTANCE_TYPE="g2.2xlarge"
SPOT_PRICE_BUFFER="0.10"

0 comments on commit fe5cb90

Please sign in to comment.