Amazon Elastic Compute Cloud (EC2) is a web service offered by Amazon Web Service (AWS) that provide scalable computing capacity in the cloud. EC2 allows users to launch virtual machines (instances) and run a wide range of applications on them.
Now let's create EC2 instance and Deploy our static website
(prerequisite: AWS account)
Step 1: Go to AWS Management Console and Search for EC2 instance also, click on it.
Step 2: Click on Launch Instance on the Dashboard.
Step 3: Write a name for the instance (example: MyWebServer). you can also give additional tags.
Step 4: Choose Amazon Linux 2 and Instance type t3.micro,
you can always choose as you want but Recommend you to use Free tier.
Step 5: Select "Create a new pair" and give a name for now say "webSarver".
you have to know where your key pair file is being downloaded.
Step 6: In the Network settings,
You can Configure the Security Group name and Description as you like but we are leaving it as default for now.
select the Inbound security groups rules you can see the Add security group rule click on it.
- Add the following Type and Source type.
Step 7: In configure storage
leave it as default for now but you can get upto 30 GiB in the free tier. This will be your root volume also known as 'boot' volume.
Step 8: In configure advance details
add the following codes in the user data field and leave other field as default.
The Script does the following:
Install an Apache web server (httpd)
configure the webserver to automatically start on boot
Activate the Web server
Create a simple web page
Step 9: Click on Lauch instance
you can see this interface with a sucess.
step 10: Wait for some time the instance is running and the status is initializing. After some time you can see that there is 2/2 checked passed on the status check.
step 11: Now, you can click on the instance Id and copy the Public IPv4 address and paste it in the browser. you would be able to see this result which was written in the user data field inside the h1 tags.
That's all, you have finally hosted a static website on the AWS cloud.
Congratulations guys!!!