Skip to content

Instantly share code, notes, and snippets.

@ukn
Last active October 27, 2016 16:00
Show Gist options
  • Select an option

  • Save ukn/0b0687c34f03254b7de331551a8c86ab to your computer and use it in GitHub Desktop.

Select an option

Save ukn/0b0687c34f03254b7de331551a8c86ab to your computer and use it in GitHub Desktop.

Revisions

  1. ukn revised this gist Oct 27, 2016. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions awsls.sh
    Original file line number Diff line number Diff line change
    @@ -5,8 +5,8 @@ awsls(){
    temp=`aws ec2 describe-instances --profile ${1}`
    fi

    # All tag version
    #aws ec2 describe-instances | jq -r '.Reservations[].Instances[] | | select (.State.Name != "terminated") | .InstanceId + "\t" + .PrivateIpAddress + "\t" + .PublicIpAddress + "\t" + .InstanceType + "\t" + (reduce.Tags[] as $tag (""; . + $tag.Key + "=" + $tag.Value + " "))'
    # All tags version
    # aws ec2 describe-instances | jq -r '.Reservations[].Instances[] | | select (.State.Name != "terminated") | .InstanceId + "\t" + .PrivateIpAddress + "\t" + .PublicIpAddress + "\t" + .InstanceType + "\t" + (reduce.Tags[] as $tag (""; . + $tag.Key + "=" + $tag.Value + " "))'

    echo $temp | jq -r '.Reservations[].Instances[] | select (.State.Name != "terminated") | .InstanceId + "\t" + .PrivateIpAddress + "\t" + ( if .PublicIpAddress then .PublicIpAddress else "\t" end) + "\t" + .InstanceType + "\t" + .State.Name + "\t " + (.Tags[] | select(.Key == "Name") | .Key + ":" + .Value)'
    unset temp
  2. ukn renamed this gist Oct 27, 2016. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  3. ukn renamed this gist Oct 27, 2016. 1 changed file with 0 additions and 0 deletions.
  4. ukn revised this gist Oct 27, 2016. 2 changed files with 13 additions and 1 deletion.
    1 change: 0 additions & 1 deletion Format "aws ec2 instances describe-instances output"
    Original file line number Diff line number Diff line change
    @@ -1 +0,0 @@
    jq -r '.Reservations[].Instances[] | select (.State.Name != "terminated") | .InstanceId + "\t" + .PrivateIpAddress + "\t" + ( if .PublicIpAddress then .PublicIpAddress else "\t" end) + "\t" + .InstanceType + "\t" + .State.Name + "\t " + (.Tags[] | select(.Key == "Name") | .Key + ":" + .Value)'
    13 changes: 13 additions & 0 deletions function that "aws ec2 describe-instances" output
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    awsls(){
    if [ -z ${1+x} ]; then
    temp=`aws ec2 describe-instances`
    else
    temp=`aws ec2 describe-instances --profile ${1}`
    fi

    # All tag version
    #aws ec2 describe-instances | jq -r '.Reservations[].Instances[] | | select (.State.Name != "terminated") | .InstanceId + "\t" + .PrivateIpAddress + "\t" + .PublicIpAddress + "\t" + .InstanceType + "\t" + (reduce.Tags[] as $tag (""; . + $tag.Key + "=" + $tag.Value + " "))'

    echo $temp | jq -r '.Reservations[].Instances[] | select (.State.Name != "terminated") | .InstanceId + "\t" + .PrivateIpAddress + "\t" + ( if .PublicIpAddress then .PublicIpAddress else "\t" end) + "\t" + .InstanceType + "\t" + .State.Name + "\t " + (.Tags[] | select(.Key == "Name") | .Key + ":" + .Value)'
    unset temp
    }
  5. ukn revised this gist Oct 27, 2016. No changes.
  6. ukn renamed this gist Oct 27, 2016. 1 changed file with 0 additions and 0 deletions.
  7. ukn renamed this gist Oct 27, 2016. 1 changed file with 0 additions and 0 deletions.
  8. ukn created this gist Oct 27, 2016.
    1 change: 1 addition & 0 deletions Format aws ec2 instances
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    jq -r '.Reservations[].Instances[] | select (.State.Name != "terminated") | .InstanceId + "\t" + .PrivateIpAddress + "\t" + ( if .PublicIpAddress then .PublicIpAddress else "\t" end) + "\t" + .InstanceType + "\t" + .State.Name + "\t " + (.Tags[] | select(.Key == "Name") | .Key + ":" + .Value)'