AWS and its Services ??
So, in a previous blog, we learned about cloud computing and its importance. Here we will start with the popular cloud service provider, Amazon Web Services(AWS).
AWS or Amazon Web Services is a cloud service provider that offers various cloud computing services that are accessible via the public internet.
The popular services provided by AWS are:
- Virtual machine(EC2),
- Virtual Network(VPC),
- Restrict access to cloud resources(IAM), etc.
- Executing functions(Lambda),
- Automating your infrastructure(CloudFormation),
- Object Storage(S3),
- Block Storage for Virtual Machines(EBS),
- Running and Managing Containers(ECS and fargate),
- Network Filesystem(EBS),
- SQL database(RDS),
- Load Balancer(ELB),
- Monitoring and logging(CloudWatch),
We will learn these services one by one. In this blog, we will cover Virtual Machines (EC2).
These services can be accessed in four ways:
- Console: access AWS services through a graphical user interface (GUI)
- CLI: to manage and access AWS services within your terminal.
- SDK: programming language to interact with the AWS API.
- blueprint(Infrastructure as a Code): A blueprint is a description of your system containing all resources and their dependencies. Blueprints will help you to automate the configuration of your infrastructure in the cloud.
Internally Console, CLI, SDK, and blueprint use APIs to access AWS services. In order to access any AWS services, an individual must have an AWS account. To create an AWS account refer here.
Now let's proceed with today's topic:
6. Configure Storage:
Terminologies that we came across in EC2:
Now let's proceed with today's topic:
- What is EC2 and how to launch it ??
What is EC2 ??
EC2 is also known as instance or node or virtual machine. In today's world services such as Google, Flipkart, Amazon, Facebook, etc. need to be run reliably 24/7. To run these requires a huge amount of computing resources(CPU/processor/storage), combinely known as Virtual Machines. In AWS, virtual machines are offered by the service called Elastic Compute Service(EC2). Next, we will learn how to launch and manage a Virtual Machine on AWS. To know more about Virtual Machine refer here.Practical
Launch an Virtual Machine(EC2):
- Go to AWS Management Console at https://console.aws.amazon.com
- Select the region, Asia Pacific( Mumbai) -ap-south-1 from the top.
- Click services and search for EC2
- Click on Launch instance.
- Now, you will be landed to Launch an Instance Page.
Now let's understand each section and parallel select it:
1. Name and Tags:
- Name: Add any name for your machine, for say "mycomputer"
2. Application and OS Image(AMI):
- In short, it means which operating system you want. We will proceed with the default one, Amazon Linuz.
- In AWS, the OS comes bundled with pre-installed software for your VM, and this bundle is known as Amazon Machine Image(AMI).
3. Instance Type:
- Instance type: Use the default one, t2.micro, which comes under a free trial.
- Depending on use case to use case instance type differs. Currently, we want instance type for general purpose, for which t2 is best or moreover T family instance type is best.
- The instance size defines the capacity of CPU, RAM, Storage, and networking. For Example, t2.micro tells you the following things:
- "t" refers to instance family.
- "2" represents the generation of the "t" family.
- "micro" represents the configuration of EC2.
- t2.micro means it contains 1 CPU, 1 GB of RAM, and 30 GB of storage.
- Normally when you buy a laptop, it comes with 4/8 GiB RAM and 2 or 4 CPUs.
- To know about more types of Instances refer here.
4. Key pair(Login):
- Click on - create a new pair
- To log in with a virtual machine, it requires a key instead of a password.
- Normally, till now we have logged in own or friends' laptop which was physically present. But here we are accessing that laptop via the internet, which is not physically present, but rather present in the AWS center. To remotely access the laptop/server/instance/VM, we use the SSH tool for the same.
- To log in via SSH, we require 3 things:
- Key("mykey.pem")
- Username("ec2-user")
- IP Address("3.111.32.82")
5. Network Settings:
- Let it be the default one. No need to change or alter anything for now in this section.
- Let it be the default one. Now need to change or alter anything in the storage section too.
- Normally when you buy a laptop it comes with an SSD or HDD(Hard drive). The minimal SSD is 128 to 256 GiB and the Hard drive is 1 TiB. Here AWS offers you 8 GiB HDD with no SSD
Before proceeding further, cross-check with the below images.
Now, Click on Launch instance.
Now, it's time to access your Virtual Machine via the terminal. To do so,
- We need to first remotely log into the Virtual Machine.
- Go to Search bar, search for EC2 --> Click on Instances(running)
- You will be landed on the running instance page.
- Now Click on Instance ID i-095e970339767fca6.
- You will see the summary of your Virtual Machine or instance.
- Now to access this machine we require a public IP Address and key(which we created at the time of launching the machine).
- sudo ssh -i mykey.pem ec2-user@3.111.32.82
- Make sure to provide the proper path of your key. Currently, I am in the same directory in which my key "mykey.pem" is present. And make sure to replace "3.111.32.82", with your instance public IP.
- Let's play with our machine. Run the below command to see the output.
- pwd
- output --> /home/ec2-user
- date
- output --> Sat Sep 16 17:56:33 UTC 2023
- cal
- free -m
- to check memory
- lscpu
- to check CPU-related info
- ifconfig
- to check the private IP of the VM.
- ps -aux
- to check the list of processes running in your VM
Example:
Host a Website.
In order to host a website, we need two things:
- Webserver(nginx or apache)
- HTML page(index.html)
Let's Install an httpd(apache) webserver, start it, and create an HTML page.
- sudo yum install httpd -y
- sudo systemctl enable httpd --now
- cd /var/www/html
- vim index.html
- "Hi, this is my first website running on Virtual Machine on AWS".
- Then, press the "esc" button and press the ":wq" button.
- Now, go to the browser and enter http://3.111.32.82/. In place of "3.111.32.82", replace it with your instance public IP address.
- You can also run in from your terminal.
- curl http://3.111.32.82/
- Instance ID: The ID of the virtual machine.
- Instance type: The size of the virtual machine (CPU and memory).
- IPv4 Public IP: The IP address that is reachable over the internet. For Example, behind "www.google.com", IP Address is "8.8.8.8".
- AMI: In AWS, the OS comes bundled with preinstalled software for your VM, and this bundle is known as Amazon Machine Image(AMI). In short, AMI refers to an Operating System.
- Key:
That's all. So, in today's blog, we learned about EC2 and how to launch it.
Now What Next?
Next, we will learn about Networking and VPC.
Comments
Post a Comment