Hands-on AWS EC2 in details
#Article-19 #100daysofAWS #cloud
Index
- Overview
- Host site on EC2
- Host GitHub site on EC2
- Host content on EC2 from S3 buckets
- using a load balancer with EC2 site.
[Note:] Delete all the resources after using it…
Overview
in this hands-on, we will be hosting a static site on EC2 through multiple ways; this will help to understand multiple use case
note: I will be referring to my previous article for repeating steps.
Host site on EC2
I already have written a detailed article on how to create an EC2 instance and Host a static site
Reference article > https://medium.com/@akashayanand1/hands-on-aws-ec2-77e9a3491873
Host on EC2 using GitHub content
Step-1:
Create a GitHub repository and Upload the index.html file there.
Step-2: (can take help from reference article )
create an EC2 Instance
SSH into it and then install a web server
Step-3:
Install git in that instance (this will help in fetching files from GitHub)
- sudo yum install git -y
Step-4:
Navigate to the below location and clone the GitHub repo here
cd /var/www/html
[Note: now you have your content into EC2 & it can be hosted as I have done in the reference article]
Host a Static Webpage with Content from S3
Context: S3 is a storage service provided by AWS, it is used to store the bulk of data in it…
Step-1:
Search for “S3” bucket in AWS and create a bucket from there.
Upload index.html file in that bucket (it can be done manually through upload option provided there)
Step-2: (can take help from reference article )
Create an EC2 instance
Install web ser init
Step-3:
Grant Role based permission to this instance so that it can access “S3” bucket
- navigate to IAM and click on “Role” in the sidebar on the left
- click “create role” > select “EC2” and click Next: Permissions
- Set Type Permission > “AmazonS3FullAccess”
Step-4:
Copy the index.html file from S3 onto the EC2 instance
// Navigate to this address
cd /var/www/html
// list all s3 buckets (work becouse have garanted AmazonS3FullAccess to this EC2 )
aws s3 ls
// You should see the index.html file you uploaded to S3. Copy it to the current directory with the following command:
aws s3 cp s3://<your_bucket_name>/index.html
// make sure your file is coppied
cat index.html
now your site will be live and accessible