Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env bash
- key_name=hww-meta-emr-dev
- alias emr-ls="aws emr list-clusters \
- | jsawk 'return this.Clusters' \
- | jsawk -n 'out(this.Id, this.Name, this.Status.State)' \
- | column -t -s','"
- alias emr-info="aws emr list-instances --cluster-id"
- alias emr-rm='aws emr terminate-clusters --cluster-ids'
- function emr-create() {
- if [ $# -ne 2 ]; then
- echo emr-create \<instance-name\> \<instance-count\>
- return
- fi
- aws emr create-cluster \
- --applications Name=Hadoop Name=Hive Name=Hue Name=Spark Name=Ganglia Name=Mahout Name=Zeppelin-Sandbox \
- --name ${1} \
- --region us-east-1 \
- --release-label emr-4.3.0 \
- --instance-groups \
- '[
- {"InstanceGroupType":"MASTER","InstanceCount":1, "BidPrice":"0.045", "InstanceType":"m3.xlarge"},
- {"InstanceGroupType":"CORE", "InstanceCount":'"${2}"', "BidPrice":"0.045", "InstanceType":"m3.xlarge"}
- ]' \
- --ec2-attributes \
- '{"KeyName":"'"$key_name\""',
- "InstanceProfile":"EMR_EC2_DefaultRole",
- "SubnetId":"subnet-5f24b462",
- "EmrManagedSlaveSecurityGroup":"sg-3cdeff45",
- "EmrManagedMasterSecurityGroup":"sg-3ddeff44"}'
- }
- function ec2-price() {
- instance_type=m3.xlarge
- if [ ! -z $1 ]; then
- instance_type=$1
- fi
- echo latest price for instance $instance_type :
- echo "us-east-1a = " $(ec2-region-price $instance_type us-east-1a | tail -1)
- echo "us-east-1b = " $(ec2-region-price $instance_type us-east-1b | tail -1)
- # echo "us-east-1c = " $(ec2-region-price $instance_type us-east-1c | tail -1)
- echo "us-east-1d = " $(ec2-region-price $instance_type us-east-1d | tail -1)
- echo "us-east-1e = " $(ec2-region-price $instance_type us-east-1e | tail -1)
- }
- function ec2-region-price() {
- aws ec2 describe-spot-price-history \
- --instance-types ${1} \
- --start-time $(date -j -v-30M "+%Y-%m-%dT%H:%M:%S") \
- --end-time $(date -j "+%Y-%m-%dT%H:%M:%S") \
- --availability-zone ${2} \
- --product-descriptions "Linux/UNIX" \
- | jsawk 'return this.SpotPriceHistory' \
- | jsawk -n 'out(this.SpotPrice)'
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement