Showing posts with label EC2. Show all posts
Showing posts with label EC2. Show all posts

2011-10-03

C#, Compact .NET, WP7 SDK 7.1 & AWS EC2

That title sounds like the beginning of some ancient joke. Well, it's anything but ancient! I just wanted to post some quick code on how to sign AWS EC2 query requests using Compact .NET in C#.

Since there is no high level API for AWS for the compact version of .NET (ie. when used for the WP7 SDK), your best bet is to make query requests directly. That also means you need to sign your requests yourself. Since I was unable to find a working example, I turned to an old piece of code and ported that to work with the compact version of .NET / WP7 SDK 7.1 (Mango) instead.

2011-06-10

Saving on EC2 costs through uptime management

For EC2 instances Amazon bills you by the hour. If you are like us, and need a few servers to be "ready" at all times - not too many, not too few - then here's a quick tip, something simple you can do to save some money on your EC2 instance costs.

For every instance, you pay at launch for the coming hour and when you cross that hour, you pay for the next one in advance. This means that stopping and starting an instance will incur an additional hour's cost - depending on when your instance was launched.

If you have several instances and don't need all of them, you can check their uptimes and see which ones are likely to cross into their next hour without being utilized until and after they do. Say, if a server has been up for 55 minutes and it's not being used at the moment, it is less likely to be used in the remaining 5 minutes than one that still has 35 minutes to go from its actual uptime hour.

But here's some actual code (in PHP, requires AWSSDKforPHP set up). Call getSortedEdgeInstanceData() to receive an array of your running instances in the order they are going to turn over into their next billing hour. I imagined these instances that are likely to turn over as "being on the edge" - hence the function name.

It's a simple idea but the costs it saves you could mount up to be significant - depending on the number of instances you manage in an on-demand manner. Hope it helps you!

2011-06-07

EC2 snapshots as backups

Today I did something silly, and changed the password to one of our AWS EC2 Windows servers to an empty string. I was gonna change it in the same RDP session to a generated password, but somehow forgot about it. My connection broke up due to a timeout (of course) and upon my next login I got this love note:

Logon failure user account restriction. Possible reasons are blank passwords not allowed, logon hour restrictions, or a policy restriction has been enforced.

Now, on one hand this is pretty cool, because it won't let me stupidly set no password on any of my instances. But it also pretty much means good-bye to that instance. Up until now, I have not found a way to change the administrator password say, through ec2config. So, I imagine the best I can do is make sure that this or something similar does not surprise me again.

2011-06-02

Listing AWS EC2 instances in PHP

You'll probably see many small snippets from me here on this site that deal with tasks that come up when working with Amazon Web Services. This example is in PHP, but AWS has many APIs for a number of languages and platforms.

This is something simple, yet I thought it could be of use for someone working with Amazon's EC2 instances via PHP. It requires Amazon's AWSSDKforPHP, which is one of the best APIs for AWS to date in my humble opinion.

What this snippet does is it lists your EC2 instances with their Name tag and public dns name. It could be an example on how to iterate through the resulting object that the describe_instances method returns.