Skip to content

Instantly share code, notes, and snippets.

@ChenLiZhan
Last active January 23, 2017 03:23
Show Gist options
  • Save ChenLiZhan/e47723ea51664ac7b4f284f91e0da30d to your computer and use it in GitHub Desktop.
Save ChenLiZhan/e47723ea51664ac7b4f284f91e0da30d to your computer and use it in GitHub Desktop.
The note of Amazon EC2

Amazon Elastic Compute Cloud(EC2)

Amazon Elastic Compute Cloud(EC2) is a web service that provide resizable compute capacity in the cloud. It is designed to make web-scale cloud computing easier for developers.

The simple interface makes us obtain and configure capacity with minimal friction

Verifying Region in the AWS console

Most of the Amazon Web Services offer a regional endpoint to the requests to reduce the data latency in the applications. An endpoints is a URL that is the entry point for a web service. You can choose multiple locations to place your EC2 instance on. Amazon EC2 locations are composed of regions that contain Availability Zone. Regions are located in seperate geographic areas (US, EU, etc.). Availability Zones are distinct locations within a region that are engineered to be isolated from failures in other Availability Zones and to provide inexpensive, low-latency network connectivity to other Availability Zones in the same region.

  • By launching instances in seperate regions, we can place instances closer to specific customers or to meet other requirements.
  • By launching instances in seperate Availability Zones, it allows us to protect applications from localized regional failures.

Below is the table concerning the region name and matched reginon code (See more information about regions from here.

Region Name Region Code
US East (Northern Virginia) Region us-east-1
US West (Northern California) Region us-east-2
US West (Oregon) Region us-east-3
Asia Pacific (Tokyo) Region ap-northeast-1
Asia Pacific (Singapore) Region ap-southeast-1
Asia Pacific (Sydney) Region ap-southeast-2
EU (Ireland) Region eu-west-1
South America (Sao Paulo) Region sa-east-1

Create an Amazon Linux Instance from Amazon Machine Image (AMI)

An Amazon Machine Image (AMI) provides the information required to launch an instance. You specify an AMI while launching an instance, and it allows us to launch as many instances from the AMI as we need. See more details about AMI from here.

  1. In the AWS Management Console, on the Services menu, click EC2.
  2. Click Launch Instance.
  3. Find the Amazon Linux AMI and click Select.
  4. Choose a instance type as you need.
  5. Click Next: Configure Instance Details.
  6. Leave the default options selected and click Next: Add Storage.

Tip: This is the location where to set access, network settings, monitoring and so forth.

  1. Leave the default settings and click Next: Tag Instance.

Note: We can easily add more virtual hard devices or change the drive size here.

  1. In the Value field of the Name attribute, type a name.
  2. Click Next: Configure Sercurity Group.

Tip: When launching multiple instances, having your instances be tagged makes it much easier to track on them.

  1. Leave the default sercurity group, as it allows port 22 (ssh) from anywhere to the Linux instance.
  2. Click Review and Launch.
  3. Click Launch.
  4. Select the acknowledgement checkbox.
  5. Launch Instances.

Tip: Key pairs are how you access your instances after it is created. if you don't have a key pair, you will NOT be able to access the instances.

  1. Click View Instances.

Complete! Once the instance state changes to running and your Status Check column says "2/2 Checks..", your instance is ready to use!

OSX and Linux Users: Connecting to your Amazon EC2 instance via SSH

First of all, you must to be having the key pair in order to access the instance. As the result, ensure to keep the key pair file in a sercure place and do not forget it.

  1. Open the terminal application
  2. Enter the followiing commands

Substitute the path/filename for the PEM file (the key pair) you keep, and paste the public DNS value from the clipboard of the instance.

chomd 600 <PATH_TO_PEM_FILE>
ssh -i <PATH_TO_PEM_FILE> ec2-user@<public DNS>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment