Time & Bill has grown. I have started with an m1.micro instance from Amazon AWS EC2 which was available for free for one 1 year. But now these period is ending and I have considered to stay or to move to other services. For example, Jiffy Box came to my mind. But calculating a little bit, Jiffy is not much cheaper than Amazon EC2 when you use reserved instances (and calculate for a year). Google App Engine tied me to much to the Google SDK and honestly I want more access to my database. Google Computing Engine is restricted to a small amount of people and so I cannot use it. I like RedHats OpenShift and will consider going there later, but for now it still needs to grow and improve. So, finally I decided to stick with Amazon AWS because of the great tools and services available.
Now the problem was to upgrade to a bigger instance as sometimes it was not really funny anymore when it came to performance.
I decided to install the Commandline Tools. Basically this is downloading the package and putting it on your path. I do that with writing the following into ~/.profile
export EC2_HOME=/path/to/ec2-api-tools-18.104.22.168 export PATH=/path/to/ec2-api-tools-22.214.171.124/bin:$PATH
On Mac OS X you have to set your JAVA_HOME variable. You don't need that very often these days. It can achieved very easily with putting this into your .profile too:
Now you should already be able to use the client tools, when you:
You will recognize that you need to authenticate against AWS to use these tools. It took me a little to find out that the keys I created for my EC2 instance are not the same I need to access with the CLI tools. You need to create keys on the security page. I uploaded my X.509 cert and as I only work with one AWS account, I could reference these keys in my .profile file too:
export EC2_PRIVATE_KEY=/path/to/pk-AAAAAAAA.pem export EC2_CERT=/path/to/cert-AAAAAAAA.pem
Now I am able to easily access AWS.
One thing I found out was, that I needed to sync my computers clock automatically. If you don't do that, you'll run into that error:
$ ec2-describe-regions Client.InvalidSecurity: Request has expired
Once you synced the clock, it takes a few minutes then it will look better:
$ ec2-describe-regions REGION eu-west-1 ec2.eu-west-1.amazonaws.com REGION sa-east-1 ec2.sa-east-1.amazonaws.com REGION us-east-1 ec2.us-east-1.amazonaws.com REGION ap-northeast-1 ec2.ap-northeast-1.amazonaws.com REGION us-west-2 ec2.us-west-2.amazonaws.com REGION us-west-1 ec2.us-west-1.amazonaws.com REGION ap-southeast-1 ec2.ap-southeast-1.amazonaws.com
Now it is time stop my EC2 instance, upgrade it to a new type and restart it again. I found out what my instance id is (looked at the web console, but surely there is a CLI trick too).
Then I tried:
$ ec2-stop-instances i-123456 Client.InvalidInstanceID.NotFound: The instance ID 'i-123456' does not exist
Well... I was sure this ID was there. Somewhere I found the tip to apply a region. I copied the region from the web console:
$ ec2-stop-instances i-123456 --region eu-west-1a Unknown host: 'https://ec2.eu-west-1a.amazonaws.com'
Looking at the available regions, well, eu-west-1a should be eu-west-1 (without a).
This finally worked well:
$ ec2-stop-instances i-123456 --region eu-west-1 INSTANCE i-123456 running stopping
Quickly I "upgraded" the size of my instance:
$ ec2-modify-instance-attribute --instance-type m1.small i-123456 --region eu-west-1 Client.IncorrectInstanceState: The instance 'i-123456' is not in the 'stopped' state.
Ups - please wait a little time, otherwise you'll get that above. A few seconds later I was able to perform that change:
$ ec2-modify-instance-attribute --instance-type m1.small i-123456 --region eu-west-1 instanceType i-123456 m1.small
And now we need to start the instance again:
$ ec2-start-instances i-123456 --region eu-west-1 INSTANCE i-123456 stopped pending
Very well - the instance was starting up again as I could see on the web console. After it started, my app was not reachable. This happened because the elastic IP i had was not longer associated with my instance. Once I fixed that, everything went well and was available as usual.
That being said, I am deeply impressed by all that technology. I would prefer not do deal with such low level details and work a little bit more in the direction of OpenShift, which lets me deal only with my app (PaaS). But well, Amazon EC2 is now - OpenShift is tomorrow. Let's see what the new day brings.