<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Khalil Faqiri on Medium]]></title>
        <description><![CDATA[Stories by Khalil Faqiri on Medium]]></description>
        <link>https://medium.com/@faqirik9?source=rss-98bc3b899ffe------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*a_Yxj4jkvpEDOClI4p0pSQ.jpeg</url>
            <title>Stories by Khalil Faqiri on Medium</title>
            <link>https://medium.com/@faqirik9?source=rss-98bc3b899ffe------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 09:34:30 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@faqirik9/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Extracting File Information from any Directory using Python — Beginner’s Friendly Guide]]></title>
            <link>https://medium.com/@faqirik9/extracting-file-information-from-any-directory-using-python-beginners-friendly-guide-d0acb38a6429?source=rss-98bc3b899ffe------2</link>
            <guid isPermaLink="false">https://medium.com/p/d0acb38a6429</guid>
            <category><![CDATA[beginners-guide]]></category>
            <category><![CDATA[extracting-data]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[scripting]]></category>
            <dc:creator><![CDATA[Khalil Faqiri]]></dc:creator>
            <pubDate>Sun, 15 Oct 2023 23:34:00 GMT</pubDate>
            <atom:updated>2023-10-15T23:34:00.325Z</atom:updated>
            <content:encoded><![CDATA[<h3>Extracting File Information from any Directory using Python — Beginner’s Friendly Guide</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mYNPWw9bYaOTyi-tcVC8NQ.png" /></figure><p>In this guide, we’ll walk through a Python program that extracts and catalogs information, such as the name and size of files in different directories, offering insights and a clearer picture of our data storage.</p><p>Python, with its rich library set, provides us with tools that make interacting with the filesystem not only possible but also efficient.</p><p>Note: — Ensure that you have a Python environment set up. This guide will not go over setting up your environment, you can check Python’s official website, and it will guide you through setting up your environment.</p><h4>Let’s dive right into the Code:</h4><p>To start off, we will need to import the “os” module, this will enable us to interact with the operating system and allow us to traverse directories and fetch file information.</p><pre>import os </pre><h4>Creating the function:</h4><p>Next, we will create a function that optionally takes a directory path. If no path is provided, it defaults to the current working directory.</p><pre>def get_file_info(dir_path=&#39;.&#39;):</pre><p>The “get_file_info” is the name of the function, and “dir_path” is the perimeter being passed in, which defaults to the current working directory unless a directory is provided by the user as input.</p><h4>Traversing Directories:</h4><p>With <em>“os.walk()”, </em>we can seamlessly loop through directories and subdirectories, extracting information as we go. It is a function available in Python’s ‘os’ module and generates file names by walking either top-down or bottom-up through the directory tree rooted at a specified directory.</p><pre>for foldername, subfolders, filenames in os.walk(dir_path):<br>  for filename in filenames: </pre><p>The outer loop provides the trio of information (directory path, subdirectories, and filenames) for every directory it explores.</p><p>The inner loop then iterates over every filename provided by the outer loop, allowing us to process each file individually.</p><p>This nested loop setup ensures we reach every file in every subdirectory, granting us the ability to extract and compile data on each file, such as its name, path, and size, which is precisely what we aimed to achieve with our project.</p><h4>Fetching and Storing File Information:</h4><p>For every file encountered, we will:</p><ul><li>Determine its full path</li><li>Retrieve its size</li><li>Append its details to our results list</li></ul><pre>filepath = os.path.join(foldername, filename)<br>file_size = os.path.getsize(filepath) <br>file_info_list.append({<br>    &#39;name&#39;: filename,<br>    &#39;path&#39;: filepath, <br>    &#39;size&#39;: file_size<br>})</pre><h4>Error Handling:</h4><p>While our script will process the files and run fun without this step, it is important to take into consideration that unforeseen issues might arise. Wrapping our logic within a try-except block ensures our program doesn’t crash and instead provides informative error messages.</p><pre>try:<br>    #file processing logic<br>except Exception as e:<br>    print(&quot;An error occured: {str(e)}&quot;)</pre><h4>Executing the Script</h4><p>Once our function is set up, we can prompt the user for a directory path and pass it to our function. If the user simply presses “Enter”, the script will default to the current working directory.</p><pre>if __name__ == &quot;__main__&quot;:<br>    user_path = input(&quot;Enter directory path (press &#39;Enter&#39; for current directory): &quot;)<br>    info = get_file_info(user_path) if user_path else get_file_info()<br>    print(info)</pre><h4>Putting Everything Together:</h4><p>The final version of the code should look like this:</p><pre>#importing the os module<br>import os<br><br>#creating the function<br>def get_file_info(dir_path=&#39;.&#39;):<br><br>    #file infor list<br>    file_info_list = []<br><br>    #try-except block to enable error handeling<br>    try:<br>        for foldername, subfolders, filenames in os.walk(dir_path):<br>            for filename in filenames:<br>                filepath = os.path.join(foldername, filename)<br>                file_size = os.path.getsize(filepath)<br>                file_info_list.append({<br>                    &#39;name&#39;: filename,<br>                    &#39;path&#39;: filepath,<br>                    &#39;size&#39;: file_size<br>                })<br>    except Exception as e:<br>        print(f&quot;An error occurred: {str(e)}&quot;)<br>    <br>    return file_info_list<br><br>if __name__ == &quot;__main__&quot;:<br>    #asking the user to enter a path, and storing it in a variable<br>    user_path = input(&quot;Please enter the directory path (press enter to use the current working directory): &quot;)<br>    <br>    #getting path from input or if no input, proceed with current directory. <br>    info = get_file_info(user_path) if user_path else get_file_info()<br>    <br>    #printing the output. <br>    print(info)</pre><p>Python offers a powerful and intuitive approach to file management, making tasks like extracting file information remarkably simple. With our script, not only can we gain insights into our data storage patterns, but we can also potentially build upon this foundation for more complex file operations such as data backup, cleanup, or analytics.</p><h4>Optional — Organizing Data in a Presentable Manner:</h4><p>Without organizing the data, we will just get a bunch of jibberish printed on the terminal which will be very hard to read. If you want to be able to read it, it must be in a readable manner. Let’s get the code to make our data organized and presentable.</p><p>When it comes to organizing and making data presentable there are lots of ways we can achieve this and get creative as much as we want to. For the efficiency of the task, we will go with a simple list table classic style using a simple print statement.</p><h4>Printing Header</h4><p>This code below will print on the screen a table-style header, and the data will be shown in a similar structure below the header.</p><pre>print(f&quot;{&#39;Name&#39;:&lt;20} {&#39;Size (bytes)&#39;:&lt;15} {&#39;Path&#39;:&lt;30}&quot;)<br>print(&#39;-&#39; * 65)  # Adding a separator line</pre><p><strong><em>f-string</em></strong> formatting — An f-string (formatted string literal) allows embedding expressions inside string literals. Here we used it to create aligned headers.</p><p><strong><em>{‘Name’:&lt;20}: &lt;20</em></strong><em> — </em>allocates 20 character-width spaces for “Name”, aligning it to the left and similarly to others such as size and path.</p><p><strong>print(‘-’ * 65) </strong>— Prints a separator line made of 65 hyphen characters, adding a visual division between the headers and the data.</p><h4>Data Iteration and Printing</h4><pre>for file_info in data:<br>    print(f&quot;{file_info[&#39;name&#39;]:&lt;20} {file_info[&#39;size&#39;]:&lt;15} {file_info[&#39;path&#39;]:&lt;30}&quot;)</pre><p>Here we are using a for loop that iterates through each dictionary (file_info) in the data list.<br> <br>For each iteration (each file’s info):<br>file_info[‘name’] — Extracts the filename.<br>file_info[‘size’] — Extracts the file size.<br>file_info[‘path’] — Extracts the file path.</p><h4>Results:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8gZ9gF-XmVsHS14a7dmIkg.png" /></figure><p>Thank you so much for reading my article. Your support means the world to me! 🙏</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d0acb38a6429" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Create a Scalable AWS VPC with Auto Scaling & Load Balancer: Hands-On Learning]]></title>
            <link>https://aws.plainenglish.io/create-a-scalable-aws-vpc-with-auto-scaling-load-balancer-hands-on-learning-ce3abe9916fa?source=rss-98bc3b899ffe------2</link>
            <guid isPermaLink="false">https://medium.com/p/ce3abe9916fa</guid>
            <category><![CDATA[hands-on-tutorials]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[vpc]]></category>
            <category><![CDATA[autoscaling]]></category>
            <category><![CDATA[load-balancing]]></category>
            <dc:creator><![CDATA[Khalil Faqiri]]></dc:creator>
            <pubDate>Wed, 20 Sep 2023 18:56:27 GMT</pubDate>
            <atom:updated>2023-10-13T00:57:50.597Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qJE-XC328Cm2aDX7dAEdLQ.png" /><figcaption>Level Up Bank — VPC Diagram</figcaption></figure><p>This guide covers the following topics:</p><p><strong>AWS VPC</strong><br> -<em>Public Subnets<br> -Internet Gateway<br> -Route Table</em></p><p><strong>AWS EC2</strong><br> -<em>Autoscaling Group<br> -Load Balancer<br> -Target Group<br> -Launch Template</em></p><p>In the context of Level Up Bank’s progressive migration towards cloud infrastructure, we’re ready to explore a crucial step: setting up a Virtual Private Cloud (VPC) with three different subnets spread across separate Availability Zones (AZs). This guide will showcase how to create a VPC with multiple subnets spread across different availability zones and run a web server on an EC2 instance with auto-scaling and load-balancing capabilities.</p><h4>Creating the VPC:</h4><p>Let’s start off by laying the foundation by creating the VPC.</p><p>To do this, navigate to the AWS console and search for VPC. <br>Click on “Create VPC” and provide a name for the VPC. In this case, it will be “levelupbank-VPC.” <br>Set the CIDR block to 10.10.0.0/16, per Level Up Bank’s requirement. Leave other options as default, and create the VPC.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EgALvIHihMQ6m0pcZjtc-Q.png" /><figcaption>Creating VPC — AWS</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/873/1*HtU6LaHMiLa26dhoSwXTyw.png" /><figcaption>VPC Setup Settings</figcaption></figure><h4>Establishing Subnets:</h4><p>The next step is to establish the Subnets. In the VPC dashboard, select “Subnets” from the left-hand side menu.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pTgl4_xx2iV30ugnnmORZA.png" /><figcaption>Create Subnet</figcaption></figure><p>Click on “Create subnet”<br>Name the subnet. In this case, it will be — “lub-subnet-1” for the first one.<br>Select the VPC — levelupbank-VPC, <br>Select an availability zone<br>Set the CIDR block to 10.10.1.0/24.</p><p>Click on “Add new subnet” to create 2 more subnets.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/841/1*rozRiyNH15fkKj0s7RlvvQ.png" /><figcaption>Creating Subnet 1</figcaption></figure><p>Subnet 2: Repeat the process for the second subnet with CIDR block 10.10.2.0/24, a different name and a different availability zone.</p><p>Subnet 3: Repeat the process for the second subnet with CIDR block 10.10.3.0/24, a different name and a different availability zone.</p><p>Note that each subnet should be in a different availability zone to increase fault tolerance and ensure high availability.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/810/1*ujc2ASyD2SylySiyEBoFZA.png" /><figcaption>Creating Subnets 2 &amp; 3</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6TymU1n1iHXO3wHi24r9ew.png" /><figcaption>Subnet Creation Success</figcaption></figure><p>Once the subnets are created, enable the auto-assign IP option to automatically assign public IPs to the EC2 instances that will be launched automatically with Auto Scaling.</p><p>On the Subnet menu page, select one subnet, click on “Edit subnet settings,” and ensure that “Enable auto-assign public IPv4 address” is enabled. Do this for all 3 subnets.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7YaOszgumm2uFwRoxV_qyQ.png" /><figcaption>Editing subset settings — VPC</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/861/1*v8SgD_QeOaGLIHMGaIopXg.png" /><figcaption>Enabling Auto-assign IPv4 — Subnet Settings</figcaption></figure><h4>Creating an Internet Gateway:</h4><p>After creating &amp; configuring the subnets in the VPC, we can create an Internet Gateway to allow internet connection to our VPC.</p><p>From the VPC left-hand side menu, select Internet Gateway and click on “Create Internet Gateway.” Name the Internet Gateway and click on Create.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BLDrwtBOGPxiVCKKamsfGQ.png" /><figcaption>Create Internet Gateway</figcaption></figure><p>Once created, we need to attach it to our desired VPC, which in this case is Level Up Bank’s VPC. Click on the “Actions” drop-down menu and select “Attach to VPC.” Select the VPC and click on “Attach internet gateway.”</p><figure><img alt="AWS Create internet gateway" src="https://cdn-images-1.medium.com/max/899/1*oOmp862dx0lVjTGLPhKMKA.png" /><figcaption>Creating the Internet Gateway</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tQMLF3EhiOAOQf3uEkOFuQ.png" /><figcaption>Attaching VPC to Internet Gateway</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/876/1*zt49lWcayo6EPNBMPW4n_w.png" /><figcaption>Attaching VPC to Internet Gateway</figcaption></figure><h4>Creating the Route Table:</h4><p>Moving forward to Route Tables. Route tables are like navigation guides for network traffic, showing the best paths between different parts of the virtual network, such as subnets and the internet. They ensure data reaches the correct destinations, making communication efficient and organized within the VPC.</p><p>To create a route table, click on “Route Table” from the VPC left-hand side menu.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iIfPSdCTc_H3DeChldjHlQ.png" /><figcaption>Create Route Table</figcaption></figure><p>Name the route table on the Create Route Table menu, select the VPC, and click “Create route table.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/841/1*CKr_-G9U_7wOsazXBx_8JQ.png" /><figcaption>Creating Route Table — Configurations</figcaption></figure><p>Once the route table has been created, we must do two things. One is to configure it so that it routes the network traffic to our VPC.</p><p>The first thing, on the route table page, click on “Edit routes.” Click on “Add route,” add the destination “0.0.0.0/0”, select the VPC for the “Target,” and click “Save changes.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Vpp1cfxVvUPras2EIV07Tg.png" /><figcaption>Adding Internet Gateway to Route Table</figcaption></figure><p>The second thing, click on Subnet associations and edit Explicit subnet associations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TBHr8l39m230KlxqLMCstw.png" /><figcaption>Route Table Subnet Associations</figcaption></figure><p>Select the three subnets and Save associations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*F7-bRS6ozZgu4xwbr2PN_A.png" /></figure><p>That’s it for VPC Configurations and setting up everything on this end. Now let&#39;s move on to EC2.</p><p>Moving on to EC2 Instance — The auto-scaling group will create the EC2 instances based on a launch template. This launch template will specify our custom AMI tailored for Level Up Bank’s Server, which is an AMI running an Ubuntu image with Apache installed and enabled.</p><h4>Creating a Launch Template:</h4><p>To create a launch template, navigate to the EC2 dashboard and locate “Launch Template” from the left-hand side menu.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*f4weX6XW0gDM5LxzO6omFg.jpeg" /></figure><p>On the launch template page:<br>- Click on “Create launch template.” <br>- Name the template. <br>- Choose the OS image.<br>- Instance Type.<br>- Select a key pair — this will allow us to access it via SSH later.<br>- Network Setting — Security group allowing SSH &amp; HTTP access.<br>- Finally, under the “advanced details” section, write/paste your bash script, and it will execute as soon as the server is launched. <br>- Leave other settings on default and create the launch template</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OWT1m7IqjSzfeqmdGM6csA.png" /><figcaption>Launch Template — Bash Script</figcaption></figure><p>With the launch template ready to be used, we can head to Auto Scaling Groups to start launching instances.</p><h4>Creating Auto Scaling Group:</h4><p>Navigate to EC2 left-hand side menu and select Auto Scaling Groups, click on Create Auto Scaling group.</p><p>Pick a name for the Auto Scaling Group and select the desired launch template, which is the Ubuntu image running the Apache server in this case. Click Next.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sGjuBzkjKIimLNK3gwjK2Q.png" /><figcaption>ASG — Choosing Name &amp; Launch Template</figcaption></figure><p>Select the desired VPC. In this case, it is the levelupbank-VPC. <br>Select the three different availability zones in which we launched the subnets. All of them should be visible under the drop-down menu. Click Next.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1003/1*B4M5T3Uj5k3k2f4xzfmUyA.png" /><figcaption>ASG — Choosing VPC &amp; AZs</figcaption></figure><p>Next, we declare the desired, minimum, and maximum capacity. This determines the number of instances launched. This number can vary depending on project requirements. Input your values and click on Next.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iWBjl609NtpfXLuPPajx1w.png" /><figcaption>ASG — Capacity &amp; Gorup Size</figcaption></figure><p>Leave other settings on default, review everything, and finally, create the Auto Scaling Group.</p><p>From here, we move on to creating a Load Balancer to distribute traffic between instances. But before we get to that, we must quickly create Target Groups.</p><h4>Creating Target Groups</h4><p>On the EC2 dashboard, find and click on Target Groups. Select “Create target group”<br>Select the target type, “Instances” in this case.<br>Name the target group.<br>Select the VPC and ensure that HTTP1 is selected since it is a web server. <br>Click Next.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/897/1*-kZERfPA6kqiqxldJJB4fg.png" /><figcaption>Creating a Target Group — Configuration</figcaption></figure><p>Select the available instances and create the target group.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pxsWoSsVPyigUEj0_q7k0A.png" /></figure><p>Once the target group is successfully created, we move on to creating the Load Balancer.</p><h4>Creating the Load Balancer:</h4><p>On the EC2 dashboard, find and click on Load Balancers. Select “Create load balancer”<br>Select “Application Load Balancer” for the balancer type.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/948/1*aeZuETSQlBvM-qYVhfQMug.png" /><figcaption>Creating Load Balancer — Selecting Balancer Type</figcaption></figure><p>- Name the load balancer<br>- Select “Internet-facing” scheme<br>- Select IPv4 for the IP address type</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1003/1*Y2ec5MK4YLWqQnz5huiy_g.png" /><figcaption>Load Balancer — Basic Config</figcaption></figure><p>- Select the VPC under Network mapping<br>- Select all three subnets <br>- Select Target group under Listeners and routing.<br>- Finally, review &amp; create the load balancer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/992/1*FalXgMYSVUMjWBPM01I3Uw.png" /><figcaption>Load Balancer — Network Mapping</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/869/1*XAxKF-kAC1zWzU03Sfy79g.png" /><figcaption>Load Balancer — Target Group</figcaption></figure><p>Testing Setup:</p><p>It is time to put our setup to the test and see if we can access the webserver. The web server can be accessed using the public IPv4 address of the EC2 instance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OCm1HoAKuUJrH8RyX5Td1A.png" /><figcaption>Level Up Bank’s Servers</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/734/1*JcdYT0OlAkqRAc2HesdlNw.png" /><figcaption>Ec2 Instance IPv4 Addresses</figcaption></figure><p>Voilà! We’ve successfully set up a robust VPC that’s both scalable and secure. While this might seem basic, with AWS’s incredible capabilities, it’s geared up to handle immense workloads. Let’s harness its power!</p><p>Thank you for reading my article! If you found it insightful, follow me for more projects!</p><h3>In Plain English</h3><p><em>Thank you for being a part of our community! Before you go:</em></p><ul><li><em>Be sure to </em><strong><em>clap</em></strong><em> and </em><strong><em>follow</em></strong><em> the writer! 👏</em></li><li><em>You can find even more content at </em><a href="https://plainenglish.io/"><strong><em>PlainEnglish.io</em></strong></a><strong><em> 🚀</em></strong></li><li><em>Sign up for our </em><a href="http://newsletter.plainenglish.io/"><strong><em>free weekly newsletter</em></strong></a><em>. 🗞️</em></li><li><em>Follow us on </em><a href="https://twitter.com/inPlainEngHQ"><strong><em>Twitter</em></strong></a><strong><em>(X</em></strong>), <a href="https://www.linkedin.com/company/inplainenglish/"><strong><em>LinkedIn</em></strong></a>, <a href="https://www.youtube.com/channel/UCtipWUghju290NWcn8jhyAw"><strong><em>YouTube</em></strong></a>, and <a href="https://discord.gg/in-plain-english-709094664682340443"><strong><em>Discord</em></strong></a><strong><em>.</em></strong></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ce3abe9916fa" width="1" height="1" alt=""><hr><p><a href="https://aws.plainenglish.io/create-a-scalable-aws-vpc-with-auto-scaling-load-balancer-hands-on-learning-ce3abe9916fa">Create a Scalable AWS VPC with Auto Scaling &amp; Load Balancer: Hands-On Learning</a> was originally published in <a href="https://aws.plainenglish.io/">AWS in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Migration to Cloud: A Step-by-Step Walkthrough with Level-Up Bank — Part One]]></title>
            <link>https://medium.com/@faqirik9/migration-to-cloud-a-step-by-step-walkthrough-with-level-up-bank-part-one-14f5eaa67df3?source=rss-98bc3b899ffe------2</link>
            <guid isPermaLink="false">https://medium.com/p/14f5eaa67df3</guid>
            <category><![CDATA[ec2]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[cloud]]></category>
            <category><![CDATA[migration]]></category>
            <category><![CDATA[apache]]></category>
            <dc:creator><![CDATA[Khalil Faqiri]]></dc:creator>
            <pubDate>Mon, 28 Aug 2023 05:09:42 GMT</pubDate>
            <atom:updated>2023-08-28T05:09:42.912Z</atom:updated>
            <content:encoded><![CDATA[<h3>Migration to Cloud: A Step-by-Step Walkthrough with Level-Up Bank — Part One</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fKJJ1HDMUl5wDL8cnFfLCQ.png" /></figure><p><strong>Introduction — </strong>In this scenario based guide will dive into setting up a web server on AWS. Leveraging the user-friendly AWS web console, we will launch an EC2 instance and install the Apache web server simultaneously.</p><h4>Scenario:</h4><p>Financial institutions are increasingly turning to the cloud to meet modern demands. Cloud platforms like AWS are becoming a top choice with unmatched scalability, unwavering reliability, and a cost-effective approach. Join me as I walk through Level-Up Bank’s transition to the cloud, highlighting the ease and benefits of using AWS’s EC2 service.</p><p><strong>The Need for Change: </strong>Previously, Level-Up Bank operated its website from a local on-premises Linux server. But as their user base grew and security became a paramount concern, they recognized the pressing need for an upgrade. That’s where AWS’s EC2 service steps in, offering the bank a new horizon of possibilities and enhancements.</p><p><strong>The First Step: </strong>Establishing a Presence on AWS by setting up an EC2 instance:<strong> </strong>We can initiate the EC2 instance using the AWS CLI or the AWS GUI. In part 1, we will use the AWS GUI as it is beginner-friendly and detailed. — Check out part 2 for using CLI guide.</p><p>To Launch an EC2 instance, navigate to the AWS Console home page, select EC2 Services, and click Launch Instance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9gtcF4q6WsatR2gUifgRyQ.png" /><figcaption>Launching an Instance — EC2 Dashboard</figcaption></figure><p>Pick a name for the instance, e.g., “levelupApacheServer’</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*O78tUFLHOTkUzB8J5GSlzg.png" /><figcaption>EC2 Instance Name</figcaption></figure><p><strong>AMI: </strong>Moving on to Application and OS Image type, in our case, we will use Ubuntu AMI, which is favored for its extensive community support and regular, long-term security updates, making it a reliable and well-documented choice for cloud projects.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NUi7B77tUX_w33AB3f3iZw.png" /><figcaption>Choosing AMI — EC2 Instance</figcaption></figure><p><strong>Instance Type: </strong>Next, we choose the “t2.micro” instance type due to its free tier status, though the choice can vary based on server needs. Following this, we select the key pair for the instance to ensure a secure SSH connection.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tPYomiAIGnoCHWR3ekgE8A.png" /><figcaption>Instance Type &amp; Key Pair</figcaption></figure><p><strong>Network/Security Group Settings: </strong>After that, we move on to Network settings and set the required network configuration. Since this is a web server, we must enable HTTP &amp; HTTPS traffic for our instance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-nY4XeJFbkDZLn0gKIVudA.png" /><figcaption>Network/Security Groups — EC2 Instance</figcaption></figure><p><strong>Installing Apache:</strong> To streamline the process, we can input a bash script in the Advanced Details section. This allows the instance to automatically install and enable the Apache server upon launch, eliminating the need for manual command input. Simply scroll to the bottom in the Advanced Details to find a blank box for script entry. Enter the following bash script and click on Launch Instance.</p><pre>#!/bin/bash<br>apt-get update -y<br>apt-get install -y apache2<br>systemctl start apache2<br>systemctl enable apache2</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eSDZC1LW1L0SGTOTWaiekQ.png" /><figcaption>Advanced Details — Bash Script — EC2 Instance</figcaption></figure><p>Upon launching the instance we must wait a few minutes for the instance to be ready and for the Apache server to install and start.</p><p>After waiting a few minutes, we can verify that we can access the server via the IPv4 address of the instance provided on the AWS EC2 instance dashboard.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g4PIewFrzx-Gf0rRxMeefw.png" /><figcaption>Apache Server Webpage — EC2 Instance Ubuntu</figcaption></figure><p><strong>Results: </strong>As you can see, we can successfully access the Apache web server’s default page running on Ubuntu EC2 instance.</p><p>From this point, we can begin transferring Level Up Bank’s website data to the server. Additionally, we can tap into other EC2 services to further enhance and introduce new features in the future. This marks the end of Part 1 of our guide. Thank you for joining us!</p><p>In the upcoming segment, we will explore launching an EC2 instance and simultaneously installing the Apache server using the AWS Command Line Interface (CLI) &amp; much more. Stay Tuned for Part 2!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=14f5eaa67df3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Leveling Up Security: A Linux Guide to Managing Permissions, Ownership, and Automation]]></title>
            <link>https://medium.com/@faqirik9/leveling-up-security-a-linux-guide-to-managing-permissions-ownership-and-automation-9505ad31435?source=rss-98bc3b899ffe------2</link>
            <guid isPermaLink="false">https://medium.com/p/9505ad31435</guid>
            <category><![CDATA[bash-script]]></category>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[linux-tutorial]]></category>
            <category><![CDATA[hands-on-tutorials]]></category>
            <category><![CDATA[linux-security]]></category>
            <dc:creator><![CDATA[Khalil Faqiri]]></dc:creator>
            <pubDate>Mon, 21 Aug 2023 16:44:21 GMT</pubDate>
            <atom:updated>2023-08-21T16:44:21.132Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*74dLWan37hfADPSIoJm5Fw.png" /></figure><h4>Introduction</h4><p>Managing user access and permissions is critical to ensuring organizational security, efficiency, and accountability. Level Up Bank, a cutting-edge financial institution, understands the importance of data security and streamlined access to information within its various departments. This article describes a use case scenario wherein Level Up Bank implemented a Linux-based system to manage directories, files, and user permissions.</p><h4>Scenario: Level Up Bank’s New Departments</h4><p>Level Up Bank has three new central departments: Development, Operations, and Analytics. Each department requires access to specific directories and files related to their functions without interference from other departments. Here’s how we are going to design the system and create a structured and secure environment:</p><blockquote>Note: The choice of server and hosting environment is paramount in ensuring optimal security, reliability, and performance for our systems. For Level Up Bank’s project, we opted for Ubuntu, renowned for its robust security features and steadfast updates. Hosting it on an AWS EC2 instance was an informed decision. AWS offers unmatched reliability, scalability, and a plethora of security features. Leveraging the powerful combination of Ubuntu on AWS EC2 ensures operational efficiency and peace of mind when dealing with sensitive data and critical operations.</blockquote><p>To start off — we need to establish a connection with the server. We will use SSH to connect with Level Up Bank’s server running on AWS EC2 Instance.</p><h4><strong>Establishing Connection via SSH:</strong></h4><p>We need an SSH client installed on our machine to connect via SSH. We also need the server’s public IPv4 along with the access key associated with the instance. This information can be retrieved from the EC2 instance dashboard, and the access key is provided in the downloads directory. That being said, it is time to establish the connection. To do this, we can use Powershell or Command Prompt in Windows or Terminal in MacOS and enter the command below with your changes:</p><pre>ssh -i &lt;path/to/youraccesskey.pem&gt; username@your.IP.v.4.address</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tcyZ2YVYEeseOGZiAh2fHQ.jpeg" /><figcaption>Connecting via SSH</figcaption></figure><p>Once we are in, we should update the system to ensure everything is up to date before creating our directories for each department. We can correct the system using the command below:</p><pre>sudo apt update </pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9zLRsw76xOe323IgTfW81Q.jpeg" /><figcaption>Updating the system — sudo apt update</figcaption></figure><h4><strong>Creating Directories &amp; Files:</strong></h4><p>When the system completes updating the packages, we can start with creating a directory for each department; Level Up Bank has three departments, so we will make three directors concerning each department. To create a directory, we can use the <em>“mkdir”</em> command, which stands for “Make Directory,” and then the directory&#39;s name. The prompt should be:</p><pre>sudo mkdir Development Operations Analytics </pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tHHzMA3sLmD5_SVgvVqtPw.jpeg" /><figcaption>Creating Directories — mkdir</figcaption></figure><p>As you can see, we have created three directories. Let&#39;s add some dummy files in each directory for testing purposes. We can make two text files in each directory using the <em>“touch” </em>command. We can create these files with the following commands in the easiest way.</p><pre>sudo touch Development/file1.txt Development/file2.txt<br>sudo touch Analytics/anafile1.txt Analytics/anafile2.txt<br>sudo touch Operations/opfile1.txt Operations/opfile2.txt</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QR_nCbHxduJnnKmSVAQvrw.jpeg" /><figcaption>Creating dummy files.</figcaption></figure><h4>Creating Users &amp; Groups:</h4><p>In Linux, users are individual accounts used to interact with the system, and groups are collections of users sharing common access rights.</p><p>In this case, users represent different personnel in Level Up Bank’s departments, and groups (Developers, Operations, Data Analysts) are used to manage and control access to respective departments efficiently. This structure ensures security and simplifies access to necessary information based on organizational roles.</p><p>For example, the Developers group would only have access to the Development directory, thus ensuring that sensitive code or development files are not accessible to Operations or Analytics teams. This separation safeguards information, minimizes the potential for accidental interference between departments, and allows for a more streamlined and secure working environment. By utilizing Linux groups, we can set clear boundaries, aligning access with organizational roles and responsibilities.</p><p><strong>Creating Groups:<br></strong>To create groups, we can use the prompt below and create groups with respect to Level Up Bank’s departments; Developers, Operations, and Data-Analysts.</p><pre>sudo groupadd Developers<br>sudo groupadd Operations<br>sudo groupadd Data-Analysts</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ds6Y2I2fhtLhn13wc3HYIg.jpeg" /><figcaption>Creating Groups — groupadd</figcaption></figure><p>As you can see in the figure above, we have created the three groups, and we confirm by using the command “getent group” to list all the groups of the system, and we can see that the groups we just created are listed there.</p><p><strong>Creating Users:</strong><br>We will consider using three users for this demonstration since we have three departments, each for a dedicated department. Let’s use Jess, who is a developer, Blake working in Operations, and Joey, who is a Data Analyst. To create users, we can use the prompt below:</p><pre>sudo useradd -m -G Developers -c &quot;Jess Waller - Email - jwaller@levelupbank.com&quot; jwaller<br>sudo useradd -m -G Operations -c &quot;Blake Dorsey- Email - bdorsey@levelupbank.com&quot; bdorsey<br>sudo useradd -m -G Data-Analysts -c &quot;Joey Ewart - Email - jewart@levelupbank.com&quot; jewart</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*v1hEzjjVs2Qj_V9WrxUJ9Q.jpeg" /><figcaption>Adding users — useradd</figcaption></figure><p>After successfully creating the users and groups, we can move on to the permissions and Ownership.</p><h4><strong>Permissions &amp; Ownership:</strong></h4><p><strong>Permissions: <br></strong>Permissions are a way to control who can read, write, or execute a file. They’re crucial for system security, allowing only authorized users to access or modify specific files.</p><p>Permissions are set for three types of users:</p><p>Owner: The user who owns the file.<br>Group: Users who are in a group and share the same permissions.<br>Others: Everyone else.<br>Each of these three categories has three types of permissions:</p><p>Read (r): Allows viewing the file’s contents.<br>Write (w): Allows modifying the file.<br>Execute (x): Allows running the file as a program.</p><p>These permissions can be represented by three numbers, each from 0 to 7, and each digit represents the permissions for one of the categories (owner, group, others) in that order.</p><p>The value for each digit is calculated by adding:</p><p><strong>4</strong> for <strong><em>read </em></strong>permission<br><strong>2 </strong>for <strong><em>write </em></strong>permission<br><strong>1</strong> for <strong><em>execute </em></strong>permission</p><p>So the value “7” means full permissions (read, write, and execute), “6” means read and write, “5” means read and execute, etc.</p><p>In Level Up Bank’s project, we need to grant permission so that only the owner of the group can read, write and execute. Users should not be able to access the directory if they are not in the correct group. For this to work, we need to grant full access (read, write, and execute) to the owner of the file as well as the group associated with the directory so users in those groups can access the files with respect to their departments. The permissions configuration command for these groups should be:</p><pre>chmod 770 Development<br>chmod 770 Operations<br>chmod 770 Data-Analytics</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/887/1*3CD631dfzpcDhqhKol9CHQ.jpeg" /><figcaption>Setting Permissions — chmod</figcaption></figure><p>As we can see, the permissions have been set so that the owner and group users have read, write, and execute permission, and other users don’t have any permissions at all, which is represented by the last three “_ _ _” dashes.</p><p><strong>Ownership:<br></strong>We must change the owner of each directory to their respective group. We can achieve this by using the command <em>“chown”</em> which stands for “change ownership”.</p><pre>sudo chown :Developers Development<br>sudo chown :Operations Operations <br>sudo chown :Data-Analysts Analytics</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/779/1*U1DSXRgOtNo9zug1dRNZig.jpeg" /><figcaption>Changing Ownership — chown</figcaption></figure><p>In the figure above, we can see that the Ownership of each directory has changed to its respective group.</p><p><strong>Switching to Each User and Verifying Access: </strong><br> To ensure our permissions are set properly and users can only access the files within their directory, we can switch to each user and check what we can access. To switch to another user, we can use the command:</p><pre>sudo su &lt;username&gt; </pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EckA9BueRZElQQ9fNaVoAA.jpeg" /><figcaption>User Access Check — Jess Waller — Development</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g3dbJRZvRjd3fezM72ywMA.jpeg" /><figcaption>User Access Check — Blake Dorsey — Operations</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2hHbQGQw3qKkFYRDfqCeNQ.jpeg" /><figcaption>User Access Check — Joey Ewart — Analytics</figcaption></figure><p>We can confirm that all the users have their permissions set in place and can only access the directory within their working department.</p><p>Until now, we have successfully created the required Directories, Groups, &amp; Users and set the permissions and ownerships necessary for Directories. Now we move on to the most exciting part. AUTOMATION!</p><h4>Automating with Bash Script:</h4><p>We can automate this process by using a Bash script, a text file containing a series of commands that will do everything with a click of a button. Isn’t that cool? Let’s Get Started!</p><p>This is what an example of a bash script file looks like:</p><pre>#!/bin/bash<br># This is a comment explaining what the script does<br><br># Create directories<br>mkdir Development Operations Analytics<br><br># Other commands follow...</pre><p>Notice the “#!/bin/bash” at the beginning of the file, that is called a shebang. It tells the system this file is a bash script and should be executed with the /bin/bash interpreter.</p><p>Here’s the script for Level Up Bank’s project:</p><pre>#!/bin/bash<br><br># Create 3 directories: Development, Operations, Analytics<br>mkdir Development Operations Analytics<br><br># Add several blank dummy files to each directory<br>touch Development/file{1..3}.txt Operations/file{1..3}.txt Analytics/file{1..3}.txt<br><br># Create 3 Groups in Linux: Developers, Operations, Data Analysts<br>groupadd Developers<br>groupadd Operations<br>groupadd DataAnalysts<br><br># Change the owner of each directory to their respective group<br>chown :Developers Development<br>chown :Operations Operations<br>chown :DataAnalysts Analytics<br><br># Modify the permissions to the directory so that only the owner of the group can read, write, and execute<br>chmod 770 Development Operations Analytics<br><br># Create the following users with the associated information<br>useradd -m -G Developers -c &quot;Jess Waller&quot; jwaller<br>useradd -m -G Operations -c &quot;Blake Dorsey&quot; bdorsey<br>useradd -m -G DataAnalysts -c &quot;Joey Ewart&quot; jewart<br><br># Verify the setup<br>echo &quot;Setup complete. Please manually verify by logging in as each user and checking their access to the directories and files.&quot;</pre><p>Once we have written and saved the script, we must make it executable. By default, the newly created script file won’t have permission to execute. You must change its permission to make it executable. We do this by using the command:</p><pre>chmod +x levelupproject.sh</pre><p><strong>Running the Script: </strong><br>Once the script is executable, we can run it by simply:</p><pre>./levelupproject.sh</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Z_mEVUPX3PTinangc9MR-w.jpeg" /><figcaption>Successful Execution of Bash Script</figcaption></figure><p>Yay! We have successfully executed the script! We can test by looking up the directories, users, or groups we created.</p><blockquote><strong><em>Important Notes:</em></strong><br><strong>Permissions:</strong> You may need to be mindful of permissions, especially if your script includes commands that require administrative privileges. Using sudo within the script or running the script as a privileged user might be necessary.<br><strong>Testing: </strong>Before running a script on a production system, it’s good practice to test it in a controlled environment to make sure it behaves as expected. Mistakes in a script can have unintended consequences.<br><strong>Organization or Project Guidelines: </strong>Always ensure that you’re following the specific guidelines, best practices, or requirements relevant to your situation.<br><strong>Always be sure:</strong> Test scripts in a controlled environment (such as a virtual machine or container) to ensure they work as intended and to avoid unintentional changes to your system or others.</blockquote><p>Thank you for taking the time to read this article. Your interest and support are greatly appreciated!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9505ad31435" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hosting a website using Apache on AWS EC2 CentOS & SSH — Step-by-step guide with a use case…]]></title>
            <link>https://medium.com/@faqirik9/hosting-a-website-using-apache-on-aws-ec2-centos-ssh-step-by-step-guide-with-a-use-case-dfb97d96c2d9?source=rss-98bc3b899ffe------2</link>
            <guid isPermaLink="false">https://medium.com/p/dfb97d96c2d9</guid>
            <category><![CDATA[amazon-web-services]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[apache]]></category>
            <category><![CDATA[ec2-instance]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <dc:creator><![CDATA[Khalil Faqiri]]></dc:creator>
            <pubDate>Mon, 14 Aug 2023 15:39:47 GMT</pubDate>
            <atom:updated>2023-08-14T15:39:47.867Z</atom:updated>
            <content:encoded><![CDATA[<h3>Hosting a website using Apache on AWS EC2 CentOS &amp; SSH — Step-by-step guide with a use case scenario</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3oA29XyknsydmX6EXXkZkA.png" /></figure><p>In today’s competitive tech landscape, the ability to scale with demand is not just a desire but a necessity, especially for start-ups navigating the delicate balance of agility and resilience. These young enterprises grapple with the paradox of needing to be agile enough to innovate while ensuring they’re robust enough to handle potential success, especially during defining moments like product launches where unpredictable traffic spikes are common. This article delves into this context, offering a step-by-step guide on deploying an Apache Web Server on AWS EC2 CentOS, complemented by SSH, and presents a flexible, efficient, and cost-effective solution tailored to address these challenges head-on.</p><h4>Here’s why the combination of Apache, AWS EC2, CentOS, and SSH is considered a winning solution:</h4><ol><li><strong>Apache Web Server:</strong> Known for its reliability and flexibility, Apache serves web content and can handle high traffic levels. It’s open-source and widely supported, offering many customization options.</li><li><strong>AWS EC2:</strong> Amazon’s Elastic Compute Cloud (EC2) provides scalable virtual private servers. With EC2, you can quickly scale your server resources up or down to match demand, making it suitable for a start-up expecting fluctuating traffic.</li><li><strong>CentOS:</strong> This free, open-source operating system is known for its stability and is based on Red Hat Enterprise Linux (RHEL) sources. It is often used in enterprise environments, making it a trustworthy choice for hosting a web server like Apache.</li><li><strong>SSH (Secure Shell): </strong>SSH provides a secure method for accessing and managing remote servers. It’s essential for administering your CentOS instance on AWS EC2, allowing secure file transfers, remote command execution, and more.</li></ol><h4>Creating EC2 instance with CentOS image on AWS:</h4><p>To start, navigate to AWS Console and select Services&gt;Compute&gt;EC2 and click on “Launch instance” — On the launch instance form write a fitting name for the instance and select the CentOS image. By default CentOS image is not visible from the list of provided options, to find a CentOS image, click on “Browse more AMIs” and click on the “AWS Marketplace AMIs” tab and search for CentOS. We want to select the CentOS image from a verified provider or authentic source like AWS.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/768/1*nAvtNGckcPg-IU7vjgtrXQ.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7Y4Mog0y6n3ufA4TcUz6oA.jpeg" /></figure><p>Next, we need to select a key pair that will be needed to gain access via SSH. We can create a new key pair or select one we already have. After this step, we move on to the Network &amp; Security groups to ensure we have the right security group that enables SSH &amp; HTTP/HTTPS access. We can create a new security group or select from the list of pre-configured security groups, it must allow SSH Traffic and HTTP/HTTPS traffic.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/773/1*UuSsC0GvTlEb4P5_PB58hw.jpeg" /></figure><p>Once the Network settings are configured and the right Security group is selected we can proceed to launch the instance.</p><p>Upon successful launch of the instance, once it is in a running state we can connect using SSH. In order to connect via SSH, we need the IPv4 address of the instance along with the key pair associated with the instance. With that requirement met we can connect from Windows or MacOS machine to our newly created CentOS instance.</p><h4>Accessing &amp; Managing — Connecting via SSH:</h4><p>In Windows we can use Command Prompt (cmd) or Windows Powershell to connect via SSH to the instance &amp; for MacOS users, Terminal will be perfect. For this example, we will use Windows cmd to connect.</p><p>Start by starting the command prompt program from the Windows menu. Using Windows commands inside the command prompt black box start by typing the following command and inputting the specific values for your use case.</p><pre>ssh -i &quot;C:\path-to\your-keypair\keypair.pem&quot; centos@12.134.55.66</pre><p>The above showed command should allow us to connect with the EC2 instance if we have configured the instance properly. Notice the <em>“centos@12.134.55.66”</em> in the command — “centos” is the username for the CentOS image and this username can differ depending on the image use and the <em>“@12.134.55.66”</em> is the instance IPv4 address.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*f-S0y6Pb1dd5bIGaCl3ESA.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KQdDSQLrujhxBZO3gAfUCg.jpeg" /><figcaption>SSH into EC2 Instance</figcaption></figure><p>And WE ARE IN! Just like that, we have established a secure shell connection with the EC2 instance running the CentOS image.</p><h4>Installing Apache:</h4><p>The first thing to do once we have accessed the Centos console, we must update the packages to ensure everything is up to date. We can do that using the <em>“sudo yum update -y”</em> command.</p><p>After completion of the system update, it is time to install the Apache webserver. We can do so by running the following command —<em> “sudo yum install httpd -y”</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kO4UgEzrDfzNpPTnh3cpAg.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DAJ8NvUo_MYB0m2VYyjR6w.jpeg" /><figcaption>Installing Apache</figcaption></figure><p>Once the installation of Apache is completed, we will need to start the service using the command — <em>“sudo systemctl start httpd” <br></em>To ensure the service has started we can run the command <em>“sudo systemctl status httpd”</em> to view the status of the service and as you can see it is in a running state.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5faBDMaFy4NxN2jkmFZe8A.jpeg" /><figcaption>Service Status</figcaption></figure><p>After successfully executing the commands we should be able to access the default Apache webserver webpage by using the IPv4 address of the EC2 instance. As you can see we have successfully established a connection!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ToCSLoRc46b7XdH43VfFKw.jpeg" /></figure><p>Yayy!! We successfully enabled the Apache server &amp; established a connection!</p><h4>Moving the website files to the server:</h4><p>When it comes to transferring data to the server there are several ways we can website files to the CentOS EC2 instance. For this example, we will be using SCP (Secure Copy Protocol) because we have the SSH already configured in the EC2 Instance. SCP uses SSH for data transfer and utilizes the same mechanisms for authentication. This is a commonly used method to securely transfer files. Here’s the command:</p><pre>scp -i /path/to/your-key.pem index.html styles.css ec2-user@your-ec2-ip-address:/path/to/destination</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5FXHy7ujuqteSmbLAa9U7g.jpeg" /><figcaption>SCP Secure Copy Protocol</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*duHUc3oF5ChAAB_v4pHnsg.jpeg" /><figcaption>Confirmation — Files copied on the server</figcaption></figure><p>Once we have transferred the files to the server, we then need to move them again into the default Apache server directory. The default directory on CentOS is found in “/var/www/html”.</p><p>We can use the “mv ~/index.html styles.css /var/www/html” command to move files to the Apache webserver directory. After moving our website files we should be able to access it through the IPv4 address just like before, the only difference is that it is now our website instead of the default HTTP server test page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Yy_DlZyUEdrBd_NMtRCQrQ.jpeg" /></figure><h4>Troubleshooting the server:</h4><p>To ensure the connection of our server we may need to review the access logs and error logs to be able to troubleshoot any problems users may be having.</p><p>To view the access logs, we will use the command <em>“sudo tail -n 15 /var/log/httpd/access_log”</em> to find the access logs and error logs, notice that because of the “-n 15” we will only be viewing the last 15 lines of the access logs.n We can also save the logs in a separate file so we can review them later.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WBHW2gsDc8_JKPxsjbRlJg.jpeg" /><figcaption>Access Logs</figcaption></figure><p>To save these access logs, we will use the same command but will add the “&gt;” symbol at the end and type the name of the file we want it to write into, for example, “access_logs.txt”. The full command will look like <em>“sudo tail -n 15 /var/logs/httpd/access_log &gt; access_logs[date].txt”</em></p><p>We can repeat the same process for accessing and saving error logs. The only difference would be replacing the <em>“access_log”</em> with <em>“error_log” </em>and naming the file with the correct name.</p><p>We’ve accomplished our goal! We’ve demonstrated a fundamental yet powerful example by successfully setting up an Apache web server on an EC2 CentOS instance and utilizing SSH for configuration. While this represents a small beginning, it can be efficiently scaled to meet the diverse demands of any organization. I appreciate you investing the time to explore this guide with me. May it offer you new insights and inspire your future endeavors in cloud engineering. Happy Cloud Engineering! :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dfb97d96c2d9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Efficient Cloud Management: Exploring SSH, RDP, and SSM for EC2 Instances on AWS]]></title>
            <link>https://medium.com/@faqirik9/efficient-cloud-management-exploring-ssh-rdp-and-ssm-for-ec2-instances-on-aws-b99b4b5a4fef?source=rss-98bc3b899ffe------2</link>
            <guid isPermaLink="false">https://medium.com/p/b99b4b5a4fef</guid>
            <category><![CDATA[ssh]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[aws-ec2]]></category>
            <category><![CDATA[rdp]]></category>
            <category><![CDATA[aws-ssm]]></category>
            <dc:creator><![CDATA[Khalil Faqiri]]></dc:creator>
            <pubDate>Wed, 02 Aug 2023 15:24:46 GMT</pubDate>
            <atom:updated>2023-08-02T15:24:46.505Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6zsb4SvJUOqSNByM_zZ39Q.gif" /></figure><p>In the fast-paced world of cloud technologies, secure access and effective management of EC2 instances are crucial. This guide will dive into AWS connectivity methods using EC2 instances, exploring SSH for direct command-line access, RDP for graphical interface management, and AWS Systems Manager (SSM) for centralized and secure instance management. Join me as we unlock the potential of these powerful tools, ensuring seamless and confident cloud management on AWS. Let’s get started!</p><p><strong>1SSH (Secure Socket Shell)</strong></p><h4><strong>Connecting using SSH step-by-step guide:</strong></h4><p>SSH is a crucial tool for managing Linux servers efficiently, allowing administrators to remotely configure web servers, install software packages, and troubleshoot applications. It’s indispensable for developers engaging in remote development and debugging tasks on Linux environments. Additionally, SSH plays a vital role in automated deployment and configuration management, seamlessly integrating with popular tools like Ansible, Puppet, and Chef.</p><p>In order to connect via SSH, the public IP of the EC2 instance, the access key pair associated with the EC2 instance, and the correct security group, allowing SSH traffic from the desired destination are required.</p><p>To find the public IP and key pair associated with the EC2 instance we navigate to the EC2 dashboard on AWS and select the instance we want to connect to.<br>For this example, we will be connecting to an EC2 instance running Amazon Linux image and Windows cmd/command prompt (content management system) to gain SSH access.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DHcLzrujob48YTjGfCvDBQ.jpeg" /></figure><p>Once we have gathered this information, we navigate to the Windows command prompt or power shell and enter the command to connect via SSH.</p><p>SSH command for connecting to ec2 instance:</p><pre>ssh -i &quot;path_to_your_private_key.pem&quot; ec2-user@your_ec2_instance_public_dns</pre><p>the “path_to_your_private_key.pem” is the location path to the key associated with the ec2 instance. “ec2-user” is the username for the Amazon Linux image and the “your_ec2_instrance_public_dns” is the public IP address of the instance.</p><pre>ssh -i C:\Users\YourUsername\Downloads\mykey.pem ec2-user@3.84.22.2</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/978/1*eFT1fzWNjA9c9sKL2gEeWw.jpeg" /><figcaption>SSH Secure Connection Established</figcaption></figure><p>And Voila! We have successfully established an SSH connection with our EC2 instance.</p><p><strong>2RDP (Remote Desktop Protocol)</strong></p><h4>Connecting using RDP step-by-step guide:</h4><p>RDP serves as a powerful solution for Windows server management, providing administrators with graphical desktop access to efficiently configure applications, services, and system settings on AWS EC2 instances. IT support teams find RDP invaluable for offering remote assistance and troubleshooting for end-users technical issues on their Windows machines. Moreover, RDP simplifies the management of Windows-specific software through its graphical interface, making installation and updates straightforward.</p><p>For this example, we will connect to an EC2 instance running Windows Server and use Remote Desktop (RDP) to gain graphical access to the Windows desktop environment for efficient server management and administration.</p><p>To connect via RDP, the public IP of the EC2 instance, the appropriate Windows credentials (username and password), and the correct security group allowing RDP traffic from the desired source are needed.</p><p>Start by navigating to the instance summary page and click on “Connect”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UzFqv_iYMZkirPDpdCz6yQ.jpeg" /><figcaption>ES2 Dashboard — Connect</figcaption></figure><p>Select “RDP” Client and download the “remote desktop file”. Notice the username is “Administrator” and click on “Get password” to access the password.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/854/1*BGjpkClTWfOYeOb9-k99wA.jpeg" /><figcaption>Ec2 Instance — RDP Setup page</figcaption></figure><p>In order to access the password, it is necessary to upload the key pair associated with the instance. Once that is uploaded, click on “Decrypt password”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/847/1*fs2i-pLME4bm7ROhgG9ATQ.jpeg" /><figcaption>RDP — Decrypt Password</figcaption></figure><p>Once we have access to the password we can go ahead and open the remote desktop file we downloaded earlier. Once we open it, it will prompt us to enter credentials. Enter the credentials and click “Ok”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/540/1*XTrqcgEcwst86WLGNbtnfQ.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/459/1*uEnBmHJOOpjC7QphPs-x3g.jpeg" /><figcaption>RDP — Credentials Prompt</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jQbCQWgJJu52UN6_NplCpQ.jpeg" /><figcaption>RDP — Successful Connection</figcaption></figure><p>And just like that, we’re inside the Windows machine!</p><p><strong>3AWS SSM (Simple System Manager)</strong></p><h4>Connecting using AWS SSM step-by-step guide:</h4><p>SSM offers enhanced security and centralized management for Linux and Windows EC2 instances on AWS. It enables administrators to control access and execute commands across multiple instances from a central location, eliminating the need to publicly expose SSH or RDP ports. SSM’s patch management capabilities ensure instances stay up-to-date with security patches and compliance requirements. Additionally, its remote session capabilities streamline troubleshooting and performance monitoring tasks directly from the AWS Management Console, simplifying incident response and improving operational efficiency. Furthermore, SSM facilitates automation, making server maintenance and management more convenient and reducing manual intervention.</p><p>For SSM to have access to our EC2 instance, the items below are required:</p><p><strong>SSM Agent:</strong> Ensure that the EC2 instance has the SSM agent installed. The SSM Agent comes pre-installed on Amazon Linux 2 and certain Windows AMIs. In this example, the agent is pre-installed so we don’t have to do this part. If the instance does not have it, follow AWS documentation to manually install the SSM Agent.</p><p><strong>SSM Enabled in Security Groups:</strong> the Security Group settings of the EC2 instances to allow inbound traffic on port 443 (SSM communication port) from the IP range or Security Group used for SSM access. This allows SSM to communicate with the instances securely. In our case we don’t have any restrictions on security groups and All access is allowed.</p><p><strong>IAM Role and Policy:</strong> An IAM role with the necessary permissions for SSM. The role should have the correct policy attached that grants the required permissions.</p><p>Navigate to the IAM service on AWS, click on Roles, and click “Create role”. <br>Choose “AWS service”, select EC2 for the use case, and click “Next”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cS4ztsdtHwZRNGHCdXy6PQ.jpeg" /><figcaption>Creating a Role for EC2 Services — IAM</figcaption></figure><p>Search for “AmazonEC2RoleforSSM”, select and click on “Next”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qm9wOASHriNZ7UbMGzWqJQ.jpeg" /><figcaption>Adding Role Policy — IAM Roles</figcaption></figure><p>Enter a role name and click on “Create role”. Once the role is created, we will have to attach it to the EC2 instance.</p><p>Continue by navigating to the EC2 service on AWS and open the desired instance. Click on “Actions” &gt; “Security” &gt; “Modify IAM role”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mCueml_LWkyefz1vWtareA.jpeg" /></figure><p>Select the IAM role we created “AmazonEC2RoleforSSM” and click on “Update IAM role”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/857/1*JNyDKi1odHVkbf2fnciY3g.jpeg" /></figure><p>Upon updating the role it may take a few mins for it to get applied and ready for connection. We can connect to the EC2 instance via SSM or access the SSM service platform on AWS to start a session with the instance.</p><p>Navigating back to the EC2 services, select the instance and click on “Connect” &gt; “Session Manager” &gt; “Connect”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Aca0IZeBeXZCcl9C9y3XQg.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/841/1*nrtse3-irAgQogCTxID-Hw.jpeg" /><figcaption>Connecting via SSM from EC2</figcaption></figure><p>Finally, we have a secured connection with our EC2 instance via SSM.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BktyN2g2kPTxGmwm1BuczA.jpeg" /><figcaption>EC2 Access via SSM</figcaption></figure><p>To conclude, this insightful guide embarked on a journey through the world of AWS connectivity methods. We learned how SSH empowers a with direct command-line access, while RDP allows one to manage servers through a graphical interface. Additionally, we explored the power of AWS Systems Manager (SSM) in providing centralized and secure instance management. I feel equipped to optimize my cloud infrastructure management on AWS. Thank you for joining me on this learning adventure!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b99b4b5a4fef" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hosting a Secure Static Website using AWS S3 and CloudFront: A Scenario-Based Tutorial]]></title>
            <link>https://medium.com/@faqirik9/hosting-a-secure-static-website-using-aws-s3-and-cloudfront-a-scenario-based-tutorial-99ad7477fc09?source=rss-98bc3b899ffe------2</link>
            <guid isPermaLink="false">https://medium.com/p/99ad7477fc09</guid>
            <category><![CDATA[cloudfront]]></category>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[s3]]></category>
            <category><![CDATA[webhosting-service]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Khalil Faqiri]]></dc:creator>
            <pubDate>Tue, 25 Jul 2023 16:01:01 GMT</pubDate>
            <atom:updated>2023-07-25T16:01:01.381Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_OR_vH_bbNZifkyzt49aPQ.jpeg" /></figure><p>Welcome to the high-stakes digital banking world, where performance and security are not just desirable but crucial. At the center of our story is Level Up Bank, a trailblazing startup determined to redefine banking experiences in the digital age. They aim to provide their customers with seamless and efficient access to their banking services while fortifying their web presence with fast access and security.</p><p>So, let’s step in and navigate this digital landscape. As we journey through deploying a secure static website using AWS S3 and CloudFront, we’ll uncover how Level Up Bank ensures their S3 content remains out of direct reach from users while still providing a high-performing, secure banking platform.</p><p>In developing a strategy for Level Up Bank, it’s critical to recognize the pivotal roles played by Amazon S3 and CloudFront in ensuring: performance, scalability, cost, and security.</p><p><strong>Amazon S3</strong> is a robust, scalable storage solution used to host the bank’s website content. Its access controls and high availability ensure the bank’s data is securely stored and always accessible.</p><p><strong>Amazon CloudFront </strong>is a key player in optimizing website performance and security. By caching the website content at various global locations, it ensures quick content delivery. Crucially, it’s configured to enforce HTTPS-only access, thereby encrypting data in transit and providing a secure browsing experience.</p><h3>Setting the Foundation using AWS S3 Simple Storage</h3><p>Our first order of business is to create an S3 bucket so we can store website files. Here’s how to do this step by step:</p><p>Sign in to the AWS Management Console.</p><p>Once logged in AWS console, navigate to the ‘Services’ dropdown menu at the console’s top left corner. In the storage section, you’ll find ‘S3’. Click on it to open the S3 dashboard.</p><p><strong>Step 1:</strong> On the Amazon S3 dashboard, click on the ‘Create bucket’ button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sl11Tlaen_btB0rrfp39sg.jpeg" /><figcaption>Creating a S3 bucket — S3 Dashboard</figcaption></figure><p><strong>Step 2:</strong> In the opened form, specify a unique ‘Bucket name’ and the ‘Region’ that aligns best with Level Up Bank’s customer base. Remember, AWS bucket names are globally unique.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/832/1*4aIOCX25P2wxuL9LQq_8ng.jpeg" /><figcaption>Creating Bucket — S3</figcaption></figure><p>Step 3: Under the ‘Permissions’ settings, we must ensure ‘Block all public access’ is on to prevent anyone from accessing the bucket unless explicitly allowed by the bucket policy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/819/1*gxJkpOn1yDBgVTLkYM0szw.jpeg" /><figcaption>Blocking direct public access to S3 Bucket — S3 Creating Bucket</figcaption></figure><p>Step 4: Leave the rest of the settings on default and click on “Create bucket”.</p><p>After creating the S3 bucket, we simply click on add files to upload the website files. To do this simply click on upload file and select the necessary website files including the index.html file.</p><p>Next, we will proceed to the bucket we just created where the files have been uploaded; from there, we will navigate to the “Properties” section and scroll down until we reach the “Static Website Hosting” option. Our objective is to enable this feature. To achieve this, follow these step-by-step instructions:</p><p>Step 1: Click on the bucket in which the files have been uploaded. In the bucket’s dashboard, click on the “Properties” tab.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/641/1*y7ICnHV6vj0md2IbWg3vlQ.jpeg" /><figcaption>Navigating to Properties to enable Static Website Hosting — S3 Bucket</figcaption></figure><p>Step 2: Scroll down to find the section labeled “Static Website Hosting” and click “Edit”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Qm5rPnqhgJeWiA9F5aXQoA.jpeg" /><figcaption>Editing Static Web Hosting — S3 Bucket</figcaption></figure><p>Step 3: Click on “Enable” under Static website hosting and provide the appropriate index document (e.g., index.html) and error document if desired.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/554/1*JjBdm1RUQd-uwJBW-pOKzA.jpeg" /></figure><p>Step 4: Save the changes to activate static website hosting for the selected bucket. Upon successfully saving the settings, you should see a static website URL at the bottom of the page, and we can test it using that link.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/873/1*_oXC3wY4SboA30H_rdvXTw.jpeg" /></figure><p>Once we have activated static website hosting in the Amazon S3 bucket, the bucket can serve web content as a static website. However, we need to set up the necessary permissions for users to access and interact with this website. We can achieve this by creating a resource-based policy, a JSON document specifying who has access to the bucket and what actions are allowed to perform.</p><p>Start by navigating to the S3 bucket.</p><p><strong>Step 1:</strong> Click on the “Permissions” tab in the bucket dashboard.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/666/1*MN6eCBtEzmO8i1m-l4cObQ.jpeg" /><figcaption>Navigating to S3 Bucket Policy</figcaption></figure><p><strong>Step 2:</strong> Under the “Bucket Policy” section, click the “Edit” button to create a new bucket policy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hO2NhA8cZpyExx8nqEE-TQ.jpeg" /><figcaption>Editing Bucket Policy</figcaption></figure><p><em>Creating a resource based policy: A resource policy is basically a JSON document specifying your users’ access permissions in the policy. The policy defines which users or resources can can access the objects inside the bucket which are the website files in our case. In this case, we are provided with a template bucket policy that we can use for our S3 Bucket with only updating our resource name. You can generate policies directly using the editor itself or find pre-written policies on AWS documentations.</em></p><p>Level Up Bank’s S3 Bucket Policy:</p><pre>{<br>    &quot;Version&quot;: &quot;2012-10-17&quot;,<br>    &quot;Statement&quot;: [<br>        {<br>            &quot;Sid&quot;: &quot;AllowCloudFrontServicePrincipal&quot;,<br>            &quot;Effect&quot;: &quot;Allow&quot;,<br>            &quot;Principal&quot;: {<br>                &quot;Service&quot;: &quot;cloudfront.amazonaws.com&quot;<br>            },<br>            &quot;Action&quot;: &quot;s3:GetObject&quot;,<br>            &quot;Resource&quot;: &quot;arn:aws:s3:::your-bucket-name/*&quot;<br>        }<br>    ]<br>}</pre><p>This S3 bucket policy is simply allowing AWS CloudFront distribution to retrieve objects from the specified S3 bucket.</p><p><strong>Step 3:</strong> <strong>Update S3 Bucket Name<br></strong>Replace “ Resrouce: ” with the actual ARN of the S3 bucket. We can find this under our bucket’s ARN (Amazon Resource Name) inside S3.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aBYqOa4w_B801_N_yWVwjw.jpeg" /></figure><p><em>Keep in mind that we must include “/*” at the end of our resource name just before the ending quotation mark ”. Including “/*” in the resource name of an S3 bucket policy means you want the policy to apply to all objects (files) inside that bucket. It’s like a shortcut to set permissions for everything in the bucket instead of specifying each object individually. This is helpful when you want consistent access controls for all files in the bucket.</em></p><p><strong>Step 4:</strong> After ensuring the policy is correct, click on the “Save changes” button to apply the resource-based policy to the bucket.</p><h3>Implementing CloudFront for Enhanced Performance and Security</h3><p>For Level Up Bank, adopting CloudFront serves a dual purpose. Firstly, it supercharges their website performance by implementing “edge caching”. This means the bank’s digital content is stored on servers worldwide, putting it closer to its global user base and minimizing latency. Secondly, CloudFront doesn’t just enforce encrypted HTTPS connections; it adds a robust security layer by ensuring that users can access the bank’s content solely via CloudFront and not directly from the S3 bucket. This provides Level Up Bank an added degree of control and security, essential in the banking sector.</p><p>We start by navigating to the Networking &amp; Content Delivery section of the AWS and choose CloudFront. Once on the dashboard of CloudFront, follow the step by step guide below:</p><p>Step 1: Click on “Create Distribution”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/606/1*7bWmkXT86mUuZKJzFf8TQg.jpeg" /></figure><p>Step 2: Enter the “Origin Domain Name” which is the static website endpoint in our case.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/818/1*nnYm_ft0BesiEAs8aV7j5Q.jpeg" /><figcaption>Selecting the origin domain for CloudFront Distribution</figcaption></figure><p>Step 3: Next, we configure the default cache behavior settings. In this phase, it is vital for Level Up Bank’s security to redirect HTTP traffic to HTTPS. This pivotal action ensures secure, encrypted connections for the bank’s website, bolstering user confidence. We also can refine other caching behaviors, tailoring the bank’s web performance to optimal levels.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/744/1*5t_0Ka09GeR2IZIstGzRyQ.jpeg" /><figcaption>Setting Default cache behavior — CloudFront Distribution</figcaption></figure><p>Step 4: Cache key and origin requests are left on CachingOptimzed which is a recommended option. This choice is crucial as it determines how effectively CloudFront caches and serves the bank’s website content, balancing performance and cost-effectiveness. This optimization ensures that the bank’s customers globally receive a fast and responsive user experience.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/725/1*9I9CLV9ZyLYDs2HZUJJtXA.jpeg" /><figcaption>Cache key and origin request — CloudFront Distribution</figcaption></figure><p>Step 5: Enabling the Web Application Firewall (WAF). It is crucial for a financial institution like Level Up Bank, where security is paramount, to enable this feature. By enabling WAF, we are activating an additional layer of protection for the bank. WAF guards against common web threats, protecting the bank’s digital operations and customer data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/813/1*JZ4ODPQI5yToI5wntYCV6g.jpeg" /><figcaption>Enabling WAF — CloudFront Distribution</figcaption></figure><p>Step 6: Leaving all the other default options, we click “Create Distribution”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9U6VSX7-2qfyLAd5CtizKw.jpeg" /><figcaption>Distribution domain name — CloudFront Distributions</figcaption></figure><p>Viola! Our destribution is created!</p><p>Notice the “Distribution domain name” that is how we are going to access our website. We have completed all the necessary steps and now it is turn to go LIVE!</p><p>In the figure below, notice that the distribution domain name can give us a secure connection with the Level Up Bank website. If you do not see the lock icon at the beginning of the URL, that will mean that your connection is not secured and you might need to do some troubleshooting to fix the issue.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lEWct-Rx8-spBVymQX7y_g.jpeg" /><figcaption>Secured Connection — Level Up Bank</figcaption></figure><h3>Navigating the Final Frontier — Testing Our Secure, High-Performance Setup</h3><p>As we reach the end of our digital expedition with Level Up Bank, ensuring that our secure, high-performance setup is working as expected is critical. Each of these following steps is designed to validate a different component of our AWS architecture:</p><ul><li><strong>Accessing the website using the CloudFront URL</strong> — validates that our website is accessible via the CloudFront distribution, guaranteeing fast, global performance for Level Up Bank’s customers.</li><li><strong>Ensuring HTTPS Redirection</strong>: By testing access with ‘http’ and being redirected to ‘https’, we confirm that our configuration for secure, encrypted access is in place, reinforcing Level Up Bank’s commitment to customer data safety.</li><li><strong>Verifying Caching</strong>: To check if CloudFront’s caching mechanism is effectively deployed, we manually change the ‘index.html’ file and upload it back to the S3 bucket. Accessing the updated site through the direct S3 link should reflect the difference instantly. However, when we revisit the site using the CloudFront URL, the displayed content should still show the previous version — confirming that the caching is functioning.</li><li><strong>Confirming S3 Access Restriction</strong>: Attempting direct access via the S3 bucket URL helps us affirm that we’ve successfully restricted direct access to our S3 bucket. This step underscores Level Up Bank’s secure infrastructure, where content is accessible only via</li></ul><p>And there you have it! We’ve walked you through the journey of Level Up Bank as they ventured to deploy a highly secure, scalable, and high-performing website using AWS’s S3 and CloudFront services. This scenario-based exploration is more than just a tutorial; it’s a testament to the potential and capabilities of cloud computing in creating seamless, secure, and customer-centric digital experiences.</p><p>Thank you so much for investing your time in reading this article. I genuinely hope it’s been an enlightening and engaging read.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=99ad7477fc09" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>