You are currently viewing The best way to Bootstrap a Net Server on AWS EC2

The best way to Bootstrap a Net Server on AWS EC2


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

We will use the next code to begin an internet 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>Hey World from $(hostname -f)</h1>" > /var/www/html/index.html

Steps to create a brand new bootstrapped occasion

Step 1 – Launch a brand new occasion

Login to your EC2 console and click on Launch situations.

Choose an Amazon Machine Picture (AMI). We’ll choose Amazon Linux 2.

Select an occasion sort from the checklist. We’ll use a Free Tier Eligible t2.micro. Click on Subsequent.

Maintain 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>Hey World from $(hostname -f)</h1>" > /var/www/html/index.html
```<determine class="wp-block-image size-large">

<img decoding="async" loading="lazy" width="683" top="350" src="https://ataiva.com/wp-content/uploads/2022/03/1-683x350.png" alt="" class="wp-image-8763" srcset="https://ataiva.com/wp-content/uploads/2022/03/1-683x350.png 683w, https://ataiva.com/wp-content/uploads/2022/03/1-300x154.png 300w, https://ataiva.com/wp-content/uploads/2022/03/1-768x394.png 768w, https://ataiva.com/wp-content/uploads/2022/03/1-1536x787.png 1536w, https://ataiva.com/wp-content/uploads/2022/03/1.png 1920w" sizes="(max-width: 683px) 100vw, 683px" /> </determine> 

Click on Subsequent.

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

### Step 2 &#8211; Add tags

Click on `Add Tag` and enter a Key of `Title` and a worth of `Bootstrapped Net Server`<determine class="wp-block-image size-large">

<img decoding="async" loading="lazy" width="800" top="254" src="https://ataiva.com/wp-content/uploads/2022/03/image-800x254.png" alt="" class="wp-image-8770" srcset="https://ataiva.com/wp-content/uploads/2022/03/image-800x254.png 800w, https://ataiva.com/wp-content/uploads/2022/03/image-300x95.png 300w, https://ataiva.com/wp-content/uploads/2022/03/image-768x243.png 768w, https://ataiva.com/wp-content/uploads/2022/03/image-1536x487.png 1536w, https://ataiva.com/wp-content/uploads/2022/03/image-2048x649.png 2048w" sizes="(max-width: 800px) 100vw, 800px" /> </determine> 

Click on Subsequent.

### Step 3 &#8211; 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 `Sort` to `HTTP`.

Click on Assessment and Launch.<determine class="wp-block-image size-large">

<img decoding="async" loading="lazy" width="701" top="350" src="https://ataiva.com/wp-content/uploads/2022/03/2-701x350.png" alt="" class="wp-image-8764" srcset="https://ataiva.com/wp-content/uploads/2022/03/2-701x350.png 701w, https://ataiva.com/wp-content/uploads/2022/03/2-300x150.png 300w, https://ataiva.com/wp-content/uploads/2022/03/2-768x384.png 768w, https://ataiva.com/wp-content/uploads/2022/03/2-1536x767.png 1536w, https://ataiva.com/wp-content/uploads/2022/03/2.png 1920w" sizes="(max-width: 701px) 100vw, 701px" /> </determine> 

Click on Launch.

### Step 4 &#8211; 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 protected. As that is the one time you'll ever be capable of obtain it.<determine class="wp-block-image size-large is-resized">

<img decoding="async" loading="lazy" src="https://ataiva.com/wp-content/uploads/2022/03/3-470x350.png" alt="" class="wp-image-8765" width="622" top="463" srcset="https://ataiva.com/wp-content/uploads/2022/03/3-470x350.png 470w, https://ataiva.com/wp-content/uploads/2022/03/3-300x223.png 300w, https://ataiva.com/wp-content/uploads/2022/03/3-768x572.png 768w, https://ataiva.com/wp-content/uploads/2022/03/3-1536x1144.png 1536w, https://ataiva.com/wp-content/uploads/2022/03/3.png 1722w" sizes="(max-width: 622px) 100vw, 622px" /> </determine> 

As soon as downloaded, click on `Launch Situations`.

### Step 5 &#8211; View the occasion

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

Within the beneath instance, the occasion id is `i-062bd33e3189adfcc`.<determine class="wp-block-image size-large is-resized">

<img decoding="async" loading="lazy" src="https://ataiva.com/wp-content/uploads/2022/03/4-505x350.png" alt="" class="wp-image-8766" width="704" top="488" srcset="https://ataiva.com/wp-content/uploads/2022/03/4-505x350.png 505w, https://ataiva.com/wp-content/uploads/2022/03/4-300x208.png 300w, https://ataiva.com/wp-content/uploads/2022/03/4-768x533.png 768w, https://ataiva.com/wp-content/uploads/2022/03/4-1536x1066.png 1536w, https://ataiva.com/wp-content/uploads/2022/03/4.png 1920w" sizes="(max-width: 704px) 100vw, 704px" /> </determine> 

After a number of seconds, you will note the brand new occasion up and operating.<determine class="wp-block-image size-large is-resized">

<img decoding="async" loading="lazy" src="https://ataiva.com/wp-content/uploads/2022/03/5-508x350.png" alt="" class="wp-image-8767" width="704" top="485" srcset="https://ataiva.com/wp-content/uploads/2022/03/5-508x350.png 508w, https://ataiva.com/wp-content/uploads/2022/03/5-300x207.png 300w, https://ataiva.com/wp-content/uploads/2022/03/5-768x530.png 768w, https://ataiva.com/wp-content/uploads/2022/03/5-1536x1059.png 1536w, https://ataiva.com/wp-content/uploads/2022/03/5.png 1920w" sizes="(max-width: 704px) 100vw, 704px" /> </determine> 

Copy the `Public IPv4 deal with` and open a brand new browser tab/window and paste it within the deal with bar.<determine class="wp-block-image size-large">

<img decoding="async" loading="lazy" width="800" top="112" src="https://ataiva.com/wp-content/uploads/2022/03/6-800x112.png" alt="" class="wp-image-8768" srcset="https://ataiva.com/wp-content/uploads/2022/03/6-800x112.png 800w, https://ataiva.com/wp-content/uploads/2022/03/6-300x42.png 300w, https://ataiva.com/wp-content/uploads/2022/03/6-768x107.png 768w, https://ataiva.com/wp-content/uploads/2022/03/6-1536x214.png 1536w, https://ataiva.com/wp-content/uploads/2022/03/6.png 1920w" sizes="(max-width: 800px) 100vw, 800px" /> </determine> 

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

Leave a Reply