AWS CLI EMR get Master node Instance ID and tag it

后端 未结 4 1675
生来不讨喜
生来不讨喜 2021-01-06 22:20

I want to automate the running of a cluster and can use tags to get attributes of an EC2 instance like its instance-id.

The documentation on https://docs.aws.amazon.

4条回答
  •  爱一瞬间的悲伤
    2021-01-06 22:46

    Below example is for Instance Fleet, it saves Cluster ID, Instance Fleet ID and Master IP as environment variables.

    Replace cluster name "My-Cluster" to the actual cluster name.

    export CLUSTER_ID=$(aws emr list-clusters --active --query 'Clusters[?Name==`My-Cluster`].Id' --output text)
    export INSTANCE_FLEET=$(aws emr describe-cluster --cluster-id $CLUSTER_ID | jq -r '.[].InstanceFleets | .[] | select(.InstanceFleetType=="MASTER") | .Id')
    export PRIVATE_IP=aws emr list-instances --cluster-id $CLUSTER_ID --instance-fleet-id $INSTANCE_FLEET  --query 'Instances[*].PrivateIpAddress' --output text
    

提交回复
热议问题