Amazon RDS Now Supports T2 Instances

That is good news.

T2 instances CPU credits is really great feature introduced 2 months ago for EC2. Amazon RDS Now Supports T2 Instances

At the same time the price for T2 RDS instances is twice less then for the previous generation.

T2.micro EC2 + T2.micro RDS are good if you are thinking about web app which will have the “scheduled” workload. E.g. the main customers are from the particular region.

While the instance is IDLE it accumulate CPU credits. And you servers will be able to burst above the baseline as needed. You can track your CPU Credits trough AWS Console. It is really fun to track them

On the image below one of my EC2 instance has 150 CPU Credits. This means that it will be able to rocket up to the “cloud”  if needed. But still you pay for micro instance. CPU Credits really brilliant idea from Amazon!


Terminate EC2 Spot/On-Demand instance by name

Declare function to terminate instance by Id

function ec2-terminate-instance($instid){
$ec2.TerminateInstances((new-object Amazon.EC2.Model.TerminateInstancesRequest).WithInstanceId($instid)).TerminateInstancesResult.TerminatingInstance[0]

Get instance by name and terminate it

$filter = (new-object Amazon.EC2.Model.Filter).WithName('tag:Name').WithValue('YourInstanceName')
(Get-EC2Instance -Filter $filter -Region 'us-east-1').RunningInstance | % { ec2-terminate-instance $_.InstanceId }

Schedule your Amazon EC2 spot instance startup time

Here I want to explain how to start your Amazon EC2 instance recurrently by scheduling.

I have used the AWS Tools for Windows PowerShell. You can use java command line or python library. The main goal is to explain the idea:

I am going to automate the starting of my Fitnesse server.

Create launch configuration

New-ASLaunchConfiguration Fitnesse -ImageId ami-00000000 -SecurityGroups Fitnesse -InstanceType t1.micro -SpotPrice 0.011

Create Auto Scaling group with MinSize=MaxSize=0

New-ASAutoScalingGroup Fitnesse-AS -LaunchConfigurationName Fitnesse -AvailabilityZones us-east-1a -MinSize 0 -MaxSize 0

Set the Start scheduling action
The core thing is the MinSize=MaxSize=1 and the -Recurrence argument which is in the cron scheduler time format

Write-ASScheduledUpdateGroupAction -AutoScalingGroupName Fitnesse-AS -ScheduledActionName Start -MinSize 1 -MaxSize 1 -Recurrence '15 13 * * *'

Optionl (stop event)

Write-ASScheduledUpdateGroupAction -AutoScalingGroupName Fitnesse-AS -ScheduledActionName Stop -MinSize 0 -MaxSize 0 -Recurrence '59 23 * * *'