Advertisement
Guest User

Untitled

a guest
Feb 9th, 2016
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.99 KB | None | 0 0
  1. #!/usr/bin/env bash
  2.  
  3. key_name=hww-meta-emr-dev
  4.  
  5. alias emr-ls="aws emr list-clusters \
  6. | jsawk 'return this.Clusters' \
  7. | jsawk -n 'out(this.Id, this.Name, this.Status.State)' \
  8. | column -t -s','"
  9. alias emr-info="aws emr list-instances --cluster-id"
  10. alias emr-rm='aws emr terminate-clusters --cluster-ids'
  11.  
  12. function emr-create() {
  13. if [ $# -ne 2 ]; then
  14. echo emr-create \<instance-name\> \<instance-count\>
  15. return
  16. fi
  17. aws emr create-cluster \
  18. --applications Name=Hadoop Name=Hive Name=Hue Name=Spark Name=Ganglia Name=Mahout Name=Zeppelin-Sandbox \
  19. --name ${1} \
  20. --region us-east-1 \
  21. --release-label emr-4.3.0 \
  22. --instance-groups \
  23. '[
  24. {"InstanceGroupType":"MASTER","InstanceCount":1, "BidPrice":"0.045", "InstanceType":"m3.xlarge"},
  25. {"InstanceGroupType":"CORE", "InstanceCount":'"${2}"', "BidPrice":"0.045", "InstanceType":"m3.xlarge"}
  26. ]' \
  27. --ec2-attributes \
  28. '{"KeyName":"'"$key_name\""',
  29. "InstanceProfile":"EMR_EC2_DefaultRole",
  30. "SubnetId":"subnet-5f24b462",
  31. "EmrManagedSlaveSecurityGroup":"sg-3cdeff45",
  32. "EmrManagedMasterSecurityGroup":"sg-3ddeff44"}'
  33. }
  34.  
  35. function ec2-price() {
  36. instance_type=m3.xlarge
  37. if [ ! -z $1 ]; then
  38. instance_type=$1
  39. fi
  40. echo latest price for instance $instance_type :
  41. echo "us-east-1a = " $(ec2-region-price $instance_type us-east-1a | tail -1)
  42. echo "us-east-1b = " $(ec2-region-price $instance_type us-east-1b | tail -1)
  43. # echo "us-east-1c = " $(ec2-region-price $instance_type us-east-1c | tail -1)
  44. echo "us-east-1d = " $(ec2-region-price $instance_type us-east-1d | tail -1)
  45. echo "us-east-1e = " $(ec2-region-price $instance_type us-east-1e | tail -1)
  46. }
  47.  
  48. function ec2-region-price() {
  49. aws ec2 describe-spot-price-history \
  50. --instance-types ${1} \
  51. --start-time $(date -j -v-30M "+%Y-%m-%dT%H:%M:%S") \
  52. --end-time $(date -j "+%Y-%m-%dT%H:%M:%S") \
  53. --availability-zone ${2} \
  54. --product-descriptions "Linux/UNIX" \
  55. | jsawk 'return this.SpotPriceHistory' \
  56. | jsawk -n 'out(this.SpotPrice)'
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement