1

I saw the ORING post; this should cover ANDING; I struggled with this one.

Given this while loop:

while read -r resourceID resourceName; do
    pMsg "Processing: $resourceID with $resourceName"
    aws emr describe-cluster --cluster-id="$resourceID" --output table > ${resourceName}.md"
done <<< "$(aws emr list-clusters --active --query='Clusters[].Id' \
--output text | sortExpression)"

I need to feed my loop with the ID AND Name of the clusters. One is easy; two is eluding me. Any help is appreciated.

todd_dsm
  • 918
  • 1
  • 14
  • 21

1 Answers1

1

If your goal is to end up with a output looking like this from list-clusters:

1  ABCD 
2  EFGH

In order to feed it to describe-cluster, then you should create a multiselect list.

Something like:

Clusters[].[Id, Name]

This is actually described in the user guide about text output format, where they show that:

'Reservations[*].Instances[*].[Placement.AvailabilityZone, State.Name,
InstanceId]' --output text 

Gives

us-west-2a      running i-4b41a37c 
us-west-2a      stopped i-a071c394 
us-west-2b      stopped i-97a217a0 
us-west-2a      running i-3045b007 
us-west-2a      running i-6fc67758

Source: https://docs.aws.amazon.com/cli/latest/userguide/cli-usage-output-format.html#text-output


So you should end up with

while read -r resourceID resourceName; do
    pMsg "Processing: $resourceID with $resourceName"
    aws emr describe-cluster \
      --cluster-id="$resourceID" \
      --output table > ${resourceName}.md"
done <<< "$(aws emr list-clusters \
  --active \ 
  --query='Clusters[].[Id, Name]' \
  --output text | sortExpression \
)"
β.εηοιτ.βε
  • 33,893
  • 13
  • 69
  • 83