Starting up Amazon EC2
- 1 What is Amazon EC2
- 2 Set Up
- 3 Connect to Instance Using Ubuntu
- 4 Connect to Amazon Linux Instance Using PuTTY
- 5 Hio-Yocto Project Requirement
- 6 AmazonEC2 Volumes
- 7 File Transfer to Amazon EC2 Using FileZilla and SFTP
- 8 Next Step : Setup Yocto Environment
What is Amazon EC2
Amazon Elastic Compute Cloud (Amazon EC2) is a service that allows users to rent virtual computers. Amazon EC2 provides scalable computing capacity in the Amazon Web Services (AWS) cloud. Users will boot up their virtual machine (instance) using Amazon Machine Image. Amazon EC2 eliminates users'need to invest in hardware up front, development and deployment of applications would be faster. Amazon EC2 can launch as many virtual servers, configure security and networking, and manage storage. Amazon EC2 also enables scale up or down to handle changes in requirements or spikes in popularity, reducing forecast traffic. 
- Select EC2 Virtual Service
- Click instance on the ES2 control panel and then click Launch Instance.
- Choose an Amazon Machine Image (AMI). For HIO project, choose Ubuntu Server 14.04 LTS:
- Choose an Instance Type.
- Click next. Go to Configure Instance Details, then assign subnet default range as us-west-2a. Subnet is where Amazon stores the data of the instance. Making sure that the data is stored close to the access point to increase the performance of the instance.
- Set up the Size to 30 Gib. For Free Tier, Amazon provides a maximum of 30Gib of data. It is possible to add additional volume to the instance later with extra cost per use.
- After Configuration, Click Review and Launch located on the lower right.
- Amazon will prompt user to create a new key pair or select an existing one.
- This key pair (*.pem) will be the password file to connect to the instance.
- To Connect an instance. Click Connect that is next to Launch Instance.
- Follow the Instruction on using "A standalone SSH client" or "A Java SSH Client directly from browser (Java required)" in the prompt.
Connect to Instance Using Ubuntu
The quickest way to connect to the Linux Instance on Amazon EC2 is to use a Linux Operating system.
- On the Instance Page, Click Connect
- Under Example, Amazon generated a command for Linux Shell. Copy the Command
- Make sure that .pem (Private key) file is located in the user home folder. Otherwise, the key location needs to specified.
- Start Terminal, paste the ssh command that just copied, change instance name root into ubuntu
- Select "yes" when prompt to connect the instance.
Connect to Amazon Linux Instance Using PuTTY
PuTTY is a free implementation of Telnet and SSH for Windows and Unix platforms, along with an xterm terminal emulator. It is written and maintained primarily by Simon Tatham. We will use PuTTY and PuTTYgen to connect to the Amazon EC2 instance. So, PuTTY is the emulator, and PuTTYgen will be used for key generation (the Amazon ".pem" file).
Generate Private Key with PuTTYgen
- Start PuTTYgen
- Under Type of key to generate, select SSH-2 RSA
- Click Load. Select the option to display files of all types
- Select the ".pem" file. Click Open. Click Ok
- Click Save private key to change the format from ".pem" to ".ppk".
- Specify the same name for the private key and PuTTYgen will automatically add the .ppk file extension.
Starting a PuTTY Session
- Start PuTTY
- In the Category Pane, select Session and complete the following fields:
- For Host Name box, enter ubuntu@public_dns_name. The public_dns_name can be found in Amazon EC2 Instances page. It is usually start with ec2-xx-xx... Copy the whole Public DNS and paste after the @ sign. For example, firstname.lastname@example.org
- Under Connection type, Select SSH
- Make sure that the Port is 22.
- In the Category pane, expand Connection,expand SSH, and select Auth
- Click Browse
- Select the ".ppk" private key file that is generated from PuTTYgen. Click Open
- To use this session again later, save the session information by Select Session in the Category pane, enter a name for he session in Saved Sessions, Click Save.
- Open to start PuTTY session
- PuTTY will displays a security aleart dialog box that ask whether the connecting host is trustable for the first login session.
- Click Yes and the emulator window will appear.
Hio-Yocto Project Requirement
|CPU||2 Core Processors|
|Remaining Disk Size||30G|
Amazon EC2 free tier provides a 1 Core processor with 30 Gib of volume. However, Hio project required at least 2 Core processors. The 30 Gib volume is barely enough to compile one image. To compile more image, it is required to create additional volume. To change the number of processor, users can choose different type of instance in the Create Instances interface.
Other than the initial free 30G, Amazon provides users option to create their own volumes to match their needs. The volume is like a separate hard drive from the instance that can be mounted and unmounted from the instance.
To create Volume:
- Expand Elastic Block Store
- Click Volumes
- Click Create Volume
- Make sure that the Availability Zone match with the one in Instances
- Click Create
To Attach the Volume into Ubuntu
- Choose a Volume and click Actions (or simply right-click on the volume)
- Select Attach Volume
- Double click on Instance and select the instance that is running
- Click Attach
After attaching the volume, input the following command into Terminal:
This command will show the name of volumes, the size, type, and where it is mounted to.
In this example, sda and sdc are the name and they are partition into multiple parts. sda1 is mounted into the root folder. sdc1 and sdc2 are not mounted yet.
Mounting the Volume
New Volume from Amazon need to be formatted before using.
Note: Format the volume will erase the whole content if it has been used before.
To format, input the following command, replace <name of the volume> with the name of the newly created volume.
$sudo mkfs.ext4 /dev/<name of the volume>
Next, a directory needs to be created to attach the volume. Eg. we will create a directory calls /data in the root folder.
$sudo mkdir /data
Mount the volume into /data directory
$sudo mount /dev/<name of the volume> /data
check the mounted device
Unmount the volume
to Unmount the follow from /data directory, input the following command
$sudo umount /dev/<name of the volume> /data
Note: Before detaching from instance, it is recommended to unmount the volume from the instance first to prevent lose of data.
File Transfer to Amazon EC2 Using FileZilla and SFTP
FileZilla is a GUI interface that allows users to transfer file between the host computer and the instance.
To install FileZilla, input the following command
$sudo apt-get install filezilla
To connect to Amazon Ec2
- Edit > Setting > Connection > SFTP, and Click Add key file
- Browse to the location of .pem and select it
- A message box will appear asking to change the current .pem to .ppk format. Click Yes and select the location to store the .ppk file
- (Optional) Select the generated .ppk file
- Click Ok
- Next step, Click File > Site Manager and Input the following parameters,
- Host: public DNS name of EC2 instance
- Protocol: SFTP
- Logon Type: Normal
- User: ubuntu
- click Connect