I’ve been messing around with Amazon EC2 recently, and I’ve discovered that most things can’t be done using available GUI based tools (such as AWS Management Console, Elasticfox etc.) So, whilst actually using the command line tools isn’t too bad (especially if you’re following guides), setting them up is a bit of a pain. I thought I’d just do a quick write up on the steps involved. (Just a note, “I:\” is my system drive. On most systems, this will most likely be “C:\”. )
- Download the Amazon EC2 API Tools from here.
- The zip archive will contain a folder named something like “ec2-api-tools-1.3-51254”. You will need to extract the contents of this folder to a location on your HDD. (In my case, “I:\Apps\EC2”)
- Installing Java is a prerequisite, so make sure you’ve got it installed and set up on your system.
Now, you will need to set up the environment variables so you don’t have to constantly point the EC2 tools to various locations. You can do this two ways:
- Using the command prompt and the set command. (E.G. To set the environment variable “TEST” to “I:\test.txt” you would write “set TEST=I:\test.txt” in the command prompt.) This method is temporary, and you will lose the these when you restart the command prompt.
- Set them using the appropriate Windows System settings as “System Variables.” (See this guide.) This method is permanent, though I noticed I needed to restart the computer to make it work with Console2, an alternate command prompt window I use.
- You will need to set the following environment variables:
- JAVA_HOME = The location of your Java Runtime Environment home directory. (In most systems, it will be “C:\Program Files\Java\jre6” or “C:\Program Files (x86)\Java\jre6”.)
- EC2_Home = The location you extracted the tools in Step 2. (In my case: I:\Apps\EC2)
- You will need to add the location of the “bin” folder in your EC2 tools folder to the end of your “PATH” variable. (I.E. You can use “set PATH=%PATH%;%EC2_HOME%\bin” in command prompt or just open up the system variable editor and add it to the end – separating each path with a semicolon: “;”).
- When you create a new EC2 account, Amazon will require you to create a X.509 certificate and private key for said certificate. You will need to have these two files on your computer. (Check here if you need to create a new certificate.) You will need to create two variables: EC2_CERT (which points to your certificate file, cert-….pem) and EC2_PRIVATE_KEY (which points to your private key, pk-….pem).
- Once you’ve done that, you should be able to use all the available EC2 API tools from your Windows machine.
- I noticed that for the EC2_CERT and EC2_PRIVATE_KEY (and possibly EC2_HOME) environment variables, it would error if I enclosed the paths with double quotes(“”).