Saturday 15 November 2014

Getting Information about the AWS EC2 Instances we have deployed

Getting Information about the AWS EC2 Instances we have deployed

So this is the bit where we are attempting to script collection of EC2 Instance information, like core count and memory size.

We need to use this cmdlet:

Get-EC2Instance

I'm starting with the following:

Get-EC2Instance -Region us-west-1 (that should list all of my instances in Ireland)

It does - now all i need to do is count them. I'm going to do that - and assign it to a variable - each time i run the script - i'm going to clear the variable at the start. Heres the script i'm using:

#This script determines the number of Instances deployed in AWS


Clear-Variable numberAWSInstances

$numberAWSInstances = Get-EC2Instance -region us-west-2

echo $numberAWSInstances.Count

And that returns a number. So pretty much - if i set my 'instance ceiling' on AWS at 5 - then if i'm going to deploy an instance, it will currently have to deploy to azure as my AWS space is full. (i currently have 5 instances in AWS)

lets work on that in the next script.

No comments:

Post a Comment