Showing posts with label work. Show all posts
Showing posts with label work. Show all posts

Monday, August 10, 2020

Show count and instance IDs of existing EC2 instances in all regions of AWS:

I'm kicking myself for not posting this earlier in my past life-- but here's a handy shell script that can list the number of instances in each region in AWS.


Show count and instance IDs of existing EC2 instances in all regions of AWS:


Single line:

Set my AWS profile to my personal account rather than work.  
To setup, use aws --profile personal configure   

$ export aws_profile=personal


If the buffer space can handle long entries, you can run this in a single line, otherwise there's a multi line below to run as a script.

    $ for i in $(aws --profile $aws_profile ec2 describe-regions --output json | grep "RegionName" | cut -d '"' -f4 | sort); do export buf=$(aws --profile $aws_profile ec2 --region $i describe-instances --output json | grep InstanceId | cut -d '"' -f4); export buf_num=$(echo $buf | grep -c .); echo "=== $i -> $buf_num instance(s) ===";echo $buf ; done

    Multi Line:

    Good for placing into a script to run, also listed this way for readability:
    1. #!/bin/bash export aws_profile=personal for i in $(aws --profile $aws_profile ec2 describe-regions --output json| grep "RegionName" | cut -d '"' -f4 | sort); do export buf=$(aws ec2 describe-instances \ --profile $aws_profile \ --region $i \ --output json | \ grep InstanceId | \ cut -d '"' -f4); export buf_num=$(echo $buf | grep -c .); echo "=== $i -> $buf_num instance(s) ==="; echo $buf; done

    Sample Output:

    1. === ap-northeast-1 -> 0 instances === === ap-northeast-2 -> 0 instances === === ap-south-1 -> 0 instances === === ap-southeast-1 -> 0 instances === === ap-southeast-2 -> 0 instances === === ca-central-1 -> 0 instances === === eu-central-1 -> 0 instances === === eu-north-1 -> 0 instances === === eu-west-1 -> 0 instances === === eu-west-2 -> 0 instances === === eu-west-3 -> 0 instances === === sa-east-1 -> 0 instances === === us-east-1 -> 0 instances === === us-east-2 -> 0 instances === === us-west-1 -> 0 instances === === us-west-2 -> 1 instances === i-012345678901234ab

    Thursday, May 20, 2010

    Late-night weekday banter....

    Good evening folks,

    Looks like I'm still waiting for the remaining laundry so I can finish packing for tomorrow morning's trip, and a good time to update the blog.

    Health and Exercise Updates:
    Since spring is here and summer is fast approaching, charity and weekend exercise events are here! Since the last post of the tour de cure, I was able to complete the I Care Classic 65-mi ride through the hills of Morgan hill, the Bay-to-Breakers in San Francisco, and of course the walk down the street to the local safeway to get groceries. On the positive side, I'm now able to last up to ~ 13 miles jogging at a mild pace, cycling up to 80 miles, which are both personal bests. When the mindset back in 2007 was to quit smoking and get into shape, I didn't think I could achieve this. Wow. It's a great feeling and quite inspiring :)

    As far as my health, I've been doing quite well. I eat breakfast on a daily weekday basis, that includes fresh fruit, cottage cheese, oatmeal, and an occasional hard boiled egg-- Lunch has also been kept to a mostly veggie-type of meal, with the occasional burger and outing here and there :)


    Technical mumbo-jumbo:
    I hate Acer with a passion. I picked up an Acer Aspire NAS awhile back, and didn't find out until after purchase that it did not support true raid-5-- it has a WHS version of "load balancing" which includes a proprietary method of balancing data distribution on the drives in a method called "folder duplication". Ummm yeah sure, that sounds reassuring. Just one question-- How in the heck would I be able to find files if one of the drives blew? Can we say, needle in a haystack? Anyway, so I was migrating data off the NAS when WHS decided to reboot because of an important windows update that needed to restart the system. I mean cmon.... right when I'm performing file copies?? two thumbs down for Windows Home Server (WHS). This sucker is going on craigslist as soon as I'm done.


    Work / LIfe:
    Vacations rock. Plain and simple. In the time I was working at my company almost 3 years ago, I have not taken vacation longer than 2-3 days. I also realized that I was throwing away days each year after not using them as we max out at a certain limit-- This year, for my health, sanity, and recreation, I have actually scheduled and taken vacation. I always told myself that one day I would love to travel, and this year I'm doing so -- North Carolina, Philippines, Switzerland, and hopefully Australia / New Zealand. Pictures speak a thousand words, and that is what I look to do when on vacation-- Enjoy the sights and sounds of foreign places and capture them in a photo :)

    Also, when was the last time you were able to wake up early, watch the sunrise while jogging on a white-sand beach? :)

    Tomorrow I'm off to vegas-- Talk to you later!