<?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>Forem: Onifade Julius</title>
    <description>The latest articles on Forem by Onifade Julius (@onifade_julius_aad5edb783).</description>
    <link>https://forem.com/onifade_julius_aad5edb783</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%2F2004652%2F28370f3e-e7d0-4ce0-ad91-c5f200e2199c.jpg</url>
      <title>Forem: Onifade Julius</title>
      <link>https://forem.com/onifade_julius_aad5edb783</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/onifade_julius_aad5edb783"/>
    <language>en</language>
    <item>
      <title>Setting Up Passwordless Authentication on Servers Using Public Keys and Passwords</title>
      <dc:creator>Onifade Julius</dc:creator>
      <pubDate>Wed, 25 Sep 2024 08:04:29 +0000</pubDate>
      <link>https://forem.com/onifade_julius_aad5edb783/setting-up-passwordless-authentication-on-servers-using-public-keys-and-passwords-1h4c</link>
      <guid>https://forem.com/onifade_julius_aad5edb783/setting-up-passwordless-authentication-on-servers-using-public-keys-and-passwords-1h4c</guid>
      <description>&lt;p&gt;Passwordless authentication is a fast way of connecting to remote servers in a secure and fast manner. It helps solve the issue of forgotten password or password being compromised. Passwordless authentication can be done via ssh keypairs or configured passwords. &lt;/p&gt;

&lt;p&gt;This guide shows the step by step process of how I set it up using public key and password automation &lt;/p&gt;

&lt;h2&gt;
  
  
  1. Setting Up Passwordless Authentication Using Public Keys
&lt;/h2&gt;

&lt;p&gt;Password Authentication relies on pair of keys both public and private&amp;gt; . The &lt;strong&gt;public key&lt;/strong&gt; is stored on the server, while the &lt;strong&gt;private key&lt;/strong&gt; remains on the client machine. The process involves matching the private key to the public key, allowing access without the need for a password.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: Generate SSH Key Pair
&lt;/h3&gt;

&lt;p&gt;Generate an SSH key pair on the  from which you’ll be connecting to the server.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ssh-keygen &lt;span class="nt"&gt;-t&lt;/span&gt; rsa &lt;span class="nt"&gt;-b&lt;/span&gt; 4096
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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%2F722gdp5r0t1bo54i01hl.jpeg" 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%2F722gdp5r0t1bo54i01hl.jpeg" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You will be asked to input a file location and passphrase. Press &lt;code&gt;Enter&lt;/code&gt; to accept the default location and to also leave the passphrase empty&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 2: Give the Keypair File read and write command
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;chmod &lt;/span&gt;600 &amp;lt;PATH to pem file&amp;gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This changes the permission of the pem file to read and write&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 3: Copy Public key to Remote Machine
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ssh-copy-id &lt;span class="nt"&gt;-f&lt;/span&gt; &lt;span class="s2"&gt;"-o IdentityFile &amp;lt;PATH TO PEM FILE&amp;gt;"&lt;/span&gt; ubuntu@&amp;lt;INSTANCE-PUBLIC-IP&amp;gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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%2F2juk5n27oz87oq5wos9t.jpeg" 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%2F2juk5n27oz87oq5wos9t.jpeg" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;ssh-copy-id: This is the command used to copy your public key to a remote machine.&lt;br&gt;
-f: This flag forces the copying of keys, which can be useful if you have keys already set up and want to overwrite them.&lt;br&gt;
"-o IdentityFile ": This option specifies the identity file (private key) to use for the connection. The -o flag passes this option to the underlying ssh command.&lt;br&gt;
ubuntu@: This is the username (ubuntu) and the IP address of the remote server you want to access. &lt;/p&gt;

&lt;p&gt;Then you would be asked to input this command.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ssh &lt;span class="nt"&gt;-o&lt;/span&gt;  &lt;span class="s1"&gt;'IdentityFile &amp;lt;PATH TO PEM FILE&amp;gt;'&lt;/span&gt; &lt;span class="s1"&gt;'ubuntu@&amp;lt;INSTANCE-PUBLIC-IP&amp;gt;'&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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%2Fh4ekq0ll82jyq92tbtx7.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%2Fh4ekq0ll82jyq92tbtx7.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You have not successfully access the remote machine. To see if it would work when you try it again you can&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;exit&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 3: Test Passwordless Authentication
&lt;/h3&gt;

&lt;p&gt;Whenever you want to log in to the machine subsequent time use,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ssh username@server_ip_address
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If everything is configured correctly, you should be able to log in without being prompted for a password.&lt;/p&gt;




&lt;h2&gt;
  
  
  2. Setting Up Passwordless Authentication Using Password
&lt;/h2&gt;

&lt;p&gt;While SSH key authentication is more secure, there are cases where password-based automation is required, such as in legacy systems or automation scripts. &lt;/p&gt;

&lt;p&gt;You can manually connect or log into your instance or server.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: Access the sshd_config file
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;vim /etc/ssh/sshd_config.d/60-cloudimg-settings.conf
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 2: Update Password Authentication
&lt;/h3&gt;

&lt;p&gt;Change the password authentication to &lt;strong&gt;YES&lt;/strong&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%2Fo4dpg5p468bjqixr4lrt.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%2Fo4dpg5p468bjqixr4lrt.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 3: Restart SSH
&lt;/h3&gt;

&lt;p&gt;You restart the ssh to make the new changes take effect by running the command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl restart ssh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 4: Set Password
&lt;/h3&gt;

&lt;p&gt;You set password that you would be asked subsequent when you want to log into that machine running the command.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;passwd ubuntu
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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%2F65scvys9picdyz2g83y1.jpeg" 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%2F65scvys9picdyz2g83y1.jpeg" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's confirm that the password is set.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;exit&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ssh-copy-id ubuntu@&amp;lt;INSTANCE-PUBLIC-IP&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You would then be asked to input the set password you created above, after then you would run the command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ssh &lt;span class="s1"&gt;'username@server_ip_address'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This method is generally not recommended for production environments due to security risks of storing plaintext passwords, but it can be useful for automated tasks in controlled environments.&lt;/p&gt;

&lt;p&gt;NOTE&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Use SSH Keys&lt;/strong&gt;: Public key authentication is more secure and should be preferred over password-based methods.
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  5. Conclusion
&lt;/h2&gt;

&lt;p&gt;Passwordless authentication is a key feature in securing and ensuring fast server access. Using public keys is the recommended method for passwordless SSH logins due to its enhanced security and ease of use.&lt;br&gt;
By following the steps in this guide, you can set up secure passwordless authentication on your servers and improve your overall workflow efficiency.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Deploying a Node.js Application on AWS EC2: A Step-by-Step Guide</title>
      <dc:creator>Onifade Julius</dc:creator>
      <pubDate>Thu, 12 Sep 2024 23:03:42 +0000</pubDate>
      <link>https://forem.com/onifade_julius_aad5edb783/deploying-a-nodejs-application-on-aws-ec2-a-step-by-step-guide-42c5</link>
      <guid>https://forem.com/onifade_julius_aad5edb783/deploying-a-nodejs-application-on-aws-ec2-a-step-by-step-guide-42c5</guid>
      <description>&lt;p&gt;AWS EC2 (Elastic Compute Cloud) provides a scalable and secure cloud platform to deploy and run applications, including Node.js apps. In this guide, I’ll walk you through the entire process of deploying a Node.js application on an AWS EC2 instance. By the end, you'll have your application running live on an EC2 instance, accessible via an IP address or domain.&lt;/p&gt;




&lt;h2&gt;
  
  
  1. Testing the Project Locally
&lt;/h2&gt;

&lt;p&gt;Before deploying to AWS, it's always a good idea to test the project locally to ensure everything works as expected. &lt;/p&gt;

&lt;h3&gt;
  
  
  Steps to Test Locally:
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Clone the Repository:&lt;/strong&gt;
First, clone the project repository to your local machine:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   git clone git@github.com:Julius36/Hosting-NodeJs-app-on-EC2.git
   &lt;span class="nb"&gt;cd &lt;/span&gt;Hosting-NodeJs-app-on-EC2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Set Up Environment Variables:&lt;/strong&gt;
Create a &lt;code&gt;.env&lt;/code&gt; file in the root directory of the project and define the following environment variables:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   &lt;span class="nv"&gt;DOMAIN&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;
   &lt;span class="nv"&gt;PORT&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;3000
   &lt;span class="nv"&gt;STATIC_DIR&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"./client"&lt;/span&gt;
   &lt;span class="nv"&gt;PUBLISHABLE_KEY&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;""&lt;/span&gt;
   &lt;span class="nv"&gt;SECRET_KEY&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;""&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Install Dependencies and Start the Application:&lt;/strong&gt;
Install all project dependencies and start the Node.js application:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   npm &lt;span class="nb"&gt;install
   &lt;/span&gt;npm run start
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

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

&lt;p&gt;At this point, the application should be up and running locally. Access it by navigating to &lt;code&gt;http://localhost:3000&lt;/code&gt; in your browser.&lt;/p&gt;

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

&lt;h2&gt;
  
  
  2. Setting Up an AWS EC2 Instance
&lt;/h2&gt;

&lt;p&gt;With the local testing complete, let’s move to the cloud and set up an EC2 instance on AWS to host the Node.js application.&lt;/p&gt;

&lt;h3&gt;
  
  
  Steps to Create an EC2 Instance:
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Create an IAM User&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Go to the &lt;a href="https://aws.amazon.com/console/" rel="noopener noreferrer"&gt;AWS Console&lt;/a&gt;, and create a new IAM user with &lt;strong&gt;Administrator Access&lt;/strong&gt;. &lt;/li&gt;
&lt;li&gt;Set the access type to &lt;strong&gt;Password&lt;/strong&gt; for easier management of your credentials.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Launch an EC2 Instance:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;In the AWS Console, navigate to &lt;strong&gt;EC2 Dashboard&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Click on &lt;strong&gt;Launch Instance&lt;/strong&gt; and follow these steps:

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Select an OS Image&lt;/strong&gt;: Choose &lt;strong&gt;Ubuntu Server&lt;/strong&gt; as your operating system (preferred version: Ubuntu 20.04 LTS).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Choose Instance Type&lt;/strong&gt;: Select the instance type as &lt;code&gt;t2.micro&lt;/code&gt; (free tier eligible).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Create a Key Pair&lt;/strong&gt;: Create a new key pair for SSH access and download the &lt;code&gt;.pem&lt;/code&gt; file securely to your local machine.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Configure Security Groups&lt;/strong&gt;: Make sure to allow &lt;strong&gt;HTTP&lt;/strong&gt; and &lt;strong&gt;SSH&lt;/strong&gt; traffic. Add an inbound rule for port &lt;code&gt;3000&lt;/code&gt; (or any other port your Node.js app uses) to allow traffic.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

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

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Connect to Your EC2 Instance&lt;/strong&gt;:
Once your EC2 instance is running, connect to it via SSH using the key pair you downloaded:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   ssh &lt;span class="nt"&gt;-i&lt;/span&gt; /path/to/instance.pem ubuntu@&amp;lt;EC2_PUBLIC_IP&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Replace &lt;code&gt;&amp;lt;EC2_PUBLIC_IP&amp;gt;&lt;/code&gt; with your instance’s public IP address.&lt;/p&gt;

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

&lt;h2&gt;
  
  
  3. Configuring Ubuntu on the EC2 Instance
&lt;/h2&gt;

&lt;p&gt;Now that you are connected to the EC2 instance, you need to install the required dependencies and configure the environment.&lt;/p&gt;

&lt;h3&gt;
  
  
  Steps to Configure Ubuntu:
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Update Packages and Dependencies&lt;/strong&gt;:
Start by updating the package list to ensure everything is up-to-date:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   &lt;span class="nb"&gt;sudo &lt;/span&gt;apt update
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Install Git&lt;/strong&gt;:
Install Git on the EC2 instance:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   &lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;git
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Install Node.js and npm&lt;/strong&gt;:
Follow &lt;a href="https://www.digitalocean.com/community/tutorials/how-to-install-node-js-on-ubuntu-20-04" rel="noopener noreferrer"&gt;this guide by DigitalOcean&lt;/a&gt; to install the latest stable version of Node.js and npm:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   &lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;nodejs
   &lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;npm
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  4. Deploying the Node.js Application on AWS EC2
&lt;/h2&gt;

&lt;p&gt;Now that the EC2 instance is configured, you can deploy your Node.js application.&lt;/p&gt;

&lt;h3&gt;
  
  
  Steps to Deploy:
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Clone the Project on the EC2 Instance&lt;/strong&gt;:
Clone the project repository just like you did locally:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   git clone git@github.com:Julius36/Hosting-NodeJs-app-on-EC2.git
   &lt;span class="nb"&gt;cd &lt;/span&gt;Hosting-NodeJs-app-on-EC2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Set Up Environment Variables&lt;/strong&gt;:
Create the &lt;code&gt;.env&lt;/code&gt; file again on the EC2 instance with the following content:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   &lt;span class="nv"&gt;DOMAIN&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;""&lt;/span&gt;
   &lt;span class="nv"&gt;PORT&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;3000
   &lt;span class="nv"&gt;STATIC_DIR&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"./client"&lt;/span&gt;
   &lt;span class="nv"&gt;PUBLISHABLE_KEY&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;""&lt;/span&gt;
   &lt;span class="nv"&gt;SECRET_KEY&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;""&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For the &lt;code&gt;DOMAIN&lt;/code&gt; variable, you can use an Elastic IP Address associated with your EC2 instance (more on Elastic IP below).&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Install Dependencies and Start the Project&lt;/strong&gt;:
Run the following commands to install dependencies and start the project:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   npm &lt;span class="nb"&gt;install
   &lt;/span&gt;npm run start
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Edit Inbound Rules to Allow Traffic&lt;/strong&gt;:
Go back to your EC2 Security Group settings and ensure that inbound traffic is allowed for port &lt;code&gt;3000&lt;/code&gt; (or the port your app uses). This will enable your app to be accessible from the web.&lt;/li&gt;
&lt;/ol&gt;

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

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

&lt;p&gt;Yippie!!! You’ve successfully deployed a Node.js application on an AWS EC2 instance. From setting up the EC2 instance to installing the necessary software and running your app, this guide has covered all the essential steps. You can now access your Node.js app through your EC2’s public IP.&lt;/p&gt;

</description>
      <category>devops</category>
      <category>opensource</category>
      <category>learning</category>
      <category>cloud</category>
    </item>
    <item>
      <title>A Beginner’s Guide to Using Cloud-Nuke: Using Cloud-Nuke for Safe and Controlled Cleanup</title>
      <dc:creator>Onifade Julius</dc:creator>
      <pubDate>Sat, 31 Aug 2024 17:56:13 +0000</pubDate>
      <link>https://forem.com/onifade_julius_aad5edb783/a-beginners-guide-to-using-cloud-nuke-using-cloud-nuke-for-safe-and-controlled-cleanup-3c04</link>
      <guid>https://forem.com/onifade_julius_aad5edb783/a-beginners-guide-to-using-cloud-nuke-using-cloud-nuke-for-safe-and-controlled-cleanup-3c04</guid>
      <description>&lt;p&gt;AWS cloud services is exciting to use until your bill starts pilling up because you did not stop one service from running. This was my reality a few days ago. The reason why we use cloud providers is to help us reduce cost and also make use of services effectively, but this might not be the case if not properly managed.&lt;/p&gt;

&lt;p&gt;In this article, I’ll will be talking about a powerful tool for cleaning up your AWS account quickly and efficiently. This tool is a fast way of doing things instead of manually managing resources or doing it through Terraform, this tool is a great alternative that can be easily run from your console.&lt;/p&gt;

&lt;h2&gt;
  
  
  Introducing Cloud-Nuke
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://github.com/gruntwork-io/cloud-nuke" rel="noopener noreferrer"&gt;Cloud-Nuke&lt;/a&gt; is an open-source tool available on GitHub. It’s designed to delete all AWS resources within an account or clean up the account, saving you from manual clean-up tasks.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. How to Install Gruntwork’s Cloud-Nuke
&lt;/h3&gt;

&lt;h4&gt;
  
  
  macOS or Linux
&lt;/h4&gt;

&lt;p&gt;For macOS or Linux users, installation is straightforward. Simply run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;brew &lt;span class="nb"&gt;install &lt;/span&gt;cloud-nuke
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Windows
&lt;/h4&gt;

&lt;p&gt;For Windows users, you can install it via Winget with the command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;winget &lt;span class="nb"&gt;install &lt;/span&gt;cloud-nuke
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;p&gt;If installing via Winget doesn’t work, you can manually download and install the Cloud-Nuke via GitHub:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Visit the &lt;a href="https://github.com/gruntwork-io/cloud-nuke/releases" rel="noopener noreferrer"&gt;Cloud-Nuke GitHub releases page&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Download the latest release for Windows (usually a &lt;code&gt;.zip&lt;/code&gt; file).&lt;/li&gt;
&lt;li&gt;Extract the &lt;code&gt;.zip&lt;/code&gt; file to a directory of your choice.&lt;/li&gt;
&lt;li&gt;Add the directory containing &lt;code&gt;cloud-nuke.exe&lt;/code&gt; to your PATH:

&lt;ul&gt;
&lt;li&gt;Open the Start Menu, search for "Environment Variables," and select "Edit the system environment variables."&lt;/li&gt;
&lt;li&gt;In the System Properties window, click on "Environment Variables."&lt;/li&gt;
&lt;li&gt;In the "System variables" section, find and select the &lt;code&gt;Path&lt;/code&gt; variable, then click "Edit."&lt;/li&gt;
&lt;li&gt;Click "New" and paste the path to the directory where &lt;code&gt;cloud-nuke.exe&lt;/code&gt; is located.&lt;/li&gt;
&lt;li&gt;Click "OK" to close all windows.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;To verify the installation, run the command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;cloud-nuke
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;h3&gt;
  
  
  2. Setting Up AWS Credentials
&lt;/h3&gt;

&lt;p&gt;Before using Cloud-Nuke, you need to export your AWS access key, secret key, and region as environment variables. Use the following commands:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;export &lt;/span&gt;&lt;span class="nv"&gt;AWS_ACCESS_KEY&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"&amp;lt;PLACE_YOUR_AWS_ACCESS_KEY&amp;gt;"&lt;/span&gt;
&lt;span class="nb"&gt;export &lt;/span&gt;&lt;span class="nv"&gt;AWS_SECRET_KEY&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"&amp;lt;PLACE_YOUR_AWS_SECRET_KEY&amp;gt;"&lt;/span&gt;
&lt;span class="nb"&gt;export &lt;/span&gt;&lt;span class="nv"&gt;AWS_REGION&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"&amp;lt;PLACE_YOUR_AWS_REGION_NAME&amp;gt;"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;p&gt;You can find these details by navigating to your AWS console:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;On the top right corner under your username, click on &lt;strong&gt;My Security Credentials&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Navigate to &lt;strong&gt;Access keys (access key ID and secret access key)&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;

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

&lt;ul&gt;
&lt;li&gt;Ensure the key status is &lt;strong&gt;ACTIVE&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  3. Deleting All AWS Resources with Cloud-Nuke
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Warning:&lt;/strong&gt; Running Cloud-Nuke will delete all the resources in your AWS account, so proceed with caution as there’s no going back!&lt;/p&gt;

&lt;p&gt;To delete all AWS resources, simply run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;cloud-nuke aws
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;p&gt;This command will display the types and quantities of resources that are about to be deleted. It will then ask for confirmation before proceeding. To confirm, type &lt;code&gt;nuke&lt;/code&gt; and hit enter.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Deleting Resources in a Specific AWS Region
&lt;/h3&gt;

&lt;p&gt;If you want to delete resources in a specific region, you can specify the region using the &lt;code&gt;--region&lt;/code&gt; flag:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;cloud-nuke aws &lt;span class="nt"&gt;--region&lt;/span&gt; us-east-1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;p&gt;This will only affect resources in the &lt;code&gt;us-east-1&lt;/code&gt; region.&lt;/p&gt;

&lt;h3&gt;
  
  
  5. Listing Supported Resource Types
&lt;/h3&gt;

&lt;p&gt;Cloud-Nuke doesn’t support all AWS resources. To list the supported resource types, run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;cloud-nuke aws &lt;span class="nt"&gt;--list-resource-types&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;h3&gt;
  
  
  6. Excluding Resources from Deletion
&lt;/h3&gt;

&lt;p&gt;To exclude specific resources from being deleted, use the &lt;code&gt;--exclude-resource-type&lt;/code&gt; flag:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;cloud-nuke aws &lt;span class="nt"&gt;--exclude-resource-type&lt;/span&gt; s3 &lt;span class="nt"&gt;--exclude-resource-type&lt;/span&gt; ec2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  7. Excluding Resources by Age
&lt;/h3&gt;

&lt;p&gt;If you only want to delete resources that were created before a certain period, use the &lt;code&gt;--older-than&lt;/code&gt; flag:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;cloud-nuke aws &lt;span class="nt"&gt;--older-than&lt;/span&gt; 24h
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  8. Targeting Specific Resource Types
&lt;/h3&gt;

&lt;p&gt;To target specific resource types, use the &lt;code&gt;--resource-type&lt;/code&gt; flag:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;cloud-nuke aws &lt;span class="nt"&gt;--resource-type&lt;/span&gt; ec2 &lt;span class="nt"&gt;--resource-type&lt;/span&gt; ami
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will focus the deletion process only on &lt;code&gt;ec2&lt;/code&gt; and &lt;code&gt;ami&lt;/code&gt; resources. You can also use this flag to speed up the search process.&lt;/p&gt;

&lt;p&gt;To inspect specific resource types without deleting them, run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;cloud-nuke inspect-aws &lt;span class="nt"&gt;--resource-type&lt;/span&gt; ec2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  9. Protecting Resources with the &lt;code&gt;cloud-nuke-after&lt;/code&gt; Tag
&lt;/h3&gt;

&lt;p&gt;To protect resources from accidental or premature deletion, you can tag them with &lt;code&gt;cloud-nuke-after&lt;/code&gt; and specify a future date in the format &lt;code&gt;2024-07-09T00:00:00Z&lt;/code&gt;. This ensures that the resources remain intact until their designated expiration date.&lt;/p&gt;




&lt;p&gt;By using Cloud-Nuke, you don’t only take control of your AWS resources you also prevent yourself from unexpected bills. NOTE, always use this tool with caution, especially in production environments, as it can have significant consequences on your infrastructure. Way to Cloud!&lt;/p&gt;

</description>
      <category>devops</category>
      <category>aws</category>
      <category>cloud</category>
      <category>opensource</category>
    </item>
  </channel>
</rss>
