Followers

AWS - EC2 Example with Security Group

Prerequisite: - A valid AWS account IAM Permission: Min EC2 Full Access,EC2InstanceConnect Challenge :- Deploy a Website on an EC2 instance...

Prerequisite:- A valid AWS account

IAM Permission: Min EC2 Full Access,EC2InstanceConnect

Challenge:- Deploy a Website on an EC2 instance and should be accessible on Port 80. Below is the configuration for the website.

OS:-   ubuntu 18.04

Webserver: Apache

Firewall to open(Inbound): 22,80

Web Pages: HTML

Region: Select Region where you want to deploy the application.

Solution: Create an EC2 instance and install apache on top of it and attach a security group that has an inbound rule to open port number 22,80. Use public IP address to access the application on a browser.

Steps to Follow

Step 1:- Create a key-value pair ( If you already have a valid public key (.pem or .ppk for putty then no need to perform this step)

  •   Click on Network & Security---> keypairs
  •   Click on Create a key pair button 
  •   Fill out the form by entering Name vdevops
  •   Key pair type:- RSA
  •   Private key format:- .pem
  •   Click on Create key pair. 
  •   Key should be listed in keypair list and a vdeops.pem file should be downloaded on your system ( keep it in some location in your computer so that we can refer it whenever it is required).

Step 2 Create Security Group (To open the firewall with defined port numbers). If you already created the security group then this step is optional.

  •    Select Network & Security--->Security Group
  •    Click on Create Security Group Button 
  •     Fill out the form by entering below details
  •    Security Group Name: sgWebServer
  •    Description: Allow Http and SSH 
  •    No change in vpc value 
  •    Inbound rules:- Click on Add rule Button
                 select Type: SSH
                 source : AnyWhere-IPV4
  •     Click on Add rule Button
                 select Type: HTTP
                 source : AnyWhere-IPV4
  • Click on Create Security Group button 
  • Security Group should be created.


Step 3: Create an EC2 instance

  •   Search Service EC2 in the search box and select EC2 from the search list.
  •   Select Instances and Click on Launch Instances 
  •   Select AMI (Amazon Machine Image) - ubuntu 18.04
  •  Select Instance Type t2.micro and Click on Next Button
  •  Instance Details - Leave as it is because we are not making any change in VPC or subnet etc. On the Same page at the bottom select User Data and select As text and enter the below code.
#!/bin/bash
sudo su
sudo apt update
sudo apt install apache2 -y

  • Click on Next
  • Add Storage :- No Change
  • Click on Next
  • Add Tags:- Click on Add Tags button
            Key: Name
            value: WebServer
  • Click on Next
  • Configure Security Group
  • select the option :- select an existing security group
  • From the below list select sgWebServer
  • Click on Review and Launch
  • Review and Launch Page :- Click on Launch
  • select existing keypair :- vdevops
  • click on acknowledge checkbox and click on Launch Instances
  • On Launch Status Page Click on the view instances button
  • In the Instances list, you will find an EC2 instance which is WebServer
  • Wait for this instance to be in running status.


Step 4: Connect to EC2 Instance - WebServer

  • For Windows
  • Open MobaXterm Click on session---> SSH
  • Remote Host: public ip address of Ec2 instance
  • user name: ubuntu
  • Click on Advance SSH Settings
  • click on use Private key checkbox
  • select path for your vdevops key and click Ok Button
  • Terminal should be connected with EC2 instance

Step 5: Deploy Web page on this EC2 instance

  •  Login with root user :- sudo su
  • Check apache is already installed because we have mentioned apache installation script in USER DATA
  • systemctl status apache2
  • Create an index.html.
  •  echo "<h1>This is my first web page on AWS EC2 instance </h1>" > /var/www/html/index.html


Step 6: Visit the website on Browser

On Browser enter URL as PublicIP address of Webserver EC2 instance and you will be able to see the web page with above contents.

Few Experiments

  1. Stop EC2 instance and check that web page is opened or not
  2. Start EC2 instance and now again check the web page is getting opened or not
  3. Remove port number 80 from sgWebServer SG and check webpage is getting opened or not
  4. Add port number 80 from sgWebServer SG and check webpage is getting opened or not













COMMENTS

Name

Ansible,6,AWS,1,Azure DevOps,1,Containerization with docker,2,DevOps,2,Docker Quiz,1,Docker Swarm,1,DockerCompose,1,ELK,2,git,2,git quiz,1,Git Worksheet,1,ITIL,1,ITSM,1,Jira,3,Kubernetes,1,Kubernetes Quiz,5,SAST DAST Security Testing,1,SDLC Quiz,5,SonarQube,3,Splunk,2,vagrant kubernetes,1,Windows,1,YAML Basics,1,
ltr
item
DevOpsWorld: AWS - EC2 Example with Security Group
AWS - EC2 Example with Security Group
https://blogger.googleusercontent.com/img/a/AVvXsEg-Us09Y2Rnuf-sqq_DC2ksf5IwXpbfMBPxx6XXSd_27Y9qPjpNtYoXczuPqPzrMtnDIQ0tzYGMMo-_NpercxnE3gjwm8_hRZyzz3RsMt1czbevyCYnZL-cRZdszTnlsz_ikJyqmKXSzbWq6RL4174oDrEAvZGFdykhRPhKVIgkiVf1WEHi3MMP1C2z=w103-h26
https://blogger.googleusercontent.com/img/a/AVvXsEg-Us09Y2Rnuf-sqq_DC2ksf5IwXpbfMBPxx6XXSd_27Y9qPjpNtYoXczuPqPzrMtnDIQ0tzYGMMo-_NpercxnE3gjwm8_hRZyzz3RsMt1czbevyCYnZL-cRZdszTnlsz_ikJyqmKXSzbWq6RL4174oDrEAvZGFdykhRPhKVIgkiVf1WEHi3MMP1C2z=s72-w103-c-h26
DevOpsWorld
https://www.devopsworld.co.in/2022/03/aws-ec2-example-with-security-group.html
https://www.devopsworld.co.in/
https://www.devopsworld.co.in/
https://www.devopsworld.co.in/2022/03/aws-ec2-example-with-security-group.html
true
5997357714110665304
UTF-8
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS PREMIUM CONTENT IS LOCKED STEP 1: Share to a social network STEP 2: Click the link on your social network Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy Table of Content