This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# lists all EMR Clusters along with the associated EC2 Instance Ids | |
# Use this directly on your command shell. It will print the result in the format: | |
# "cluster_id | [$ec2_instance-id]... " | |
# depends on AWS CLI and JQ | |
for cluster in `aws emr list-clusters --active --query 'Clusters[].Id' --output text`; do | |
instances=$(aws emr list-instances --cluster-id ${cluster} --query 'Instances[?Status.State==`RUNNING`].[InstanceGroupId, InstanceType]' | jq -r -c '.[] | @tsv') | |
echo ${cluster} '|' ${instances//$'\n'/ } | |
done |
OlderNewer