<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Sanmi</title>
    <description>The latest articles on DEV Community by Sanmi (@snmi___).</description>
    <link>https://dev.to/snmi___</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F469532%2Fdf9b1ce4-27bb-4433-a16e-f813f382cce7.jpg</url>
      <title>DEV Community: Sanmi</title>
      <link>https://dev.to/snmi___</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/snmi___"/>
    <language>en</language>
    <item>
      <title>Deploying a secured Node.js Application on AWS EC2 Instance from scratch (Detailed Guide)</title>
      <dc:creator>Sanmi</dc:creator>
      <pubDate>Tue, 31 Oct 2023 11:27:09 +0000</pubDate>
      <link>https://dev.to/snmi___/deploying-a-secured-nodejs-application-on-aws-ec2-instance-from-scratch-detailed-guide-2l23</link>
      <guid>https://dev.to/snmi___/deploying-a-secured-nodejs-application-on-aws-ec2-instance-from-scratch-detailed-guide-2l23</guid>
      <description>&lt;p&gt;Every website or web application you have ever come across on the internet contains code deployed there by someone like you (or by aliens; I can't tell the extent of their involvement at this time) and for you as a web/software developer, knowing how to deploy your code to the streets of the internet via a remote server such as cloud servers is an invaluable skill to have today. There are several decent hosting services around that enable you to properly and securely host your website or web app such as &lt;a href="https://www.digitalocean.com/" rel="noopener noreferrer"&gt;Digital Ocean&lt;/a&gt;, &lt;a href="https://www.heroku.com/" rel="noopener noreferrer"&gt;Heroku&lt;/a&gt;, &lt;a href="https://vercel.com/" rel="noopener noreferrer"&gt;Vercel&lt;/a&gt; (mostly for front-end apps) and chief amongst them, &lt;a href="https://aws.amazon.com/" rel="noopener noreferrer"&gt;Amazon Web Services (AWS)&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Today, you will learn how to deploy your node.js project to the internet via an Amazon Web Services EC2 Instance at little or no cost. You will learn how to create an AWS EC2 Instance and work in Amazon Linux 2, create and manage services with SYSTEMD, use NGINX as a reverse proxy and obtain an SSL certificate from &lt;a href="https://letsencrypt.org/" rel="noopener noreferrer"&gt;Let's Encrypt&lt;/a&gt; to ensure your website is secure via HTTPS protocol. So let’s get to it and deploy your project to your EC2 Instance. &lt;/p&gt;

&lt;h2&gt;
  
  
  Create an AWS EC2 Instance
&lt;/h2&gt;

&lt;p&gt;As I said in my last post, Amazon Elastic Compute Cloud (AWS EC2) is an Infrastructure as a service (IAAS) cloud service provided by &lt;a href="http://amazon.com/" rel="noopener noreferrer"&gt;Amazon.com&lt;/a&gt; that enables you to rent a virtual machine where you can host and run your computer applications. Amazon EC2 provides you with what is called an Instance, which is a web service you can use to initialize an Amazon Machine Image (AMI) to configure your virtual machine that contains your software. AWS also offers services like AWS CLI, AWS S3, AWS CodeDeploy, AWS Lambda and AWS Elastic Beanstalk to further streamline deployment and management.&lt;/p&gt;

&lt;p&gt;In my previous &lt;a href="https://devyarnswithsanmi.hashnode.dev/how-to-create-and-set-up-an-aws-ec2-instance" rel="noopener noreferrer"&gt;post&lt;/a&gt;, I gave a detailed description of how to create and set up an AWS EC2 in just a few minutes.&lt;/p&gt;

&lt;h2&gt;
  
  
  Connect to your Instance
&lt;/h2&gt;

&lt;p&gt;There are numerous ways to connect to your AWS EC2 (Elastic Compute Cloud) instance, providing flexibility and accessibility tailored to your needs. One of the most common methods is through SSH (Secure Shell), which allows you remote and secure access to your Instance through the command line. Another option is using &lt;a href="https://docs.aws.amazon.com/systems-manager/latest/userguide/session-manager-working-with-sessions-start.html#start-ec2-console" rel="noopener noreferrer"&gt;AWS Systems Manager Session Manager&lt;/a&gt;, a browser-based SSH-like interface that doesn't require you to open incoming ports on your instance. Additionally, you can connect via &lt;a href="https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/connecting_to_windows_instance.html" rel="noopener noreferrer"&gt;Remote Desktop Protocol (RDP)&lt;/a&gt; for Windows instances which enables graphical desktop access, or utilize AWS SSM Run Command for executing commands remotely. For web applications, you can access your EC2 instance through a web browser by configuring security groups and setting up a web server. AWS also offers the EC2 Instance Connect feature, enabling one-click browser-based SSH access as I have illustrated in the gif below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4awn2rgh58d007ge5u0n.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4awn2rgh58d007ge5u0n.gif" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;These diverse connection methods enable you to interact with your EC2 instance efficiently and securely, catering to various use cases and preferences.&lt;/p&gt;

&lt;p&gt;In this post, I will use SSH to access the Instance on Amazon Linux via the command line. To connect to your Instance via SSH you have to first navigate to the directory/path where your key pair (&lt;code&gt;.pem&lt;/code&gt; file) is located and then run a command following this pattern in the command line&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

 ssh -I”/path/key-pair-name.pem” instance-user-name@instance-public-dns-name


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;code&gt;path/key-pair-name.pem&lt;/code&gt; refers to the path to your &lt;code&gt;.pem&lt;/code&gt; file but you can simply enter the name of the file without the path if you’re connecting to your Instance from a directory that contains the file, &lt;code&gt;instance&lt;/code&gt; is often &lt;code&gt;ec2&lt;/code&gt; and &lt;code&gt;username&lt;/code&gt; is often &lt;code&gt;user&lt;/code&gt; although you may want to read your Amazon Machine Image usage instructions to check if the AMI owner has changed the default AMI user name, finally your &lt;code&gt;public-dns-name&lt;/code&gt; refers to an IPv4 address assigned to your Instance that allows you to access your Instance on the Internet. To find the &lt;code&gt;public-dns-name&lt;/code&gt; of your instance, go to your Instance details and check for Public IPv4 DNS. I have indicated in the image below, just copy it and add it to your command.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh5k0kxerhdp6eu8fkfjq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh5k0kxerhdp6eu8fkfjq.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So following that pattern, this is the command I will execute in the command line to connect to MY Instance&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

ssh -i "my-key-pair.pem" ec2-user@ec2-16-171-152-245.eu-north-1.compute.amazonaws.com


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;On your first attempt to connect to your Instance you will be prompted with a response requiring you to grant permission to add your Public DNS name to the list of known authentic hosts allowed to access your Instance.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fssijqh7c2em76zblbhsd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fssijqh7c2em76zblbhsd.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I will simply reply with yes. You can do that or enter the fingerprint (indicated above). Once you have chosen your preferred response for establishing the authenticity of your host (public DNS name), you will get a response similar to the image below signifying that your host has been permanently added to the list of known hosts.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F13wb9v2tbi6sk7c52baz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F13wb9v2tbi6sk7c52baz.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If your connection closes like mine, connect to your Instance once again and this time you get a response similar to the image below&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0p0gkhf02lj5y6e54n1i.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0p0gkhf02lj5y6e54n1i.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you get this response, then congratulations! You have successfully connected to your EC2 Instance in Amazon Linux via SSH.&lt;/p&gt;

&lt;h2&gt;
  
  
  Install NPM/&amp;amp;Node
&lt;/h2&gt;

&lt;p&gt;Since you intend to deploy a Node.js application to this Instance, you have to install Node and package manager (NPM or Yarn) in your Amazon Linux Instance using Yum to set up your node.js development environment. To do this, you can either directly install node package manager (npm) by simply running the command in your terminal&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

$ sudo yum install npm


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;This should allow you to easily run your node.js application in this instance and manage and install JavaScript packages and libraries for your application OR you can run the following command in your terminal&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

curl -o- https://raw.Githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;This will install node version manager (nvm), you will use nvm to install Node.js as nvm can install multiple versions of Node.js and allow you to switch between them. I will not go deep into this method now but you can get a more detailed explanation of this method on &lt;a href="https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/setting-up-node-on-ec2-instance.html" rel="noopener noreferrer"&gt;AWS documentation&lt;/a&gt;. For this post, I shall install npm directly.&lt;/p&gt;

&lt;h2&gt;
  
  
  Import your Source code
&lt;/h2&gt;

&lt;p&gt;There are multiple ways to import your code to your Instance. You can import your code files from your Windows computer by using &lt;a href="https://technotaught.com/how-to-upload-files-to-aws-ec2-using-winscp/" rel="noopener noreferrer"&gt;WinSCP&lt;/a&gt; or use a utility like &lt;a href="https://saturncloud.io/blog/how-to-use-rsync-to-transfer-files-to-an-amazon-ec2-instance/" rel="noopener noreferrer"&gt;rsync&lt;/a&gt; to efficiently transfer your code files from your local storage (your computer) to remote servers (your Instance) or you can be like me and use the most straight forward method which is to use git to download your code from your source code management platform which is &lt;a href="https://github.com/" rel="noopener noreferrer"&gt;Github&lt;/a&gt; in my case (and hopefully yours).&lt;/p&gt;

&lt;p&gt;To import your source code to your instance from Github, you should first install Git by executing the command.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

$ sudo yum install git


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;You will then use &lt;code&gt;git clone&lt;/code&gt; to download the source from your Github repository to your Instance via the command&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

git clone https://Github.com/Dukesanmi/my_nodejs_project.git


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;This may prompt you to authenticate your Github account (If it's a private repo). To do this, enter your Github username in response to the first prompt that requests your username, When you enter your correct username you will be prompted to enter your password. Here’s where it gets a bit tricky, the password you are to provide here is not going to be the password to your Github account. Github has revoked the support for password authentication since Aug 2021, so you will have to enter your Github Personal Access Token as the password. Check out &lt;a href="https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens" rel="noopener noreferrer"&gt;Github Personal Access Tokens&lt;/a&gt; to learn more about them and how to generate them.&lt;/p&gt;

&lt;h2&gt;
  
  
  NPM install your dependencies
&lt;/h2&gt;

&lt;p&gt;Once your code has been downloaded to your instance from Github, run&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

npm install


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;in the directory that contains your code (specifically the &lt;code&gt;package.json&lt;/code&gt; file) to install your project’s dependencies and ensure your code runs locally on localhost without any errors.&lt;/p&gt;

&lt;h2&gt;
  
  
  Run your code locally
&lt;/h2&gt;

&lt;p&gt;Once you have confirmed that your code runs fine in your Amazon Linux terminal (i.e. you ran the code in your Instance on &lt;code&gt;localhost:portnumber&lt;/code&gt; and it ran smoothly with no errors), you can then test it in your browser and your URL will be the port number your project runs on locally appended to your public IP address in case of the Instance in this post my URL will be something like&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

http://16.171.152.245:8000/


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Ensure you run via HTTP and not HTTPS (you don’t have HTTPS privileges yet lol). Also, make sure you switch out &lt;code&gt;16.171.152.245&lt;/code&gt; for your public IP address.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Feknzoybrqmu1680v6njo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Feknzoybrqmu1680v6njo.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnxohs0uxtynmysos4r2z.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnxohs0uxtynmysos4r2z.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Note: For this to work, you must have an Inbound security group rule that allows inbound traffic to your server on your localhost port number. If you don’t have such a rule, navigate to your instance details, You will see a tab beside the details tab named security, click on it and then you will see the security group your Instance is using. Click on the security and scroll down in the security group view to see and click the Edit inbound rules button, you will be taken to a view that enables you to manage your inbound rules. So you can now add a new inbound rule setting Type to Custom TCP and Port range to your local port number. You can check out my previous &lt;a href="https://devyarnswithsanmi.hashnode.dev/create-and-set-up-your-first-aws-ec2-instance" rel="noopener noreferrer"&gt;post&lt;/a&gt; to see how to create inbound security group rules.&lt;/p&gt;

&lt;h2&gt;
  
  
  Create and manage a node service with systemd
&lt;/h2&gt;

&lt;p&gt;At this point, your application only works on the internet when you manually run it in your Amazon Linux Instance locally from your computer, this is not ideal as it’s no different from running your application using localhost.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd1gg1q9vmn9yfi2ooh6h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd1gg1q9vmn9yfi2ooh6h.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
You want your application to be available on the internet whenever it is accessed on any authorized device, from any authorized location. To achieve this, you can create a service to manage your node app. This service will be managed in &lt;a href="https://systemd.io/" rel="noopener noreferrer"&gt;Systemd&lt;/a&gt; to reliably ensure that your application is always running smoothly (i.e. starting, stopping, restarting, monitoring and occasionally fixing issues to keep the application running). This means that Systemd will ensure that the application is available to users at all times even when your Linux terminal or/and your local computer is off as long your Instance is running remotely on your AWS account, your application should be running smoothly on the internet.&lt;/p&gt;

&lt;p&gt;So let’s create the node service to manage your node application. First, we will create a service file (I will name mine &lt;code&gt;node-api.service&lt;/code&gt;) in the &lt;code&gt;system&lt;/code&gt; subdirectory of the &lt;code&gt;systemd&lt;/code&gt; directory that contains configuration files for system-wide services and units. These files define how &lt;code&gt;systemd&lt;/code&gt; should manage various system services, like network services, daemons, or custom applications. The contents of this directory are owned by the root user so we will be making use of the &lt;code&gt;[sudo](https://www.sudo.ws/)&lt;/code&gt; prefix to execute commands in this phase of the process.&lt;/p&gt;

&lt;p&gt;Let’s get to it! To create your service file, you can use &lt;a href="https://www.vim.org/" rel="noopener noreferrer"&gt;Vim&lt;/a&gt; (if you enjoy a challenge) or &lt;a href="https://www.nano-editor.org/" rel="noopener noreferrer"&gt;Nano&lt;/a&gt; as your editor, and I will be using Nano. Thank you and God bless 🙏🏿. So to create your service file in the appropriate directory, you will execute the command&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

$ sudo nano /etc/systemd/system/node-api.service


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;This should open up a new file inside which you should input the following content&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

[Unit]
Description=Uber Elephants #Brief description of your service and maybe what it does
Documentation=https://example.com #Link to application’s docs
After=network.target

[Service]
Type=simple
User=ec2-user #User account under which a service should run.
EnvironmentFile=/home/ec2-user/mycode/myapp.env #Path to your environmental variables file   
ExecStart=/usr/bin/node /home/ec2-user/mycode/my_nodejs_project /index.js 
Restart=on-failure

[Install]
WantedBy=multi-user.target



&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Let me quickly give a brief explanation for the parts of the file’s content that are not self-explanatory&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;[Unit]&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;After=network.target&lt;/code&gt;: This tells &lt;code&gt;systemd&lt;/code&gt; to wait until the point in the boot process when the network services are up and running before starting up your application.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;[Service]&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Type=simple&lt;/code&gt;: This tells &lt;code&gt;systemd&lt;/code&gt; that your service is a simple, straightforward program that runs as a single process i.e., it just starts and runs, it doesn't involve complex forking or management. This means that &lt;code&gt;systemd&lt;/code&gt; will start your service and consider it running as long as the main process (which in this case is your index.js script) is active.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;ExecStart=/usr/bin/node /home/ec2-user/mycode/my_nodejs_project /index.js&lt;/code&gt;: This specifies to &lt;code&gt;systemd&lt;/code&gt; the command that should be executed to start a service. In this case, the command tells &lt;code&gt;systemd&lt;/code&gt; to run your entry point file.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;/usr/bin/node&lt;/code&gt;: This is the path to the Node.js interpreter executable (node). It tells &lt;code&gt;systemd&lt;/code&gt; to use node.js to run your application. This path will be a little different if you installed node.js using &lt;code&gt;nvm&lt;/code&gt;, you will have to use the path to your node.js interpreter executable which is likely to be something like&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

  /home/ec2-user/.nvm/versions/node/v18.15.0/bin/node


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;/home/ec2-user/mycode/my_nodejs_project/index.js&lt;/code&gt;: This is the full path to the JavaScript file that serves as the entry point for your node.js project. When the service starts, systemd will execute this file using the node.js interpreter specified in &lt;code&gt;/usr/bin/node&lt;/code&gt;. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;Restart=on-failure&lt;/code&gt;: This specifies to &lt;code&gt;systemd&lt;/code&gt; the condition under which the service should be automatically restarted if it dies.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;[Install]&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;WantedBy=multi-user.target&lt;/code&gt;: This ensures that your service starts as part of the normal system startup process when the system is ready to serve multiple users and services.&lt;/p&gt;

&lt;p&gt;You can now save the file and exit the nano editor.&lt;/p&gt;

&lt;p&gt;Once your node service file has been saved you can now use &lt;code&gt;[systemctl](https://www.digitalocean.com/community/tutorials/how-to-use-systemctl-to-manage-systemd-services-and-units)&lt;/code&gt; to control and manage your service. First, check the current state of your service, To do that execute the command&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

$ sudo systemctl status node-api.service


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;(Remember to replace &lt;code&gt;node-api.service&lt;/code&gt; with your service file name.) You should see a response like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbyq2kv5gu97w7upvn2ny.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbyq2kv5gu97w7upvn2ny.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
You can see that your service is currently disabled and inactive so you have to change that. To enable your service run the command&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

$ sudo systemctl enable node-api.service


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;You should get a response like this to confirm that your service has been successfully enabled.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

Created symlink /etc/systemd/system/multi-user.target.wants/node-api.service → /etc/systemd/system/node-api.service.


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;This means that a symbolic link has been created for your service to help &lt;code&gt;systemd&lt;/code&gt; efficiently manage your service. The next thing you do now and whenever you make changes to your service file is to run the command.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

$ sudo systemctl daemon-reload


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;This will reload all unit files, rerun all generators, and recreate the entire dependency tree with your updated service files.&lt;/p&gt;

&lt;p&gt;Now you can start your service by running the command&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

$ sudo systemctl start node-api.service


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;(Again, do not forget to switch out &lt;code&gt;node-api.service&lt;/code&gt; for the name of your service file). Run the status check command again and if your service has started successfully, you should get a response similar to this.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fco635y7s89fvbr9z5hxq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fco635y7s89fvbr9z5hxq.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To test that this works fine, exit your terminal and close it even or try the previous URL &lt;a href="http://16.171.152.245:8000/" rel="noopener noreferrer"&gt;http://16.171.152.245:8000/&lt;/a&gt; in your browser and on another device. You will see that your application will keep running fine without having to manually run it locally.&lt;/p&gt;

&lt;h2&gt;
  
  
  Install and setup NGINX as a reverse proxy server
&lt;/h2&gt;

&lt;p&gt;Now your application runs automatically from anywhere, on any device as long the correct URL is requested but you still have to add your port number to your IP address to be able to access your web application on the internet. This is because your application only listens on your custom port number and not the standard HTTP/HTTPS port number.&lt;/p&gt;

&lt;p&gt;To change that and be able to access your website without your localhost's port number i.e. in my case &lt;code&gt;http://16.171.152.245/&lt;/code&gt;, your application will have to listen on port 80 to use HTTP protocol to load your webpages (still don’t have HTTPS privileges yet).&lt;/p&gt;

&lt;p&gt;To make all of this possible, you need a reverse proxy server that will act as a middleman between a user’s device and your web application, ensuring your web requests get to the right place and return the web pages or data that is requested.&lt;/p&gt;

&lt;p&gt;You can and should use &lt;a href="https://en.wikipedia.org/wiki/Nginx" rel="noopener noreferrer"&gt;NGINX&lt;/a&gt; as your &lt;a href="https://kinsta.com/blog/reverse-proxy/" rel="noopener noreferrer"&gt;reverse proxy server&lt;/a&gt;. Start by installing Nginx on your Linux Instance. Execute the command&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

$ sudo yum install nginx –y


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Once your installation is complete, run to enable your nginx service&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

$ sudo systemctl enable nginx


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;And then start your nginx service by running this command&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

$ sudo systemctl start nginx


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Once it has started successfully, you can check nginx service status by executing the command&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

$ sudo systemctl status nginx


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Your response should look something like this&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fft2ik0y3bfgml4t4hq5m.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fft2ik0y3bfgml4t4hq5m.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now when you run your website in the browser without adding our custom port number, the server returns the nginx default “Welcome” page.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F927wjdmmuct8f7cow3zx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F927wjdmmuct8f7cow3zx.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
The next thing to do now is to configure nginx to direct requests to your node.js project so it will serve your webpages and data when requests are made to our server through HTTP. We would create an nginx configuration file for our application by executing this command&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

$ sudo nano /etc/nginx/conf.d/node-app.conf


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;and then add the following configuration to the file&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

server {
    listen 80;
    server_name 16.171.152.245; #Your domain name or ip

    location / {
        proxy_pass http://16.171.152.245:8000; #your_nodejs_port
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
    }
}



&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Your server_name at this point is your public IP address and you should replace the port number on your proxy_pass with the port number your node.js application is running on locally. Save and exit your editor, then run the command&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

$ sudo nginx –t


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;This is to test the configuration for syntax errors, if there are no errors you should get the response below&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffghxm7cb5ozyjss5jxuh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffghxm7cb5ozyjss5jxuh.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you get the above response, run the following commands&lt;/p&gt;

&lt;p&gt;To reload all the systemd units and generators&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

$ sudo systemctl daemon-reload


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;And then restart the nginx service by running.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

$ sudo systemctl restart nginx


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;You can now check the status of your nginx service to ensure it's still running fine and then go to your browser and refresh your URL which I believe is currently just your public IP address over HTTP, it should return your application's webpage.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fain2uiiwwfztvemhe4f2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fain2uiiwwfztvemhe4f2.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Create name servers for your domain in Route 53
&lt;/h2&gt;

&lt;p&gt;At this point, I assume you already have a domain name you intend to host your website with but if you are not sure how or where to purchase a domain name, you may want to check out one of the many domain name providers available today like &lt;a href="https://www.namecheap.com/" rel="noopener noreferrer"&gt;Namecheap&lt;/a&gt;, &lt;a href="https://www.whogohost.com/" rel="noopener noreferrer"&gt;Whogohost&lt;/a&gt; or &lt;a href="https://aws.amazon.com/getting-started/hands-on/get-a-domain/" rel="noopener noreferrer"&gt;AWS Route53&lt;/a&gt;. Once you have purchased a domain name, go to AWS Route 53 (a &lt;a href="https://en.wikipedia.org/wiki/Domain_Name_System" rel="noopener noreferrer"&gt;DNS&lt;/a&gt; management service) dashboard and under DNS Management, click on “Create &lt;a href="https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/hosted-zones-working-with.html" rel="noopener noreferrer"&gt;Hosted Zone&lt;/a&gt;”&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fooc3weacvusyfmly4g2m.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fooc3weacvusyfmly4g2m.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fho3gv5q1u06yxxvlfrrx.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fho3gv5q1u06yxxvlfrrx.gif" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
Once you have created your hosted zone, update the name servers assigned to your domain name by your domain name provider with the new ones assigned to your hosted zone by AWS (This will be done with your domain name provider).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuxsuqnpjnle4n2qka7ee.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuxsuqnpjnle4n2qka7ee.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
Check that your newly updated name servers have been propagated by checking your domain name on a DNS propagation check service like &lt;a href="http://dnschecker.org/" rel="noopener noreferrer"&gt;dnschecker.org&lt;/a&gt; (Propagation often takes some time so be a little patient).&lt;/p&gt;

&lt;p&gt;Once you have confirmed that your name servers have been propagated, go back to Route53 where you created a hosted zone and create a new record inside your hosted zone. In the new record enter your public IP address in the value field so whenever your domain name URL is entered in a browser it re-routes to your public IP which then via nginx serves your webpage.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fr0jzp547j3duv1wgeb0g.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fr0jzp547j3duv1wgeb0g.gif" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, enter your domain name as your URL in the browser using HTTP (still don’t have HTTPS privileges yet. Remain small lol) for example yourdomainname.com. Access to your web application on the internet is now really straightforward for your users with your custom domain name instead of the more complicated IP address numbers.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuh73s7uc7mdw98cusli1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuh73s7uc7mdw98cusli1.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Get SSL certificates and enable HTTPS
&lt;/h2&gt;

&lt;p&gt;So far, any connection to your website has been unprotected and any data transferred over HTTP will have been transmitted in plain text without any encryption. If packets of data to or from your website were intercepted, it would be easy for the interceptor (lol) to read and alter that data. This lack of encryption makes HTTP unsuitable for transmitting sensitive or confidential information, as it can make your web application vulnerable to eavesdropping, data breaches, and man-in-the-middle attacks.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fod54h1ivojqt9dop0k96.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fod54h1ivojqt9dop0k96.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To prevent these kinds of vulnerabilities in your website, you have to enable &lt;a href="https://www.ssl.com/faqs/what-is-https/" rel="noopener noreferrer"&gt;HTTPS&lt;/a&gt;, a secure version of the HTTP that uses &lt;a href="https://www.ssl.com/faqs/faq-what-is-ssl/" rel="noopener noreferrer"&gt;SSL (Secure Sockets Layer)/TLS (Transport Layer Security)&lt;/a&gt; for encrypting data transferred between your application’s server and client by concealing data in layers of encryption so that in the case of interception, it will be nearly impossible to decipher without the correct decryption key. It is essential for every website especially if your website sends or receives sensitive data such as passwords, security keys, credit card information, bank information etc.&lt;/p&gt;

&lt;p&gt;To enable HTTPS on your website, you need an &lt;a href="https://www.kaspersky.com/resource-center/definitions/what-is-a-ssl-certificate" rel="noopener noreferrer"&gt;SSL/TLS&lt;/a&gt; certificate which is a digital certificate that authenticates a website's identity and enables encrypted connection. I will show you how to obtain an SSL certificate from &lt;a href="https://letsencrypt.org/" rel="noopener noreferrer"&gt;Let’s Encrypt&lt;/a&gt; and enable your website to run on port 443 which is the standard port number for HTTPS protocol.&lt;/p&gt;

&lt;p&gt;For Let’s Encrypt, you need to install Certbot. Installing Cerbot on Amazon Linux 2023 may present itself to be a struggle as EPEL 8 version of Certbot is built for a version of Python (v3.6) that is not available in Amazon Linux 2023. So you have to manually install it using Python by the following process I have highlighted below:&lt;/p&gt;

&lt;p&gt;First, run these commands to set up the Python3 virtual environment&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

$ sudo python3 -m venv /opt/certbot/


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

$ sudo /opt/certbot/bin/pip install --upgrade pip


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Then to install Certbot for Nginx, run the command&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

$ sudo /opt/certbot/bin/pip install certbot cerbot-nginx


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;You can now obtain your SSL certificate by running&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

$ sudo certbot –nginx


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;This will also allow Certbot to automatically modify your Nginx configuration to enable HTTPS. When you execute that command, you will be prompted to provide an email address so you can be contacted in case of urgent renewal and security notices.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqdnatv5k7afduluy4uoy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqdnatv5k7afduluy4uoy.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Respond appropriately to the other prompts (just type in y) and when your account is registered, you will see the view below asking you to select the domain you want to enable HTTPS from a list.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F48mqxyywm20hmoud5jjn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F48mqxyywm20hmoud5jjn.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
You will likely see your domain there, this is as a result of the record you previously created in your Hosted Zone in Route 53 which points to your server’s IP address and Certbot detecting it as an available domain because it can potentially match subdomains under that wildcard domain.&lt;/p&gt;

&lt;p&gt;You have finally earned HTTPS privileges 👏🏿, you can now access your website using HTTPS in your URL like &lt;a href="https://yourdomainname.com" rel="noopener noreferrer"&gt;https://yourdomainname.com&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fztzydq723021pjxpgm0d.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fztzydq723021pjxpgm0d.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There is one more tiny detail you should take care of. Your newly obtained SSL certificate will expire after some time (typically 90 days I think) and you may not always remember to manually renew it. So execute the following command to automatically renew your certificate days before it expires using a &lt;a href="https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/#:~:text=A%20CronJob%20creates%20Jobs%20on,schedule%2C%20written%20in%20Cron%20format." rel="noopener noreferrer"&gt;cron job&lt;/a&gt;.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

$ echo "0 0,12   root /opt/certbot/bin/python -c 'import random; import time; time.sleep(random.random()  3600)' &amp;amp;&amp;amp; sudo certbot renew -q" | sudo tee -a /etc/crontab &amp;gt; /dev/null


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Thanks, &lt;a href="https://dev.to/0xfedev"&gt;oxFedev!&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To check your auto-renewal configuration, view your domain config file at&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

$ sudo cat /etc/letsencrypt/renewal/yourdomainname.conf


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;You should see the number of days before expiry Certbot will auto renew your certificate.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8q9qsv10mtapsrfugwf9.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8q9qsv10mtapsrfugwf9.gif" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
Congratulations! You are now capable of using AWS EC2 Instance to deploy your Node.js project as a secured web application to the streets of the internet for the entire world to interact with, proud of you 🙌🏿. See you on the next one! Cheers ✌🏿&lt;/p&gt;

</description>
      <category>aws</category>
      <category>node</category>
      <category>nginx</category>
      <category>backend</category>
    </item>
    <item>
      <title>How to create and set up your first AWS EC2 Instance</title>
      <dc:creator>Sanmi</dc:creator>
      <pubDate>Thu, 17 Aug 2023 21:24:21 +0000</pubDate>
      <link>https://dev.to/snmi___/how-to-create-and-set-up-your-first-aws-ec2-instance-5ckm</link>
      <guid>https://dev.to/snmi___/how-to-create-and-set-up-your-first-aws-ec2-instance-5ckm</guid>
      <description>&lt;h2&gt;
  
  
  What exactly is an AWS EC2 Instance?
&lt;/h2&gt;

&lt;p&gt;Amazon Elastic Compute Cloud (AWS EC2) is an Infrastructure as a service (IAAS) cloud service provided by Amazon.com that enables users rent a virtual machine where they host and run their computer applications. Amazon EC2 provides users with what is called an Instance, a web service through which a user can boot an Amazon Machine Image (AMI) to configure a virtual machine that contains your software. Users can create, launch or terminate EC2 instances as desired. Websites such as Netflix (As at 2022, they were the biggest EC2 user by monthly spend), Facebook, LinkedIn and Twitch are some of the most popular websites that use AWS EC2 for their cloud services.&lt;/p&gt;

&lt;p&gt;Get ready to get your steps in as i walk you through how to create and configure your first EC2 Instance.&lt;/p&gt;

&lt;h2&gt;
  
  
  Create an AWS EC2 Instance
&lt;/h2&gt;

&lt;p&gt;To be able to create an EC2 Instance, you need to have an AWS account, if you need guidance creating one you can check out &lt;a href="https://docs.aws.amazon.com/accounts/latest/reference/manage-acct-creating.html"&gt;how to create an AWS account&lt;/a&gt;. Once you have an AWS account, you can go ahead and begin creating your EC2 Instance. &lt;/p&gt;

&lt;p&gt;First, when you are logged into your AWS account, you go to EC2 instances view, this can be done by using the search bar to navigate to EC2 instances by clicking on EC2 and then navigating to the Instances view&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--asYFMQ2J--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mmw17w9x99iltgsi89ur.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--asYFMQ2J--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mmw17w9x99iltgsi89ur.png" alt="Image description" width="800" height="445"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Where you can create (launch) and manage your EC2 Instances. To begin creating your new Instance, click on the Launch Instance button.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--CgBvrW2v--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yq3mmejd40k9t1r53me2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--CgBvrW2v--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yq3mmejd40k9t1r53me2.png" alt="Image description" width="800" height="380"&gt;&lt;/a&gt;&lt;br&gt;
This should take you to a view with a form that allows you configure your EC2 Instance. I will walk you through basic configuration in &lt;strong&gt;6&lt;/strong&gt; steps: &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1:&lt;/strong&gt; Choose a name for your EC2 Instance. You can choose whatever name you want for your Instance. E.g. myinstance-1&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--mbsXHh26--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/afxxuz93eea4l0f46p9r.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--mbsXHh26--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/afxxuz93eea4l0f46p9r.png" alt="Image description" width="800" height="558"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2:&lt;/strong&gt; Select the Amazon Machine Image (operating system) you will prefer to use to launch your Instance.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ImJ6M5g5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tzma7z8d06mlrdk6yrv1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ImJ6M5g5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tzma7z8d06mlrdk6yrv1.png" alt="Image description" width="800" height="454"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ORFKLuGe--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4v0xq20g78jwpwec47x5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ORFKLuGe--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4v0xq20g78jwpwec47x5.png" alt="Image description" width="582" height="478"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As a beginner or a non-enterprise user, it is advisable to select an Amazon Machine Image (AMI) that is free tier eligible to keep cost at a minimum.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3:&lt;/strong&gt; Select the Instance type that’s most suitable for your use case. Amazon EC2 provides a wide array of Instance types that suit different use cases. These Instance types have various combinations of storage, CPU, memory and networking capacity. To learn more about how different Instance types can meet your computing needs, check out &lt;a href="https://aws.amazon.com/ec2/instance-types/"&gt;AWS EC2 Instance types&lt;/a&gt;. Again, it is advisable to select an Instance type that is low cost or free tier eligible if you are not an enterprise user.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--jNtAhO6R--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7wthrbi6y9tqyfmle2lw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--jNtAhO6R--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7wthrbi6y9tqyfmle2lw.png" alt="Image description" width="795" height="707"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 4:&lt;/strong&gt; Create a key pair or select one if you have previously created one. Your key pair consists of a public key and private key. They serve as your security credentials that allow you access to your EC2 Instance. Go to &lt;a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-key-pairs.html"&gt;Amazon EC2 key pairs&lt;/a&gt; to learn more about key pairs.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--4draHf4p--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/37lv2sakoebkbchp0tim.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--4draHf4p--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/37lv2sakoebkbchp0tim.png" alt="Image description" width="800" height="257"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Gl8iBJcA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5uavdwcr6m9icfvbhyv5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Gl8iBJcA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5uavdwcr6m9icfvbhyv5.png" alt="Image description" width="800" height="556"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 5:&lt;/strong&gt; Configure your network settings. The default network settings are fine the way they are but you can edit them to configure them as you’d want especially to select a particular availability zone.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--x6HerRS2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uzsm4j91nnwxryisi73s.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--x6HerRS2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uzsm4j91nnwxryisi73s.png" alt="Image description" width="800" height="622"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ADV_9pq7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/u01d042ipra45ho5g1s1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ADV_9pq7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/u01d042ipra45ho5g1s1.png" alt="Image description" width="800" height="596"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Availability zones are isolated and independent data centers spread across a region that offers protection from failures or catastrophic events in data centers at other zones. Although the default no preference setting (which is preferred setting) allows access to any availability zone but you can select a specific availability zone of your choice.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 5.5:&lt;/strong&gt; The second half of the network settings require you to select or create a security group. A security group basically acts as a virtual firewall that controls inbound and outbound traffic to your Instance and by extension your website or web app. You can instantly create and configure a security group from the edit network settings view.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--j0mmqvC3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fxl8l54efqyd8knef8xc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--j0mmqvC3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fxl8l54efqyd8knef8xc.png" alt="Image description" width="796" height="705"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;First, you choose a security group name, note that you will not be able edit this name once you have created the security group and your security group name cannot start with &lt;code&gt;sg-&lt;/code&gt;. A security group name must also be unique for the &lt;a href="https://docs.aws.amazon.com/vpc/latest/userguide/what-is-amazon-vpc.html"&gt;VPC&lt;/a&gt;. After entering your security group name, you can enter a brief description of your security group (between you and me that could be anything). Now it gets interesting, you will configure your Inbound security group rules. The default security group rule listens on port 22 which allows SSH access for Linux Instances or RDP access for windows Instances from command line on your computer. &lt;/p&gt;

&lt;p&gt;I will now walk you through how to create a new Inbound security group rule if your instance is going to function as a web server. First, you click on the “Add security group rule” located after the default security group rule then you get another security group rule that looks like the second image below. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--uU0K9vht--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b16x72n1q9ml9gsb779c.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--uU0K9vht--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b16x72n1q9ml9gsb779c.png" alt="Image description" width="800" height="446"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--5rV8dlFs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v3o1w49wx96cyn6qvp18.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--5rV8dlFs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v3o1w49wx96cyn6qvp18.png" alt="Image description" width="800" height="670"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We are going to be creating two new security group rules that allow all IP addresses access your instance via HTTP and HTTPS so your users can browse content on your web server.&lt;br&gt;
For the first security group rule, select &lt;code&gt;HTTP&lt;/code&gt; as &lt;code&gt;Type&lt;/code&gt; which refers to network traffic type, this will automatically set &lt;code&gt;Protocol&lt;/code&gt; to &lt;code&gt;TCP&lt;/code&gt; and &lt;code&gt;Port range&lt;/code&gt; to &lt;code&gt;80&lt;/code&gt; as that is the port number assigned to HTTP server. You will then select &lt;code&gt;Source type&lt;/code&gt; which refers to where your instance can be accessed from. You can either allow your instance to be accessed from anywhere or only from predefined known sources i.e. setting &lt;code&gt;Source type&lt;/code&gt; to &lt;code&gt;My IP&lt;/code&gt; which specifies your current IP address as the only source that can access your Instance or to &lt;code&gt;Custom&lt;/code&gt; where you can specify the IP Address or security group that will be allowed access to your Instance. So for the purpose of this post, you will set our &lt;code&gt;Source type&lt;/code&gt; to &lt;code&gt;Anywhere&lt;/code&gt; which will set the &lt;code&gt;Source&lt;/code&gt; to &lt;code&gt;0.0.0.0/0&lt;/code&gt; this allows your Instance to be accessed from anywhere in the world via HTTP.&lt;/p&gt;

&lt;p&gt;Configuring the second security group rule should be straightforward, you will set the &lt;code&gt;Type&lt;/code&gt; to &lt;code&gt;HTTPS&lt;/code&gt;, this will also automatically set &lt;code&gt;Protocol&lt;/code&gt; to &lt;code&gt;TCP&lt;/code&gt; and &lt;code&gt;Port range&lt;/code&gt; to ‘443’ this is because similarly, ‘443’ is the port number assigned to HTTPS which is a secure version of HTTP. Just like the HTTP rule, we will also set &lt;code&gt;Source type&lt;/code&gt; to &lt;code&gt;Anywhere&lt;/code&gt;. When you are done, your Inbound security group rules should look something like this;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--qenpFGx_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4owc0u9kwf3h5ymewuwp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--qenpFGx_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4owc0u9kwf3h5ymewuwp.png" alt="Image description" width="772" height="728"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can learn more about security groups by checking out &lt;a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-security-groups.html"&gt;Security groups&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 6:&lt;/strong&gt; Configure storage. When it comes to configuring storage options for your EC2 Instance, it is okay to go with the default option which is quite sufficient if your software does not require enormous storage space. AWS offers free tier eligible customers up to 30GB of storage space (EBS General Purpose (SSD) or Magnetic Storage)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ydyDqkws--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ecux3n0af7pxiepf7d2p.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ydyDqkws--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ecux3n0af7pxiepf7d2p.png" alt="Image description" width="800" height="334"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And that seems like a sufficient amount of storage space so I will stick with the default storage options.&lt;br&gt;
At this point, we do not need to change any of the advanced details so we will leave them and then proceed to launch our EC2 instance by clicking the orange button highlighted in the image below&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--USIr4EcH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/al65owlj4dlxi37y5kd1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--USIr4EcH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/al65owlj4dlxi37y5kd1.png" alt="Image description" width="800" height="494"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once you click the button, the Instance launch process will be initiated and in a few seconds your EC2 Instance will be created. This will then take you to a view that shows that the launch of your instance is successful.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--WlYBrc_u--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d3cq32jpeqs90er672v9.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--WlYBrc_u--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d3cq32jpeqs90er672v9.gif" alt="Image description" width="600" height="267"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Then click the ‘View all Instances’ button at the end of the page to view and manage all the Instances you have created.&lt;/p&gt;

&lt;p&gt;Ensure that your Instance state shows as running and that it passes 2/2 status checks, if this isn’t the case, you may need to refresh this web page for the changes to reflect.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--SefK6-Dk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j0g52erng5ihuxwv2cd7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--SefK6-Dk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j0g52erng5ihuxwv2cd7.png" alt="Image description" width="800" height="195"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s---29a-JI1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2yy0vqwjmsc9p30evm12.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s---29a-JI1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2yy0vqwjmsc9p30evm12.png" alt="Image description" width="800" height="221"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;At last, your AWS EC2 Instance is up and running, you can now proceed to deploy your software to your virtual server and put your website or web app on the streets of the internet. In another post, I will talk about how to deploy your code to your EC2 Instance, till then stay tuned! Cheers guys.&lt;/p&gt;

</description>
      <category>aws</category>
      <category>cloudcomputing</category>
      <category>devops</category>
      <category>backenddevelopment</category>
    </item>
  </channel>
</rss>
