johnallen3d
1/8/2016 - 5:36 PM

Create an elastigroup cluster on spotinst.com

Create an elastigroup cluster on spotinst.com

#!/bin/bash

PASSWORD=$1

if [[ $1 = '' ]]; then
  echo Please provide your spotinst password
  exit 1
fi

echo $PASSWORD
echo "username=john.allen@technekes.com&password=${PASSWORD}&grant_type=password&client_id=yZRQ4akeqQMZTG0g&client_secret=HzmdK7Aih17Xk4LkNDqflzByGOL00tOV"

TOKEN=$(
  curl \
    -X POST \
    -H "Content-Type: application/x-www-form-urlencoded" \
    -d "username=john.allen@technekes.com&password=${PASSWORD}&grant_type=password&client_id=yZRQ4akeqQMZTG0g&client_secret=HzmdK7Aih17Xk4LkNDqflzByGOL00tOV" \
    https://www.spotinst.com:9540/token \
  | jq '.response.items[0].accessToken'
)

echo $TOKEN

curl \
  -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer ${TOKEN}" \
  -d @clusters/tk-qa-pap-ecs.json \
  'https://www.spotinst.com:8081/aws/ec2/group'