Hacker News new | ask | show | jobs
by failmode 2357 days ago
Bash-My-AWS wraps AWSCLI as thinly as possible and makes use of JMESPath and the text output.

The result is you have a simple set of commands that don't require you to type hundreds of characters.

  instances() {
    local instance_ids=$(__bma_read_inputs)
    local filters=$(__bma_read_filters $@)

    aws ec2 describe-instances                                            \
      $([[ -n ${instance_ids} ]] && echo --instance-ids ${instance_ids})  \
      --query "
        Reservations[].Instances[][
          InstanceId,
          InstanceType,
          State.Name,
          [Tags[?Key=='Name'].Value][0][0],
          LaunchTime,
          Placement.AvailabilityZone,
          VpcId
        ]"                                                               \
      --output text       |
    grep -E -- "$filters" |
    LC_ALL=C sort -b -k 6 |
    column -s$'\t' -t
  }