EC2 Introduction
In this lecture you are learning How to create simple EC2 Instance and its resources.
- Amazon Machine Image (AMI)
- Instance Types
- Create Key Pair
- Default usernames for Linux AMIs
- Create EC2 instance
- How to Login to EC2
- Billing Preferences
Amazon Machine Image (AMI): An AMI is a template that contains the software configuration (operating system, application server, and applications) required to launch your instance. In simple words its image that can be used to create EC2 Instance.
Instance Types: Amazon offering different family of EC2 Instances as mentioned below for different business workloads.
- General purpose: General purpose instances provide a balance of compute, memory and networking resources, and can be used for a variety of diverse workloads. These instances are ideal for applications that use these resources in equal proportions of compute resources.
- Compute optimized: Compute Optimized instances are ideal for compute bound applications that benefit from high performance processors
- Memory optimized: Memory optimized instances are designed to deliver fast performance for workloads that process large data sets in memory.
- Storage optimized: Storage optimized instances are designed for workloads that require high, sequential read and write access to very large data sets on local storage.
- Accelerated computing: Accelerated computing instances use hardware accelerators, or co-processors, to perform functions, such as floating point number calculations, graphics processing, or data pattern matching, more efficiently than is possible in software running on CPUs.
Follow the LINK to know more about the different instance types of these instance family.
LINK: https://aws.amazon.com/ec2/instance-types/
Create Key Pair: key pair is to securely connect to your EC2 instance. Follow the LINK to know how to create EC2 Key Pair.
LINK: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/create-key-pairs.html#having-ec2-create-your-key-pair
Notes:
- When you create keypair it creates public key and private key files and private key file is automatically downloaded by your browser.
- Note that it’s not possible to re-download the private key once gain from AWS if you lost it.
- Keypair follows encryption algorithm of either RSA or ED25519 type to create the public and private keys.
- Keypair can be create of private key type .pem or .ppk.
- The base file name is the name that you specified as the name of your key pair, and the file name extension is determined by the file format that you chose [like edwiki.pem or edwiki.ppk]. Save the private key file in a safe place.
- If you are using PUTTY tool to connect to the EC2 then choose .ppk and if you are using MacOS or Linux based terminal to connect to the EC2 then choose .pem type.
- EC2 Keypair is the region based resource hence, Keypair created in one region can not be used in another region.
- Once EC2 Instance created with Keypair attached; its not possible to remove/change the keypair from the existing running EC2 instance.
- One instance can not used multiple key pairs however one key pair can be used by multiple instances.
Default usernames for Linux AMIs:
The default user name for your EC2 instance is determined by the AMI that was specified when you launched the instance.
The default user names are:
- For Amazon Linux 2 or the Amazon Linux AMI, the user name is ec2-user.
- For a CentOS AMI, the user name is centos or ec2-user.
- For a Debian AMI, the user name is admin.
- For a Fedora AMI, the user name is fedora or ec2-user.
- For a RHEL AMI, the user name is ec2-user or root.
- For a SUSE AMI, the user name is ec2-user or root.
- For an Ubuntu AMI, the user name is ubuntu.
- For an Oracle AMI, the user name is ec2-user.
- For a Bitnami AMI, the user name is bitnami.
- Otherwise, check with the AMI provider.
Create EC2 instance: Follow the below simple steps to create EC2 Instance.
- Login to AWS Management Console
- Select EC2 Service à Click on Launch Instances to create on-demand ec2 instance
- Provide below details
- Name of the instance
- Select AMI
- Select Instance Type
- Select KeyPair
- Leave rest of the details as default as other details are advances and will be covered later
How to Login to EC2:
Login from Putty:
- Download Putty from https://www.putty.org/
- Open PuTTY by clicking on the putty.exe file from the downloaded folder.
- In the Host Name (or IP address) box, please give ec2 instance public ip.
- Make sure:
- Port is set to 22
- Connection type is SSH
- In the Category pane on the left of the PuTTY Configuration window, under Connection, click on the + next to SSH to expand the choices ,then click on Auth
- Under Authentication parameters, click Browse and navigate to the directory where your PuTTY Private Key (.ppk) file that was downloaded when you created EC2 Keypair.
- Click on the (.ppk) file to select it.
- Click Open.
Note: If you want to save these settings to use later, navigate to Sessions in the PuTTY Category tree. Enter a name in the Saved Sessions box and click Save on the right.
- Click Open in PuTTY Configuration to connect to your Instance.
- If this is the first time you have connected to your Instance, a PuTTY Security Alert will ask you whether to proceed with the connection.
- Click Yes to complete the connection.
- The login prompt will appear give it username based on AMI that you have used to create EC2.
Login from Linux client or Mac OS Terminal:
If you will use an a macOS or Linux client terminal to connect to your EC2 Linux instance, use the following command to set the permissions of your private key file so that only you can read it.
chmod 400 key-pair-name.pem
Then, Use the below command to login to EC2 instance from your terminal.
ssh –I edwiki.pem ec2-user@<EC2-IP>
Billing Preferences:
As AWS Free Tier is providing limited capacity of resources without billing it’s recommended to configure Billing Preferences to get alerts when user breach the Free Tier limits.
Previous
Next