Search code examples
amazon-web-servicesapicygwincommand-line-interface

EC2 Instance Status using cygwin terminal


I'm trying to get into the reporting of AWS instances within my environments, and I am trying to create a script using AWS cli to generate a report of the status of EC2 instances. I'm still a beginner, so I'm learning how all this works. I was wondering if it was possible to do with a line similar to this:

AWS EC2 describe-instances --region $REGION --query 'Reservations[].Instances[?LaunchTime>=`2015-03-01`][].{id: InstanceId, type: InstanceType, launched: LaunchTime}'

I am using the Cygwin Terminal to perform this query, and any with this would be awesome thanks!

If it's possible I am also trying to see if I could get the CPU usage at that time of the report. I am still trying to understand how all this works since I am new to the AWS API.


Solution

  • Thanks for everyone's input! I was able to figure it out here. I'm starting to understand how the population output all comes together, but right now I'm trying to put this information into at TSV file. To get the status and launch time of the instances I used the following:

    aws ec2 describe-instances --region $REGION --query "Reservations[].Instances[].[InstanceId, LaunchTime, State.Name] --output text >> Instances_In_AWS.tsv
    

    Thank you guys for your help!