Wednesday, October 28, 2026
HomeSoftware EngineeringHow one can Bootstrap a Net Server on AWS EC2

How one can Bootstrap a Net Server on AWS EC2

[ad_1]

If you launch an EC2 occasion, you should utilize the user-data to bootstrap a occasion creation script.

We are able to use the next code to start out an online server and echo out it’s occasion id:

#!/bin/bash yum replace -y yum set up -y httpd systemctl begin httpd systemctl allow httpd echo "<h1>Howdy World from $(hostname -f)</h1>" > /var/www/html/index.html

Code language: Bash (bash)

Steps to create a brand new bootstrapped occasion

Step 1 – Launch a brand new occasion

Login to your EC2 console and click on Launch cases.

Choose an Amazon Machine Picture (AMI). We are going to choose Amazon Linux 2.

Select an occasion sort from the checklist. We are going to use a Free Tier Eligible t2.micro. Click on Subsequent.

Hold all of the choices as default and scroll to the underside of the web page. Within the Consumer Information textfield, enter the next code snippet:

#!/bin/bash yum replace -y yum set up -y httpd systemctl begin httpd systemctl allow httpd echo "<h1>Howdy World from $(hostname -f)</h1>" > /var/www/html/index.html

Code language: Bash (bash)

Click on Subsequent.

Don’t change any Storage choices, and click on Subsequent.

Step 2 – Add tags

Click on Add Tag and enter a Key of Identify and a price of Bootstrapped Net Server

Click on Subsequent.

Step 3 – Create a safety group

Choose Create a brand new safety group and provides it a reputation and outline of EC2 default and Default safety group entry for EC2 respectively.

Click on Add Rule and alter the Kind to HTTP.

Click on Assessment and Launch.

Click on Launch.

Step 4 – Create and obtain a key pair

Create a brand new key pair from the primary dropdown and provides it a reputation of EC2 Occasion.

Click on Obtain Key Pair and hold it secure. As that is the one time you’ll ever have the ability to obtain it.

As soon as downloaded, click on Launch Cases.

Step 5 – View the occasion

On the Standing Web page, click on on the occasion id that’s proven on the high.

Within the under instance, the occasion id is i-062bd33e3189adfcc.

After just a few seconds, you will note the brand new occasion up and working.

Copy the Public IPv4 handle and open a brand new browser tab/window and paste it within the handle bar.

The occasion is now up and working and serving HTTP visitors on port 80.

[ad_2]

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments