Importing a Virtual Machine into Amazon EC2 (Part 3)

If you would like to read the other parts in this article series please go to:

In my previous article, I explained how you could configure and test the environment variable required by Amazon CLI, Amazon’s command line interface. Later on in this series we will be using Amazon CLI to migrate a virtual machine to Amazon EC2. For right now though we have to get Amazon CLI up and running. In this article, I will show you how to install and configure this tool.

The first thing that you must understand about Amazon CLI is that there are different installation methods that you can use. For the purposes of this article, I am going to use the Windows Installer, but you can opt to use PIP (a Python based tool) if you happen to be using a Mac or a Linux based system. You can download the AWS CLI installer here.

To install the Windows Installer version of AWS CLI, just download and run the installation file. This will cause a fairly typical installation wizard to appear. Click Next to bypass the wizard’s Welcome screen and you will be prompted to accept the software’s license agreement. After doing so, click Next two more times and then click Install. The installation process should complete within a matter of seconds.

Now that the rather painless process of installing AWS CLI is complete, we need to configure it. If you go with the quick configuration option then the configuration process is fairly simple. In fact, you only have to provide four pieces of information. As with many things in life however, the devil is in the details.

Two of the pieces of information that AWS CLI needs are your account credentials. The software needs a username and password in order to be able to access AWS. Although this sounds easy enough (and it is), there is a problem. From a security prospective, it is a bad idea to provision AWS CLI with your username and password. Instead, Amazon recommends the use of a secret access key.

There are actually two different components that make up an AWS key. There is the Access Key ID and the Secret Access Key. You can think of the AWS Access Key ID as being like a user name and the AWS secret access key as being sort of like a password. The two work together very similarly to the way that public and private keys work in PKI encryption. You will use these keys to sign programmatic requests that you make of AWS.

So with that said, the first thing that you will have to do is to generate the Access Key ID and the Secret Access Key. To do so, open the IAM console and then log in using your regular credentials. When you arrive at the main AWS screen, click on the Identity and Access Management link, found in the Administration & Security section, shown in Figure A.

Image
Figure A: Click on the Identity & Access Management link.

Once you arrive at the navigation menu, click on Users and then select your IAM user name. If no names are shown then you can create a user by clicking on the Create New Users button, shown in Figure B.

Image
Figure B: If no users exist then you will need to click on the Create New Users button.

After clicking on a user account, you will need to click the Manage Access Keys button, shown in Figure C.

Image
Figure C: Click on the Manage Access Keys button.

At this point, you will need to click Create Access Key, as shown in Figure D.

Image
Figure D: Click on Create Access Key.

For security reasons I can’t show you a screen capture of the resulting keys, but they will look something like this:

  • Access key ID example: AKIAIOSFODNN7EXAMPLE
  • Secret access key example: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY

The last step in this process is to click Download Credentials and then store the keys in a secure location. It is extremely important that you put the keys in a safe place. Downloading the keys is a one-time operation. For security reasons, Amazon will not let you re-download your keys. The copy that you download is the only copy in existence.

So now that you have downloaded the keys we can go back to the task at hand, which is configuring AWS CLI. To use AWS CLI, you will need to open an elevated Command Prompt window and then navigate to C:\Program Files\Amazon\AWSCLI. This path is based on the 64-bit Windows version of AWS CLI. If you have installed a different version then the path will be different.

Now let’s check to make sure that AWS CLI is working. To do so, enter the following command (note that two dashes are being used):

AWS –version

The command should return the AWS version, as shown in Figure E.

Image
Figure E: You should see the AWS version.

So now it is time to configure AWS CLI. To do so, enter the following command (there are no dashes used):

AWS Configure

Upon doing so, AWS CLI will ask you for four pieces of information. The first two things asked for are your Access Key ID and your Secret Access Key. Both of these are included in the CSV file that you downloaded earlier. The easiest thing to do is to open the CSV file in Notepad and then copy and paste the values into the Command Prompt window as they are required.

The next piece of information that you will need to enter is a default region name. I am going to be using US-East-1, but you should use the region that is most appropriate for your needs.

Finally, you will need to enter a default output format. I am going to be using text.

You can see the full process in Figure F, although I have blacked out my keys for security reasons.

Image
Figure F: This is what the configuration process looks like.

When you have completed the configuration process, AWS CLI will create two files – Config and Credentials. These are both text files and are located at C:\Users\<user name>\AWS. You can open these files using Notepad as a way of verifying that AWS CLI has been properly configured. You can see the contents of the Config file in Figure G.

Image
Figure G: AWS CLI creates a Config file and a Credentials file.

Conclusion

Now that we have gotten AWS CLI set up, it is possible for us to interact with AWS from the Windows Command Prompt window. Now that we have gotten to this point, it’s time to begin taking a look at the virtual machine migration process. In Part 4 of this article series, my plan is to begin stepping you through a sample virtual machine migration from Hyper-V to Amazon EC2. Amazon actually makes it a little bit easier to work with VMware than Hyper-V because there is a vCenter plugin that you can download. However, I wanted to get things started by showing you how to perform a Hyper-V based migration.

If you would like to read the other parts in this article series please go to:

About The Author

Leave a Comment

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Scroll to Top