<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/"
    xmlns:atom="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/" version="2.0">
    <channel>
        
        <title>
            <![CDATA[ ec2 - freeCodeCamp.org ]]>
        </title>
        <description>
            <![CDATA[ Browse thousands of programming tutorials written by experts. Learn Web Development, Data Science, DevOps, Security, and get developer career advice. ]]>
        </description>
        <link>https://www.freecodecamp.org/news/</link>
        <image>
            <url>https://cdn.freecodecamp.org/universal/favicons/favicon.png</url>
            <title>
                <![CDATA[ ec2 - freeCodeCamp.org ]]>
            </title>
            <link>https://www.freecodecamp.org/news/</link>
        </image>
        <generator>Eleventy</generator>
        <lastBuildDate>Sat, 23 May 2026 22:20:43 +0000</lastBuildDate>
        <atom:link href="https://www.freecodecamp.org/news/tag/ec2/rss.xml" rel="self" type="application/rss+xml" />
        <ttl>60</ttl>
        
            <item>
                <title>
                    <![CDATA[ How to Connect Your AWS EC2 Instance to VS Code ]]>
                </title>
                <description>
                    <![CDATA[ As a DevOps engineer, it is crucial to master at least one cloud provider. Cloud services simplify storage, data migration, and CI/CD workflows and help make these tasks easier and more efficient. If you need a basic introduction to cloud computing, ... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/how-to-connect-your-aws-ec2-instance-to-vs-code/</link>
                <guid isPermaLink="false">67e2ec52cd467794ee79d63e</guid>
                
                    <category>
                        <![CDATA[ ec2 ]]>
                    </category>
                
                    <category>
                        <![CDATA[ AWS ]]>
                    </category>
                
                    <category>
                        <![CDATA[ software development ]]>
                    </category>
                
                    <category>
                        <![CDATA[ ssh ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Cloud ]]>
                    </category>
                
                    <category>
                        <![CDATA[ server ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Ijeoma Igboagu ]]>
                </dc:creator>
                <pubDate>Tue, 25 Mar 2025 17:48:02 +0000</pubDate>
                <media:content url="https://cdn.hashnode.com/res/hashnode/image/upload/v1742397603245/c1ca0496-dbab-4570-8b6b-cb4bac5f72c1.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>As a DevOps engineer, it is crucial to master at least one cloud provider. Cloud services simplify storage, data migration, and CI/CD workflows and help make these tasks easier and more efficient.</p>
<p>If you need a basic introduction to cloud computing, here’s a beginner-friendly tutorial for you: <a target="_blank" href="https://www.freecodecamp.org/news/cloud-computing-guide-for-beginners/"><strong>What is Cloud Computing? A Guide for Beginners.</strong></a></p>
<p>In this guide, I’ll show you how to create an AWS EC2 instance. This is one of AWS’s top services for building applications. By the end of this guide, you'll know how to launch an AWS EC2 instance and connect it to VS Code.</p>
<h2 id="heading-table-of-contents"><strong>Table of Contents</strong></h2>
<ul>
<li><p><a class="post-section-overview" href="#heading-prerequisites">Prerequisites</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-what-is-an-aws-ec2-instance">What is an AWS EC2 Instance?</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-why-connect-your-aws-ec2-instance-to-vs-code">Why Connect Your AWS EC2 Instance to VS Code?</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-how-to-launch-and-connect-your-aws-ec2-instance-to-vs-code">How to Launch and Connect Your AWS EC2 Instance to VS Code</a></p>
<ul>
<li><p><a class="post-section-overview" href="#heading-step-1-create-an-aws-ec2-instance">Step 1: Create an AWS EC2 Instance</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-step-2-connect-the-aws-ec2-instance-to-your-code-editor">Step 2: Connect the AWS EC2 Instance to Your Code Editor</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-step-3-install-the-programming-language">Step 3: Install the Programming Language</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-open-a-remote-window">Step 4: Open a Remote Window</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-step-5-access-your-project-folder">Step 5: Access Your Project Folder</a></p>
</li>
</ul>
</li>
<li><p><a class="post-section-overview" href="#heading-conclusion">Conclusion</a></p>
</li>
</ul>
<h2 id="heading-prerequisites">Prerequisites</h2>
<p>Before you start, make sure you have:</p>
<ul>
<li><p>An AWS account. If you do not have one, <a target="_blank" href="https://aws.amazon.com/free/?gclid=Cj0KCQiAvvO7BhC-ARIsAGFyToVguvjmSCa99VkB7XsHepginSELSYCCYnVzZXeZSKFpRRTC8DKyh98aAkZkEALw_wcB&amp;trk=2d3e6bee-b4a1-42e0-8600-6f2bb4fcb10c&amp;sc_channel=ps&amp;ef_id=Cj0KCQiAvvO7BhC-ARIsAGFyToVguvjmSCa99VkB7XsHepginSELSYCCYnVzZXeZSKFpRRTC8DKyh98aAkZkEALw_wcB:G:s&amp;s_kwcid=AL!4422!3!645125273261!e!!g!!aws!19574556887!145779846712&amp;all-free-tier.sort-by=item.additionalFields.SortRank&amp;all-free-tier.sort-order=asc&amp;awsf.Free%20Tier%20Types=*all&amp;awsf.Free%20Tier%20Categories=*all">sign up here</a>.</p>
</li>
<li><p>A GitHub repository with your source code. If you don’t have a GitHub account, <a target="_blank" href="https://github.com/">sign up here</a>.</p>
</li>
<li><p>Basic knowledge of web development and version control.</p>
</li>
<li><p>A code editor. For this tutorial, I’m using VS Code.</p>
</li>
</ul>
<p>Let’s jump right in!</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1735997217784/fdb3b399-7a07-4cf2-8577-10859bf5542d.gif" alt="fdb3b399-7a07-4cf2-8577-10859bf5542d" class="image--center mx-auto" width="220" height="220" loading="lazy"></p>
<h2 id="heading-what-is-an-aws-ec2-instance">What is an AWS EC2 Instance?</h2>
<p>AWS EC2 (Elastic Compute Cloud) allows you to run virtual machines in the cloud. These computers allow you to run your applications without needing physical hardware.</p>
<p>There are a number of things you can you do with AWS EC2, such as hosting websites or apps, running big data or machine-learning tasks, creating testing environments, and handling tasks that need flexible, scalable computing power.</p>
<h2 id="heading-why-connect-your-aws-ec2-instance-to-vs-code">Why Connect Your AWS EC2 Instance to VS Code?</h2>
<p>Connecting your AWS EC2 instance to VS Code is helpful for several reasons. Before we start the setup process, it’s important to learn why it’s beneficial.</p>
<ol>
<li><p>Using VS Code provides a familiar and efficient development space. It feels like coding on your own machine.</p>
</li>
<li><p>You don’t have to log into your AWS EC2 instance each time. You can edit files, run commands, and debug code from a distance.</p>
</li>
<li><p>You can streamline your workflow with built-in terminal access and extensions. This way, you won't have to switch between SSH clients all the time.</p>
</li>
<li><p>You can push changes to GitHub. This makes working together and deploying much smoother.</p>
</li>
<li><p>VS Code works well with Java, Node.js, and Python. It supports many languages and frameworks, so it's great for cloud development.</p>
</li>
</ol>
<p>Now that you understand the benefits, let’s move on to setting up the connection.</p>
<h2 id="heading-how-to-launch-and-connect-your-aws-ec2-instance-to-vs-code"><strong>How to Launch and Connect Your AWS EC2 Instance to VS Code</strong></h2>
<p>To launch an EC2 instance on AWS, just follow these steps:</p>
<h3 id="heading-step-1-create-an-aws-ec2-instance"><strong>Step 1: Create an AWS EC2 Instance</strong></h3>
<p>First, log into your AWS account. Then, use the search bar to find EC2 and select it.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1736016609765/f784db8e-46cc-4e03-abc0-7bdea9b1c668.png" alt="Searching for EC2 on AWS Console" class="image--center mx-auto" width="1920" height="970" loading="lazy"></p>
<p>Click EC2 and follow the on-screen instructions to create a new instance.</p>
<ol>
<li><p><strong>Choose an AMI (Amazon Machine Image):</strong> This is a pre-configured template that includes an operating system and may come with additional software.</p>
</li>
<li><p><strong>Select an instance type:</strong> Pick the right size for your needs. For example, <code>t2.micro</code> is a good option for beginners and small workloads.</p>
</li>
<li><p><strong>Configure Your EC2 Instance:</strong> Set up networking, storage, security groups, and other options based on your requirements.</p>
</li>
<li><p><strong>Launch Your Instance:</strong> Start your virtual server and access it remotely to begin using it.</p>
</li>
</ol>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1736174305817/e8d9d8dd-f09d-4bca-a838-42ee55607fa5.gif" alt="creating an EC2 instance" class="image--center mx-auto" width="1920" height="971" loading="lazy"></p>
<p>Launched instance running:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1736174700999/b729de98-bd8f-496f-9486-3079d87fb4de.png" alt="Launched Instance" class="image--center mx-auto" width="1553" height="209" loading="lazy"></p>
<p>So what’s happening in Step 1?</p>
<p>By launching an AWS EC2 instance, you are setting up a remote server in the cloud. AWS offers different AMIs that serve as pre-configured environments.</p>
<h3 id="heading-step-2-connect-the-aws-ec2-instance-to-your-code-editor">Step 2: <strong>Connect the AWS EC2 Instance to Your Code Editor</strong></h3>
<p>To connect your EC2 instance created in AWS to your VS Code, you need SSH.</p>
<h4 id="heading-what-is-ssh">What is SSH?</h4>
<p>SSH (Secure Shell) is a secure way to connect and communicate with other devices. It keeps your connection safe. This is important when you access servers or repositories. In Git, you can use SSH instead of HTTPS to clone repositories with a secure connection.</p>
<h4 id="heading-why-is-ssh-important-here">Why is SSH important here?</h4>
<p>With SSH, you can link your local code editor (like VS Code) to your AWS EC2 instance. This allows you to work on files stored on the EC2 instance directly from your editor as if on your local computer.</p>
<p><strong>To connect your AWS EC2 instance to your local editor using SSH, follow these steps:</strong></p>
<ul>
<li><p>Open your terminal.</p>
</li>
<li><p>Go to the folder where your <code>.pem</code> key file is. The key file (.pem) downloads automatically when you create your EC2 instance (usually in the Downloads folder).</p>
</li>
<li><p>Update the file permissions to keep your key secure and ensure proper authentication.</p>
</li>
</ul>
<p>For Linux users, use this command to update the file permissions:</p>
<pre><code class="lang-bash">chmod 400 codebuild-keypair.pem
</code></pre>
<p>For Windows users, first you’ll need to find the username of your laptop, as you’ll need it to update the file permissions.</p>
<p>To do this, open your terminal and type:</p>
<pre><code class="lang-powershell">whoami
</code></pre>
<p>This will display your current username.</p>
<p>Once you have your username, use the following command to update the file permissions:</p>
<pre><code class="lang-powershell">icacls <span class="hljs-string">"codebuild-keypair.pem"</span> /reset
icacls <span class="hljs-string">"codbuild-keypair.pem"</span> /grant:<span class="hljs-built_in">r</span> <span class="hljs-string">"%USERNAME%:R"</span>
icacls <span class="hljs-string">"codebuld-keypair.pem"</span> /inheritance:<span class="hljs-built_in">r</span>
</code></pre>
<p>Here's what I mean: My username is <strong>ijeon</strong>, so you should replace it with <strong>your laptop's username</strong> and <strong>own</strong> key, which ends with <code>.pem</code> extension.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1736021541861/048a9411-2348-48dc-8a6e-04d51dbd347d.png" alt="pasting the command on the terminal" class="image--center mx-auto" width="1096" height="102" loading="lazy"></p>
<p>Running this command above updates the file permissions. So with this, you can work with your remote server.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1736021649692/118c75cf-30b4-474c-b726-142c2b4326e9.png" alt="the output of the command pasted" width="722" height="153" loading="lazy"></p>
<p>Now that you have set the correct file permissions, you can use the SSH command along with the IPv4 address to connect to our EC2 instance. Type the following command:</p>
<pre><code class="lang-powershell">ssh <span class="hljs-literal">-i</span> [<span class="hljs-type">PATH</span> <span class="hljs-type">TO</span> <span class="hljs-type">YOUR</span> <span class="hljs-type">.PEM</span> <span class="hljs-type">FILE</span>] ec2<span class="hljs-literal">-user</span><span class="hljs-selector-tag">@</span>[<span class="hljs-type">YOUR</span> <span class="hljs-type">PUBLIC</span> <span class="hljs-type">IPV4</span> <span class="hljs-type">DNS</span>]
</code></pre>
<p>Example:</p>
<pre><code class="lang-powershell">ssh <span class="hljs-literal">-i</span> <span class="hljs-string">"C:\Users\ijeon\OneDrive\Desktop\devops-series-nextwork\codebuild-keypair.pem"</span> ec2<span class="hljs-literal">-user</span>@ec2<span class="hljs-literal">-35</span><span class="hljs-literal">-178</span><span class="hljs-literal">-142</span><span class="hljs-literal">-201</span>.eu<span class="hljs-literal">-west</span><span class="hljs-literal">-2</span>.compute.amazonaws.
</code></pre>
<p>Breaking it down:</p>
<ol>
<li><p><code>ssh</code>: This starts a secure remote connection.</p>
</li>
<li><p><code>-i "C:\Users\ijeon\...\codebuild-keypair.pem"</code>: This tells SSH to use the <code>.pem</code> key file for secure access.</p>
</li>
<li><p><a target="_blank" href="mailto:ec2-user@ec2-35-178-142-201.eu-west-2.compute.amazonaws.com"><code>ec2-user@ec2-35-178-142-201.eu-west-2.compute.amazonaws.com</code></a>:</p>
<ul>
<li><p><code>ec2-user</code> is the default username for EC2 instances.</p>
</li>
<li><p><code>@ec2-35-178-142-201...</code> is the public address of your EC2 instance.</p>
</li>
</ul>
</li>
</ol>
<p>This command logs you into your EC2 instance remotely from your computer. It then uses the key (<code>.pem</code> file) instead of a password for security. It also lets you control the EC2 instance from your terminal as if you were using it directly.</p>
<p>If everything is set up correctly, a “success message” will appear. This confirms that you've logged in and can access the remote server.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1742153348953/a68f32fc-7578-4904-9b2e-e63a353e84a0.gif" alt="connecting via ssh" class="image--center mx-auto" width="1920" height="1079" loading="lazy"></p>
<h3 id="heading-step-3-install-the-programming-language"><strong>Step 3: Install the Programming Language</strong></h3>
<p>Now that you’ve linked your instance to the editor, you can install the packages needed to build your web app. You can use any programming language you're comfortable with, but we’ll use Java for this tutorial. This will be a simple web application – we don’t need to go into advanced details.</p>
<h4 id="heading-1-install-java"><strong>1. Install Java</strong></h4>
<p>In your terminal, run the following commands to install <strong>Java</strong>:</p>
<pre><code class="lang-powershell">sudo dnf install <span class="hljs-literal">-y</span> java<span class="hljs-literal">-1</span>.<span class="hljs-number">8.0</span><span class="hljs-literal">-amazon</span><span class="hljs-literal">-corretto</span><span class="hljs-literal">-devel</span>

export JAVA_HOME=/usr/lib/jvm/java<span class="hljs-literal">-1</span>.<span class="hljs-number">8.0</span><span class="hljs-literal">-amazon</span><span class="hljs-literal">-corretto</span>.x86_64

export PATH=/usr/lib/jvm/java<span class="hljs-literal">-1</span>.<span class="hljs-number">8.0</span><span class="hljs-literal">-amazon</span><span class="hljs-literal">-corretto</span>.x86_64/jre/bin/:<span class="hljs-variable">$PATH</span>
</code></pre>
<p>This installs Java on your system. You also need Maven. It helps manage Java projects and create templates for web applications.</p>
<h4 id="heading-2-install-maven"><strong>2. Install Maven</strong></h4>
<p>Maven helps you organize Java projects. It also lets you create templates for web applications. Run these commands to install Maven:</p>
<pre><code class="lang-powershell"><span class="hljs-built_in">wget</span> https://archive.apache.org/dist/maven/maven<span class="hljs-literal">-3</span>/<span class="hljs-number">3.5</span>.<span class="hljs-number">2</span>/binaries/apache<span class="hljs-literal">-maven</span><span class="hljs-literal">-3</span>.<span class="hljs-number">5.2</span><span class="hljs-literal">-bin</span>.tar.gz

sudo tar <span class="hljs-literal">-xzf</span> apache<span class="hljs-literal">-maven</span><span class="hljs-literal">-3</span>.<span class="hljs-number">5.2</span><span class="hljs-literal">-bin</span>.tar.gz <span class="hljs-literal">-C</span> /opt

<span class="hljs-built_in">echo</span> <span class="hljs-string">"export PATH=/opt/apache-maven-3.5.2/bin:<span class="hljs-variable">$PATH</span>"</span> &gt;&gt; ~/.bashrc

source ~/.bashrc
</code></pre>
<p>To confirm Maven's correct installation, run this command:</p>
<pre><code class="lang-powershell">mvn <span class="hljs-literal">-v</span>
</code></pre>
<p>Also, run the following command to check whether you have Java installed:</p>
<pre><code class="lang-powershell">java <span class="hljs-literal">-version</span>
</code></pre>
<p>Now that you have installed Maven, you can use it to create a Java web app with the following command:</p>
<pre><code class="lang-powershell">mvn archetype:generate \
  <span class="hljs-literal">-DgroupId</span>=com.nextwork.app \
  <span class="hljs-literal">-DartifactId</span>=nextwork<span class="hljs-literal">-web</span><span class="hljs-literal">-project</span> \
  <span class="hljs-literal">-Dpackage</span>=com.nextwork.app \
  <span class="hljs-literal">-DarchetypeArtifactId</span>=maven<span class="hljs-literal">-archetype</span><span class="hljs-literal">-webapp</span> \
  <span class="hljs-literal">-DarchetypeVersion</span>=<span class="hljs-number">1.4</span> \
  <span class="hljs-literal">-DinteractiveMode</span>=false
</code></pre>
<p>Running the command above generates a template for your application. In the terminal, it should show a "Build Success" message. This means the setup worked.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1742122446716/7c51b3a2-6a8c-463d-817c-9630488a803d.png" alt="Installing the template" class="image--center mx-auto" width="1410" height="854" loading="lazy"></p>
<h3 id="heading-step-4-open-a-remote-window"><strong>Step 4:</strong> Open a Remote Window</h3>
<p>Now that you’ve installed the necessary packages and set up your app template, you need to open your IDE or code editor. This will let you access the folders on your remote server.</p>
<p>In your terminal, click the double arrow icon at the bottom left.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1736073016500/cb3a4d44-3ae5-4ccb-9006-c592c0be30f7.png" alt="double arrow at the left" class="image--center mx-auto" width="155" height="119" loading="lazy"></p>
<p>When you click on it, it opens a modal window for you.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1736073334686/a24d115c-9da3-4b46-80be-a75d73a189ab.gif" alt="connect to the host" class="image--center mx-auto" width="1920" height="1079" loading="lazy"></p>
<p>A window will appear. Click "Connect to Host," which will open another window.</p>
<p>Then choose "Add New SSH Host" to open the SSH connection terminal.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1736073802080/45dbc209-0b4c-41a2-83eb-3fa05a8eff20.gif" alt="adding ssh host" class="image--center mx-auto" width="1920" height="1079" loading="lazy"></p>
<p>Input your SSH command to configure the host.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1736078262849/b09d017e-cbd3-476e-9641-63dc41e34d83.png" alt="image of SSH connection command" class="image--center mx-auto" width="928" height="146" loading="lazy"></p>
<p>After pressing "Enter," a configuration file will open. In this file, ensure that the <code>.pem</code> file and the <code>IP4v DNS</code> addresses from your EC2 instance are correct.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1736083806867/e158ee79-67d3-41c8-bb63-870caab0033b.png" alt="place to press for the configuration file" class="image--center mx-auto" width="890" height="207" loading="lazy"></p>
<p>Here’s a GIF view of the image above:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1736083586490/7520a325-376d-42a8-905d-2e22770498de.gif" alt="a gif view of how to open your configuration file" class="image--center mx-auto" width="1920" height="1079" loading="lazy"></p>
<p>Here’s the configuration file:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1736084278100/6e71324f-6b47-4a2a-b7a1-89c1be10c39b.png" alt="config file" class="image--center mx-auto" width="1348" height="349" loading="lazy"></p>
<p>Go back to your editor and click on that double arrow again. This will automatically open a new window.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1736086002267/53e4edd8-afe2-4652-90ab-56bc90f80405.gif" alt="Re-opening a new window" class="image--center mx-auto" width="1920" height="1079" loading="lazy"></p>
<p>If your editor displays the IPv4 DNS address, your VS Code is successfully connected to the EC2 instance.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1736086479299/e399f86c-e236-4efc-8d4d-a7055139d01e.png" alt="connection to the remote server" width="683" height="209" loading="lazy"></p>
<p>Now that you’re connected and a new window has opened, let’s access the folder stored in the cloud.</p>
<h3 id="heading-step-5-access-your-project-folder">Step 5: Access Your Project Folder</h3>
<p>In step 3, remember when you installed Maven? It created a template for your web app. Now, you’ll access the folder where you created this.</p>
<ol>
<li><p>Go to the Explorer panel in the window.</p>
</li>
<li><p>Click the <strong>“</strong>Open Folder<strong>”</strong> button.</p>
</li>
</ol>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1736087503207/7fb21fcb-939e-4f17-83d2-93a6e0e3ee68.png" alt="access remote folder" class="image--center mx-auto" width="219" height="171" loading="lazy"></p>
<p>Clicking on this button opens a modal box for you to select your folder, which was created by the Maven template:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1742134089654/77104e69-4c7a-4b59-812d-423167079f24.gif" alt="accessing the folder" class="image--center mx-auto" width="1920" height="1079" loading="lazy"></p>
<p>To access the template file, click the “src” folder. This takes you to the <code>index.jsp</code> file.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1742135158716/4cfedc15-1c2e-4d60-b9f6-fe04c300dfa0.png" alt="template automatically created for you" width="1920" height="1080" loading="lazy"></p>
<p>With this template created, you can decide to tweak it and send it to your Git repository for storage.</p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>Great job! You’ve set up an AWS EC2 instance, linked it to your code editor, and installed the tools needed for your web app. In this tutorial, we used Java, but you can also choose other languages like Node.js or Python.</p>
<p>If you found this article helpful, please share it with others who may find it interesting.</p>
<p>Stay updated with my projects by following me on <a target="_blank" href="https://twitter.com/ijaydimples">Twitter</a>, <a target="_blank" href="https://twitter.com/ijaydimples">LinkedIn</a> and <a target="_blank" href="https://github.com/ijayhub">GitHub</a>.</p>
<p>Thank you for reading.</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ AWS EC2: How to Quickly Host Your Website with User Data Scripts ]]>
                </title>
                <description>
                    <![CDATA[ If you want to practice and improve your web hosting skills, this tutorial is for you. With AWS EC2 and a little magic called user data scripts, you’ll be running a stunning website with a CSS template in no time. And the best part? You don’t need to... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/aws-ec2-how-to-host-a-website-with-user-data-scripts/</link>
                <guid isPermaLink="false">67462204c9e1cbc5414b4e0c</guid>
                
                    <category>
                        <![CDATA[ AWS ]]>
                    </category>
                
                    <category>
                        <![CDATA[ ec2 ]]>
                    </category>
                
                    <category>
                        <![CDATA[ hosting ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Kedar Makode ]]>
                </dc:creator>
                <pubDate>Tue, 26 Nov 2024 19:31:16 +0000</pubDate>
                <media:content url="https://cdn.hashnode.com/res/hashnode/image/upload/v1732639814571/62719c49-cd15-4f2c-9586-22a5a300bc4a.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>If you want to practice and improve your web hosting skills, this tutorial is for you. With AWS EC2 and a little magic called user data scripts, you’ll be running a stunning website with a CSS template in no time. And the best part? You don’t need to manually install everything – the user data script does all the heavy lifting for you.</p>
<p>Before getting started with this guide, make sure you've read through my <a target="_blank" href="https://www.freecodecamp.org/news/host-a-website-on-aws-ec2-using-a-css-template">previous tutorial</a> on AWS EC2. It covers the essentials of creating and configuring an EC2 instance. You'll learn how to navigate the AWS Management Console, select the right instance type, configure security groups, and more.</p>
<p>This foundational knowledge will make sure you're fully prepared to launch your website effortlessly with the help of user data scripts.</p>
<p>So, grab a coffee, and let’s dive into this fun and simple guide. By the end, you’ll be able to launch your own website without breaking a sweat.</p>
<h2 id="heading-table-of-contents">Table of Contents</h2>
<ul>
<li><p><a class="post-section-overview" href="#heading-what-well-cover">What We'll Cover</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-step-1-launch-your-ec2-instance">Step 1: Launch Your EC2 Instance</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-step-2-wait-the-script-did-everything-already">Step 2: Wait… The Script Did Everything Already?</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-step-3-access-your-website">Step 3: Access Your Website</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-wrapping-up">Wrapping Up</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-want-more">Want more?</a></p>
</li>
</ul>
<h2 id="heading-what-well-cover">What We’ll Cover:</h2>
<p>Today, we’re going to:</p>
<ul>
<li><p>Launch an EC2 instance (Don’t worry, it’s easier than it sounds).</p>
</li>
<li><p>Use a user data script to automate setting up a web server.</p>
</li>
<li><p>Download a CSS template and host it on your instance.</p>
</li>
</ul>
<p>You might be wondering: why a user data script? Imagine it as a to-do list for your EC2 instance. When the instance boots up, it runs through this list and sets everything up automatically. It’s like having a personal assistant that handles all the tedious setup tasks. Sounds good, right?</p>
<h3 id="heading-step-1-launch-your-ec2-instance">Step 1: Launch Your EC2 Instance</h3>
<p>First things first, head over to your AWS Management Console. This is where all the magic happens.</p>
<p>Log in to AWS and head to the AWS Console. If you don’t already have an account, don’t worry, you can just sign up – it's free for basic usage.</p>
<p>Now here are the steps you’ll follow to launch the instance:</p>
<ul>
<li><p>In the console, type <strong>EC2</strong> in the search bar and click on the EC2 service.</p>
</li>
<li><p>Click the big <strong>Launch Instance</strong> button.</p>
</li>
<li><p>Give your instance a cool <strong>name</strong> like "Webserver".</p>
</li>
<li><p><strong>Choose Your AMI</strong>: Select the Amazon Linux 2 AMI (free-tier eligible). It’s lightweight, fast, and perfect for our use case.</p>
</li>
<li><p><strong>Instance Type</strong>: Go for the t2.micro (it’s free for most use cases, and we love free things, right?).</p>
</li>
<li><p><strong>User Data Script</strong>: Now, this is where things get good. Scroll down to Advanced Details, and in the User Data field, paste in the following script. This script will handle everything from installing Apache to downloading and unzipping a fancy CSS template.</p>
</li>
<li><p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1732640127024/ec187a49-61ac-4a98-82c1-c149bcf8ef91.png" alt="user data script" class="image--center mx-auto" width="735" height="567" loading="lazy"></p>
<pre><code class="lang-bash">  <span class="hljs-comment">#!/bin/bash</span>

  <span class="hljs-comment"># Update the instance and install necessary packages</span>
  yum update -y
  yum install -y httpd wget unzip

  <span class="hljs-comment"># Start Apache and enable it to start on boot</span>
  systemctl start httpd
  systemctl <span class="hljs-built_in">enable</span> httpd

  <span class="hljs-comment"># Navigate to the web root directory</span>
  <span class="hljs-built_in">cd</span> /var/www/html

  <span class="hljs-comment"># Download a CSS template directly</span>
  wget https://www.free-css.com/assets/files/free-css-templates/download/page284/built-better.zip

  <span class="hljs-comment"># Unzip the template and move the files to the web root</span>
  unzip built-better.zip -d /var/www/html/
  mv /var/www/html/html/* /var/www/html/

  <span class="hljs-comment"># Clean up unnecessary files</span>
  rm -r /var/www/html/html
  rm built-better.zip

  <span class="hljs-comment"># Restart Apache to apply changes</span>
  systemctl restart httpd
</code></pre>
<ul>
<li><strong>Configure Your Security Group</strong>: You want the world to be able to see your site, right? So, make sure to allow <strong>HTTP</strong> (port 80). This will let your website be accessible to anyone with the link.</li>
</ul>
</li>
</ul>
<ul>
<li><strong>Launch Your Instance</strong>: After double-checking everything, click <strong>Launch</strong>. AWS will ask you to choose a key pair (which you’ll need if you want to SSH into your instance later). If you don’t have one, create a new key pair.</li>
</ul>
<p>    Boom! Your EC2 instance is launching. Grab a snack, it’ll be ready in a few minutes.</p>
<h3 id="heading-step-2-waitthe-script-did-everything-already">Step 2: Wait…The Script Did Everything Already?</h3>
<p>Yes, that’s right! Thanks to the user data script, all the heavy lifting is done for you.</p>
<p>Here’s what just happened behind the scenes:</p>
<ul>
<li><p>Apache Web Server was installed and started.</p>
</li>
<li><p>A CSS template called “Built Better” was downloaded directly into the server.</p>
</li>
<li><p>The template was unzipped and placed in the web directory.</p>
</li>
</ul>
<p>All of this happened while you were sipping your coffee.</p>
<h3 id="heading-step-3-access-your-website">Step 3: Access Your Website</h3>
<p>The exciting part is finally here! Let’s see your website in action.</p>
<ul>
<li><p>Find Your Instance’s Public IP:</p>
<ul>
<li><p>Head to your EC2 Dashboard, and you’ll see your running instance.</p>
<p>  Copy the Public IPv4 Address.</p>
</li>
</ul>
</li>
<li><p>Open Your Browser:</p>
<ul>
<li><p>In the address bar, type: <code>http://your-public-ip</code> (replace <code>your-public-ip</code> with the one you just copied).</p>
</li>
<li><p>Hit enter, and… <strong>Voilà!</strong> Your website is live, looking all professional with the “Built Better” CSS template.</p>
</li>
</ul>
</li>
</ul>
<h2 id="heading-wrapping-up">Wrapping Up</h2>
<p>Let’s take a moment to appreciate what you’ve accomplished:</p>
<ul>
<li><p>Launched an EC2 instance ✔️</p>
</li>
<li><p>Automated the setup using a user data script ✔️</p>
</li>
<li><p>Hosted a slick website using a CSS template ✔️</p>
</li>
</ul>
<p>You’ve just dipped your toes into the world of AWS and cloud hosting. It’s not as intimidating as it sounds, right? If you enjoyed this, keep exploring AWS – the possibilities are endless. Until next time, happy coding and hosting!</p>
<h3 id="heading-want-more">Want more?</h3>
<p>Follow me on Twitter or connect on LinkedIn for more awesome cloud tips and tricks. I’m always sharing helpful content and would love to hear about your cloud journey!</p>
<p>You can follow me on</p>
<ul>
<li><p><a target="_blank" href="https://twitter.com/Kedar__98">Twitter</a></p>
</li>
<li><p><a target="_blank" href="https://www.linkedin.com/in/kedar-makode-9833321ab/?originalSubdomain=in">LinkedIn</a></p>
</li>
</ul>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How to Host a Website on AWS EC2 Using a CSS Template ]]>
                </title>
                <description>
                    <![CDATA[ Are you ready to take your web hosting skills to the next level by using a CSS template? Hosting a professional looking website doesn’t have to be complicated, and with AWS EC2, you can have your website live in no time! In this guide, I’ll show you ... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/host-a-website-on-aws-ec2-using-a-css-template/</link>
                <guid isPermaLink="false">672e5a06d7a5828f344ec242</guid>
                
                    <category>
                        <![CDATA[ AWS ]]>
                    </category>
                
                    <category>
                        <![CDATA[ ec2 ]]>
                    </category>
                
                    <category>
                        <![CDATA[ CSS ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Kedar Makode ]]>
                </dc:creator>
                <pubDate>Fri, 08 Nov 2024 18:35:50 +0000</pubDate>
                <media:content url="https://cdn.hashnode.com/res/hashnode/image/upload/v1731103973241/e1277a4c-3456-4f11-b809-24caf56ae13a.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>Are you ready to take your web hosting skills to the next level by using a CSS template? Hosting a professional looking website doesn’t have to be complicated, and with AWS EC2, you can have your website live in no time!</p>
<p>In this guide, I’ll show you how to host a website using a pre-designed template from <a target="_blank" href="https://www.free-css.com/free-css-templates"><strong>CSS templates</strong></a> directly on your EC2 instance.</p>
<p>Before we dive into this guide, make sure you’ve gone through my <a target="_blank" href="https://www.freecodecamp.org/news/how-to-launch-an-ec2-instance-and-a-web-server-using-httpd/"><strong>previous blog</strong></a> on how to launch and connect to an EC2 instance. If you haven’t set up an EC2 instance yet, head over to that post first to get your instance up and running. Once that’s done, you’re all set to proceed!</p>
<h3 id="heading-step-1-download-the-built-better-template">Step 1: Download the "Built Better" Template</h3>
<p>For this tutorial, we’ll use the Built Better template, which is free and easy to set up.</p>
<p>Head over to <a target="_blank" href="https://www.free-css.com/free-css-templates/page284/built-better">this link</a> and download the template.</p>
<p>Right-click on the download button and select "Copy clean link". We’ll use this link to download the template directly into your EC2 instance.</p>
<h3 id="heading-step-2-download-the-template-directly-to-your-ec2-instance">Step 2: Download the Template Directly to Your EC2 Instance</h3>
<p>Now that you have the link to the template, let’s download it straight to your EC2 instance using <code>wget</code>.</p>
<p>Log in to your EC2 instance via SSH or MobaXterm (as covered in my <a target="_blank" href="https://www.freecodecamp.org/news/connect-to-your-ec2-instance-using-mobaxterm/"><strong>previous blog</strong></a>) and navigate to the <code>/var/www/html</code> directory where your website files will be stored:</p>
<pre><code class="lang-bash"><span class="hljs-built_in">cd</span> /var/www/html
</code></pre>
<p>Use the <code>wget</code> command followed by the copied link to download the "Built Better" template directly into your EC2 instance:</p>
<pre><code class="lang-bash">sudo wget https://www.free-css.com/assets/files/free-css-templates/download/page284/built-better.zip
</code></pre>
<p><strong>Note:</strong> After downloading, it's a good idea to check the file name to ensure it matches the file used in the subsequent commands. You can do this by running the <code>ls</code> command:</p>
<pre><code class="lang-bash">ls
</code></pre>
<h3 id="heading-step-3-unzip-the-template-files">Step 3: Unzip the Template Files</h3>
<p>Now that the template has been downloaded, it’s time to extract it. Install the <code>unzip</code> utility if it’s not already installed:</p>
<pre><code class="lang-bash">sudo dnf install unzip -y
</code></pre>
<p>Then unzip the template:</p>
<pre><code class="lang-bash">sudo unzip built-better.zip -d /var/www/html/
</code></pre>
<p>After unzipping, make sure to check the folder name where the files were extracted from. You can do this by listing the contents of the <code>/var/www/html</code> directory:</p>
<pre><code class="lang-bash">ls /var/www/html/
</code></pre>
<p>In this case, the unzipped contents are located inside a folder named <code>html</code>. This folder contains all the template files. If the folder name is different in your case, adjust the following steps accordingly.</p>
<p>First, move the files from the <code>html</code> folder to the root <code>/var/www/html/</code> directory:</p>
<pre><code class="lang-bash">sudo mv /var/www/html/html/* /var/www/html/
</code></pre>
<p>Then remove the unnecessary folder:</p>
<pre><code class="lang-bash">sudo rm -r /var/www/html/html
</code></pre>
<p>Lastly, remove the ZIP file:</p>
<pre><code class="lang-bash">sudo rm built-better.zip
</code></pre>
<h3 id="heading-step-4-set-up-the-web-server-to-host-your-template">Step 4: Set Up the Web Server to Host Your Template</h3>
<p>If you haven’t already, make sure your Apache HTTPD web server is installed and running. You can follow these steps to ensure your server is ready:</p>
<p>Install Apache (if not installed):</p>
<pre><code class="lang-bash">sudo yum install httpd -y
</code></pre>
<p>Start the Apache service:</p>
<pre><code class="lang-bash">sudo systemctl start httpd
</code></pre>
<p>Enable Apache to start on boot:</p>
<pre><code class="lang-bash">sudo systemctl <span class="hljs-built_in">enable</span> httpd
</code></pre>
<p>Now your web server should be up and running, ready to serve your template.</p>
<h3 id="heading-step-5-test-your-website">Step 5: Test Your Website</h3>
<p>Now for the exciting part seeing your site live! Open a browser and navigate to your EC2 instance’s public IP address. You should now see the Built Better template live and ready to go.</p>
<p>Here’s how to check:</p>
<ul>
<li><p>Find your EC2 instance’s public IP from the AWS EC2 dashboard.</p>
</li>
<li><p>Enter the IP in your browser, like so: <a target="_blank" href="http://your-ec2-public-ip"><code>http://your-ec2-public-ip</code></a></p>
</li>
<li><p>Your website should now be live with the Built Better template! 🎉</p>
</li>
</ul>
<h3 id="heading-wrapping-up">Wrapping Up</h3>
<p>Congratulations! You’ve successfully hosted a professional-looking website using the Built Better CSS template on your EC2 instance.</p>
<p>With just a few steps, you’ve moved from launching an EC2 instance to hosting a fully styled website, all using the AWS powerful cloud infrastructure.</p>
<p>You can follow me on</p>
<ul>
<li><p><a target="_blank" href="https://twitter.com/Kedar__98">Twitter</a></p>
</li>
<li><p><a target="_blank" href="https://www.linkedin.com/in/kedar-makode-9833321ab/?originalSubdomain=in">LinkedIn</a></p>
</li>
</ul>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How to Launch an EC2 Instance and Set Up a Web Server Using HTTPD ]]>
                </title>
                <description>
                    <![CDATA[ Hey there! Have you ever thought about creating your own web server on the cloud? Well, you’re in for a treat because in this article, we’re going to explore how you can launch an EC2 instance and use HTTPD to host a simple web server. Don’t worry – ... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/how-to-launch-an-ec2-instance-and-a-web-server-using-httpd/</link>
                <guid isPermaLink="false">672a1e5f52317a5d102c0dd9</guid>
                
                    <category>
                        <![CDATA[ ec2 ]]>
                    </category>
                
                    <category>
                        <![CDATA[ AWS ]]>
                    </category>
                
                    <category>
                        <![CDATA[ apache ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Kedar Makode ]]>
                </dc:creator>
                <pubDate>Tue, 05 Nov 2024 13:32:15 +0000</pubDate>
                <media:content url="https://cdn.hashnode.com/res/hashnode/image/upload/v1730780706184/e2ac9a27-7221-47c6-a8ae-db2f62892036.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>Hey there! Have you ever thought about creating your own web server on the cloud? Well, you’re in for a treat because in this article, we’re going to explore how you can launch an EC2 instance and use HTTPD to host a simple web server.</p>
<p>Don’t worry – it’s simpler than it sounds, and I promise to walk you through it step-by-step with a bit of fun along the way.</p>
<p>By the end of this guide, you’ll feel like a cloud wizard, casting spells that make servers appear out of thin air (well, out of Amazon’s data centers, but you get the point).</p>
<p>Ready? Let’s dive in!</p>
<h2 id="heading-table-of-content">Table Of Content</h2>
<ul>
<li><p><a class="post-section-overview" href="#heading-what-is-ec2">What Is EC2?</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-what-is-httpd">What is HTTPD?</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-step-1-how-to-launch-your-ec2-instance">Step 1: How to Launch Your EC2 Instance</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-step-2-how-to-connect-to-your-ec2-instance">Step 2: How to Connect to Your EC2 Instance</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-step-3-how-to-install-and-start-httpd-apache-web-server">Step 3: How to Install and Start HTTPD (Apache Web Server)</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-step-4-how-to-host-your-custom-web-page">Step 4: How to Host Your Custom Web Page</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-wrapping-up">Wrapping Up</a></p>
</li>
</ul>
<h2 id="heading-what-is-ec2">What Is EC2?</h2>
<p>Think of EC2 (Elastic Compute Cloud) as a hotel room in the cloud. Instead of booking a physical server to store your website, you’re renting one from Amazon’s magical cloud infrastructure. This room (or instance) comes with all the amenities you need to host a website. Today, we’ll install <strong>HTTPD</strong> (a web server software) in our “room” to make our website live. 🏨✨</p>
<h2 id="heading-what-is-httpd">What is HTTPD?</h2>
<ul>
<li><p>At its core, HTTPD stands for Hypertext Transfer Protocol Daemon. Let’s break that down:</p>
</li>
<li><p><strong>Hypertext Transfer Protocol (HTTP)</strong>: This is the standard protocol used on the web. When you type a URL into your browser or click a link, you’re using HTTP to tell the server, “Hey, send me this web page!”</p>
</li>
<li><p><strong>Daemon (D)</strong>: A daemon is just a fancy term for a background process that runs continuously on a server. In this case, the daemon is responsible for responding to requests from web browsers (like Chrome or Firefox) and sending back the appropriate content.</p>
</li>
<li><p>So, <strong>HTTPD</strong> is a program that listens for incoming HTTP requests (like when you visit a webpage) and serves back the data (HTML, CSS, images, and so on) needed to display that page.</p>
</li>
</ul>
<h4 id="heading-httpd-vs-apache2-different-names-same-game">HTTPD vs. Apache2: Different Names, Same Game</h4>
<p>Depending on your Linux distribution, you may encounter different names for the same basic software:</p>
<ul>
<li><p>On RPM-based distributions (like Red Hat, CentOS, or Fedora), it’s called httpd.</p>
</li>
<li><p>On Debian-based distributions (like Ubuntu or Debian itself), it’s referred to as apache2.</p>
</li>
</ul>
<p>Let’s look at the steps you can use to launch your EC2 instance, and how to set up a web server using HTTPD.</p>
<h2 id="heading-step-1-how-to-launch-your-ec2-instance">Step 1: How to Launch Your EC2 Instance</h2>
<p>First things first, let’s launch our EC2 instance. You’ll need an AWS account—signing up is free, and AWS offers a free tier, so this won’t cost you a dime for small-scale experiments.</p>
<p>Head over to the AWS Management Console and log in. From the search bar, type “EC2” and click on <strong>EC2 Dashboard</strong>.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1730267447129/5460a622-b2de-456a-9fae-b757caf37eef.png" alt="EC2 Dashboard" class="image--center mx-auto" width="600" height="400" loading="lazy"></p>
<p>Create a new instance by clicking on the orange <strong>Launch Instance</strong> button.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1730345828735/7f2df691-278c-4945-97a6-44e173819eb0.png" alt="Create Instance on AWS" class="image--center mx-auto" width="600" height="400" loading="lazy"></p>
<p>Next, choose the Amazon Machine Image (AMI) by selecting the Amazon Linux AMI, which is free-tier eligible and super reliable. Don’t forget to give your instance a unique name!</p>
<p>Adding a "Name" tag with a value like "MyFirstInstance" or "ProductionServer" helps you keep track of multiple instances while adding a personal touch to your cloud workspace.</p>
<p>Also, remember to check the default username for the AMI you select. Since you’ve chosen Amazon Linux, the default username is <strong>ec2-user</strong>. Keep this in mind for connecting to your instance later!</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1730346031697/3c707686-c8f9-4cdf-aaec-c369722eaea0.png" alt="Amazon Machine Image (AMI) and Tags (Name)" class="image--center mx-auto" width="600" height="400" loading="lazy"></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1730346255437/478efdf2-70b3-46e0-a0ca-131757929a69.png" alt="Amazon Machine Image (AMI) Default Username" class="image--center mx-auto" width="600" height="400" loading="lazy"></p>
<p><strong>Select an Instance Type</strong>: The t2.micro is your best buddy here again, free-tier eligible and perfect for our needs.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1730346372896/b902fd57-e7e3-4144-9186-832b590b3321.png" alt="Instance Type for EC2" class="image--center mx-auto" width="600" height="400" loading="lazy"></p>
<p><strong>Key Pair for SSH Access</strong>: Here’s where it gets important to have a <strong>.pem</strong> file to securely connect to your instance. This file, also known as a key pair, acts like the secret key to your cloud “hotel room,” allowing you to log in via SSH.</p>
<p>If you already have a <strong>.pem</strong> file for a previously created key pair, go ahead and choose that from the dropdown menu.</p>
<p>If you don’t have a <strong>.pem</strong> file, no worries! Create a new key pair by clicking <strong>Create New Key Pair</strong>, and download the <strong>.pem</strong> file to your computer. Make sure to store this file safely—you’ll need it to log in, and if you lose it, you won’t be able to access your EC2 instance!</p>
<p>Why is this file important? The <strong>.pem</strong> file is your private key, and AWS uses it to verify that you are the rightful owner trying to connect to the instance. You won’t get access without it, just like how you can’t get into a hotel room without the key.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1730346428068/e8d1c913-af2f-40ad-8a80-b2b31af934f4.png" alt="Key Pair for AWS EC2" class="image--center mx-auto" width="600" height="400" loading="lazy"></p>
<p><strong>Configure Security Group</strong>: AWS EC2 security groups are like virtual firewalls that control traffic in and out of your instance, ensuring only specific types of access. To allow web visitors, set up an HTTP rule on port 80, and for secure server logins, enable SSH on port 22 with restricted IPs.</p>
<p>You can reuse security groups across instances, making configuration easier and more consistent. Regularly review these settings to keep your instance secure and organized.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1730346477838/1b296a9d-ab53-48f6-a92b-07057332eaed.png" alt="Security Group for AWS EC2" class="image--center mx-auto" width="600" height="400" loading="lazy"></p>
<p><strong>Launch the instance</strong>: Boom! You’ve just launched your very own server in the cloud.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1730346693723/9aa28c70-8732-4071-ae03-12d983c6cb15.png" alt="Launch AWS EC2 Instance" class="image--center mx-auto" width="600" height="400" loading="lazy"></p>
<p>Wait a minute or two for your instance to come online. Now that we have our EC2 instance running, let’s move to the next step of `setting up our web server.</p>
<h3 id="heading-step-2-how-to-connect-to-your-ec2-instance">Step 2: How to Connect to Your EC2 Instance</h3>
<p>To connect, we’ll use the <strong>.pem</strong> file (key pair) we created earlier. If you’re on a Mac or Linux machine, this is super simple with SSH. For Windows folks, I recommend using <strong>MobaXterm</strong>—it’s a user-friendly terminal with SSH built-in.</p>
<p>If you’re new to connecting EC2 instances using MobaXterm, I’ve written a detailed guide in my previous blog post. You can check it out <a target="_blank" href="https://www.freecodecamp.org/news/connect-to-your-ec2-instance-using-mobaxterm/">here</a>, where I show how to set up and connect to an EC2 instance using MobaXterm.</p>
<p>For now, here’s a quick overview of the connection process using SSH:</p>
<pre><code class="lang-bash">ssh -i <span class="hljs-string">"your-key.pem"</span> ec2-user@your-ec2-public-ip
</code></pre>
<p>Replace <code>"your-key.pem"</code> with the name of your key pair and <code>"your-ec2-public-ip"</code> with the public IP of your instance (you can find this in the EC2 dashboard).</p>
<p>If you’ve connected successfully, congratulations! 🎉 You’re inside your cloud server.</p>
<h3 id="heading-step-3-how-to-install-and-start-httpd-apache-web-server">Step 3: How to Install and Start HTTPD (Apache Web Server)</h3>
<p>Alright, time to install our web server software (HTTPD)! We’ll be using Apache, one of the most popular web servers around. Don’t worry, you don’t need a degree in IT to get this working.</p>
<p>After you successfully connect to your EC2 instance from MobaXterm, you should be all set to start the installation. You’re just a few commands away from having your web server up and running!</p>
<p>It’s always good practice to make sure your server is up to date. To update your server, run:</p>
<pre><code class="lang-bash">sudo dnf update -y
</code></pre>
<p>Next, we’ll install HTTPD (Apache):</p>
<pre><code class="lang-bash">sudo dnf install httpd -y
</code></pre>
<p>Then start the HTTPD service. Run this command to get the server running.</p>
<pre><code class="lang-bash">sudo systemctl start httpd
</code></pre>
<p>Next, enable it to start on boot so that every time your EC2 instance reboots, your web server comes back to life automatically.</p>
<pre><code class="lang-bash">sudo systemctl <span class="hljs-built_in">enable</span> httpd
</code></pre>
<p>Time to test it out! Open your browser and type in your instance’s public IP. If you see the Apache test page, give yourself a high-five. 🖐️ You’ve just launched a web server!</p>
<h3 id="heading-step-4-how-to-host-your-custom-web-page">Step 4: How to Host Your Custom Web Page</h3>
<p>Now, let’s get creative! Instead of the default web server message, let’s host your very own custom web page in just one step. This will allow you to display a unique message on your site in no time.</p>
<p>Run the following command in your EC2 instance to create and display a simple, personalized web page:</p>
<pre><code class="lang-bash"><span class="hljs-built_in">echo</span> <span class="hljs-string">"Welcome to the Cloud! You’re now hosting your own custom web server 
using AWS EC2 and Apache!"</span> &gt; /var/www/html/index.html
</code></pre>
<p><strong>What does this command do?</strong></p>
<ul>
<li><p>The <code>echo</code> command outputs the text: <code>"Welcome to the Cloud! You’re now hosting your own custom web server using AWS EC2 and Apache!"</code>.</p>
</li>
<li><p>The <code>&gt;</code> symbol redirects this output to a file.</p>
</li>
<li><p><code>/var/www/html/index.html</code> is the path to the file where the message is saved. This file is the homepage of your web server.</p>
</li>
</ul>
<p>By running this command, you're replacing the default Apache test page with your custom message.</p>
<p>Now, select your EC2 instance, and you’ll find its public IP address. Open your browser, enter that IP, refresh the page, and boom! Your custom message is live on the site. 🎉</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1730347026257/8ae32095-27f2-401a-a812-12b1354c3a93.png" alt="EC2 Instance Public IP Address" class="image--center mx-auto" width="600" height="400" loading="lazy"></p>
<p>Feel free to modify the text to make it uniquely yours!</p>
<h3 id="heading-wrapping-up">Wrapping Up</h3>
<p>And there you have it – you’ve just launched an EC2 instance and set up a simple web server using HTTPD! With these steps, you’ve not only spun up a server in the cloud but also configured it to be accessible to the world. By following along, you’ve learned the essentials of creating instances, setting up security groups, connecting via SSH, and installing Apache to serve up web content.</p>
<p>Keep exploring EC2’s features, and don’t hesitate to test new configurations and ideas. Each step adds to your cloud skills, bringing you one step closer to mastering AWS. So keep building, experimenting, and, most importantly, enjoying the journey. Happy cloud computing!</p>
<p>You can follow me on</p>
<ul>
<li><p><a target="_blank" href="https://twitter.com/Kedar__98">Twitter</a></p>
</li>
<li><p><a target="_blank" href="https://www.linkedin.com/in/kedar-makode-9833321ab/?originalSubdomain=in">LinkedIn</a></p>
</li>
</ul>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How to Connect to Your EC2 Instance Using MobaXterm with SSH and a Keypair (.pem) File ]]>
                </title>
                <description>
                    <![CDATA[ In this article, I’ll walk you through the steps of connecting to your EC2 instance using MobaXterm with a .pem keypair file. Whether you're a beginner dipping your toes into the cloud or an experienced user looking for a quicker method, I’ve got you... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/connect-to-your-ec2-instance-using-mobaxterm/</link>
                <guid isPermaLink="false">6717846983737f44dd20e110</guid>
                
                    <category>
                        <![CDATA[ AWS ]]>
                    </category>
                
                    <category>
                        <![CDATA[ ec2 ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Kedar Makode ]]>
                </dc:creator>
                <pubDate>Tue, 22 Oct 2024 10:54:33 +0000</pubDate>
                <media:content url="https://cdn.hashnode.com/res/hashnode/image/upload/v1729574902773/f80eb07d-524a-4fa2-a8d8-29c6438d37aa.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>In this article, I’ll walk you through the steps of connecting to your EC2 instance using MobaXterm with a <code>.pem</code> keypair file. Whether you're a beginner dipping your toes into the cloud or an experienced user looking for a quicker method, I’ve got you covered. So, let’s dive in!</p>
<h2 id="heading-table-of-contents"><strong>Table of Contents</strong></h2>
<ul>
<li><p><a class="post-section-overview" href="#heading-why-mobaxterm">Why MobaXterm?</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-step-1-install-mobaxterm">Step 1: Install MobaXterm</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-step-2-get-your-ec2-instance-public-ip-and-key-pair">Step 2: Get Your EC2 Instance Public IP and Key Pair</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-step-3-open-mobaxterm-and-start-a-new-ssh-session">Step 3: Open MobaXterm and Start a New SSH Session</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-step-4-enter-ssh-session-details">Step 4: Enter SSH Session Details</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-step-5-attach-your-pem-key-pair">Step 5: Attach Your .pem Key Pair</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-step-6-connect-to-your-ec2-instance">Step 6: Connect to Your EC2 Instance</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-step-7-troubleshooting-common-issues">Step 7: Troubleshooting Common Issues</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-wrapping-up">Wrapping Up</a></p>
</li>
</ul>
<h2 id="heading-why-mobaxterm">Why MobaXterm?</h2>
<p>You may be wondering why we’re using MobaXterm over other SSH tools. Well, for starters, it’s super beginner-friendly, and it combines a bunch of powerful tools in one. You can use it to transfer files, run scripts, or even open multiple sessions simultaneously.</p>
<p>Plus, it’s like the Swiss Army knife for remote connections. Whether you’re working with AWS, Google Cloud, or even a Raspberry Pi at home, MobaXterm can do it all.</p>
<h2 id="heading-step-1-install-mobaxterm">Step 1: Install MobaXterm</h2>
<p>If you’re not already familiar with MobaXterm, it’s basically used for all things remote access. You can download it <a target="_blank" href="https://mobaxterm.mobatek.net/download-home-edition.html">here</a> for free. Installation is super easy – just download, click, and install.</p>
<p>Once you have it set up, fire up MobaXterm and get ready for the fun part.</p>
<h2 id="heading-step-2-get-your-ec2-instance-public-ip-and-key-pair">Step 2: Get Your EC2 Instance Public IP and Key Pair</h2>
<p>Before we continue, there are two key pieces of information you’ll need:</p>
<p><strong>Public IP Address</strong>: This is the unique address AWS assigns to your EC2 instance. To find it, go to the <strong>EC2 Dashboard</strong> in AWS, select your running instance, and grab the <strong>Public IPv4 Address</strong> (it looks like <code>13.123.45.67</code>).</p>
<p><strong>Your .pem File</strong>: This is the private key file you downloaded when you created your EC2 instance. If you didn’t save it, you may have to create a new key pair because AWS only lets you download it once. (No pressure – just don’t lose it this time!)</p>
<h2 id="heading-step-3-open-mobaxterm-and-start-a-new-ssh-session">Step 3: Open MobaXterm and Start a New SSH Session</h2>
<p>Time to work some magic with MobaXterm! Open the app, and you’ll see an intuitive interface. Don’t let all the buttons scare you, just focus on the top left where it says <strong>Session</strong>.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1729567478544/cf69a56b-9d1e-4de3-b6d8-224634b55ae3.png" alt="MobaXterm user interface" class="image--center mx-auto" width="600" height="400" loading="lazy"></p>
<p>Here’s what to do next:</p>
<ul>
<li><p>Click <strong>Session</strong> (you’ll feel powerful just pressing that button).</p>
</li>
<li><p>In the new window, select <strong>SSH</strong> as the session type.</p>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1729567593446/ee8f369d-24be-419d-971f-30e3e4355dd6.png" alt="MobaXterm Session setting tab" class="image--center mx-auto" width="600" height="400" loading="lazy"></p>
<h2 id="heading-step-4-enter-ssh-session-details">Step 4: Enter SSH Session Details</h2>
<p>It’s time to fill in the details that’ll connect MobaXterm to your EC2 instance. Here’s what you need to know:</p>
<ul>
<li><p><strong>Remote Host</strong>: Enter the <strong>Public IP Address</strong> of your EC2 instance here. Remember, you grabbed that from the EC2 Dashboard earlier.</p>
</li>
<li><p><strong>Username</strong>: If you’re using Amazon Linux, your default username is <code>ec2-user</code>. If you’re on Ubuntu, it’s <code>ubuntu</code>.</p>
</li>
</ul>
<h2 id="heading-step-5-attach-your-pem-key-pair">Step 5: Attach Your .pem Key Pair</h2>
<p>MobaXterm makes it super easy to use your <code>.pem</code> key file for authentication (no converting to <code>.ppk</code> necessary, like you’d have to with other tools).</p>
<p>Here’s how to attach your <code>.pem</code> file:</p>
<ul>
<li><p>Head over to the <strong>Advanced SSH Settings</strong> tab.</p>
</li>
<li><p>Check the <strong>Use private key</strong> option.</p>
</li>
<li><p>Click <strong>Browse</strong> and find your <code>.pem</code> file on your computer.</p>
</li>
<li><p>Select the file and hit <strong>OK</strong>.</p>
</li>
</ul>
<p>It’s like giving MobaXterm the secret key to unlock your EC2 instance.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1729567798203/535c226e-fbd2-43fc-b1af-a48ce171b974.png" alt="535c226e-fbd2-43fc-b1af-a48ce171b974" class="image--center mx-auto" width="600" height="400" loading="lazy"></p>
<h2 id="heading-step-6-connect-to-your-ec2-instance">Step 6: Connect to Your EC2 Instance</h2>
<p>Now that you’ve filled in all the details, click <strong>OK</strong> to start your session. If everything’s been set up correctly, you should see a terminal pop up, and MobaXterm will work its magic to connect you to your EC2 instance.</p>
<p>🎉 And just like that, you’re in! You should see a terminal window connected to your instance, and now you can start typing commands like a pro.</p>
<h2 id="heading-step-7-troubleshooting-common-issues">Step 7: Troubleshooting Common Issues</h2>
<p>We all know that tech doesn’t always behave. Here are some common problems you might run into—and how to solve them:</p>
<ul>
<li><p><strong>Connection Timed Out</strong>: This could be due to your instance’s security group settings. Make sure your EC2 security group allows inbound traffic on <strong>port 22</strong> (the SSH port) from your IP address.</p>
</li>
<li><p><strong>Authentication Failed</strong>: Ensure you’re using the correct username (<code>ec2-user</code> for Amazon Linux, <code>ubuntu</code> for Ubuntu).</p>
</li>
</ul>
<h2 id="heading-wrapping-up">Wrapping Up</h2>
<p>And there you have it! Connecting to your EC2 instance using MobaXterm with your <code>.pem</code> keypair is as simple as following these steps. It’s not rocket science—but it kind of feels like it, doesn’t it? Now that you’ve got your EC2 instance up and running, the sky’s the limit.</p>
<p>So, go on, take what you've learned here, explore, experiment, and, most importantly, have fun with it! Until next time, happy cloud computing! ☁️</p>
<p>You can follow me on</p>
<ul>
<li><p><a target="_blank" href="https://twitter.com/Kedar__98">Twitter</a></p>
</li>
<li><p><a target="_blank" href="https://www.linkedin.com/in/kedar-makode-9833321ab/?originalSubdomain=in">LinkedIn</a></p>
</li>
</ul>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ What is Amazon EC2 Auto Scaling? ]]>
                </title>
                <description>
                    <![CDATA[ Auto scaling is like having a smart system that keeps an eye on how many people are visiting your website. When you have a lot of people, it quickly adds more servers to handle the extra traffic. And when things quiet down, it scales back to save you... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/what-is-amazon-ec2-auto-scaling/</link>
                <guid isPermaLink="false">66b906c577c23fa04d7098f7</guid>
                
                    <category>
                        <![CDATA[ Amazon ]]>
                    </category>
                
                    <category>
                        <![CDATA[ ec2 ]]>
                    </category>
                
                    <category>
                        <![CDATA[ scaling ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Destiny Erhabor ]]>
                </dc:creator>
                <pubDate>Mon, 06 May 2024 16:32:47 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2024/05/christophe-hautier-902vnYeoWS4-unsplash.jpg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>Auto scaling is like having a smart system that keeps an eye on how many people are visiting your website. When you have a lot of people, it quickly adds more servers to handle the extra traffic. And when things quiet down, it scales back to save you money.</p>
<p>In AWS, there are two important services that help with this: Amazon EC2 Auto Scaling and AWS Auto Scaling. Amazon EC2 Auto Scaling is specifically for managing your EC2 servers, while AWS Auto Scaling can also handle other things like DynamoDB tables and Amazon Aurora databases.</p>
<p>In this article, we'll dive deeper into how Amazon EC2 Auto Scaling works and how you can use it to keep your website running smoothly without overspending on servers.</p>
<h2 id="heading-prerequisites">Prerequisites</h2>
<ul>
<li>Have an AWS account</li>
<li>Basic understanding of EC2 instance</li>
</ul>
<h2 id="heading-table-of-content">Table of Content</h2>
<ul>
<li><a class="post-section-overview" href="#heading-prerequisites">Prerequisites</a></li>
<li><a class="post-section-overview" href="#heading-example-use-case">Example Use case</a></li>
<li><a class="post-section-overview" href="#advantages-of-amazon-ec2-auto-scaling">Advantages of Amazon EC2 Auto Scaling</a></li>
<li><a class="post-section-overview" href="#heading-components-of-ec2-auto-scaling">Components of EC2 Auto Scaling</a></li>
<li><a class="post-section-overview" href="#what-is-launch-configurations-vs-launch-templates">What is Launch Configurations vs Launch Templates</a></li>
<li><a class="post-section-overview" href="#heading-how-to-create-a-launch-template">How to create a launch template</a></li>
<li><a class="post-section-overview" href="#heading-what-are-auto-scaling-groups-asgs">What are Auto Scaling Groups (ASGs)</a></li>
<li><a class="post-section-overview" href="#heading-how-to-create-an-auto-scaling-group">How to create an Auto Scaling Group</a></li>
<li><a class="post-section-overview" href="#heading-what-are-scaling-policies">What are Scaling Policies</a></li>
<li><a class="post-section-overview" href="#heading-conclusion">Conclusion</a></li>
</ul>
<h2 id="heading-example-use-case">Example Use Case</h2>
<h3 id="heading-scenario">Scenario:</h3>
<p>Imagine running a website that sells trendy clothes. Sometimes, lots of people visit your site at once, especially during lunch breaks or evenings. Other times, it's pretty quiet.</p>
<h3 id="heading-problem">Problem:</h3>
<p>You need enough servers to handle busy times, but you don't want to waste money on too many servers when it's quiet.</p>
<h3 id="heading-solution-with-amazon-ec2-auto-scaling">Solution with Amazon EC2 Auto Scaling:</h3>
<p><strong>Traffic Analysis</strong>: Look at when people visit your site the most. This helps you understand when you need more servers.</p>
<p><strong>Set Rules</strong>: Decide when to add or remove servers automatically. For example, you might say, "If more than 70% of our servers are busy for more than 5 minutes, add one more server."</p>
<p><strong>Adjust Server Numbers</strong>: Tell Amazon the smallest and biggest number of servers you need. You can also say how many you'd like on average. For instance, you might say, "Keep at least 2 servers running all the time. But if it's busy, go up to 10 servers. And usually, we need around 4."</p>
<p><strong>Load Balancing</strong>: Make sure all servers get some work. Use a load balancer to send visitors to the least busy server. This keeps everything running smoothly even if you have many servers.</p>
<p><strong>Test and Watch</strong>: Before trusting everything, test to see if it works as planned. Keep an eye on it afterward to make sure it's doing its job right.</p>
<p><strong>Save Money</strong>: With auto scaling, you don't pay for servers you're not using. When traffic is low, it reduces the number of servers, saving you money. When traffic picks up, it adds more servers, so your site stays fast.</p>
<h2 id="heading-advantages-of-using-amazon-ec2-auto-scaling">Advantages of Using Amazon EC2 Auto Scaling</h2>
<p><strong>Cost Optimization</strong>: EC2 Auto Scaling helps optimize costs by automatically adjusting the number of EC2 instances based on demand. During periods of low traffic, it reduces the number of instances, saving on operational costs. Conversely, during high traffic, it scales up to ensure optimal performance without over-provisioning resources.</p>
<p><strong>Improved Availability</strong>: By automatically distributing incoming traffic across multiple instances and fault tolerance of your application. If any instance fails/is unhealthy, the Auto Scaling group replaces it with a new one, ensuring minimal disruption to your services.</p>
<p><strong>Scalability</strong>: EC2 Auto Scaling allows your application to handle sudden spikes in traffic or increased workload without manual intervention. </p>
<p><strong>Enhanced Performance</strong>: With EC2 Auto Scaling, you can maintain consistent performance levels even during peak usage periods. By automatically adding more instances when traffic increases, it prevents performance degradation and ensures a smooth user experience.</p>
<p><strong>Ease of Management</strong>: EC2 Auto Scaling simplifies the management of your EC2 fleet by automating instance provisioning, scaling, and monitoring.</p>
<p><strong>Integration with AWS Services</strong>: EC2 Auto Scaling integrates seamlessly with other AWS services such as Elastic Load Balancing (ELB) and Amazon CloudWatch.</p>
<p><strong>Highly Customizable</strong>: EC2 Auto Scaling offers flexibility and customization options to meet the specific needs of your application.</p>
<h2 id="heading-components-of-ec2-auto-scaling">Components of EC2 Auto Scaling</h2>
<p>Let's get a better understanding on how the Auto Scaling works through its different components. </p>
<p>There are two distinct steps to configuration. The first step is the creation of a launch configuration or launch template. The second is the creation of an Auto Scaling group.</p>
<h2 id="heading-launch-configurations-and-launch-templates">Launch Configurations and Launch Templates</h2>
<p>Launch configurations or launch templates define the configuration settings for the EC2 instances that will be launched by the Auto Scaling group. </p>
<p>These settings include the AMI (Amazon Machine Image), instance type, security groups, key pair, and user data. </p>
<p>Launch configurations are older and being phased out in favor of launch templates, which offer more features and flexibility.</p>
<h3 id="heading-how-to-create-a-launch-template">How to Create a Launch Template</h3>
<p>First, navigate to EC2 Instance page</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/05/launch-template-1.png" alt="AWS instance page" width="600" height="400" loading="lazy">
<em>AWS instance page</em></p>
<p>Select the Launch Templates under the instances and click the create button.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/05/launch-template-2.png" alt="AWS launch templates" width="600" height="400" loading="lazy">
<em>AWS launch templates</em></p>
<p>The following screen should show up, almost similar to launching an <code>EC2 instance</code>. You can fill the required information accordingly.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/05/screencapture-us-east-1-console-aws-amazon-ec2-home-2024-05-03-22_52_38-1.png" alt="Create AWS launch templates" width="600" height="400" loading="lazy">
<em>Create AWS launch templates</em></p>
<p>After configuration, click the "Create Launch" template button and allow it to create, then view your newly created launch template with default and latest version as 1. You can use this launch template to create another launch template and specify a different version for it.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/05/launch-template-3-1.png" alt="View AWS launch templates" width="600" height="400" loading="lazy">
<em>View AWS launch templates</em></p>
<p>Auto scaling requires either a launch template or launch configuration to identify the instance it's launching and its configurations.</p>
<h2 id="heading-what-are-auto-scaling-groups-asgs">What are Auto Scaling Groups (ASGs)</h2>
<p>Auto Scaling groups are the core component of EC2 Auto Scaling. They define the group of EC2 instances that are managed together and share the same scaling policies. ASGs ensure that your application can automatically scale out (add instances) or scale in (remove instances) based on demand.</p>
<h3 id="heading-how-to-create-an-auto-scaling-group">How to create an Auto Scaling Group</h3>
<p>First, navigate to EC2 Instance page and under the Auto Scaling group, select and click the create button.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/05/asg-1.png" alt="Image" width="600" height="400" loading="lazy">
<em>creating an Auto Scaling group</em></p>
<p>On the create screen, the first step is to give your ASG a <code>Name</code> and then select your <code>launch template</code> created from the steps above. </p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/05/asg-2.png" alt="Image" width="600" height="400" loading="lazy">
<em>creating a launch template</em></p>
<p>The next step requires you to select or override an instance launch template. You also select a VPC and subnet.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/05/asg-3.png" alt="Image" width="600" height="400" loading="lazy">
<em>selecting instance launch template</em></p>
<p>The next step is to configure advanced options such as adding a load balancer and monitoring. You can attach or add a new load balancer but for this article we will skip this part.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/05/asg-4.png" alt="Image" width="600" height="400" loading="lazy">
<em>configuring advanced options</em></p>
<p>Next, configure the group size and scaling. Here, we want to configure the scale between minimum of 2 and maximum of 5. Also, set the metrics type to track the CPU utilization (set to 50 – you can increase to 70 or more) for scaling.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/05/screencapture-us-east-1-console-aws-amazon-ec2-home-2024-05-03-23_41_58.png" alt="Image" width="600" height="400" loading="lazy">
<em>configuring group size and scaling</em></p>
<p>Next two steps are for adding notifications (you will need to create an SNS service for this) and tags. In this article, we are going to skip these and create our ASG.</p>
<p>Create and view the ASG created. From its <strong>activity</strong> folder, you can see those two instances launched. Also, from the instances page, you should see two EC2 instances. This is because we set our desired state to 2.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/05/asg-5.png" alt="Image" width="600" height="400" loading="lazy">
<em>Auto Scaling groups</em></p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/05/asg-6.png" alt="Image" width="600" height="400" loading="lazy">
<em>Auto Scaling groups</em></p>
<h2 id="heading-what-are-scaling-policies">What are Scaling Policies?</h2>
<p>Scaling policies define the rules that govern how the Auto Scaling group scales in or out in response to changing demand. There are four types of scaling policies:</p>
<p>Let's break down each type of scaling with examples:</p>
<h3 id="heading-manual-scaling">Manual Scaling</h3>
<p>Manual scaling involves adjusting the number of EC2 instances in your Auto Scaling group manually, without relying on automated triggers or policies. This type of scaling is typically done in response to predictable events or planned changes in demand.</p>
<p><strong>Example</strong>: Assuming you run an e-commerce website, and you know that there will be a flash sale event that will attract a large number of visitors. To handle the expected surge in traffic, you can manually increase the desired capacity of your Auto Scaling group before the event, adding more EC2 instances in advance of the anticipated demand spike. After the event is over, you can manually reduce the desired capacity back to its normal level.</p>
<h5 id="heading-pros">Pros:</h5>
<ul>
<li><strong>Control</strong>: Offers direct control over the number of EC2 instances in the Auto Scaling group.</li>
<li><strong>Flexibility</strong>: Allows for immediate adjustments based on specific requirements or events.</li>
</ul>
<h5 id="heading-cons">Cons:</h5>
<ul>
<li><strong>Manual Intervention</strong>: Relies on human intervention, which can be time-consuming and prone to errors.</li>
<li><strong>Lack of Automation</strong>: Not suitable for handling dynamic or unpredictable fluctuations in demand efficiently.</li>
</ul>
<h3 id="heading-schedule-scaling">Schedule Scaling</h3>
<p>Schedule scaling involves defining predefined schedules to adjust the number of EC2 instances in your Auto Scaling group automatically. This type of scaling is useful for applications with predictable traffic patterns, such as daily or weekly fluctuations in demand.</p>
<p><strong>Example</strong>: Consider a video streaming service that experiences peak traffic during evenings and weekends. You can set up a schedule scaling policy to increase the desired capacity of your Auto Scaling group every evening at 6 PM and decrease it every morning at 6 AM. This ensures that you have enough capacity to handle peak demand periods without overspending on resources during off-peak hours.</p>
<h5 id="heading-pros-1">Pros:</h5>
<ul>
<li><strong>Predictability</strong>: Well-suited for applications with predictable traffic patterns, such as daily or weekly fluctuations.</li>
<li><strong>Cost Optimization</strong>: Helps optimize costs by aligning resources with expected demand patterns.</li>
</ul>
<h5 id="heading-cons-1">Cons:</h5>
<ul>
<li><strong>Limited Adaptability</strong>: May not be responsive to sudden changes in demand or unexpected traffic spikes.</li>
<li><strong>Requires Planning</strong>: Requires upfront planning and configuration of schedules based on historical data or business insights.</li>
</ul>
<h3 id="heading-dynamic-scaling">Dynamic Scaling</h3>
<p>Dynamic scaling adjusts the number of EC2 instances in your Auto Scaling group automatically based on real-time metrics, such as CPU utilization, network traffic, or other application-specific metrics. This type of scaling is responsive to fluctuations in demand and helps ensure optimal performance and cost-effectiveness.</p>
<h5 id="heading-types">Types:</h5>
<ul>
<li><strong>Step Scaling</strong>: This policy scales the number of instances based on a series of scaling adjustments defined by step adjustments and associated metrics thresholds. </li>
<li><strong>Target Tracking</strong>: This policy automatically adjusts the number of instances to maintain a specified target metric, such as average CPU utilization or network traffic.</li>
</ul>
<p>When adding instances to the ASG, it will take a few minutes for them to come online and handle load. This is why a cooldown policy has to be set.</p>
<p><strong>Scaling Cooldowns:</strong> Scaling cooldowns help prevent rapid fluctuations in the number of instances by imposing a cooldown period after a scaling activity is triggered. During this cooldown period, EC2 Auto Scaling will not launch or terminate additional instances, allowing time for the newly launched instances to stabilize or for the impact of terminated instances to be observed.</p>
<p><strong>Example</strong>: Let's say you operate a ride-sharing platform where demand can vary unpredictably throughout the day. With dynamic scaling, you can configure Auto Scaling policies to add more EC2 instances when the number of ride requests exceeds a certain threshold, and remove instances when demand decreases. This allows you to dynamically adapt to changing traffic patterns in real-time, ensuring a seamless experience for both drivers and passengers.</p>
<h5 id="heading-pros-2">Pros:</h5>
<ul>
<li><strong>Real-Time Responsiveness</strong>: Adjusts resource allocation dynamically in response to actual demand, ensuring optimal performance.</li>
<li><strong>Cost Efficiency</strong>: Automatically scales resources up or down, helping to optimize costs by only using what is needed.</li>
</ul>
<h5 id="heading-cons-2">Cons:</h5>
<ul>
<li><strong>Potential Over-Provisioning</strong>: May lead to over-provisioning during sudden spikes in demand if scaling policies are not properly configured.</li>
<li><strong>Complexity</strong>: Requires careful configuration of scaling policies and monitoring of metrics to ensure effective scaling behavior.</li>
</ul>
<h3 id="heading-predictive-scaling">Predictive Scaling</h3>
<p>Predictive scaling uses machine learning algorithms and historical data to forecast future demand and proactively adjust the number of EC2 instances in your Auto Scaling group. This type of scaling helps prevent under-provisioning or over-provisioning of resources by anticipating changes in demand before they occur.</p>
<p><strong>Example</strong>: Suppose you operate a weather forecasting application that experiences increased demand during severe weather events. By analyzing historical data on weather patterns and user behavior, predictive scaling can predict when a surge in traffic is likely to occur and automatically scale up the capacity of your Auto Scaling group ahead of time. This ensures that your application remains responsive and available during peak usage periods without unnecessary resource waste.</p>
<h5 id="heading-pros-3">Pros:</h5>
<ul>
<li><strong>Proactive Optimization</strong>: Anticipates future demand based on historical data, ensuring resources are provisioned ahead of time.</li>
<li><strong>Improved Cost Management</strong>: Helps prevent under-provisioning and over-provisioning, optimizing resource usage and costs.</li>
</ul>
<h4 id="heading-cons-3">Cons:</h4>
<ul>
<li><strong>Data Dependence</strong>: Relies on accurate historical data and effective machine learning models for accurate predictions.</li>
<li><strong>Initial Setup</strong>: Requires initial setup and configuration of predictive scaling models, which can be complex and resource-intensive.</li>
</ul>
<h2 id="heading-conclusion">Conclusion</h2>
<p>In conclusion, Amazon EC2 Auto Scaling offers a range of strategies to effectively manage and optimize the performance of applications running on EC2 instances.</p>
<p>Whether it's through manual adjustments, scheduled scaling, dynamic responses to real-time metrics, or proactive measures based on predictive analytics, EC2 Auto Scaling provides the flexibility and automation needed to ensure that resources are aligned with demand. </p>
<p>By leveraging these scaling capabilities, businesses can enhance availability, improve cost efficiency, and deliver a seamless user experience, ultimately driving better outcomes for their applications and customers on the AWS platform.</p>
<p>As always, I hope you enjoyed the article and learned something new. If you want, you can also follow me on <a target="_blank" href="https://www.linkedin.com/in/destiny-erhabor">LinkedIn</a> or <a target="_blank" href="https://twitter.com/caesar_sage">Twitter</a>.</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How to Connect a Domain Name to a Website Hosted on AWS EC2 ]]>
                </title>
                <description>
                    <![CDATA[ By Obed Ehoneah You may want to host your website on a virtual private server or a virtual machine like AWS EC2. But it can be a challenge to connect a domain name that you purchased from providers like Namecheap or Godaddy. But if you know the steps... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/how-to-connect-a-domain-to-a-website-hosted-on-aws-ec2/</link>
                <guid isPermaLink="false">66d45e3c680e33282da25e69</guid>
                
                    <category>
                        <![CDATA[ AWS ]]>
                    </category>
                
                    <category>
                        <![CDATA[ ec2 ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Mon, 19 Feb 2024 23:51:10 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2023/12/my-hashnode-technical-blog-images.jpg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By Obed Ehoneah</p>
<p>You may want to host your website on a virtual private server or a virtual machine like AWS EC2. But it can be a challenge to connect a domain name that you purchased from providers like Namecheap or Godaddy.</p>
<p>But if you know the steps to follow, this doesn't have to be difficult.</p>
<p>In this post, I'll break the whole process of connecting a domain name to a website hosted on EC2 down. I'll show you how to do it practically with screenshots guiding you through every step. I'll be using a Namecheap domain in this example.</p>
<p>There are 4 major steps that you'll need to follow, and it shouldn't be too tricky if you follow the discussion in this tutorial. Here they are:</p>
<ul>
<li>Step1: <a class="post-section-overview" href="#step-1-how-to-set-up-your-website-on-ec2#step-1-how-to-set-up-your-website-on-ec2">Set up your website on EC2</a></li>
<li>Step 2: <a class="post-section-overview" href="#heading-step-2-how-to-set-up-route-53-for-dns-management">Set up Route 53 for DNS management</a></li>
<li>Step 3: <a class="post-section-overview" href="#heading-step-3-update-nameservers-with-your-domain-provider">Update nameservers with your domain provider</a></li>
<li>Step 4: <a class="post-section-overview" href="#wait-for-propagation">Wait for propagation</a></li>
</ul>
<p>Let's get started.</p>
<h2 id="heading-step-1-how-to-set-up-your-website-on-ec2">Step 1: How to Set Up Your Website on EC2</h2>
<p>First, visit <a target="_blank" href="https://aws.amazon.com/console/">https://aws.amazon.com/console/</a>. Click on the sign in button at the top right corner or the Log back in button in the middle.</p>
<p><img src="https://lh7-us.googleusercontent.com/1P8t02v71WBoFie3Noxs-9-32Ckege-I36ZM4vpfsXqBiSrJTeOgvOA2F9FCTPBTFo4fkWUhwxCDIXAiB2ZTyPgRXqJpyYOGIv7EhV2AS01LnsMilBBCgvgYwKxVauR70bKfIQ3FVFD7JrrPwW_9A94" alt="Image" width="1600" height="757" loading="lazy">
<em>AWS Management Console</em></p>
<p>Create an account if you don’t already have one. Otherwise sign in with your credentials.</p>
<p><img src="https://lh7-us.googleusercontent.com/_4dJQGRVfyRepII17I6GGUmpHiEJ_YShtzztq9SBMPS8GIqk79HdS_678Cue6g7Ws06LlV28ity_Nqjwk8QJkF3SZOUgSdImmdTbOhfvpUWXZ4foziwGLkwtL1NJdTfiHnje9k9GwugtjxGRP2b14fU" alt="Image" width="1600" height="757" loading="lazy">
<em>User Login Page</em></p>
<p>After logging in, you will be redirected to the main dashboard.</p>
<p><img src="https://lh7-us.googleusercontent.com/1ten0edaOEW9fyi94wZJDYLAO4iwjMOxpR9iVX9Q-52fnDO8_W2zq85Jm9y70K0Nm32twNDmEFmFjQ1FYUvkW7iqcfHpaeBCRSZqYWSIYouvkmgvScm4p15zeH6r6El_6S23mW_GBTCd-OQ3DC-FUs4" alt="Image" width="1600" height="775" loading="lazy">
<em>User Dashboard</em></p>
<p>In the search bar at the very top, you can search for EC2 and click on the first option under Services.</p>
<p><img src="https://lh7-us.googleusercontent.com/wVnUvVADZoMmKBmWMTGjA79mBeSni4Ie7U6IuvatJNeglH1ss4-JPapyqWUNHuCTEmxHm4_Wl12jhL4Y7DbSmhO_HqFhLCRxxqfT9N_2K3o_0Sp5t_5xoAagztYd5ZXIoTX_qCZTTh07VA99E1pQRsE" alt="Image" width="1169" height="902" loading="lazy">
<em>Searching for EC2</em></p>
<p>This will then open the EC2 dashboard that gives you a summary of all the EC2 resources that you are using. If you are not using any of them, then you are likely to find that the value for each will be zero.</p>
<p><img src="https://lh7-us.googleusercontent.com/G7PsvT8tE97xb4pp75H1Kmta3Jdv_A8xIWtAROQXz7vNNYQ2O6g8VliULPxLQmcGwOxf_BXcwE_QBrKtLVqdlM-8j5BSkJUzfGiI6NDBtCaAsyMRwxC7Oj_HEDkNt0_CcgEL-yOqgfPws1ZMs4PAutQ" alt="Image" width="1600" height="787" loading="lazy">
<em>EC2 Dashboard</em></p>
<h3 id="heading-launching-an-ec2-instance">Launching an EC2 instance</h3>
<p>Click on the Launch Instance button.</p>
<p>On the "Launch an instance" page, you will select the specifications for the virtual machine intended to host your website or web application. Initially, assign a name to your machine for easy identification..</p>
<p>For the sake of this example, I used the name "FC Web Server".</p>
<p><img src="https://lh7-us.googleusercontent.com/PGh6o3yysjEl5xkqof7IvhE7Dg0eU6SWO9fmRaRY0sEUJoWLPiXcunxQQ4MI1Z_k1oaGbymInJLxTJv9l02pcmrfxi_YPjRZdPnW72PojjOTwqtihrtFVUwK5FZw-y_d1UyrdcjOafbr_KlIlKQkN_4" alt="Image" width="1264" height="390" loading="lazy">
<em>Naming your EC2 Instance</em></p>
<p>Choose the Amazon Machine Image (AMI) which represents the specific operating system and applications you want to have by default on your virtual machine when you boot it.</p>
<p>For the sake of this example, I selected Ubuntu, and I'm using the Free tier eligible Ubuntu Server 22.04 LTS as the AMI. I left the architecture at 64-bit (x86).</p>
<p><img src="https://lh7-us.googleusercontent.com/T2FD0Pwnrkni6FWDuK1P_NFgPVmoV63I9QRFFLPt6HijKo4MuBGZr8Kua4ELs8p9ThtDYOF4juugnrZOYi3G9Pq4u1GkF-V8ZJjUq3rj9zg1pCyAwJj-0L3-vi-CFs8G718iZlVFPgSzGsjOPY7G61Y" alt="Image" width="1318" height="743" loading="lazy">
<em>Choosing an Amazon Machine Image</em></p>
<p>For the instance type, you can also stick with the Free tier eligible t2.micro – but if your app or website requires more resources, then you'll have to choose the most appropriate instance based on the number of vCPU and memory required.</p>
<p><img src="https://lh7-us.googleusercontent.com/L-syY4yUQNlpzBn_3EchnBFOPzCcVs_6yOgtdjljp05Gn6cTr0XLONAiDY_nNuILJq4tV2y5yug6IJdEagCu599FanEYkrV9QrKwbwpxqAD0EOGpZJcDQob1A99y3E977vV7BaY1m9oBxLyfA79YJ5A" alt="Image" width="803" height="291" loading="lazy">
<em>Choosing the instance type</em></p>
<p>To securely connect to your virtual machine, you will need an SSH key pair. Go ahead and click on the Create new key pair link under the Key pair section if you don’t already have an existing key pair that you can use.</p>
<p><img src="https://lh7-us.googleusercontent.com/35slbh7seL4zxMwSnR4ZrZPddFJ0yAOxvJIPatukKXAb0wIbuJ9wfOWRdbGHSFJRaMUsSiCV0-d-NiZqMe0gQVppGCU4WbMyN33XcrOvnwmXtf1ZEeMYJhyAAugpcawQ7jz2zuwiX6Yiyy7_xwOLOH0" alt="Image" width="716" height="669" loading="lazy">
<em>Creating a key pair</em></p>
<p>Give your key pair a name that you can easily identify. Set the key pair type to RSA and the private key file format to .pem. You can also use .ppk if you are in a windows environment and know how to use PuTTY. </p>
<p>Click the Create key pair button. After clicking it, the file will automatically be downloaded. Make sure you keep this file in a secured place.</p>
<p>Move on to the Network settings. You need to set up a firewall that controls the various protocols through which your website or web app can be accessed. For the sake of this example, you can choose Create security group and allow SSH, HTTPS, and HTTP. </p>
<p>You can leave the IP address at Anywhere 0.0.0.0/0.</p>
<p><img src="https://lh7-us.googleusercontent.com/pmqY3ZoEQF7G0EcQPi49Ik6LjrwM3AkK3k2pgXbC4YpEn61ISeXjZID3l2cIK2cyNMrRKSTksLtRNeOZQ4zRyTAyKHZcxattdNOgY5bLunSvKzMJI8gaDovxxYKz6yKc-LXPPwVrG3xtc_SxjhLXMoY" alt="Image" width="1276" height="695" loading="lazy">
<em>Network settings for your instance</em></p>
<p>Finally, you need to configure the storage options. You can also go with the default 8GiB gp2. You can ignore the additional details and click on the Launch instance button.</p>
<p><img src="https://lh7-us.googleusercontent.com/og9GB9frMs-IFbrDxUhwS5FXefMLDISspiJCMhskzN0nX9JVabNKbo-VWw-HQ1q9Tq7_ONdQRGAzbttG_nbEuWihA2mjVX-BZNFOL32pEyzz0JNUR6ESr3-M8TWwckI7IfslpirqkXKULWg06Ag7ssI" alt="Image" width="1215" height="557" loading="lazy">
<em>Storage configuration for your instance</em></p>
<p>After the instance has successfully be launched, you will get a success message.</p>
<p><img src="https://lh7-us.googleusercontent.com/qNgmnZI1S2YUOoSc6Pv92rlo40HDxFquPmXOP_1Qdqx103KxBfsSZyzw1Q6xDpy2J7q_3cIdXHpsGsa8B3NEeTYAaImUk31nf4M5DmgXeQouwYQKwDzo9YYWD9akS0tfv7xPHhbFeANXAfR4AXe041I" alt="Image" width="1600" height="762" loading="lazy">
<em>Success message after launching instance</em></p>
<h3 id="heading-connecting-to-an-ec2-instance">Connecting to an EC2 instance</h3>
<p>You've now created your virtual machine – so you need to connect to it and turn it on. You can do this by clicking on the Connect to instance. You can also click on  View all instances to see the instance that you created.</p>
<p>If you click on view all instances, it will take you to this page where you see your instance (see below). If you have only one, then you will see something like what is shown below. But if you have other instances, then you will see all of the instances created in that same AWS region. </p>
<p><img src="https://lh7-us.googleusercontent.com/kKXsADE-G5yS_Z0EKK6KQx7QviZnJrrhAyorzGJC6DPPH53aXcVWmxW_AjvpfwrAtYNzIS6JF3uKySS2R3ehgQGxKmCFL-lGAqtCSsA9sB95HIr15XP3gVCb9hNcU9ca8nZX_ocgmNGpWhCSt_a5LfE" alt="Image" width="1600" height="239" loading="lazy">
<em>List of EC2 instances launched</em></p>
<p>Select the specific instance that you just created and click the Actions dropdown at the top right side. You can then click on Connect from the dropdown menu.</p>
<p><img src="https://lh7-us.googleusercontent.com/HlYh7FNpoUi-BvMCg_J9hANAg9w0HWoISqCquGaJ5agnv5a6fpkG29qqpPsh8D47ntjd35TZY5e6FyQF2SxzQ4VmsBoY2uFigDIXsl-zy7xWAP6d-g92s-uDyqk1NITQ3c6hnax5hWx87dOS-IZ6FUQ" alt="Image" width="1600" height="316" loading="lazy">
<em>Connecting to the selected instance</em></p>
<p>The third way that you could have used to reach the connect to instance page is to click on the Instance ID from the list of instances. It takes you to the instance page with details about your selected instance. You will then find a Connect button at the top right side.</p>
<p><img src="https://lh7-us.googleusercontent.com/TjXw51BB3V9HLxnXsKszZUyIRNzAwa_GvobWLHxPzYf0QnrzCLofCa8TGVspGR5NpfDniXSiiYkEtxpmsAkHHlz8XXVdqZhd_Xn5H3gaVkECfHCFAWmbA23Ni8-GUTrYzwk0tGKfgW28xJt9SFckaOM" alt="Image" width="1600" height="866" loading="lazy">
<em>Details about the selected instance</em></p>
<p>On the <strong>Connect to instance</strong> page, you are presented with several options to connect to your instance. For the sake of this example, you can use EC2 Instance Connect. This option will allow you to connect to your virtual machine through the browser. You can stick with the default values and click the Connect button.</p>
<p><img src="https://lh7-us.googleusercontent.com/SjIELpNqBcMXahNHK_dJx3Jhky8CdXxr0kbdhOpWqQZ-nM3BLEQ9A8uGv4Uh-alBNA5aYWDuXOGEw_MS48VM3InAQQJquHHvq2yl7FYlk98GDy0QDd0a9LFaGENVUMM9Sucz7Rc1ti6LjeZuKPTsLGw" alt="Image" width="927" height="772" loading="lazy">
<em>Options to connect to the instance</em></p>
<p>This opens up a terminal in the browser. This is your virtual machine. Remember that you installed Ubuntu so now you have access to an Ubuntu machine with all the specifications you selected.</p>
<p><img src="https://lh7-us.googleusercontent.com/KdV49cJVMg2EEVOdVkhZNWbG9qtA2u0H3OahaZDCnkoTcgjnZBuI4ZWY_GQKG1o_fbUkocBljYl8RB2LbVG969eq6az-R8csZEXAIxo74mv-1frHdrE_pAwwwHsa4CCHz1eM2rHynGX6NeFAtgineEg" alt="Image" width="1600" height="804" loading="lazy">
<em>Ubuntu terminal opened in the browser</em></p>
<p>It is now time for you to install NGINX. Follow the steps below to install NGINX on your instance.</p>
<h3 id="heading-update-your-package-list">Update your package list</h3>
<p>Use this command to update your package lists:</p>
<p><code>sudo apt update</code></p>
<p><img src="https://lh7-us.googleusercontent.com/cnk6SxfwNaz-dsEUd1C3AcaM1Ueh-GGTRCRTEoRNDYKIs_Gp2bU1JwsBwLzd05mwGLrDjVscZuWq2mu-6CU0Ch5Tx7TQ0rraMc3_BVUIGtBH8jjsQcH7FlkYR5vRBQ33jvUVc6bIIQ5RHAkY24bHyQg" alt="Image" width="1581" height="857" loading="lazy">
<em>Updating the package list</em></p>
<h3 id="heading-install-nginx">Install NGINX</h3>
<p>Use this command to install NGINX:</p>
<p><code>sudo apt install nginx -y</code></p>
<p><img src="https://lh7-us.googleusercontent.com/5xyqlguhGA2pCjltDJXeLFKNsm-HaKTlDab6QjmlucpBWRLGdEbjoFg5_5FJ3xV73s047_ycOX59A7Yphq4xyKBZmcv1NfWySx3G6nqi6a8e2XgQutrJBWazwR4UlYi9CA49c-8TL2-7E7PVRml6h38" alt="Image" width="1600" height="775" loading="lazy">
<em>Installing NGINX</em></p>
<p>Once the installation is done, you can access the default page for NGINX by entering the public IP address of your instance in the address bar of your browser. </p>
<p>To find the public IP, you can check the bottom of your terminal or go to the instance page and look for Public IPv4 address.</p>
<p><img src="https://lh7-us.googleusercontent.com/hYkF9Fvl2yc-W6kR5XWQWGTnEINJbEdj3k9_SQZUGcdb_MQ3MgQ6fKOh791HgxEdDXC28g2Mazk04n-JsM1xwT2TttF5u_vZQqp5aUD963ZzKelbImsPqW_1ePkI0FNFH-mPT0QC3CWhzgYxQZxLmos" alt="Image" width="821" height="404" loading="lazy">
<em>Public IP address of the instance from below the terminal</em></p>
<p><img src="https://lh7-us.googleusercontent.com/86hZhXn99AFBdk-gZ6fqa-yLLzJqqAASd43rL0zM-kD0ZflQJ_65yP4s4bSKcxYFvaPiLThaX948B8Q12iQrmeQw8rwkbCwrhP-RdWdU2ZOhUz1OVTTHr7BbEYFxDtX_Obpfj7rqHhzAjgqntzW0s4g" alt="Image" width="879" height="245" loading="lazy">
<em>Public IP address of the instance from the details page</em></p>
<p>You should get the default page open in your browser like shown below:</p>
<p><img src="https://lh7-us.googleusercontent.com/JZPEFIWMHIUAWSURn80p-AEYsWukl-W5Um2YZ9ce5d4Ox9H8UQozMnYCltaLTBfbzl_tvmZ3Fn6tJEO_VOv-_1ne7F8ElYIUexdg9I7JgySqSmI2yo0b2fmT0zJYxHArDYxY39LTsmDrRbmG6M5ZKsQ" alt="Image" width="1578" height="493" loading="lazy">
<em>Default page for NGINX web server</em></p>
<p>NB: You may have to refresh the page for it to work.</p>
<p>For the next set of steps to set up your website or web app, it will depend on the programming language or framework that you used. But since this tutorial is focused on connecting a domain name to your EC2, you can proceed with the next steps for connecting the domain.</p>
<p><img src="https://lh7-us.googleusercontent.com/m9xoyqffR1ExdcIcXO7Ir5owVxyZgVP3z1iPaG_ISKUyIn6nwlCP_sJH-Yn6y64ZytEQkS0hLMXTirDdwHzAHnUrr0j8H4vj8v-2i1KATd7cDf7r8d47siBIEET12RKg68Q183mrw3XmXFnQG0l4gxE" alt="Image" width="1482" height="668" loading="lazy">
<em>Default page of NGINX</em></p>
<p>Working from this image, let’s now connect our domain name to this website. As you can see in the image above, I am accessing it with the public IP address of the EC2 instance.</p>
<p>To connect the website with a domain name simply means to replace its IP address with a more memorable name. In our case, I will be replacing it with the domain name <code>krachy.com</code>.</p>
<h2 id="heading-step-2-how-to-set-up-route-53-for-dns-management">Step 2: How to Set Up Route 53 for DNS Management</h2>
<p>AWS provides a service called Route 53 that you can use for DNS (Domain Name Service) management. So now, we need to set up this service to manage the domain that you purchased. </p>
<p>I have my domain with Namecheap, but the process will be similar for almost every other domain retailing company.</p>
<p>First, you'll need to create a <a target="_blank" href="https://aws.amazon.com/route53/faqs/#:~:text=A%20hosted%20zone%20is%20an,domain%20name%20as%20a%20suffix.">hosted zone</a> in Route 53.</p>
<p><img src="https://lh7-us.googleusercontent.com/XVis1IAhzZ3CdJiDBOu9NXc66ER63DSDgfuWLL-zqiJStnsjEa0COfK-EtuKYnpjBr6gOouLcAYDQlhcrRX1YNIFbNk4qyzYIuLHqJ2Y3f1zo4Rz7OI0lv-MI2Z6g_AMvgoCcjY-5zNYernNhhCoUv0" alt="Image" width="1600" height="864" loading="lazy">
<em>Amazon Route 53</em></p>
<h3 id="heading-creating-a-hosted-zone-in-route53">Creating a hosted zone in Route53</h3>
<p>To do that, click on the orange <code>Get started</code> button. It takes you to the next page, as shown below.</p>
<p><img src="https://lh7-us.googleusercontent.com/2ZJ658N8zV3L9UjxrRDqmAUSF-6se1J6yc0qBRO_tsATMijkY3k7cWc5D2TFIiC_PHLOEvukyQnVo5vJi7mQQq19y1bNJCeeYsvBQ_Of5RrfL7tjRfWYOfaPzRtjKiEKnENyU48ZxQeXr63R4IY9mU4" alt="Image" width="1210" height="710" loading="lazy">
<em>Getting started options for Route 53</em></p>
<p>Choose <code>Create hosted zones</code> and click the <code>Get started</code> button. Go ahead and fill out the details on the next page.</p>
<p><img src="https://lh7-us.googleusercontent.com/ibfwFdt41BH4rgMKJ44-4qmcF-xUTePMD6WL7Q341AzcBM6KWUtrwvGAavwuZmEWNeImMVuPLQfRsfkaMKjiDSpfA1r5IRQEXo1crcbZL33vpNCH8hrbYetMUCuFYsTOXZrU18fe-H3NR_BCNdpdE3g" alt="Image" width="866" height="877" loading="lazy">
<em>Hosted zone configuration</em></p>
<p><img src="https://lh7-us.googleusercontent.com/-UmPq2sd9RuiNkRxwC545W0iXzSnofRok4d3XVJ4yMoxP4j7jM_WQp2FzUeptBEmlFknPgeB4DY3EjDUtlu-dGgwfLK-bCyCtHv4DyUxYHXWOYKv9V1M3Z-oyPrcJDKXULWPxFi7WTmkjWUsXi8oTwY" alt="Image" width="776" height="515" loading="lazy">
<em>Providing details for hosted zone</em></p>
<p>Provide the domain name that you want to connect to the EC2 instance and then give it a description that will make it easier for you to distinguish this hosted zone from any others you may have. Choose <code>Public hosted zone</code> since you want your website to be accessible to the public.</p>
<p>Click the orange <code>Create hosted zone</code> button.</p>
<p><img src="https://lh7-us.googleusercontent.com/A4_iFzOVyOTal9QBXCCVAaI56OaNs-Z9yQfZKqDWzSbMj1sE953_z3kUi9v_L8hq25FBjgt-MolYw0pANYVsawS4oek9KkJpJikW6XWmDsaxEr2-XaPi_Um2Zl58MdNrsuw5CFKvFolNSxieIlduwnE" alt="Image" width="1269" height="728" loading="lazy">
<em>Success message for the hosted zone</em></p>
<p>You'll get a green success message showing that you have successfully created the hosted zone. </p>
<h3 id="heading-adding-records-to-the-created-hosted-zone">Adding records to the created Hosted Zone</h3>
<p>From the screenshot above, you can see that Route 53 automatically created two records for us: the NS (Name Server) and the SOA (Start of Authority) records. The NS record is what you will need for pointing your domain to this service. But before you grab those, you have a couple of things to do here.</p>
<p>Because our website is being hosted on an EC2 instance which can be accessed through its public IP address, you need to create an <strong>A record</strong> for it. Also just so you ensure that people who try accessing your website with the <code>www</code> subdomain are still able to access it, you will also need to add another record with an <strong>alias</strong> for it. </p>
<p>To do that, start by clicking the orange <code>Create record</code> button, as you can see in the screenshot below:</p>
<p><img src="https://lh7-us.googleusercontent.com/0Sb2ip2tg_IvOAaumH1KB4V8d6XPFtBk9s1lBJ1lyTXHnia3kCe5VicjCqd-D1VX14fpGSoJp0GlskDDxtgOb8ztgFrGXJP_cHQgomH114x85tXrxQEC177Yn8pUsz3XghjBPc_OTRoUiBcuDA-500I" alt="Image" width="1053" height="876" loading="lazy">
<em>Adding an A record</em></p>
<p>For the <strong>A record</strong>, don't put anything in the <code>subdomain</code> input box. Under Record type, make sure <code>A – Routes traffic to an IPv4 address and some AWS resources</code> is selected. Then paste or type the public IP of your EC2 instance in the textarea for Value. </p>
<p>You can leave everything as default (NB: Check to ensure that the Routing policy is Simple routing).</p>
<p>To get the IP address, visit the instance that you are using and look for the Public IPv4 address and copy that.</p>
<p><img src="https://lh7-us.googleusercontent.com/m1uIxp03So9xxaiE-YvmS9Px93lq48sMG0V6ZA84MmNsjHHn6eQZW6SyWN1nvacKelmqboYRG-RSJzViGtmJ1M9YOI8iX8dnmEKPiioPZhfE5sf65WhGHCfukTVY8OjfUvlNYpEgm-EF53AWwBigGXw" alt="Image" width="1600" height="452" loading="lazy">
<em>IP address from instance details page</em></p>
<p>It should now look like what is shown below (where 18.232.109.18 is the public IP for my instance). Afterwards, click the orange <code>Create records</code> button in the bottom right corner.</p>
<p><img src="https://lh7-us.googleusercontent.com/5oj2JsQt_YRKWqDSbINcSWbnK5ON3T1u49MI9TyYqhuSMkcaJ3SU__aYJjh7cc7730OVsIDVRC9WMiWzEshiDkYl1NIJ8cb6sdYmHQuvW9Y7kcYarxdBk-BcZ91zPHKyZkFIpWBJCZ4aI_ouyPWx374" alt="Image" width="1434" height="861" loading="lazy">
<em>Completing the A Record creation</em></p>
<p>You should see a success message. Also, that the record will now be added to the records table that you saw earlier, as shown below:</p>
<p><img src="https://lh7-us.googleusercontent.com/DlR8djeTU_JtBEWHJIbwxfhxHzI_ubQl5Bfx2X6f3qlpnDwr3R_xs1YuZN_2donh4sH8KTG1PRWicd7wjzLLcjjoRcdTOHENhKGpvcNDEecudxvYC3JAhCvvEh6rmgBOVKDAkF_rZWZrbyP61dV0SkI" alt="Image" width="1445" height="785" loading="lazy">
<em>Success message after creating the record</em></p>
<p>You still have to add the record to cater to the possible use of <code>www</code> when reaching your website. Click the <code>Create record</code> button to add that record. This time around, you will put <code>www</code> into the subdomain input box.</p>
<p><img src="https://lh7-us.googleusercontent.com/4JBcC8FFtVm9GLd3hl0wm3PptwXgpaySUlxdw2g1vWnu0g3jote---0v5MxLVTz6Ypj3yjAEngPx4XfUDgJ2-uShQiY5z8sKTI0yLiCJLH4saASR5xdwxLXSKyxzySYGBrgWa_E3LsdVBruMJ9dSIr8" alt="Image" width="1451" height="818" loading="lazy">
<em>Adding A record to handle the use of www</em></p>
<p>Also, you will need to turn on <code>Alias</code> which is beneath the Record name. After turning it on, a new set of options (Route traffic to) will be made available. </p>
<p><img src="https://lh7-us.googleusercontent.com/xd5aFDvaDaCl6i4ZV-8ZHhmRTBcE8UDLjTe9N1p6ffOhRYFZuAt2ElEAGyXV4piLPk8pJD3e_uS-3MXBZDU5nN1n4XWHd9k49HYkrGeiZMtQl4935dhvhjzgC2wgS2tIpNSs4HARQ5Dl5hVZvZ6h1SY" alt="Image" width="1403" height="727" loading="lazy">
<em>Turning on the Alias for the record</em></p>
<p>For the <code>Choose endpoint</code> dropdown, select <code>Alias to another record in this hosted zone</code> and the Region will automatically be populated for you. But it also brings up another field labeled <code>Choose record</code>.</p>
<p><img src="https://lh7-us.googleusercontent.com/tzVQSFj6MyEhnT-7p_310X_DgbuucKT3BqKmbgIUqihIAfdiFvJw83HTlpG8mGVdhOFjyCOn0lFSkFFlgdk2sQH9aE6fINs29BoyPZs35uZwbP-p76mGU9cFGBnqFmHNVVaRWJd-G2MxTGRBldM4TMA" alt="Image" width="1404" height="798" loading="lazy">
<em>Select an option for "Route traffic to"</em></p>
<p>Go ahead and click within the <code>Choose record</code> field and it will suggest your domain name for you. Go ahead and select it.</p>
<p><img src="https://lh7-us.googleusercontent.com/cCGijn9B6_j8BtxIs-zncIDZyRoRsb66JdeLPJv4-RgSNlbT8aZr6CELWboC7zYfuspwoRE3bhlOKvCeZ4RFESKzmA47SoYTX5N9119kdA9QxC6gw2e2895IK3Vlo5tWwyOs62zYESw22keeTWs3nU4" alt="Image" width="1410" height="832" loading="lazy">
<em>Associate domain with record</em></p>
<p>Now you are ready to add this record too so proceed to click the <code>Create records</code> button. You will get a success message and see that the new record has been added to the records table.</p>
<p><img src="https://lh7-us.googleusercontent.com/2SmlaORdC9UHuNL_FDJxTKNUBTqfRloS3jK1TtB4N_mzfVIWwXI-N33kd2qizIGlUGvuGm1lvBUdMj3T99BnG6t-AcOiZd2mQk-dnBY-i2rLr7OWVwwO8VaEauOLsIpk2r7pqQFujv5OWw_dIzjC0DY" alt="Image" width="1441" height="787" loading="lazy">
<em>Success message after adding new record</em></p>
<p>Once you are done setting up the records, you can now proceed to update your name servers with our Domain retailing company (NameCheap in my case).</p>
<h2 id="heading-step-3-update-nameservers-with-your-domain-provider">Step 3: Update Nameservers with Your Domain Provider</h2>
<p>If you already have an account with a domain provider, then log in to your account. But if not, then you'll need to sign up with one to purchase a new domain. </p>
<p>Personally, I use Namecheap for most of my domains. So, I will be showing how to get this done with Namecheap (but again, it will be similar for various Domain providers). </p>
<p>Note that I already have a domain name, and for any domain that you purchase you will have some default nameservers. Your goal here is to change the default nameservers or whatever your nameservers currently are to the ones which Route 53 provides you. </p>
<h3 id="heading-changing-nameservers-in-namecheap">Changing nameservers in Namecheap</h3>
<p><img src="https://lh7-us.googleusercontent.com/Lkdxzcd7dt-85SamUv4R2c1OI0UY9W3zAqqlXljpI6x4ywSlFUxbPJ-y1F3CGHlxW6Laz55IaS542jSeZuo3uc_gQqsMEL4ysQEK4pR3i6Ig81GXXNjCB0uuqlWyrufEEGjYbMYvqIbT-4lbkeu72Qs" alt="Image" width="1522" height="802" loading="lazy">
<em>Namecheap user Dashboard</em></p>
<p>Click on the <code>Domain list</code> to see a list of all the domains that you have in that account. Look for the specific domain that you have.</p>
<p><img src="https://lh7-us.googleusercontent.com/4eSm_L1erf8ma66aZNKJCQtFCjIgJgQ0i7mx013PJ6ZRZU-zp2gHOltqYrZFaworF9-sUGE5iW07joLUw4rlUnPx7aUiCdyxDCljZtFv7l5C5HViYdZh-my2aOXji55OaIwG2m7_anaUs1XPS-aR3fg" alt="Image" width="1600" height="884" loading="lazy">
<em>Domain list</em></p>
<p>Next to each domain name, you will find the <code>Manage</code> button. Click the respective one for the domain that you are using (krachy.com in my case).</p>
<p><img src="https://lh7-us.googleusercontent.com/sTT4r41ZnwwtG9FURnWSo4SDEvhhuiXXfhDrJDgSxg26Jk2VmWhLMkL-SWhQJ9b84l88LsPf-ywDaxnWpbI7VD44tl3Kprau26EoTzRRfo2cdcRPSxvqAnFCyGqnmQrMgrJ-zgXl-o6r_QBMxPRHgVc" alt="Image" width="1523" height="771" loading="lazy">
<em>Detail page for selected domain</em></p>
<p>Under Nameservers, make sure you have selected <code>Custom DNS</code>. Then go back to Route 53 and copy the nameservers that you were provided with. Then delete what you currently have and add what you get from Route 53.</p>
<p>In my case, Route 53 gave me four different Nameservers. So I have to copy them one after the other and add them to Namecheap (remember to delete any old ones that were in the domain provider account).</p>
<p><img src="https://lh7-us.googleusercontent.com/vq9KwsyF13Tmt00vHzDIkIMU47h_5EzB4CaXFUhrvjpIJqpWCI8qOcmXEkdqJS92d6up3nvVYq78gSE-4SHMATFxJWSNQJvdhZZW-SUh4tAOi4llNRIJwy4_Kj5qRhhuHHth1mDpQS08gTu_R-OcjGg" alt="Image" width="1368" height="139" loading="lazy">
<em>Nameservers for the domain name</em></p>
<p>In Namecheap, they provide two spaces for the nameservers – but there is a button just below that lets you add more than 2. In my case, I added all four of them as you can see below:</p>
<p><img src="https://lh7-us.googleusercontent.com/Bunq4l59Hm7HzrnOzqDwU1YesduGAhxdlpuOYVp8290Mc30rY3z3iwSg0D6LCra4t2JJ2ysGEWqdIdDA18YfGIEvdpWNMFuGkKF7k9RAJ-v-A1Z678QfdVJqv4GZUsDP9cjZnt6eNmlOoGFk4XpaPKg" alt="Image" width="1186" height="635" loading="lazy">
<em>Updating nameservers</em></p>
<p>Also, after adding them, you need to accept the changes and save them. In the screenshot above, you can see that at the far right of <code>Custom DNS</code> is a check mark and an x mark. Click on the check mark to save the changes.</p>
<p>After saving, you will notice that those buttons are no longer available.</p>
<p><img src="https://lh7-us.googleusercontent.com/7xuh7yPSzecl12m5BCblDIWBcXo27f5dqPK6huZpGLvZ-R2gH3wTYHaWCl02X3xTZLBAKWbNvGyyIPn4pkaMMQv6xO9nORX-BDZw21k_0hwVx4L8rSXYq0UuzTPTnhuSIFNLhbgWpl63BxXubJf5yDk" alt="Image" width="936" height="205" loading="lazy">
<em>Nameservers updated on Namecheap</em></p>
<h2 id="heading-step-4-dns-propagation">Step 4: DNS Propagation</h2>
<p>Congratulations, you are now done with the set up. Now you just need to wait for the DNS propagation to be completed.</p>
<p>This step doesn’t involve you taking any action, but just waiting for a couple of minutes. The propagation can take anywhere from a couple of minutes to more than 24 hours. </p>
<p>But after a short while, just enter your domain name in your browser’s address bar and see if it shows the website that you have hosted on the EC2 instance.</p>
<p>Once the DNS propagation goes through, your website will be live on the domain name that you used. Congratulations once again!</p>
<p><img src="https://lh7-us.googleusercontent.com/UOIjgyUqN4-DGBvTfLscjsnulDkapBsOvEfga7m-NkEkp8CriJfXEL-w1a6ZdlqIOc_ebkK1NLQm7H-tZDIOEMhcj3_cWfEUPLXjyob7aq4bU19qyN3lWHlL60G1pCH_AdrydjUE1KiZPC4gHCwwvQw" alt="Image" width="1562" height="717" loading="lazy">
<em>Website linked to domain after DNS propagation</em></p>
<p>As you can see, this is the same interface that I started with – but the good news is that now, I accessed it with the domain name I purchased and not the IP address of the instance.</p>
<h2 id="heading-wrapping-up">Wrapping Up</h2>
<p>Even though you are done, you are currently using a non-secured transfer protocol (http) for your website. This is because you haven't yet installed an SSL certificate on your website. </p>
<p>Watch out for my next tutorial where I walk you through how to install SSL on your domain to make it secure (https).  </p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How to Deploy Your Django Project on an EC2 Machine using GitHub Actions ]]>
                </title>
                <description>
                    <![CDATA[ Deploying a Django application can be streamlined and automated using GitHub Actions. This article provides a comprehensive guide on how to set up a continuous deployment pipeline for a Django project hosted on an AWS EC2 instance. By leveraging GitH... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/how-to-deploy-django-project-on-ec2/</link>
                <guid isPermaLink="false">66bb8fd2fce17a7d998852e2</guid>
                
                    <category>
                        <![CDATA[ Django ]]>
                    </category>
                
                    <category>
                        <![CDATA[ ec2 ]]>
                    </category>
                
                    <category>
                        <![CDATA[ GitHub Actions ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Muhammad Haseeb ]]>
                </dc:creator>
                <pubDate>Tue, 30 Jan 2024 15:40:16 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2024/01/Deploying-Django-Project-on-EC2-Machine-using-GitHub-Actions.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>Deploying a Django application can be streamlined and automated using GitHub Actions.</p>
<p>This article provides a comprehensive guide on how to set up a continuous deployment pipeline for a Django project hosted on an AWS EC2 instance.</p>
<p>By leveraging GitHub Actions, developers can automate their deployment process, making it more efficient and error-free.</p>
<h2 id="heading-prerequisites">Prerequisites</h2>
<ul>
<li>A Django project hosted in a GitHub repository.</li>
<li>An AWS EC2 instance set up for hosting a Django application.</li>
<li>Basic familiarity with YAML and GitHub workflows.</li>
</ul>
<h2 id="heading-how-to-set-up-the-ec2-instance">How to Set up the EC2 Instance</h2>
<p>Before diving into GitHub Actions, ensure your EC2 instance is ready to host your Django application. </p>
<p>Use the command below to connect to your EC2 instance:</p>
<pre><code>ssh -i /path/to/your-key.pem ec2-user@your-ec2-instance-public-dns
</code></pre><p>You can update your system packages using these:</p>
<pre><code>sudo apt-get update
sudo apt-get upgrade
</code></pre><p>Next, if you haven't already, install Python and Pip:</p>
<pre><code>sudo apt-get install python3
sudo apt-get install python3-pip
</code></pre><p>Then install Django using this command:</p>
<pre><code>pip3 install django
</code></pre><h2 id="heading-how-to-configure-a-web-server">How to Configure a Web Server</h2>
<p>In this section, you'll see how to configure your web server.</p>
<p>First, install Nginx:</p>
<pre><code>sudo apt-get install nginx
</code></pre><p>Then configure Nginx for Django. Start by creating a new configuration file for your Django project.</p>
<pre><code>sudo nano /etc/nginx/sites-available/mydjangoapp
</code></pre><p>Then add the following server block:</p>
<pre><code>server {
    listen <span class="hljs-number">80</span>;
    server_name your-domain.com;

    location = /favicon.ico { access_log off; log_not_found off; }
    location /<span class="hljs-keyword">static</span>/ {
        root /path/to/your/django/project;
    }

    location / {
        include proxy_params;
        proxy_pass http:<span class="hljs-comment">//unix:/path/to/your/gunicorn.sock;</span>
    }
}
</code></pre><p>Lastly, enable the Nginx configuration:</p>
<pre><code>sudo ln -s /etc/nginx/sites-available/mydjangoapp /etc/nginx/sites-enabled
sudo nginx -t
sudo systemctl restart nginx
</code></pre><h2 id="heading-how-to-setup-a-database">How to Setup a Database</h2>
<p>You can install PostgreSQL using this:</p>
<pre><code>sudo apt-get install postgresql postgresql-contrib
</code></pre><p>After the installation, create a database and user using this command:</p>
<pre><code>sudo -u postgres psql
</code></pre><p>Run this SQL query to create a new database and add a new user:</p>
<pre><code class="lang-sql"><span class="hljs-keyword">CREATE</span> <span class="hljs-keyword">DATABASE</span> mydjangodb;
<span class="hljs-keyword">CREATE</span> <span class="hljs-keyword">USER</span> mydjangouser <span class="hljs-keyword">WITH</span> <span class="hljs-keyword">PASSWORD</span> <span class="hljs-string">'password'</span>;
<span class="hljs-keyword">ALTER</span> <span class="hljs-keyword">ROLE</span> mydjangouser <span class="hljs-keyword">SET</span> client_encoding <span class="hljs-keyword">TO</span> <span class="hljs-string">'utf8'</span>;
<span class="hljs-keyword">ALTER</span> <span class="hljs-keyword">ROLE</span> mydjangouser <span class="hljs-keyword">SET</span> default_transaction_isolation <span class="hljs-keyword">TO</span> <span class="hljs-string">'read committed'</span>;
<span class="hljs-keyword">ALTER</span> <span class="hljs-keyword">ROLE</span> mydjangouser <span class="hljs-keyword">SET</span> timezone <span class="hljs-keyword">TO</span> <span class="hljs-string">'UTC'</span>;
<span class="hljs-keyword">GRANT</span> <span class="hljs-keyword">ALL</span> <span class="hljs-keyword">PRIVILEGES</span> <span class="hljs-keyword">ON</span> <span class="hljs-keyword">DATABASE</span> mydjangodb <span class="hljs-keyword">TO</span> mydjangouser;
\q
</code></pre>
<p>Then configure Django to use PostgreSQL. In your Django <code>settings.py</code> file, update the <code>DATABASES</code> setting:</p>
<pre><code class="lang-python">DATABASES = {
    <span class="hljs-string">'default'</span>: {
        <span class="hljs-string">'ENGINE'</span>: <span class="hljs-string">'django.db.backends.postgresql'</span>,
        <span class="hljs-string">'NAME'</span>: <span class="hljs-string">'mydjangodb'</span>,
        <span class="hljs-string">'USER'</span>: <span class="hljs-string">'mydjangouser'</span>,
        <span class="hljs-string">'PASSWORD'</span>: <span class="hljs-string">'password'</span>,
        <span class="hljs-string">'HOST'</span>: <span class="hljs-string">'localhost'</span>,
        <span class="hljs-string">'PORT'</span>: <span class="hljs-string">''</span>,
    }
}
</code></pre>
<p>The GitHub Actions workflow for deploying a Django project involves several key steps:</p>
<h3 id="heading-step-1-checkout-and-preparation">Step #1 - Checkout and Preparation</h3>
<p>The first step in your workflow is to check out the latest code from your GitHub repository and set up the environment for the deployment.</p>
<pre><code class="lang-yaml"><span class="hljs-attr">name:</span> <span class="hljs-string">Deploy</span> <span class="hljs-string">Django</span> <span class="hljs-string">to</span> <span class="hljs-string">EC2</span>

<span class="hljs-attr">on:</span>
  <span class="hljs-attr">push:</span>
    <span class="hljs-attr">branches:</span>
      <span class="hljs-bullet">-</span> <span class="hljs-string">main</span>

<span class="hljs-attr">jobs:</span>
  <span class="hljs-attr">deploy:</span>
    <span class="hljs-attr">runs-on:</span> <span class="hljs-string">ubuntu-latest</span>
    <span class="hljs-attr">steps:</span>
    <span class="hljs-bullet">-</span> <span class="hljs-attr">name:</span> <span class="hljs-string">Checkout</span> <span class="hljs-string">repository</span>
      <span class="hljs-attr">uses:</span> <span class="hljs-string">actions/checkout@v2</span>
</code></pre>
<h3 id="heading-step-2-deployment-script">Step #2 - Deployment Script</h3>
<p>The deployment script involves pulling the latest code, installing dependencies, running migrations, and restarting the web and WSGI servers. </p>
<p>Create a new file <code>deploy_script.sh</code> on your EC2 machine and add the code below:</p>
<pre><code class="lang-bash"><span class="hljs-meta">#!/bin/bash</span>

DRY_RUN=<span class="hljs-variable">$1</span>

<span class="hljs-built_in">echo</span> <span class="hljs-string">"Pulling latest code from repository..."</span>
<span class="hljs-comment"># Skip actual git pull in dry run</span>
[ <span class="hljs-string">"<span class="hljs-variable">$DRY_RUN</span>"</span> != <span class="hljs-string">"true"</span> ] &amp;&amp; git pull origin main

<span class="hljs-built_in">echo</span> <span class="hljs-string">"Installing dependencies..."</span>
<span class="hljs-comment"># Skip actual installation in dry run</span>
[ <span class="hljs-string">"<span class="hljs-variable">$DRY_RUN</span>"</span> != <span class="hljs-string">"true"</span> ] &amp;&amp; pip install -r requirements.txt

<span class="hljs-built_in">echo</span> <span class="hljs-string">"Running migrations..."</span>
<span class="hljs-comment"># Skip actual migrations in dry run</span>
[ <span class="hljs-string">"<span class="hljs-variable">$DRY_RUN</span>"</span> != <span class="hljs-string">"true"</span> ] &amp;&amp; python manage.py migrate

<span class="hljs-built_in">echo</span> <span class="hljs-string">"Restarting the server..."</span>
<span class="hljs-comment"># Skip actual restart in dry run</span>
[ <span class="hljs-string">"<span class="hljs-variable">$DRY_RUN</span>"</span> != <span class="hljs-string">"true"</span> ] &amp;&amp; sudo systemctl restart myapp

<span class="hljs-built_in">echo</span> <span class="hljs-string">"Deployment complete."</span>
</code></pre>
<h3 id="heading-step-3-create-a-step-to-run-the-deployment-script">Step #3 - Create a Step to Run the Deployment Script</h3>
<p>Use GitHub Actions to SSH into your EC2 instance. You'll need to store your EC2 instance's SSH key as a GitHub secret.</p>
<pre><code class="lang-yaml"><span class="hljs-bullet">-</span> <span class="hljs-attr">name:</span> <span class="hljs-string">Run</span> <span class="hljs-string">Deployment</span>
  <span class="hljs-attr">run:</span> <span class="hljs-string">|
    ssh -i ${{ secrets.EC2_SSH_KEY }} ec2-user@your-ec2-instance 'bash -s' &lt; deploy_script.sh
</span>  <span class="hljs-attr">env:</span>
    <span class="hljs-attr">ACTIONS_RUNNER_DEBUG:</span> <span class="hljs-literal">false</span>
</code></pre>
<h2 id="heading-security-considerations">Security Considerations</h2>
<p>Here are some security considerations to keep in mind:</p>
<ul>
<li><strong>SSH Keys</strong>: Store your SSH private keys securely in GitHub Secrets.</li>
<li><strong>Minimal Permissions</strong>: Ensure the EC2 instance's IAM role has minimal permissions necessary for deployment.</li>
</ul>
<h2 id="heading-testing-and-validation">Testing and Validation</h2>
<p>Before fully implementing this workflow, test it with a development or staging environment to ensure that the deployment process works as expected.</p>
<p><strong>Dry Run Deployment</strong>: Implement a step in your GitHub Actions workflow that does a 'dry run' of the deployment process. This can help validate the deployment scripts without affecting the live EC2 instance. Add the step below to pass <code>dry_run = true</code> in deployment script.</p>
<pre><code class="lang-yaml"><span class="hljs-bullet">-</span> <span class="hljs-attr">name:</span> <span class="hljs-string">Dry</span> <span class="hljs-string">Run</span> <span class="hljs-string">Deployment</span>
  <span class="hljs-attr">run:</span> <span class="hljs-string">|
    ssh -i ${{ secrets.EC2_SSH_KEY }} ec2-user@your-ec2-instance 'bash -s' &lt; deploy_script.sh true
</span>  <span class="hljs-attr">env:</span>
    <span class="hljs-attr">ACTIONS_RUNNER_DEBUG:</span> <span class="hljs-literal">true</span>
</code></pre>
<p><strong>Logging and Monitoring</strong>: You can see current action capture logs of the deployment process from <code>deploy_script.sh</code>, which can be reviewed if any issues arise.</p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>Automating Django deployments using GitHub Actions offers a streamlined and reliable way to manage application delivery. </p>
<p>By following the steps outlined above, developers can set up a robust deployment pipeline that pushes their latest Django code to an EC2 instance seamlessly upon every push to the main branch.</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How to Select the Right EC2 Instance – A Guide to EC2 Instances and Their Capabilities ]]>
                </title>
                <description>
                    <![CDATA[ EC2 (Elastic Compute Cloud) is the most widely-used compute service from AWS. It's also one of the oldest services launched by AWS, as it was started in 2006. In this article, I will go through some things you should consider when selecting an EC2 in... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/how-to-select-the-right-ec2-instance/</link>
                <guid isPermaLink="false">66d45e15052ad259f07e4a89</guid>
                
                    <category>
                        <![CDATA[ AWS ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Cloud Computing ]]>
                    </category>
                
                    <category>
                        <![CDATA[ ec2 ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Daniel Adetunji ]]>
                </dc:creator>
                <pubDate>Thu, 15 Dec 2022 19:08:27 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2022/12/cover-photo.jpg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>EC2 (Elastic Compute Cloud) is the most widely-used compute service from AWS. It's also one of the oldest services launched by AWS, as it was started in 2006.</p>
<p>In this article, I will go through some things you should consider when selecting an EC2 instance.</p>
<p>You can think of an EC2 instance as not too different from your personal computer. If you are going to buy a computer, three broad technical considerations may cross your mind (ignoring any aesthetic or design preferences you may have, of course):</p>
<ol>
<li><p>How much processing can it handle?</p>
</li>
<li><p>How much memory does it have?</p>
</li>
<li><p>How much storage does it have?</p>
</li>
</ol>
<p>These three questions should also cross your mind when selecting an EC2 instance. The difference being, you are only renting the instance from AWS, instead of buying it as you would with a personal computer.</p>
<p>Each EC2 instance is composed of:</p>
<ol>
<li><p>CPU – how much processing can be achieved</p>
</li>
<li><p>Memory</p>
</li>
<li><p>Storage – this only applies to some instances that have physically attached storage (called the <a target="_blank" href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/InstanceStorage.html">instance store</a>). For other EC2 instances, you'll need to choose network storage using EBS (Elastic Block Storage) separately.</p>
</li>
</ol>
<h2 id="heading-compute-memory-and-storage-an-analogy">Compute, Memory, and Storage – An Analogy</h2>
<p>A good analogy for an EC2 instance is your work desk.</p>
<p><img src="https://substackcdn.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F44e98a5c-f6fb-4f23-8840-477a52ef0b6c_1257x690.png" alt="Image" width="1257" height="690" loading="lazy"></p>
<p>Your brain is the compute, the surface of your desk is the memory, and your desk drawer is the storage. Note that this analogy (like all analogies) has its limitations. Its purpose is to neatly spilt the role of compute, memory, and storage in an EC2 instance.</p>
<p>What exactly does compute mean? Compute is concerned with <em>parallelism –</em> the ability to execute multiple tasks simultaneously.</p>
<p>Human brains can handle some level of parallelism. You might be able talk on the phone while taking notes simultaneously, for example. You cannot, however, write two different letters simultaneously, or talk on the phone while taking notes and reading a book.</p>
<p>These activities cannot be executed in parallel because our brain can be crudely thought of as a CPU with a single core. To increase compute, we need to increase parallelism, and this can be achieved by having multiple CPU cores. More cores equals more parallelism which equals more compute power.</p>
<p>Memory and storage are theoretically the same thing. We use them both for storing data. Practically, though, they are physically distinct pieces of infrastructure simply because there is no single storage device that is both fast and non volatile.</p>
<p>Memory is fast and volatile while storage is slow and non-volatile. Things kept on the surface of your desk are quickly and easily accessible, just like data in a computer’s memory. But anything left on your desk overnight in a busy office is at risk of being moved, lost, or stolen. The surface of your desk, just like a computer’s memory, is volatile.</p>
<p>Storage, on the other hand, is non-volatile but slower to read/write from. Just like items in your desk drawers are less likely to go missing but take longer to get your hands on.</p>
<h2 id="heading-how-to-select-the-right-ec2-instance">How to Select the Right EC2 Instance</h2>
<p>So, CPU, memory, and sometimes storage are the three levers you can pull when selecting an EC2 Instance. Recall that storage is often selected separately from the EC2 instance using EBS volumes, except for storage optimized instances that have physically attached storage.</p>
<p>When you select an instance type, you are effectively selecting for the <strong>lowest price per unit of the metric most important for your workload</strong>. This metric can be CPU/GPU performance, memory, or storage.</p>
<p>There are five AWS instance types:</p>
<ul>
<li><p>general purpose: By choosing a general purpose instance, you are taking a balanced approach and not optimizing for any one metric.</p>
</li>
<li><p>compute optimized: By choosing a compute optimized instance, you are optimizing for the lowest price per unit of CPU performance (number of CPU cores).</p>
</li>
<li><p>accelerated computing: By choosing an accelerated computing instance, you are optimizing for the lowest price per unit of GPU performance (think of this as a specialised CPU needed for high performance compute workloads).</p>
</li>
<li><p>storage optimized: By choosing a storage optimized instance, you are optimizing for the lowest price per unit of storage capacity and efficiency.</p>
</li>
<li><p>memory optimized: And by choosing a memory optimized instance, you are optimizing for the lowest price per unit of memory.</p>
</li>
</ul>
<p>Let’s go through the instance types in more detail.</p>
<p>AWS has a great outline of this <a target="_blank" href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instance-types.html">here</a> that I have summarised below:</p>
<ol>
<li><p><strong>General Purpose</strong> – For workloads that require a balance of compute, memory and networking. Ideal use case is web servers.</p>
</li>
<li><p><strong>Compute Optimized</strong> – For workloads that require high performance processors. Lowest dollar cost per number of CPU cores. Ideal for compute intensive workloads like scientific modelling and gaming.</p>
</li>
<li><p><strong>Accelerated Computing</strong> – For workloads that require even larger amounts of compute resources than compute optimized instances. This type of instance uses GPUs (graphical processing units) which is a specialised CPU designed for machine learning and high performance computing workloads.</p>
</li>
<li><p><strong>Storage Optimized</strong> - For workloads that require high rates of reads and writes for large amounts of data, that is high IOPS (Input/Output Operations per second).</p>
</li>
</ol>
<p>Unlike other instances, these do not use separate EBS volumes for storage. Instead they come with physically attached storage volumes (called the <a target="_blank" href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/InstanceStorage.html">instance store</a>). This means that data does not have to go through a network, allowing it to achieve high IOPS.</p>
<p>Ideal use case is NoSQL databases – like Elasticsearch, MongoDB, Cassandra and some data warehousing applications. Instance store volumes, however come with a catch: any data stored there does not persist beyond the life of the instance. So, if the instance stops, hibernates, terminates or fails, you lose all data on that instance.</p>
<p>The ideal use case for storage optimized instances is thus for workloads that require high IOPs <strong>and</strong> can tolerate the failure of an instance (usually by having data replicated to another instance for redundancy). 5. <strong>Memory Optimized –</strong> For workloads that require large amounts of RAM. Lowest dollar cost per unit of RAM. Ideal for in memory databases, caches, SQL databases.</p>
<h2 id="heading-anatomy-of-an-ec2-instance-name">Anatomy of an EC2 Instance Name</h2>
<p>You may have come across EC2 instance names like t2.nano, r6a.large or i3en.6xlarge. What exactly do the letters and numbers mean?</p>
<p>Let’s take a complex name like i3en.6xlarge as an example and break it down.</p>
<p><img src="https://substackcdn.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fc5f1844b-80a3-4f87-b7de-1027f4c16aec_1280x720.jpeg" alt="Image" width="1280" height="720" loading="lazy"></p>
<p><em>Anatomy of an EC2 instance name broken down</em></p>
<h3 id="heading-instance-family">Instance Family</h3>
<p>Reading from left to right, the first letter is the instance family. Every family belongs to only one of the instance types, that is general purpose, compute optimized, accelerated computing, storage optimized or memory optimized.</p>
<p>There is no need to cram trying to learn which instance family belongs to which instance type. As you work more with AWS, it will become almost second nature. You can have a look <a target="_blank" href="https://aws.amazon.com/ec2/instance-types/">here</a> for reference if you'd like.</p>
<p>The i3en.6xlarge instance above belongs to the “i” family, which is a storage optimized instance.</p>
<h3 id="heading-instance-generation">Instance Generation</h3>
<p>This is a number that shows the instance generation. The higher the number, the more recent the generation.</p>
<p>When given the option between different generations for the same instance, you should, ideally, always select the latest generation. The latest generation instance usually comes with the latest hardware. This typically means lower cost per unit of performance relative to older generations.</p>
<p>The i3en.6xlarge instance in the example above is a third generation instance.</p>
<h3 id="heading-special-features">Special Features</h3>
<p>These are optional letters that come after the instance generation. Each letter denotes some special feature about the instance.</p>
<p>In this case the “<strong>e</strong>” signifies <strong>extra</strong> <strong>capacity</strong> (can be RAM or storage) and “<strong>n</strong>” signifies that the instance is <strong>network</strong> <strong>optimized</strong>. This means that it has high network bandwidth, meaning the instance can handle a high data transfer rate, typically measured in Gb per second.</p>
<p>Other special feature characters and their capabilities are as follows:</p>
<ul>
<li><p><strong>a</strong> – AMD processors</p>
</li>
<li><p><strong>g</strong> – AWS Graviton processors</p>
</li>
<li><p><strong>i</strong> – Intel processors</p>
</li>
<li><p><strong>d</strong> – Instance store volumes</p>
</li>
<li><p><strong>b</strong> – Block storage optimization</p>
</li>
<li><p><strong>z</strong> – High frequency</p>
</li>
</ul>
<p>These extra features do not come for free, so only select an instance with extra features if you need these additional features.</p>
<h3 id="heading-instance-size">Instance Size</h3>
<p>The size appears after the full stop. It consists of two parts: a number and letters denoting size. The size options range from nano to xlarge (extra large).</p>
<p>The number only appears with xlarge instances. It denotes how much larger the instance is compared to an xlarge. So a 2xlarge is twice as large as an xlarge and a 6xlarge is six times as large as the xlarge.</p>
<p>But, what does twice or six times as large really mean?</p>
<p>For the same instance type, the number after the full stop acts as a multiplier for the compute (number of vCPUs), memory (amount of RAM), and storage size (not all the time – some instances use EBS volumes where storage can scale independently of the instance. Storage optimized instances, on the other hand, use physically attached instance storage that scales based on the instance size.).</p>
<p>An i3en.xlarge instance has 4 vCPUs, 32 GiB memory, and 2500 GB storage capacity. An i3en.<strong>6</strong>xlarge is six times larger since it has <strong>six times</strong> the number of vCPUs (24), six times the memory (192 GiB), and six times the storage capacity (15,000 GB).</p>
<h2 id="heading-bringing-it-all-together-how-to-select-your-instance">Bringing it All Together – How to Select Your Instance</h2>
<p>So, let’s say you need to select an EC2 instance for your web server, or your NoSQL database – what are some logical steps to follow?</p>
<h3 id="heading-step-1-select-instance-type">Step 1: Select instance type</h3>
<p>Choosing between general purpose, compute optimized, accelerated computing, storage optimized and memory optimized is the first and most important decision. Every subsequent decision will be driven by this one.</p>
<p>Here, the decision you are making is primarily one of cost - you are trying to <strong>optimize for the lowest dollar cost per unit of the metric that's most important for your workload</strong>.</p>
<p>If your workload is generic, like a web server, choose a general purpose instance. If your workload is compute intensive, go with a compute optimized instance type. The same logic applies if your workload is memory or storage intensive.</p>
<h3 id="heading-step-2-select-instance-family">Step 2: Select instance family</h3>
<p>A good mental model for choosing the right instance family is to go through the technical documentation for the application you plan to run on that instance and use their recommendation.</p>
<p>For example, Elasticsearch (a full-text search engine database) recommends the “i” family of instances – specifically the “i3”. Recall that the number after the instance family is simply the instance generation, and the latest is usually the greatest.</p>
<p>When a newer generation of the “i” family arrives, Elasticsearch will likely recommend the “i4” instance. You can reason by analogy when selecting the instance family. Look at what the application recommends, as it's a great way to reduce any errors of omission or commission.</p>
<p>The company behind the application will have a lot of experience testing different families and will have done the experimentation on your behalf. No need to re-invent the wheel (unless, of course, your workload is truly niche and no best practice exists).</p>
<h3 id="heading-step-3-select-an-instance-with-special-features">Step 3: Select an instance with special features</h3>
<p>Do this only if absolutely needed. You will be paying extra for this.</p>
<h3 id="heading-step-4-select-an-instance-size">Step 4: Select an instance size</h3>
<p>This is purely specific to your workload and is usually an iterative process. You can run some tests while monitoring CPU and memory utilisation to see if the size you selected is appropriate.</p>
<p>You usually try to have some safety margin, so if your workload is consuming, on average, 90% of memory and CPU, you may need to choose a larger instance. A utilisation of 90% does not provide much headroom for any estimation errors you may have made during testing.</p>
<p>Deciding on the amount of headroom you need is more art than engineering, so there are no hard qualitative numbers on this. But as a rough guide, utilisation in the 90% range is bad, 80% range is acceptable, and 70% and below is good.</p>
<p>You need to provide some headroom to prevent any performance problems from occurring during peak demand.</p>
<h2 id="heading-wrapping-up">Wrapping Up</h2>
<p>When you select an instance type, you are effectively selecting for the lowest price per unit of the metric most important for your workload. This is an important foundation in any project you are working on, as it ensures you are paying the lowest dollar amount per unit of performance.</p>
<p>Selecting the instance size is the most difficult piece of the puzzle and is likely to be an iterative process where you start small, test, and then scale up as required.</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How to Spin Up a Remote Server on AWS ]]>
                </title>
                <description>
                    <![CDATA[ By Jillian Rowe AWS is so cool because it is made up of discreet building blocks that you can use to build some fairly complex infrastructure. This is awesome once you get a handle on things. But when you are just starting out you need to know things... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/getting-started-with-server-administration-on-aws/</link>
                <guid isPermaLink="false">66d45f67b3016bf139028d58</guid>
                
                    <category>
                        <![CDATA[ AWS ]]>
                    </category>
                
                    <category>
                        <![CDATA[ ec2 ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Tue, 14 Apr 2020 04:37:56 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2020/04/cloudiness-clouds-cloudy-daylight-417045.jpg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By Jillian Rowe</p>
<p>AWS is so cool because it is made up of discreet building blocks that you can use to build some fairly complex infrastructure. This is awesome once you get a handle on things. But when you are just starting out you need to know things like "how do I get the IP address of my server" and "wait which SSH key". </p>
<p>Let's go over a few of the key concepts, and then spin up our very own server on the cloud!</p>
<h2 id="heading-what-you-need-to-know-to-administer-remote-servers-on-aws">What you need to know to administer remote servers on AWS</h2>
<p>There are many reasons why you might want to get started on AWS. Maybe your company is moving infrastructure onto the cloud. Maybe you want to start freelancing and don't want to invest in upfront server costs. Or maybe you just want to learn a new skillset. </p>
<p>In order to spin up a remote server on AWS you need to know a few foundational AWS terms and concepts. I'll go over some terms that are directly applicable to spinning up a remote server, but these same concepts are used for more complex infrastructure services such as ElasticBeanstalk, Docker Swarm, and Kubernetes. </p>
<h3 id="heading-elastic-compute-cloud-ec2">Elastic Compute Cloud (EC2)</h3>
<p><a target="_blank" href="https://aws.amazon.com/ec2/">AWS EC2</a> instances are where you compute power lives. These are your remote servers. Knowing how to deal with EC2 instances is incredibly important because they appear just about everywhere. </p>
<h3 id="heading-security-groups">Security Groups</h3>
<p><a target="_blank" href="https://docs.aws.amazon.com/vpc/latest/userguide/VPC_SecurityGroups.html">Security groups</a> are what allow access to your various AWS services, in this case an EC2 instance. These define which ports are open for inward and outward bound traffic. </p>
<h3 id="heading-key-pairs">Key Pairs</h3>
<p><a target="_blank" href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-key-pairs.html">Key pairs</a> are your SSH keys. Make sure you keep track of these and keep them somewhere safe! Also, if you use AWS a lot you will start a collection of key pairs, so make sure that you give them descriptive names and not just <code>ssh</code>. ;-)</p>
<h3 id="heading-virtual-private-cloud-vpc">Virtual Private Cloud (VPC)</h3>
<p>A <a target="_blank" href="https://aws.amazon.com/vpc/">VPC</a> is an isolated resource where your compute infrastructure lives. To carry on with my everything is Legos philosophy, the VPC is the Lego box while the EC2, Security Groups, and KeyPairs are the actual Legos. </p>
<p>VPCs take care of all of your networking. When you sign up for an AWS account you will get a default VPC and that is what we will be using today. </p>
<h2 id="heading-how-to-launch-an-ec2-instance">How to Launch an EC2 Instance</h2>
<p>There are so, so many ways to launch an EC2 instance. Which one you want will depend upon your needs. Today we will go over using the AWS web console and using the python <code>boto3</code> library.</p>
<p>As a quick aside, because AWS has so many services you have to go into each service individually to manage it. If you're ever lost, just search for your service from the 'Services' Menu.</p>
<h2 id="heading-launch-an-ec2-instance-using-the-wizard">Launch an EC2 Instance Using the Wizard</h2>
<p>First you'll need to login to your <a target="_blank" href="https://console.aws.amazon.com/">AWS Console.</a></p>
<h3 id="heading-navigate-to-the-ec2-dashboard">Navigate to the EC2 Dashboard</h3>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/04/AWS-Services-Menu---Search-EC2.png" alt="Image" width="600" height="400" loading="lazy">
<em>Bring up the EC2 services page by searching for it in 'Services'</em></p>
<ol>
<li>Click on Services to bring up the search box.</li>
<li>Type in the service name you want - in this case, EC2.</li>
<li>Click on your service name from the menu to bring you to that services dashboard. </li>
</ol>
<h3 id="heading-select-launch-instance">Select 'Launch Instance'</h3>
<p>Once we're at the EC2 Dashboard you'll want to click the 'Launch Instance' button in the middle of the screen. This will start up the the AWS EC2 Launch Wizard, which will walk us through the process of starting up an EC2 instance.</p>
<p>If you want to go through part 2 where we'll startup an EC2 server programatically with Python this is an excellent chance to write down your default VPC id!</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/04/AWS_EC2_-_Select_Instance_Type-1.png" alt="Image" width="600" height="400" loading="lazy"></p>
<h3 id="heading-ec2-wizard-overview">EC2 Wizard Overview</h3>
<p>Once you select 'Launch Instance' you'll be brought to a wizard. The wizard menu has 7 steps, and you can switch between them as you like to get your instance configured just the way you want it.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/04/AWS-EC2-Wizard-Menu.png" alt="Image" width="600" height="400" loading="lazy"></p>
<h3 id="heading-ec2-wizard-select-your-ami-type">EC2 Wizard - Select Your AMI Type</h3>
<p>Here is where the magic happens!</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/04/AWS_EC2_-_Select_Instance_Type.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>This is where you will choose your AMI type, which is mostly what operating system you want. There are any number of preconfigured AMIs for lots of common use cases, including ML applications, web servers, and databases. Check out the <a target="_blank" href="https://aws.amazon.com/marketplace">AWS Marketplace</a> to see all the cool AMIs out there!</p>
<p>I like the Amazon Linux 2 image, but you can search for any image type, including Ubuntu, Centos, or any number of <a target="_blank" href="https://bitnami.com/partners/aws">Bitnami</a> images. </p>
<p>Quick side note here. I love the Bitnami images. They are all awesome, and if you're looking into deploying any kind of web application such as Ghost, Wordpress, Nginx, or even more complex applications like Redash or Airflow I really recommend them. </p>
<h3 id="heading-ec2-wizard-choose-your-instance-type">EC2 Wizard - Choose your Instance Type</h3>
<p>I'm going with the free one because I intend on killing this, but if you're actually using this EC2 instance for anything important you'll want to add more power. If you need anything involving internet, such as transferring data, make sure that you pay attention to the internet capabilities and choose something in the moderate range. </p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/04/AWS-EC2-Choose-Instance-Type-Size.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>Scroll down and choose either 'Launch' to launch with default settings or 'Configure your Instance' to add in additional configurations such as changing the root file system size, choosing a VPC, or adding in user data.</p>
<h3 id="heading-ec2-wizard-add-tags">EC2 Wizard - Add Tags</h3>
<p>When you're just starting out this doesn't matter too much, but as you get going with AWS you will want to make sure that all of your instances have, at the least, <code>Name</code> tags. This will allow you to more easily search for your instances and do nice things like create resource groups to group together your AWS services. </p>
<p>In the wizard menu select 'Add Tags'. Don't worry, you can switch between steps in the wizard as often as you like.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/04/AWS-EC2-Wizard---Tag.png" alt="Image" width="600" height="400" loading="lazy"></p>
<h3 id="heading-ec2-wizard-configure-the-security-group">EC2 Wizard - Configure the Security Group</h3>
<p>Before we finish up we'll configure the security group, which is what defines the access rules. AWS will create a security group for you, or you can choose one already. The default is to open port 22 for SSH, but if you'll use this for any web or database applications you will need to open those ports too. </p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/04/AWS-EC2-Wizard-Seccurity-Group.png" alt="Image" width="600" height="400" loading="lazy"></p>
<h3 id="heading-ec2-wizard-launch">EC2 Wizard - LAUNCH</h3>
<p>Now that we've told AWS what we want let's launch our instance! Click on the Review and Launch. You'll get a popup window asking you which SSH Key you want. You can also create a new SSH Keypair here. </p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/04/EC2-Wizard---KeyPair.png" alt="Image" width="600" height="400" loading="lazy"></p>
<h3 id="heading-ec2-wizard-confirmation-page">EC2 Wizard - Confirmation Page</h3>
<p>Once you've launched you'll be brought to a confirmation page with your EC2 Instance ID. </p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/04/AWS-EC2-Launch-Confirmation.png" alt="Image" width="600" height="400" loading="lazy"></p>
<h3 id="heading-ec2-dashboard-get-your-ip-address">EC2 Dashboard - Get your IP Address</h3>
<p>There we go! Now all that is left is to wait for our instance to be ready and SSH on over.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/04/AWS-EC2-Dashboard---Get-IP-Address.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>Ok! Now we just have to SSH over to our instance. The details for this will be slightly different depending on which instance type you chose.</p>
<p>This assumes you downloaded your keypair named <code>my-remote-server.pem</code> and moved it to <code>~/.ssh</code></p>
<pre><code class="lang-bash">chmod 400 ~/.ssh/my-remote-server.pem

<span class="hljs-comment"># Amazon linux 2 ami</span>
ssh -i ~/.ssh/my-remote-server.pem ec2-user@PUBLIC_DNS

<span class="hljs-comment"># Ubuntu or Bitnami</span>
ssh -i ~/.ssh/my-remote-server.pem ubuntu@PUBLIC_DNS
</code></pre>
<p>That's it! Now you have a remote server on the cloud!</p>
<h2 id="heading-spin-up-an-ec2-instance-with-the-boto3-python-library">Spin up an EC2 Instance with the Boto3 Python Library</h2>
<p>Full disclaimer here. This is well beyond what I would normally do with the boto3 library. For anything beyond launching an EC2 instance I would recommend using the console or using an infrastructure as code tool such as <a target="_blank" href="https://aws.amazon.com/cloudformation/">Cloudformation</a> or <a target="_blank" href="https://www.freecodecamp.org/news/p/91bf3938-5e24-4f7a-99b0-090255995d6c/terraform.io">Terraform</a>. But when you are starting out it is really important to understand the foundations.</p>
<p>I also have an obsessive need to write out reports for absolutely everything. Feel free to remove if you're not as paranoid. ;-)</p>
<pre><code><span class="hljs-keyword">import</span> boto3
<span class="hljs-keyword">import</span> time
<span class="hljs-keyword">import</span> json
<span class="hljs-keyword">from</span> pprint <span class="hljs-keyword">import</span> pprint
<span class="hljs-keyword">from</span> select <span class="hljs-keyword">import</span> select
<span class="hljs-keyword">import</span> logging
<span class="hljs-keyword">from</span> logging <span class="hljs-keyword">import</span> Logger
<span class="hljs-keyword">from</span> paramiko <span class="hljs-keyword">import</span> SSHClient
<span class="hljs-keyword">import</span> paramiko
<span class="hljs-keyword">from</span> typing <span class="hljs-keyword">import</span> Any
<span class="hljs-keyword">import</span> os

logger = logging.getLogger(<span class="hljs-string">'launch_ec2'</span>)
logger.setLevel(logging.DEBUG)

PROJECT = <span class="hljs-string">"my-remote-server"</span>
KEY_PAIR = <span class="hljs-string">"my-remote-server"</span>
SECURITY_GROUP=<span class="hljs-string">"sg-some-number"</span>
# Amazon Linux <span class="hljs-number">2</span> AMI
AMI_ID=<span class="hljs-string">"ami-062f7200baf2fa504"</span>
INSTANCE_TYPE=<span class="hljs-string">"t3a.medium"</span>

report_data = {
    <span class="hljs-string">'name'</span>: PROJECT,
    <span class="hljs-string">'computer_name'</span>: KEY_PAIR,
}

def initialize_dir():
    <span class="hljs-string">""</span><span class="hljs-string">"
    Initialize a directory to write out our keypair and reports
    "</span><span class="hljs-string">""</span>
    <span class="hljs-keyword">if</span> not os.path.exists(KEY_PAIR):
        os.mkdir(KEY_PAIR)


def create_key_pair():
    ec2_client = boto3.client(<span class="hljs-string">'ec2'</span>)
    key_pair_response = ec2_client.create_key_pair(KeyName=KEY_PAIR)
    report_data[<span class="hljs-string">'ssh_key'</span>] = {}
    report_data[<span class="hljs-string">'ssh_key'</span>][<span class="hljs-string">'id'</span>] = key_pair_response[<span class="hljs-string">'KeyPairId'</span>]
    report_data[<span class="hljs-string">'ssh_key'</span>][<span class="hljs-string">'name'</span>] = key_pair_response[<span class="hljs-string">'KeyName'</span>]
    report_data[<span class="hljs-string">'ssh_key'</span>][<span class="hljs-string">'key'</span>] = key_pair_response[<span class="hljs-string">'KeyMaterial'</span>]
    report_data[<span class="hljs-string">'ssh_key'</span>][<span class="hljs-string">'key_file'</span>] = os.path.abspath(os.path.join(KEY_PAIR, <span class="hljs-string">'keypair.pem'</span>))
    logger.info(<span class="hljs-string">'Successfully created ssh key'</span>)


def write_key_file():
    <span class="hljs-string">""</span><span class="hljs-string">"
    Write out the .pem ssh key file
    :return:
    "</span><span class="hljs-string">""</span>
    f = open(os.path.join(KEY_PAIR, <span class="hljs-string">'keypair.pem'</span>), <span class="hljs-string">'w+'</span>)
    f.write(report_data[<span class="hljs-string">'ssh_key'</span>][<span class="hljs-string">'key'</span>])
    f.close()
    os.chmod(os.path.join(KEY_PAIR, <span class="hljs-string">'keypair.pem'</span>), <span class="hljs-number">0o400</span>)
    logger.info(
        <span class="hljs-string">'Wrote out ssh key file to {keypair}'</span>.format(
            keypair=
            os.path.abspath(os.path.join(KEY_PAIR, <span class="hljs-string">'keypair.pem'</span>))
        )
    )


def create_instance():
    ec2 = boto3.resource(<span class="hljs-string">'ec2'</span>)
    instance = ec2.create_instances(
        SecurityGroupIds=[SECURITY_GROUP],
        ImageId=AMI_ID,
        MinCount=<span class="hljs-number">1</span>,
        MaxCount=<span class="hljs-number">1</span>,
        InstanceType=INSTANCE_TYPE,
        KeyName=KEY_PAIR,
        TagSpecifications=[
            {
                <span class="hljs-string">'ResourceType'</span>: <span class="hljs-string">'instance'</span>,
                <span class="hljs-string">'Tags'</span>: [
                    {
                        <span class="hljs-string">'Key'</span>: <span class="hljs-string">'Name'</span>,
                        <span class="hljs-string">'Value'</span>: PROJECT
                    },
                ]
            },
        ],
    )
    report_data[<span class="hljs-string">'ec2'</span>] = {}
    report_data[<span class="hljs-string">'ec2'</span>][<span class="hljs-string">'id'</span>] = instance[<span class="hljs-number">0</span>].id
    report_data[<span class="hljs-string">'ec2'</span>][<span class="hljs-string">'PublicIP'</span>] = None


def get_public_ip():
    print(<span class="hljs-string">'Waiting for instance to initialize with public IP address...'</span>)
    print(<span class="hljs-string">'This may take some time...'</span>)
    time.sleep(<span class="hljs-number">10</span>)
    ec2 = boto3.resource(<span class="hljs-string">'ec2'</span>)
    running_instances = ec2.instances.filter(Filters=[
        {
            <span class="hljs-string">'Name'</span>: <span class="hljs-string">'instance-state-name'</span>,
            <span class="hljs-string">'Values'</span>: [<span class="hljs-string">'running'</span>]
        },
        {
            <span class="hljs-string">'Name'</span>: <span class="hljs-string">'instance-id'</span>,
            <span class="hljs-string">'Values'</span>: [report_data[<span class="hljs-string">'ec2'</span>][<span class="hljs-string">'id'</span>]]
        }
    ])
    <span class="hljs-keyword">for</span> instance <span class="hljs-keyword">in</span> running_instances:
        # Add instance info to a dictionary
        report_data[<span class="hljs-string">'ec2'</span>] = {
            <span class="hljs-string">'instance_id'</span>: report_data[<span class="hljs-string">'ec2'</span>][<span class="hljs-string">'id'</span>],
            <span class="hljs-string">'Type'</span>: instance.instance_type,
            <span class="hljs-string">'State'</span>: instance.state[<span class="hljs-string">'Name'</span>],
            <span class="hljs-string">'PrivateIP'</span>: instance.private_ip_address,
            <span class="hljs-string">'PublicIP'</span>: instance.public_ip_address,
            <span class="hljs-string">'LaunchTime'</span>: str(instance.launch_time)
        }


def write_report():
    <span class="hljs-string">""</span><span class="hljs-string">"
    Write out a JSON file with all of the IDs and things we need
    "</span><span class="hljs-string">""</span>
    logger.info(<span class="hljs-string">'Writing report to {}'</span>.format(
        os.path.abspath(os.path.join(KEY_PAIR, <span class="hljs-string">'report.json'</span>))
    ))
    f = open(os.path.abspath(os.path.join(KEY_PAIR, <span class="hljs-string">'report.json'</span>))
             , <span class="hljs-string">'w+'</span>)
    json.dump(report_data, f, ensure_ascii=False, indent=<span class="hljs-number">4</span>)
    f.close()


def print_helper_commands():
    <span class="hljs-string">""</span><span class="hljs-string">"
    Print some helper commands for ssh and rsync to the screen
    "</span><span class="hljs-string">""</span>
    rsync_command = <span class="hljs-string">"rsync -av --progress -e 'ssh -i {key_file}' HOST_DIR ec2-user@{public_id}:/home/ec2-user/efs"</span>.format(
        key_file=report_data[<span class="hljs-string">'ssh_key'</span>][<span class="hljs-string">'key_file'</span>],
        public_id=report_data[<span class="hljs-string">'ec2'</span>][<span class="hljs-string">'PublicIP'</span>]
    )
    ssh_command = <span class="hljs-string">"ssh -i {key_file} ec2-user@{public_ip}"</span>.format(
        key_file=report_data[<span class="hljs-string">'ssh_key'</span>][<span class="hljs-string">'key_file'</span>],
        public_ip=report_data[<span class="hljs-string">'ec2'</span>][<span class="hljs-string">'PublicIP'</span>]
    )
    report_data[<span class="hljs-string">'ssh_command'</span>] = ssh_command
    report_data[<span class="hljs-string">'rsync_command'</span>] = rsync_command
    print(<span class="hljs-string">'Some helpful commands!'</span>)
    print(<span class="hljs-string">'###################################'</span>)
    print(<span class="hljs-string">'# SSH to the instance with: '</span>)
    print(ssh_command)
    print(<span class="hljs-string">'###################################'</span>)

    print(<span class="hljs-string">'###################################'</span>)
    print(<span class="hljs-string">'# Rsync data to the instance with: '</span>)
    print(rsync_command)
    print(<span class="hljs-string">'###################################'</span>)


def print_end_message():
    print(<span class="hljs-string">'##################################'</span>)
    print(<span class="hljs-string">'Finished!'</span>)
    print(<span class="hljs-string">'See {dir}/report.json for details'</span>.format(dir=KEY_PAIR))


initialize_dir()
create_key_pair()
write_key_file()
create_instance()
<span class="hljs-keyword">while</span> report_data[<span class="hljs-string">'ec2'</span>][<span class="hljs-string">'PublicIP'</span>] is None:
    get_public_ip()
print_helper_commands()
write_report()
print_end_message()
</code></pre><h2 id="heading-wrapup">WrapUp</h2>
<p>That's all you need to know to get started with spinning up remote servers in the cloud! What kinds of projects do you want to deploy to the cloud?</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How to Connect Amazon EC2 Using Microsoft Remote Desktop in macOS ]]>
                </title>
                <description>
                    <![CDATA[ By Clark Jason Ngo I created this guide because of an experience I had while teaching. My students needed to use an application that was only available on Windows OS but the students only had macOS. We will be touching on the technologies shown below... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/ec2-with-microsoft-remote-desktop/</link>
                <guid isPermaLink="false">66d45e24230dff01669057dd</guid>
                
                    <category>
                        <![CDATA[ configuration ]]>
                    </category>
                
                    <category>
                        <![CDATA[ ec2 ]]>
                    </category>
                
                    <category>
                        <![CDATA[ macOS ]]>
                    </category>
                
                    <category>
                        <![CDATA[ rdp ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Thu, 09 Apr 2020 01:22:54 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2020/04/rdp.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By Clark Jason Ngo</p>
<p>I created this guide because of an experience I had while teaching. My students needed to use an application that was only available on Windows OS but the students only had macOS.</p>
<p>We will be touching on the technologies shown below:  </p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/04/image-56.png" alt="Image" width="600" height="400" loading="lazy"></p>
<ul>
<li>Amazon EC2: launch a Windows Server 2019</li>
<li>Microsoft Remote Desktop: macOS application to remote desktop connect (RDP) to EC2</li>
</ul>
<h2 id="heading-amazon-ec2">Amazon EC2</h2>
<h3 id="heading-launching-a-windows-server-ec2-instance">Launching a Windows Server EC2 Instance</h3>
<ol>
<li>Sign in to your <a target="_blank" href="https://aws.amazon.com/console/">AWS Management Console</a>.</li>
<li>Choose <strong>Services</strong>, then <strong>EC2</strong>.</li>
<li>In the sidebar, click <strong>Instances</strong>.</li>
</ol>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/04/image-57.png" alt="Image" width="600" height="400" loading="lazy">
<em>EC2 sidebar</em></p>
<ol start="4">
<li>Click <strong>Launch Instance</strong>.</li>
</ol>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/04/image-58.png" alt="Image" width="600" height="400" loading="lazy">
<em>Launch Instance button</em></p>
<ol start="5">
<li>Scroll down and choose <strong>Microsoft Windows Server 2019 Base</strong>.</li>
</ol>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/04/image-59.png" alt="Image" width="600" height="400" loading="lazy">
<em>Choose AMI page</em></p>
<ol start="6">
<li>At the bottom of the Choose Instance Type page, click <strong>Review and Launch</strong>. This will skip you to the Review page.</li>
</ol>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/04/image-60.png" alt="Image" width="600" height="400" loading="lazy">
<em>Launch with minimal configuration</em></p>
<ol start="7">
<li>In the Review page, click <strong>Launch</strong>. You'll be prompted to select an existing key pair or new key pair. </li>
</ol>
<p>If you choose <strong>Create a new key pair</strong>, you need to give the new key pair a name, then download the key pair.  Then you'll be able to proceed to choose <strong>Launch Instance</strong>.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/04/image-61.png" alt="Image" width="600" height="400" loading="lazy">
<em>Key pair to access the instance</em></p>
<p>If you choose <strong>Choose an existing key pair</strong>, you need to select a key pair and tick the checkbox to acknowledge the use of the key pair.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/04/image-62.png" alt="Image" width="600" height="400" loading="lazy">
<em>Last step to launch instance</em></p>
<ol start="8">
<li>Click the generated Instance ID.</li>
</ol>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/04/image-63.png" alt="Image" width="600" height="400" loading="lazy">
<em>Accessing the EC2 Instance</em></p>
<ol start="9">
<li><p>Find and save the following information:</p>
</li>
<li><p>Public DNS (IP Address)</p>
</li>
<li>Username</li>
<li>Password</li>
</ol>
<p>To get the IP Address, scroll to the right of your EC2 instance:  </p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/04/image-70.png" alt="Image" width="600" height="400" loading="lazy">
<em>IP Address of EC2 Instance</em></p>
<p>You can also find this in the Description tab below:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/04/image-67.png" alt="Image" width="600" height="400" loading="lazy">
<em>IP Address of EC2 Instance</em></p>
<ol start="10">
<li>To get the username and password, choose the EC2 instance (tick the checkbox), click <strong>Actions</strong>, then <strong>Get Windows Password</strong>.</li>
</ol>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/04/image-68.png" alt="Image" width="600" height="400" loading="lazy">
<em>Obtaining the username and password</em></p>
<p>You may encounter <em>Password not available</em> and you'll need to wait a couple of minutes.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/04/image-71.png" alt="Image" width="600" height="400" loading="lazy">
<em>Provisioning the auto-generated password</em></p>
<ol start="11">
<li>Locate the existing key pair or the newly created key pair you have downloaded in your local machine. Click <strong>Choose File</strong>.</li>
</ol>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/04/image-72.png" alt="Image" width="600" height="400" loading="lazy">
<em>Retrieve the key pair</em></p>
<ol start="12">
<li>After uploading the key pair, click <strong>Decrypt Password</strong>.</li>
</ol>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/04/image-73.png" alt="Image" width="600" height="400" loading="lazy"></p>
<ol start="13">
<li>Copy the following information and save it in a file or clipboard. Click <strong>Close</strong> when you are done.</li>
</ol>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/04/image-74.png" alt="Image" width="600" height="400" loading="lazy">
<em>Information for remote desktop connection</em></p>
<h2 id="heading-microsoft-remote-desktop">Microsoft Remote Desktop</h2>
<h3 id="heading-installing-the-application-and-connecting-to-ec2-instance">Installing the application and connecting to EC2 instance</h3>
<ol>
<li>Open your App Store, then search for <strong>Microsoft Remote Desktop</strong>. Click Install (it shows UPDATE here as I already have installed).</li>
</ol>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/04/image-64.png" alt="Image" width="600" height="400" loading="lazy">
<em>Microsoft Remote Desktop in the App Store</em></p>
<ol start="2">
<li><p>After installation, Open Microsoft Remote Desktop.</p>
</li>
<li><p>At the top, click the <strong>+</strong> Icon and choose <strong>Desktop</strong>.</p>
</li>
</ol>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/04/image-65.png" alt="Image" width="600" height="400" loading="lazy">
<em>Creating a new desktop connection</em></p>
<ol start="4">
<li>In the PC name, copy the EC2 Instance IP address, then click <strong>Add</strong>.</li>
</ol>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/04/image-66.png" alt="Image" width="600" height="400" loading="lazy">
<em>Adding the IP address</em></p>
<ol start="5">
<li>Copy the Administrator and Password from earlier and paste it here. Hit <strong>Continue</strong>.</li>
</ol>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/04/image-75.png" alt="Image" width="600" height="400" loading="lazy">
<em>Signing in with the username and password</em></p>
<p>You are now connected to your Windows Server EC2 Instance.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/04/image-76.png" alt="Image" width="600" height="400" loading="lazy">
<em>Windows Server EC2 Instance</em></p>
<p>Note: To avoid getting charged after you have used up the free tier for EC2, either click <strong>Stop</strong> to have a lower cost, or <strong>Terminate</strong> to remove the instance and not be charged. </p>
<p>You have access to this by selecting the instance and choosing <strong>Actions &gt; Instance State &gt; Stop/Terminate</strong>.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/04/image-77.png" alt="Image" width="600" height="400" loading="lazy"></p>
<h2 id="heading-heres-a-video-tutorial">Here's a video tutorial:</h2>
<div class="embed-wrapper">
        <iframe width="560" height="315" src="https://www.youtube.com/embed/QQIivlr_CKk" style="aspect-ratio: 16 / 9; width: 100%; height: auto;" title="YouTube video player" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen="" loading="lazy"></iframe></div>
<p>Connect with me on LinkedIn <a target="_blank" href="https://www.linkedin.com/in/clarkngo/">here</a>.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/03/image-243.png" alt="Image" width="600" height="400" loading="lazy"></p>
 ]]>
                </content:encoded>
            </item>
        
    </channel>
</rss>
