<?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 Brian Mathenge on Medium]]></title>
        <description><![CDATA[Stories by Brian Mathenge on Medium]]></description>
        <link>https://medium.com/@brian639?source=rss-1a88380b4fb2------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*1StFPiRDKCyGxODG5qtFCA.jpeg</url>
            <title>Stories by Brian Mathenge on Medium</title>
            <link>https://medium.com/@brian639?source=rss-1a88380b4fb2------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 17:55:23 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@brian639/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[A Guide to Integrating Amazon EFS and S3 for Shared Workloads]]></title>
            <link>https://awstip.com/a-guide-to-integrating-amazon-efs-and-s3-for-shared-workloads-789b7fc1569d?source=rss-1a88380b4fb2------2</link>
            <guid isPermaLink="false">https://medium.com/p/789b7fc1569d</guid>
            <category><![CDATA[amazon-s3]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[amazon-efs]]></category>
            <category><![CDATA[network-drive]]></category>
            <category><![CDATA[amazon-datasync]]></category>
            <dc:creator><![CDATA[Brian Mathenge]]></dc:creator>
            <pubDate>Mon, 04 Mar 2024 13:53:05 GMT</pubDate>
            <atom:updated>2024-03-04T18:24:45.649Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pRkrKmaL6SEr85GPXUf7DQ.png" /><figcaption>Photo credits: NetApp BlueXP</figcaption></figure><p>Two departments within your business handle crucial workloads necessary for their operations. To ensure flawless execution of workloads, your business requires data integration into their respective applications.</p><p>Your uses Amazon EFS, an advanced network storage solution, because it reduces redundant data copies and improves efficiency. Its inherent scalability also enables your business to readily accommodate future workloads.</p><p>With a huge amount of your data stored in an Amazon S3 data lake, how can you streamline operations by establishing smooth integration between Amazon EFS and Amazon S3?</p><p>This article demonstrates how to set up a shared drive that both departments in your business can access, thereby fostering collaboration and operational efficiency throughout your business in the most efficient way possible.</p><h3>Prerequisites</h3><p>To get the most out this guide, you should have a basic knowledge of AWS and its core services such as EC2, S3 and EFS.</p><p>A basic understanding of networking concepts such as VPCs, Subnets, Security Groups and Internet Gateways will also be beneficial.</p><p>Finally, you should have basic proficiency with Linux commands for file management, directory navigation and user permissions.</p><h3>1. Set up a Networking Environment</h3><p>Before creating our network file system, we need to create a custom VPC.</p><p>Open your Management Console and search for <em>VPC</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*83c37rKbFVxORRkeD0hL4A.png" /></figure><p>Click on <em>Create VPC</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/987/1*WitflHcJcrstoy0RqXB0Yw.png" /></figure><p>Configure the following settings:</p><ul><li>Resources to create: <em>VPC only</em></li><li>Name tag: <em>EFS_VPC</em></li><li>IPv4 CIDR: <em>10.0.0.0/16</em></li><li>IPv6 CIDR block: <em>No IPv6 CIDR block</em></li><li>Tenancy: <em>Default</em></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*99c6-W0kILTNWf44SY9YIA.png" /></figure><p>Click on <em>Create VPC</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cJMWZ_IHUNVhmlVD3BJ8DA.png" /></figure><p>Your custom VPC should be displayed alongside the AWS default VPC.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u6GRYWSB08lxuAeaN-ka_w.png" /></figure><p>Next up, you’ll need to create subnets inside your custom VPC.</p><p>Navigate to the left navigation panel of your screen and select <em>Subnets</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/326/1*Q0PyQqBbp_8pz1ME4_KVgQ.png" /></figure><p>Select <em>Create Subnet</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pamhd8r32wYZu019jij1DA.png" /></figure><p>Under <em>VPC ID</em>, select the custom VPC <em>(EFS_VPC)</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gospgTssAAhFM9jiziveNQ.png" /></figure><p>Configure the following settings for your first subnet.</p><ul><li>Subnet name: <em>Subnet A</em></li><li>Availability Zone: <em>us-east-1a (This will depend on which region you used while launching your VPC)</em></li><li>IPv4 VPC CIDR block: <em>10.0.0.0/16</em></li><li>IPv4 subnet CIDR block: <em>10.0.0.0/24</em></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Lt1_aezHw6qyEEpH8hOZUQ.png" /></figure><p>Configure the following settings for your second subnet.</p><ul><li>Subnet name: <em>Subnet B</em></li><li>Availability Zone: <em>us-east-1b (This will depend on which region you used while launching your VPC)</em></li><li>IPv4 VPC CIDR block: <em>10.0.0.0/16</em></li><li>IPv4 subnet CIDR block: <em>10.0.1.0/24</em></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fDroUSnHiN9L4B5EcFSGgQ.png" /></figure><p>Click on <em>Create Subnet</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HbBqOiF5-E1nxtQPAtsBfg.png" /></figure><p>Your 2 new subnets should appear under the <em>Subnets</em> section.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TE34rFmV30nRsR8IARl_tA.png" /></figure><p>To provide internet access to the instances you’ll launch later on, you need to configure an Internet Gateway.</p><p>Navigate to the left navigation panel and select <em>Internet Gateways</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/320/1*SpWDqhrTHJA51jPCi1Aw1g.png" /></figure><p>Click on <em>Create Internet Gateway</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XNCgOQwBdjzZDAB0TFWzoQ.png" /></figure><p>Configure the following setting</p><ul><li>Name tag: <em>EFS_IGW</em></li></ul><p>Click on <em>Create Internet Gateway</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*94M8SHjyviiR9VRiWnld5Q.png" /></figure><p>Once you’ve created it, navigate to <em>Actions</em> and select <em>Attach to VPC</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m_hI4IrKj-J4ct2PkwlIUQ.png" /></figure><p>Select your custom VPC <em>(EFS_VPC)</em> and click on <em>Attach Internet Gateway</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R-GBnz2WqJiwOuGUlgh6Ng.png" /></figure><p>You’ve now attached your Internet Gateway to your Custom VPC.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*phNHaQ-c1QzV8Ndtg0MoMA.png" /></figure><p>To ensure internet traffic is routed to your Internet Gateway, you’ll need to configure your route tables.</p><p>Navigate to the left navigation panel and select <em>Route Tables</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/313/1*JfQtLf5SopXpRZMQPz23tw.png" /></figure><p>Select <em>Create route table</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vq0xg3QssNy5MjUkk0VOUg.png" /></figure><p>Configure the following settings:</p><ul><li>Name: <em>Public Route</em></li><li>VPC: <em>EFS_VPC</em></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4Cfg0OHZ94yqaD2ESojBzA.png" /></figure><p>Click on <em>Create route table</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lWI943F4jQfTEWUT_-6uCw.png" /></figure><p>You’ve now created a route table which has a default route.</p><p>On the <em>Routes</em> tab, select <em>Edit Routes</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9LAkOtIXMhtjFCaShVOdRQ.png" /></figure><p>Click on Create Route and configure the following settings:</p><ul><li>Destination: <em>0.0.0.0/0</em></li><li>Target: <em>Internet Gateway (select the Internet Gateway you just created)</em></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Q-KJqjE9j86SKfhqZuLF-A.png" /></figure><p>Click on <em>Save changes</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zZjFZ-o7IaXFSVi4IrPuGw.png" /></figure><p>Navigate to the <em>Subnet associations</em> tab and click on <em>Edit subnet associations</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zmCiwEa8zzUhtJMG0dHNFg.png" /></figure><p>Check both <em>Subnet A</em> and <em>Subnet B</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WDI4G9WX685upKsC1VnKIA.png" /></figure><p>Click on <em>Save associations</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u6zENa8tc5_B6HzGt4DxKg.png" /></figure><p>Finally, you’ll need to create appropriate security groups for your EC2 instances as well as your EFS File System Mount Targets.</p><p>Navigate to the left navigation panel and select <em>Security Groups</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/293/1*_NzA3QKIzlXri8My_5UUuQ.png" /></figure><p>Select <em>Create security group</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HNX9xnGsRupEdAgIPfv7nw.png" /></figure><p>Configure the following settings:</p><ul><li>Security group name: <em>EFS_Client</em></li><li>Description: <em>Allows SSH access</em></li><li>VPC: <em>EFS_VPC</em></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/984/1*-OSUeM4HMpD-OjVV9wYmOg.png" /></figure><p>Create an Inbound rule with the following configurations</p><ul><li>Type: <em>SSH</em></li><li>Protocol: <em>TCP</em></li><li>Port range: <em>22</em></li><li>Source: <em>Anywhere</em></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5ajRc-DBGsSO7dLx7jA6pg.png" /></figure><p>Select <em>Create security group</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZgViBo-U8THcjPf8fX-tsw.png" /></figure><p>This Security group allows you to SSH into the instances which you will launch later on.</p><p>Copy the Security group ID for <em>EFS_Client</em> to your clipboard</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Jp8NiAOGzYf6k1dQrpv7fA.png" /></figure><p>Navigate back to the Security Groups dashboard and select <em>Create security group</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HNX9xnGsRupEdAgIPfv7nw.png" /></figure><p>Configure the following settings:</p><ul><li>Security group name: <em>EFS Mount Target</em></li><li>Description: <em>Inbound NFS access from EFS clients</em></li><li>VPC: <em>EFS_VPC</em></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1007/1*MpUQuvpGLxVj9vzQ0IUJcQ.png" /></figure><p>Create an Inbound rule with the following configurations</p><ul><li>Type: NFS</li><li>Protocol: TCP</li><li>Port range: 2049</li><li>Source: Custom</li><li>Paste the Security group ID you copied earlier (EFS_Client)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rsLOzq4xB5I7lYf2Fo2cXQ.png" /></figure><p>Click on <em>Create security group</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0sYshh0dBjzAlkIxxxCM7A.png" /></figure><p>This security group provides access to your EFS File System. You will later attach this security group to your EFS Mount Targets.</p><p>You’ve now configured a networking environment for your network drive and created the required security groups for your instances as well as your network drive.</p><h3>2. Create an EFS System</h3><p>Next up, you’ll create an EFS File System inside your custom VPC.</p><p>In your Management Console, search for <em>EFS</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wug9f6vw62mmJB7xfLc-3w.png" /></figure><p>Select <em>Create File System</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_Ef0WmkJA-rQErn20nVrVg.png" /></figure><p>Click on <em>Customize</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/894/1*hiNgDNqZ_xT5bbZ9nnDRxw.png" /></figure><p>Configure the following settings for your file system:</p><ul><li>File system type: <em>Regional</em></li><li>Automatic backups: <em>Enable automatic backups</em></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7HV25be6riCnPml_ESc_Jw.png" /></figure><p>For the Performance settings, select <em>Enhanced</em> and click on <em>Elastic</em>.</p><p>This ensures your file system scales with storage size.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CqNbynyK4zz36hJx8qMC2Q.png" /></figure><p>Configure the following tag</p><ul><li>Tag key: <em>Name</em></li><li>Tag value: <em>CFS_Network_Drive</em></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0xEgPV3Z2jMSXEd2vquhag.png" /></figure><p>Click on <em>Next</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XwsgCoqtC93PaQQ3pesmmg.png" /></figure><p>Configure the following settings under Network</p><ul><li>Virtual Private Network: <em>EFS_VPC</em></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BtBQwbllaNiBTGIaAL9vuQ.png" /></figure><p>In the Mount targets section, detach the default security groups and attach the <em>EFS Mount Target</em> Security group for both Availability zones.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SiTfSBs0dCHALv9JoJjj2A.png" /></figure><p>Select <em>Next</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5JZytilCNMtGoBGvR_jJzg.png" /></figure><p>Click <em>Next</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Piy_A--zZcHs705n_8GTDQ.png" /></figure><p>Review your file system configurations and click on <em>Create</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Y2On0y0IXJGerbRHjha-WQ.png" /></figure><p>Wait a few minutes for your EFS File System to become available.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P8za5bgO_jMPYfjkhLwTCQ.png" /></figure><h3>3. Create EC2 Instances</h3><p>Next, you will launch 2 EC2 instances in your custom VPC. You will also mount the EFS network share in both instances.</p><p>In your Management Console, search for <strong><em>EC2</em></strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yaq_OU7UewaeFcY5AgPw5g.png" /></figure><p>Select <strong><em>Launch instance</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/531/1*Ei17Wsz6nji137OexctIwA.png" /></figure><p>Configure the following settings for your first instance.</p><ul><li>Name: <em>Instance A</em></li><li>AMI: <em>Amazon Linux</em></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G9Z7SawzGKWL4Nqah3kavg.png" /></figure><p>Instance type: <em>t2.micro</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dvfcasyb5Arv1pys2EzxBw.png" /></figure><p>Select <em>Create new key pair</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xpCLv5ils9LszqOVY804Ig.png" /></figure><p>Configure the following settings</p><ul><li>Key pair name: <em>cfs</em></li><li>Key pair type: <em>RSA</em></li><li>Private key file format: <em>.pem (Linux &amp; MacOS), .ppk (Windows)</em></li></ul><p>Click on <em>Create key pair</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/886/1*uP2POX5xg0arWnSaUdvcig.png" /></figure><p>Once you create a key pair, a<em> </em>file will be downloaded onto your local machine.</p><p>Select the key pair you just created.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mhCb1mP-acx0Z_zTGCfyOw.png" /></figure><p>Edit the network settings as follows:</p><ul><li>VPC: <em>EFS_VPC</em></li><li>Subnet: <em>Subnet A</em></li><li>Auto-assign public IP: <em>Enable</em></li><li>Security groups:<em> Select existing security groups (EFS_Client)</em></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xrNxm0isspMSE0404sA17g.png" /></figure><p>Scroll down to the File systems section and select <em>Edit</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*btxSVFHT2VcwgH6jwqjYdg.png" /></figure><p>Under <em>EFS</em>, select the EFS File System you created earlier <em>(CFS_Network_Drive)</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QmeBC_t-OUV1B74SUyJ26Q.png" /></figure><p>Scroll to the bottom and select <em>Launch instance</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/507/1*_AoQTRLjNgTAQVfXxcVpBg.png" /></figure><p>Repeat the same steps you took while launching the first instance <em>(Instance A)</em> to launch a second instance <em>(Instance B)</em>. However, ensure that the second instance is launched in a different subnet <em>(Subnet B) </em>to ensure high availability.</p><p>Wait for a few seconds for both of your instances to start running.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eY8SGpsPCR_MHBSFFIhduQ.png" /></figure><p>Select <em>Instance A</em> and copy its <em>Public IPv4 address</em> onto your clipboard.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mQNiPU0axYxyomSDJJ-Ijg.png" /></figure><h4><em>SSH into your instance (Linux &amp; MacOS)</em></h4><p>Open your terminal and navigate to the directory that contains your key-pair file.</p><pre>cd ~/Downloads</pre><p>Change the permissions on the key to be read-only, by running this command:</p><pre>chmod 400 cfs.pem</pre><p>Run the following command and replace &lt;public-ip&gt; with the EC2 Public IPv4 address you copied earlier.</p><pre>ssh -i cfs.pem ec2-user@&lt;public-ip&gt;</pre><p>For example, if your Public IPv4 address is <em>52.90.60.133</em>, run the command as follows:</p><pre>ssh -i cfs.pem ec2-user@52.90.60.133</pre><p>When prompted to allow the connection, type <em>yes</em> and hit <em>Enter</em>.</p><p>Once you’re done, open another SSH connection into Instance B.</p><h4>SSH into your instance (Windows)</h4><p>For Windows users, you can explore and learn how to SSH into your instance using this <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/putty.html">guide</a>.</p><p>Alternatively, you can use Instance Connect which will automatically open an SSH connection on your Management console.</p><p>To connect, via Instance Connect, select <em>Instance A</em> and click on the <em>Connect</em> button at the top.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mQNiPU0axYxyomSDJJ-Ijg.png" /></figure><p>Select the <em>EC2 Instance Connect</em> tab, scroll to the bottom and select <em>Connect</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jH8TZlHUQ5yIn47W0F5hBA.png" /></figure><p>This opens an SSH connection into your instance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lBOGlIrVg_xeD0dJqQ-LtA.png" /></figure><p>Open another Instance Connection into Instance B.</p><h3>4. Create a new directory and mount the EFS File System</h3><p>In your SSH session, make a new directory called ‘efs’ by entering the following command:</p><pre>sudo mkdir efs</pre><p>Navigate to the EFS page and select the File System’s name.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dgemjugGgrphKQ8cA5ULNQ.png" /></figure><p>At the top right corner, select <em>Attach</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zx5AFkiD8-OHY0E920KyQQ.png" /></figure><p>Select the <em>Mount via IP</em> tab.<br>Availability Zone: <em>us-east-1a</em><br>Copy the command displayed under <em>Using the NFS client</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LIzmq16QbOpNnoQgdPQK9Q.png" /></figure><p>Navigate back to your instance connection, paste and enter the command.</p><p>No output will be displayed once your file system has been successfully mounted.</p><p>Once completed, mount the same file system onto Instance B.</p><p>NOTE: To copy the EFS mount command for Instance B, select <em>us-east-1b</em> (The same AZ where Instance B was launched) as the Availability Zone.</p><p>Navigate into the <em>efs</em> directory on Instance A by entering the following command:</p><pre>cd efs</pre><p>Create a simple text file.</p><pre>sudo touch file.txt</pre><p>You can edit the file using a text editor of your choice.</p><p>Once you’ve created the file, move into the Instance B session, navigate into the efs directory and confirm that the file you created in Instance A appears in Instance B.</p><p>You have now created a file system which both your EC2 instances can access.</p><h3>4. Create an S3 Bucket</h3><p>In this section, you will create a simple S3 bucket and upload some dummy data to simulate an S3 data lake.</p><p>In your Management Console, search for <em>S3</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zSF7QS304dy9VvfjSnxgrg.png" /></figure><p>Select <em>Create Bucket</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*X1YpaElrAmPS5kzdoc9UJQ.png" /></figure><p>Provide a globally unique name for your bucket.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S-I-ZusoSc2k-Z7aebx3sQ.png" /></figure><p>Scroll to the bottom and click on <em>Create bucket</em>.</p><p>Click on the bucket’s name.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ElS81FM7A7wHChWgfcugqw.png" /></figure><p>At the top right corner, select <em>Upload</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WEOiydYmptbgDKCvYa3erQ.png" /></figure><p>Upload some dummy data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KYnITbz1BxyxYOTbtgHF9g.png" /></figure><h3>5. Create a DataSync Task</h3><p>Finally, you will create a DataSync task that will be configured to copy data from your S3 bucket to your EFS file system.</p><p>Navigate to the Management Console and search for <em>DataSync</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g4TZk3gao1fBd-HhOxnFTQ.png" /></figure><p>On the left navigation bar, select <em>Tasks</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/413/1*iUYKMGzkChIu9DnKw0Q3rA.png" /></figure><p>Select <em>Create Task</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qeJCmSyOMTuoMZ4cGd529w.png" /></figure><p>For the <em>Source location options</em>, select <em>Create a new location</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VeedngYd3wKBwivKI_uFXA.png" /></figure><p>Configure the following settings:</p><ul><li>Location type: <em>Amazon S3</em></li><li>Region: <em>us-east-1</em> (<em>select the region where you launched your bucket)</em></li><li>S3 bucket: <em>&lt;select the bucket that you created in the previous section&gt;</em></li><li>IAM role: <em>Autogenerate</em></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J_nTT3zU0nLx3HlzlnZlLQ.png" /></figure><p>Create the following tag</p><ul><li>Key: <em>Name</em></li><li>Value: <em>DataSync_Source_Location</em></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eVo81PhsjGN06dsRGCaAtw.png" /></figure><p>Click on <em>Next</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SKs2qBTr2B6JFzL6nRdLTQ.png" /></figure><p>For <em>Destination location options</em>, select <em>Create a new location</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m3i5J_0dN_F-v6F39sclpg.png" /></figure><p>Configure the following settings:</p><ul><li>Location type: <em>Amazon EFS file system</em></li><li>Region: <em>us-east-1 &lt;select the region where you launched your file system&gt;</em></li><li>File system: <em>CFS_Network_Drive</em></li><li>Subnet: <em>Subnet A</em></li><li>Security groups: <em>EFS_Client</em></li><li>In-transit encryption: <em>None</em></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/949/1*DgHMqesumhUrLUVRAH7AzQ.png" /></figure><p>Create the following tag.</p><ul><li>Key: Name</li><li>Value: DataSync_Destination_Location</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dOv1kQsl2bCzG52vRZUPWQ.png" /></figure><p>Click on <em>Next</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*66W4kPqYjWdyOSrn6CwaPQ.png" /></figure><p>Configure the following settings:</p><ul><li>Task name: <em>S3_EFS_Transfer</em></li><li>Contents to scan: <em>Everything</em></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GCpXY-3BRGfeqqxkN5aN8w.png" /></figure><p>Configure the following settings under <em>Transfer options</em>.</p><ul><li>Transfer mode: <em>Transfer only data that has changed</em></li><li>Verification: <em>Verify only the data transferred</em></li><li>Bandwidth limit: <em>Use available</em></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RIBviYz16U93Y_Sk0T-34A.png" /></figure><p>Schedule the frequency to occur once every hour.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XbszHAdknMQHDAPL6yEIqA.png" /></figure><p>Scroll to the bottom and click <em>Next</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VZkFOgWFmY0XZyd43277Xw.png" /></figure><p>Review your task configurations and click on <em>Create task</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iRI1yhDzsL0QYKHA5-g0hg.png" /></figure><p>Your task should be successfully created.</p><p>To execute your task, select the task you’ve just created, navigate to <em>Actions</em> and select <em>Start</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Vv3LMHiaTAtvX5LkN446cw.png" /></figure><p>Your task will take a few minutes to execute.</p><p>Once the task is done executing, navigate to the left navigation panel and select Task history.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/415/1*RLlGsnBq_vAtH61Y7clzcQ.png" /></figure><p>A history of your task executions will be displayed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CKS3lFuXgfg8X1Qa5Xc1hw.png" /></figure><p>To confirm that the S3 objects were transferred to your EFS File System, navigate back to your Instance connection (assuming you’re still connected) and run the <strong><em>ls</em></strong> command.</p><p>Verify that your S3 objects appear in your file system in both instances.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/448/1*oV7Hw76C_mW3Mox_VBEJ_g.png" /></figure><p>Your S3 data has now been transferred to EFS</p><h3>Conclusion</h3><p>Using Amazon EFS, you have configured a network file system that you can mount and access from your EC2 instances. You have also utilized AWS DataSync to help sync data in your S3 to be used by your NFS share for your workloads.</p><p>As an alternative to DataSync, you can consider exploring manual transfer via the CLI or SDKs.</p><p>I hope you found this extensive walk-through helpful. Feel free to connect with me via <a href="https://www.linkedin.com/in/wamwangi-mathenge/">LinkedIn</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=789b7fc1569d" width="1" height="1" alt=""><hr><p><a href="https://awstip.com/a-guide-to-integrating-amazon-efs-and-s3-for-shared-workloads-789b7fc1569d">A Guide to Integrating Amazon EFS and S3 for Shared Workloads</a> was originally published in <a href="https://awstip.com/">AWS Tip</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Step-by-step Walk-through to Implementing an Inventory Tracking System using AWS Serverless…]]></title>
            <link>https://awstip.com/a-step-by-step-walk-through-to-implementing-an-inventory-tracking-system-using-aws-serverless-ba4a8cde6e6d?source=rss-1a88380b4fb2------2</link>
            <guid isPermaLink="false">https://medium.com/p/ba4a8cde6e6d</guid>
            <category><![CDATA[lambda]]></category>
            <category><![CDATA[serverless]]></category>
            <category><![CDATA[serverless-architecture]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[awsserverless]]></category>
            <dc:creator><![CDATA[Brian Mathenge]]></dc:creator>
            <pubDate>Wed, 17 Jan 2024 13:06:06 GMT</pubDate>
            <atom:updated>2024-01-19T13:19:52.246Z</atom:updated>
            <content:encoded><![CDATA[<h3>A Step-by-step Walk-through to Implementing an Inventory Tracking System using AWS Serverless Technology</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/881/1*AefNeBTrb1EGBqWjzPJZkw.png" /><figcaption>Image credits: Stackify</figcaption></figure><h3><strong>Introduction</strong></h3><p>Serverless is a cloud computing model that allows developers to create and run code without managing servers or infrastructure.</p><p>AWS not only handles the underlying infrastructure, but also automatically scales and provisions resources based on your application needs.</p><p>Some of the use cases of serverless computing include batch processing, real-time data analytics and business process automation.</p><p>This article demonstrates how to create an inventory tracking system by triggering a Lambda function when an inventory file is uploaded to Amazon S3. The Lambda function loads the inventory data into an Amazon DynamoDB table. After completion of this project, you will enable users to receive an email notification when an item is out of stock by creating an SNS topic. The solution architecture is as shown below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gCRE6TRhuqNDrMh9w-Gf1Q.png" /></figure><h3>Prerequisites</h3><p>To get the most out of this guide, you should have an AWS account and a basic understanding of AWS services.</p><p>Proficiency in Python will be also be helpful.</p><p>The resources you’ll need for this walk-through can be found <a href="https://github.com/wamwangi-mathenge/Lambda_serverless">here</a>.</p><h3>1. Create IAM Roles for Lambda Functions</h3><p>Your first task will be to create an IAM Role for Lambda that gives it permission access your S3 buckets and DynamoDB. Lambda will also require permissions to send a notification to Amazon SNS.</p><p>Open your AWS console and search for <strong><em>IAM</em></strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Uxm9EyZX_SXjxx8dLwa6GA.png" /></figure><p>In the left navigation bar, select <strong><em>Roles</em></strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/398/1*50fWoAi24yTQTeWTZ7WrHQ.png" /></figure><p>Click on <strong><em>Create Role</em></strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SmDwLVGUbakIs0RyHOLToQ.png" /></figure><p>Select <strong><em>AWS service</em></strong> as the <strong><em>Trusted entity type</em></strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Y3HHsXJQS30YzjH9_jdORQ.png" /></figure><p>Select <strong><em>Lambda</em></strong> as the <strong><em>Service or use case</em></strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zCwiwJtDM_E0Y_h-ht4PBw.png" /></figure><p>Click on <strong><em>Next</em></strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hjW9ZD55iZKx82XF0fq_AQ.png" /></figure><p>Search for and add the following permissions:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BxIFn0hIKrj40fcE3N7D5g.png" /></figure><p>Click on <strong><em>Next</em></strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YEcPFAJ7uGE_cGtAz5myKA.png" /></figure><p>Configure the following settings:</p><ul><li>Role name: <strong><em>Lambda-Check-Stock-Role</em></strong></li><li>Description: <strong><em>Allows Lambda to send a notification to Amazon SNS</em></strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TM-ERF60ORuKYqKt819Z2w.png" /></figure><p>Click on <strong><em>Create Role</em></strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1Vu_u1zCR1mq6o5C-Rgv8A.png" /></figure><p>Create an additional Lambda role and configure it as follows:</p><ul><li>Trusted entity type: <strong><em>AWS service</em></strong></li><li>Service or use case: <strong><em>Lambda</em></strong></li><li>Permissions:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZDK_lglt13C_jft8ochHsQ.png" /></figure><ul><li>Role Name: <strong><em>Lambda-Load-Inventory-Role</em></strong></li><li>Description: <strong><em>Gives the Lambda function permissions to access S3 and DynamoDB.</em></strong></li></ul><h3>2. Create a Lambda function that loads the inventory data</h3><p>Open your AWS console and search for <strong><em>Lambda</em></strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*D1HPDbBV6AKvz1SrCdC9mg.png" /></figure><p>Click on <strong><em>Create Function</em></strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*enDw2eL5qtbFebnEsQ_bNQ.png" /></figure><p>Select <strong><em>Author from scratch</em></strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5e1H2l4wtNEeTinOjOAyfg.png" /></figure><p>Configure the following settings:</p><ul><li>Function name: <strong><em>Load-Inventory</em></strong></li><li>Runtime: <strong><em>Python 3.8</em></strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t3tJmZ0TQwyqXnF3uTFNcQ.png" /></figure><p>In the <strong><em>Permissions</em></strong> section, tick the <strong><em>Use an existing role</em></strong> option and select <strong><em>Lambda-Load_inventory-Role</em></strong> as the <strong><em>Existing Role</em></strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dkgP-v0yADvV5Rc1b8oMWA.png" /></figure><p>Click on <strong><em>Create Function</em></strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ReqJH8AOXhLixDCzber5nA.png" /></figure><p>You will receive a success message once the function has been created.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8TQpwfa2vdG46JREfoGCdg.png" /></figure><p>Scroll down to the <strong><em>Code source</em></strong> section and open the <strong><em>lambda_function.py</em></strong> file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*riri1HRFga8mlegkbOAJ_w.png" /></figure><p>Delete the code in the file and paste in the code below:</p><pre># Load-Inventory Lambda function<br>#<br># This function is triggered by an object being created in an Amazon S3 bucket.<br># The file is downloaded and each line is inserted into a DynamoDB table.<br>import json, urllib, boto3, csv<br># Connect to S3 and DynamoDB<br>s3 = boto3.resource(&#39;s3&#39;)<br>dynamodb = boto3.resource(&#39;dynamodb&#39;)<br># Connect to the DynamoDB tables<br>inventoryTable = dynamodb.Table(&#39;Inventory&#39;);<br># This handler is run every time the Lambda function is triggered<br>def lambda_handler(event, context):<br>  # Show the incoming event in the debug log<br>  print(&quot;Event received by Lambda function: &quot; + json.dumps(event, indent=2))<br>  # Get the bucket and object key from the Event<br>  bucket = event[&#39;Records&#39;][0][&#39;s3&#39;][&#39;bucket&#39;][&#39;name&#39;]<br>  key = urllib.parse.unquote_plus(event[&#39;Records&#39;][0][&#39;s3&#39;][&#39;object&#39;][&#39;key&#39;])<br>  localFilename = &#39;/tmp/inventory.txt&#39;<br>  # Download the file from S3 to the local filesystem<br>  try:<br>    s3.meta.client.download_file(bucket, key, localFilename)<br>  except Exception as e:<br>    print(e)<br>    print(&#39;Error getting object {} from bucket {}. Make sure they exist and your bucket is in the same region as this function.&#39;.format(key, bucket))<br>    raise e<br>  # Read the Inventory CSV file<br>  with open(localFilename) as csvfile:<br>    reader = csv.DictReader(csvfile, delimiter=&#39;,&#39;)<br>    # Read each row in the file<br>    rowCount = 0<br>    for row in reader:<br>      rowCount += 1<br>      # Show the row in the debug log<br>      print(row[&#39;store&#39;], row[&#39;item&#39;], row[&#39;count&#39;])<br>      try:<br>        # Insert Store, Item and Count into the Inventory table<br>        inventoryTable.put_item(<br>          Item={<br>            &#39;Store&#39;:  row[&#39;store&#39;],<br>            &#39;Item&#39;:   row[&#39;item&#39;],<br>            &#39;Count&#39;:  int(row[&#39;count&#39;])})<br>      except Exception as e:<br>         print(e)<br>         print(&quot;Unable to insert data into DynamoDB table&quot;.format(e))<br>    # Finished!<br>    return &quot;%d counts inserted&quot; % rowCount</pre><p>The above python code performs the following:</p><ul><li>Downloads the file from the S3 bucket.</li><li>Loops through each line in the file and inserts the data into the DynamoDB Inventory table.</li></ul><p>Click on <strong><em>Deploy</em></strong> to save your changes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AiqqTlNDnCnOFCOgrbEh1Q.png" /></figure><p>You have now successfully created a Lambda function to load data.</p><h3><strong>3. Configure an S3 Event</strong></h3><p>Your next step will be to configure Amazon S3 to trigger the Lambda function when an inventory file is uploaded.</p><p>Open the <strong><em>AWS Management Console</em></strong> on a new tab and search for <strong><em>S3</em></strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*piyrMdZVXH2zaTtrjY3mTw.png" /></figure><p>Click on <strong><em>Create Bucket</em></strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*En8oBChR_IlMYxSyjwHUCA.png" /></figure><p>Provide a unique bucket name.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bLoWP6V2GSUSCxwyxhu_dQ.png" /></figure><p>Scroll down and click on <strong><em>Create Bucket</em></strong>.</p><p>NOTE: If you receive an error that states:<strong><em> The requested bucket name is not available</em></strong>, edit the bucket’s name and provide a unique name. Your S3 Bucket’s name is required to be globally unique otherwise the bucket cannot be successfully created.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JrMwGcEzUYyADm6Bn9e0QA.png" /></figure><p>Select the bucket you’ve just created.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4RuLU27Tvt-tvYKFyi87ZQ.png" /></figure><p>Move to the <strong><em>Properties</em></strong> tab.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xpJ_zRMCIX64bHoPA_iIjw.png" /></figure><p>Scroll down to <strong><em>Event notifications</em></strong> and click on <strong><em>Create event notification</em></strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jj0hUiI_GHe2z5GVDk__LA.png" /></figure><p>Event name: <strong><em>Load-Inventory</em></strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0zla3z6ZqR23MEP7FXu0ZQ.png" /></figure><p>Scroll to <strong><em>Object creation</em></strong> and tick the <strong><em>All object create events</em></strong> checkbox.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L4hkwBUGLqr0700nm8-cQA.png" /></figure><p>Scroll down to the <strong><em>Destination</em></strong> section and configure the following settings:</p><ul><li>Destination: <strong><em>Lambda function</em></strong></li><li>Specify Lambda function: <strong><em>Choose from your Lambda functions</em></strong></li><li>Lambda function: <strong><em>Load-Inventory</em></strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gFZnYXSfNauWzK6E3Ozvmw.png" /></figure><p>Scroll to the bottom and click on <strong><em>Save changes</em></strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*193pqjMVrPwPfqcDb1t8Aw.png" /></figure><p>With this event notification in place, the <strong><em>Load-Inventory</em></strong> Lambda function is triggered when an inventory file is uploaded to the bucket.</p><h3><strong><em>4. Test the Loading Process</em></strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GyNXxILl6_lbP-q8YoW-ug.png" /></figure><p>Download the following inventory files:</p><ul><li><a href="https://github.com/wamwangi-mathenge/Lambda_serverless/blob/main/Inventory_Files/inventory-berlin.csv">inventory-berlin.csv</a></li><li><a href="https://github.com/wamwangi-mathenge/Lambda_serverless/blob/main/Inventory_Files/inventory-calcutta.csv">inventory-calcutta.csv</a></li><li><a href="https://github.com/wamwangi-mathenge/Lambda_serverless/blob/main/Inventory_Files/inventory-karachi.csv">inventory-karachi.csv</a></li><li><a href="https://github.com/wamwangi-mathenge/Lambda_serverless/blob/main/Inventory_Files/inventory-pusan.csv">inventory-pusan.csv</a></li><li><a href="https://github.com/wamwangi-mathenge/Lambda_serverless/blob/main/Inventory_Files/inventory-shanghai.csv">inventory-shanghai.csv</a></li><li><a href="https://github.com/wamwangi-mathenge/Lambda_serverless/blob/main/Inventory_Files/inventory-springfield.csv">inventory-springfield.csv</a></li></ul><p>You will use these files to test the system.</p><p>Return to your S3 bucket, select the Object tab and click on <strong><em>Upload</em></strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Y_nFjwhr2P8RYwa6MNU6eg.png" /></figure><p>Upload <strong><em>any</em></strong> of the inventory files you just downloaded.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S6Q5EScAVpZkGxr3propOQ.png" /></figure><p>Click on <strong><em>Upload.</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ojU91hni2vIHGOiTOBqU6Q.png" /></figure><p>Amazon S3 will automatically trigger the Lambda function which will in turn load the data into a DynamoDB table.</p><h3>5. View the Data on DynamoDB</h3><p>Open the AWS Management Console on a new browser tab and search for <strong><em>DynamoDB</em></strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*19K-ewPoJVWtCPNz3eah3A.png" /></figure><p>Select <strong><em>Tables</em></strong> on the left navigation bar.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/423/1*yZCoEhppduMi_HmL-DPXiQ.png" /></figure><p>Select the Inventory table displayed</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sl80QmpIs_ma1D0ylFreZA.png" /></figure><p>Click on the <strong><em>Actions</em></strong> drop-down menu and select <strong><em>Explore items</em></strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/653/1*M2Bd-88SIqNdPoN54DnJdw.png" /></figure><p>The data from the inventory file you uploaded will be displayed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bkiuBlpR130CwvGD5vvYIQ.png" /></figure><h3>6. Configure Inventory Notifications</h3><p>Amazon SNS (Amazon Simple Notification Service) is an online service that manages the transmission of messages to subscribed clients or endpoints.</p><p>In this next task, you will use Amazon SNS to notify management staff when the store runs out of stock for an item.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jgfAtwOOYT76-AIYoYlJWA.png" /></figure><p>Open the AWS Management Console on a new browser tab and select <strong><em>SNS</em></strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lGSPYoJGmN6qKRVHHutdig.png" /></figure><p>Click on <strong><em>Create Topic</em></strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KNL26jsoYBr26Y1nHAb6AA.png" /></figure><p>Select <strong><em>Standard</em></strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5z2moEG3MVd-xTRrC6mPwA.png" /></figure><p>Name: <strong><em>NoStock</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6gCYkxeFZ_vRypjWTWt75Q.png" /></figure><p>Scroll down and click on <strong><em>Create topic</em></strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ion2YnOiG1BHmg8kW2LVcA.png" /></figure><p>Once you’ve created the topic, move to the <strong><em>Subscriptions</em></strong> tab and click on <strong><em>Create Subscription</em></strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xa1b4aWaioJO6NtofEhf4g.png" /></figure><p>Configure the following settings:</p><ul><li>Protocol: <strong><em>Email</em></strong></li><li>Endpoint: <strong><em>Enter your email address</em></strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AJ27efuCAs7h1Pqs6-Nj1A.png" /></figure><p>Click on <strong><em>Create subscription</em></strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pBmJqSZroq1yYq6Z-WqyTw.png" /></figure><p>After creating the subscription, you will receive a confirmation email message.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GjQEdcTP8UT0JRpYQtnj4g.png" /></figure><p>Click on the <strong><em>Confirm subscription</em></strong> link.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/815/1*7N5hOW542D-JXql8Yua5Aw.png" /></figure><p>You’ve now successfully created an SNS topic. You will now receive an email for any message that is sent to the SNS topic.</p><h3>7. Create a Lambda function that checks inventory levels</h3><p>Your next task will be to create a Lambda function checks inventory levels and sends a notification through SNS if it notices that an item is out of stock.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3hLna0aqLjVuKsK4laCPVQ.png" /></figure><p>Return to the Management Console and select <strong><em>Lambda</em></strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*33e7e_dtjsCcvAkp3DWddQ.png" /></figure><p>Click on <strong><em>Create function</em></strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NndGbDQNPQEjVh15Ye4l9Q.png" /></figure><p>Select <strong><em>Author from scratch</em></strong> and configure the following settings.</p><ul><li>Function name: <strong><em>Check-Stock</em></strong></li><li>Runtime: <strong><em>Python 3.8</em></strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*z5IU1l_TDUMn9c2yPPJMhg.png" /></figure><p>In the <strong><em>Permissions</em></strong> section, tick the <strong><em>Use an existing role</em></strong> option and select <strong><em>Lambda-Check-Stock-Role</em></strong> as the <strong><em>Existing Role</em></strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GZYOBM5IHtY73vPWZeoeTQ.png" /></figure><p>Click on <strong><em>Create function</em></strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*a6pAuv2XtS9RsNk4S_khIg.png" /></figure><p>In the <strong><em>Code source</em></strong> section, open the <strong><em>lambda_function.py</em></strong> file, delete all the code and paste in the code below.</p><pre># Stock Check Lambda function<br>#<br># This function is triggered when values are inserted into the Inventory DynamoDB table.<br># Inventory counts are checked and if an item is out of stock, a notification is sent to an SNS Topic.<br>import json, boto3<br># This handler is run every time the Lambda function is triggered<br>def lambda_handler(event, context):<br>  # Show the incoming event in the debug log<br>  print(&quot;Event received by Lambda function: &quot; + json.dumps(event, indent=2))<br>  # For each inventory item added, check if the count is zero<br>  for record in event[&#39;Records&#39;]:<br>    newImage = record[&#39;dynamodb&#39;].get(&#39;NewImage&#39;, None)<br>    if newImage:      <br>      count = int(record[&#39;dynamodb&#39;][&#39;NewImage&#39;][&#39;Count&#39;][&#39;N&#39;])  <br>      if count == 0:<br>        store = record[&#39;dynamodb&#39;][&#39;NewImage&#39;][&#39;Store&#39;][&#39;S&#39;]<br>        item  = record[&#39;dynamodb&#39;][&#39;NewImage&#39;][&#39;Item&#39;][&#39;S&#39;]  <br>        # Construct message to be sent<br>        message = store + &#39; is out of stock of &#39; + item<br>        print(message)  <br>        # Connect to SNS<br>        sns = boto3.client(&#39;sns&#39;)<br>        alertTopic = &#39;NoStock&#39;<br>        snsTopicArn = [t[&#39;TopicArn&#39;] for t in sns.list_topics()[&#39;Topics&#39;]<br>                        if t[&#39;TopicArn&#39;].lower().endswith(&#39;:&#39; + alertTopic.lower())][0]  <br>        # Send message to SNS<br>        sns.publish(<br>          TopicArn=snsTopicArn,<br>          Message=message,<br>          Subject=&#39;Inventory Alert!&#39;,<br>          MessageStructure=&#39;raw&#39;<br>        )<br>  # Finished!<br>  return &#39;Successfully processed {} records.&#39;.format(len(event[&#39;Records&#39;]))</pre><p>The above python code does the following:</p><ul><li>Loops through inventory levels.</li><li>Sends a message to the SNS <strong><em>NoStock</em></strong> topic if the inventory count is zero.</li></ul><p>Click on <strong><em>Deploy</em></strong> to save your changes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*THsp8nJ2MMq8mZJZWGNXHA.png" /></figure><p>Scroll up to the <strong><em>Function overview</em></strong> section and click on <strong><em>Add trigger</em></strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iU-dOmYBvwmXHaRoXGP5fg.png" /></figure><p>Select <strong><em>DynamoDB</em></strong> as the trigger.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wjdZmop427TAHyt836-cJg.png" /></figure><p>Select <strong><em>Inventory</em></strong> as the <strong><em>DynamoDB table</em></strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/981/1*BvgK7PTfbp2bFht46lx0Yg.png" /></figure><p>Click on <strong><em>Add</em></strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lBFZJ9GHYCNXsOtwUUsxEA.png" /></figure><p>You have now successfully created a Lambda function that checks for inventory levels.</p><h3>8. Test the Check Inventory System</h3><p>Your final task will be to test the lambda function you’ve just created.</p><p>Navigate back to the Management Console and open the <strong><em>S3</em></strong> dashboard.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hl-k6J2xa_RejqqkY8V6Bg.png" /></figure><p>Select the bucket which you created earlier.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jmmAkFMb9kvouhDHK-sQtQ.png" /></figure><p>Click on <strong><em>Upload</em></strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AsBLg1zfJtN9DdyWo7-EBw.png" /></figure><p>Upload any inventory file.</p><p>NOTE: The list of inventory files can be found <a href="https://github.com/wamwangi-mathenge/Lambda_serverless/tree/main/Inventory_Files">here</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eNaxFeUOK_TOUV33qlP7Ig.png" /></figure><p>Click on <strong><em>Upload</em></strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*r1FuqwEA9PRfSdmkUO_EdQ.png" /></figure><p>Navigate back to the <strong><em>Tables</em></strong> section in <strong><em>DynamoDB </em></strong>and <strong><em>Explore the items</em></strong> in the <strong><em>Inventory</em></strong> table.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nNrmwkcke4ocTcyqfISd1Q.png" /></figure><p>The items returned will include that of the new inventory file you just uploaded.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TYNLlFqass48NqNGoOosjg.png" /></figure><p>Each of the inventory files has one item that was out of stock. After uploading the inventory file, you should also receive an AWS notification via email indicating that an item is out of stock.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fnBFFdTPqQEUV1OIH7tlhw.png" /></figure><h3>Conclusion</h3><p>Congratulations, you have successfully created an inventory tracking system by leveraging AWS Serverless technology. You can explore how to set up notifications for items that are running out of stock or define reorder points for each item to automate restocking. You can also explore how to receive inventory notifications via SMS instead of email.</p><p>I hope you found this extensive walk-through helpful. Feel free to connect with me via <a href="https://www.linkedin.com/in/wamwangi-mathenge/">LinkedIn</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ba4a8cde6e6d" width="1" height="1" alt=""><hr><p><a href="https://awstip.com/a-step-by-step-walk-through-to-implementing-an-inventory-tracking-system-using-aws-serverless-ba4a8cde6e6d">A Step-by-step Walk-through to Implementing an Inventory Tracking System using AWS Serverless…</a> was originally published in <a href="https://awstip.com/">AWS Tip</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Guide to Setting Up and Connecting to MySQL Database on Amazon RDS]]></title>
            <link>https://medium.com/@brian639/a-guide-to-setting-up-and-connecting-to-mysql-database-on-amazon-rds-1d6e50848119?source=rss-1a88380b4fb2------2</link>
            <guid isPermaLink="false">https://medium.com/p/1d6e50848119</guid>
            <category><![CDATA[mysql]]></category>
            <category><![CDATA[relational-databases]]></category>
            <category><![CDATA[aws-cloud]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[amazon-rds]]></category>
            <dc:creator><![CDATA[Brian Mathenge]]></dc:creator>
            <pubDate>Wed, 10 Jan 2024 03:02:19 GMT</pubDate>
            <atom:updated>2024-01-10T03:02:19.222Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*D_T6Eu8YWAzNh0Y1ZpG6Lg.png" /></figure><h3>Introduction</h3><p>Amazon Relational Database Service (Amazon RDS) is a managed service that provides an easy way to set up, run and scale databases in the cloud.</p><p>Amazon RDS supports a variety of database engines for data organization and storage. These engines include Amazon Aurora, PostgreSQL, MySQL, MariaDB, Microsoft SQL Server and Oracle.</p><p>Relational database management tasks such as data migration, backup, recovery and patching are made easier with the help of Amazon RDS.</p><p>This article provides a comprehensive guide for setting up an Amazon RDS instance on AWS and connecting to it using MySQL Workbench. This guide will introduce you to the basics of provisioning and managing a relational database in the cloud.</p><h3>Prerequisites</h3><p>To get the most out of this guide, you should have a basic familiarity of the AWS services as well as the AWS Management Console. Having an active AWS account is highly recommended in order to get the most out of this guide.</p><p>You should have MySQL workbench installed on your machine. An installation guide can be found <a href="https://dev.mysql.com/downloads/workbench/">here</a>. Familiarity with basic SQL is also recommended.</p><p>The services used in this guide will be within the <a href="https://aws.amazon.com/free/?all-free-tier.sort-by=item.additionalFields.SortRank&amp;all-free-tier.sort-order=asc&amp;awsf.Free+Tier+Types=*all&amp;awsf.Free+Tier+Categories=*all&amp;awsf.Free%20Tier%20Types=*all&amp;awsf.Free%20Tier%20Categories=*all">AWS Free Tier</a>.</p><h3>1. Creating an RDS Instance</h3><p>The first step will be to create an RDS instance.</p><p>Login to your AWS console. Click on the search bar at the top of the console and search for RDS.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AMH-j34NbbceWP-JOS0b2Q.png" /></figure><p>In the RDS Console, click on <strong><em>Create Database</em></strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q786TiLOq2-SlySjhP-e2w.png" /></figure><p>Select <strong><em>Standard Create</em></strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gs12R8WBpam42n4Czaa1cg.png" /></figure><p>Select the <strong><em>MySQL</em></strong> engine</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*v0Z93w1eVKgIkasx5cArLQ.png" /></figure><p>There are pre-configured templates to choose from: <strong><em>Production</em></strong>, <strong><em>Dev/Test</em></strong> and <strong><em>Free tier</em></strong>. Select the Production template. As you proceed, you will configure this template within the Free Tier limits.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7fPb2JgSm2WGvRamkDYXyQ.png" /></figure><p>Under the <strong><em>Availability and durability</em></strong> section, click on <strong><em>Single DB instance</em></strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9IFwJqDvghYk67eN-zRbxA.png" /></figure><p>Leave the <strong><em>DB Instance Identifier </em></strong>and <strong><em>Master username</em></strong> as <strong><em>database-1</em></strong> and <strong><em>admin</em></strong> respectively.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9TLQBTyE_nUTCLEJMVI3lQ.png" /></figure><p>Provide and confirm a master password.</p><p><strong>NOTE: </strong>You will later use this password as you connect to the database on MySQL workbench, so keep it handy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7zKlps9FYr3xBFzh6iBS6g.png" /></figure><p>Under Instance configuration, toggle the <strong><em>Include previous generation classes</em></strong> switch, select <strong><em>Burstable classes (Includes t classes)</em></strong> and select <strong><em>db.t2.micro </em></strong>which is<strong> </strong>Free Tier eligible.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jPwHQ130nemkOLh4LwLeUQ.png" /></figure><p>In the <strong><em>Storage</em></strong> section, choose the <strong><em>General Purpose SSD (gp2)</em></strong> storage type and allocate <strong><em>20GiB</em></strong> storage.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1bRkF8SHbYZCVI8wW2IEGw.png" /></figure><p>Scroll to the <strong><em>Connectivity</em></strong> section and select <strong><em>Don’t connect to an EC2 compute resource</em></strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Gm-ZB2mrP5udEvbuEm4vQA.png" /></figure><p>Leave the default options for the <strong><em>VPC</em></strong> and <strong><em>subnet group</em></strong>.</p><p>Enable <strong><em>Public access</em></strong> by clicking on <strong><em>Yes</em></strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4jMxU14dPS5i4keNESzh2A.png" /></figure><p>You will create a new VPC security group. Select <strong><em>Create new, </em></strong>provide a <strong><em>VPC security group name</em></strong> and select <strong><em>No preference</em></strong> for <strong><em>Availability Zone</em></strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*r2qe33ru4nHJmn04VM2bGQ.png" /></figure><p>Scroll to the <strong><em>Database authentication</em></strong> section and select <strong><em>Password authentication</em></strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/820/1*1uy_4766erCO-GLe0xwnxQ.png" /></figure><p>Open the <strong><em>Additional configuration</em></strong> section, and provide an <strong><em>Initial database name</em></strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tkhzdgfkiuQDl7kvtHAPWw.png" /></figure><p>Finally, AWS will provide you with an Estimated Monthly. However, if you selected for a <strong><em>db.t2.micro</em></strong>, you are within the Free Tier limits.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kGUWK6RbkaEVmcqa0PwLfw.png" /></figure><p>Click on <strong><em>Create Database</em></strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3660jhZjDePanZVrSvN5gg.png" /></figure><p>Your RDS instance will be created after a couple of minutes. Wait for the status to read <strong><em>Available</em></strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3NG8fK_KU9Tp5DVq7P7oAQ.png" /></figure><p>Once your database is created, click on the DB identifier. Information about the database such as CPU, Class, Status and Region &amp; AZ is provided.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XyXfgkTJ0a2Cc0hkFTRi-Q.png" /></figure><p>Your next task will be to modify the Security Groups and provide necessary permissions that allow you to connect to the database.</p><p>Scroll down to <strong><em>Connectivity &amp; Security</em></strong> and click on security group under <strong><em>VPC security groups</em></strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kckqIk8-MK8WFqmwWbf17w.png" /></figure><p>Select the security group you created earlier.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jypnX4cREBqSnIvoDNsRPw.png" /></figure><p>Scroll down, select the <strong><em>Inbound rules</em></strong> tab and click on <strong><em>Edit inbound rules</em></strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Byipu4UpP8v6l12AuwRhcQ.png" /></figure><p>Change the <strong><em>Source</em></strong> to <strong><em>Anywhere-IPv</em></strong>4.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CHwQ1KVI-cqzklyPMUABhg.png" /></figure><p>Click on <strong><em>Save rules</em></strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/594/1*gvy2vcWw8mm3ss61YDeRyw.png" /></figure><p>You have now created an RDS instance with the necessary permissions to establish a connection.</p><h3>2. Connecting to the Database</h3><p>Open MySQL workbench on your machine and click on the <strong><em>+</em></strong> sign to establish a connection.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i9rF7ergiHFYV5N60-mh5g.png" /></figure><p>Configure the following settings:</p><ul><li><strong><em>Connection Name:</em></strong> Provide a name for the connection.</li><li><strong><em>Connection Method: </em></strong>Standard (TCP/IP)</li><li><strong><em>Hostname: </em></strong>Copy the RDS instance’s endpoint (The instance’s endpoint can be found under Connectivity &amp; security)</li><li><strong><em>Port:</em></strong> 3306</li><li><strong><em>Username: </em></strong>admin</li><li><strong><em>Password: </em></strong>Click on <strong><em>Store in Keychain</em></strong> and enter<strong><em> </em></strong>the same password as you used when creating the RDS instance.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uGQgCz5c-CHpYzBAAdwoWw.png" /></figure><p>Click on <strong><em>Test Connection</em></strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-ckjlGrxNtpPOtD_FU9VRQ.png" /></figure><p>A success message should pop out indicating that the connection has been successfully made.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/930/1*HI6I04e37SLbMgfkF8l9mA.png" /></figure><p>Click on <strong><em>OK</em></strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eG13RRSt1Q3mef8le68H5g.png" /></figure><p>The new connection will appear under <strong><em>MySQL Connections</em></strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/419/1*R_suZ2L9z0tNwX13ZqZYhQ.png" /></figure><p>You have now successfully connected to your Amazon RDS instance.</p><h3>3. Perform Basic Database Operations</h3><p>Once connected, you can create tables, insert data and run SQL queries to interact with the database.</p><p>Click on the connection you established. An SQL Editor should open up.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aQ2RdWdci9wV1dJYVVnQIQ.png" /></figure><p>Run and execute the following SQL query:</p><pre>CREATE TABLE mytable (<br>  first_name VARCHAR(20),<br>  last_name VARCHAR(20)<br>);</pre><p>Once executed, you can view your tables under <strong><em>Schemas</em></strong> on the navigation bar at the left side of the window.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/687/1*0oKbSgkLSXjNv3g_qf4zFQ.png" /></figure><p>You’ve now performed an SQL operation on your database.</p><h3>4. Resource Cleanup</h3><p>To avoid incurring ongoing charges, terminate the RDS instance after successfully completing this walk-through.</p><h3>Conclusion</h3><p>Well done for learning how to set up an Amazon RDS instance and use MySQL Workbench to connect to it. You can explore how to perform complex SQL queries against your AWS-hosted database.</p><p>I hope you found this guide helpful as I continue to provide you with tips and insights in the world of AWS Cloud. Feel free to connect with me via <a href="https://www.linkedin.com/in/wamwangi-mathenge/">LinkedIn</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1d6e50848119" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Step-by-Step Guide to Hosting Your Static Website on Amazon S3]]></title>
            <link>https://medium.com/@brian639/a-step-by-step-guide-to-hosting-your-static-website-on-amazon-s3-aeb8a68f95f3?source=rss-1a88380b4fb2------2</link>
            <guid isPermaLink="false">https://medium.com/p/aeb8a68f95f3</guid>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[static-website-hosting]]></category>
            <category><![CDATA[aws-s3]]></category>
            <category><![CDATA[static-websites]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Brian Mathenge]]></dc:creator>
            <pubDate>Fri, 05 Jan 2024 15:54:14 GMT</pubDate>
            <atom:updated>2024-01-05T15:54:14.769Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*irSpjoeDRfCSCoRAMWh2wQ.jpeg" /><figcaption>Photo Credits: Adex</figcaption></figure><h3>Introduction</h3><p>Amazon S3 is an object storage service offered by Amazon Web Services (AWS). Amazon S3 allows you to store and protect any volume of data for a range of applications such as mobile applications, enterprise applications, big data analytics and data lakes. Amazon S3 can also be used to host static websites.</p><p>Static websites do not need server-side programming and databases. They contain HTML pages, style-sheets and pictures. This article provides a comprehensive walk-through for hosting a static website on AWS using Amazon S3.</p><h3>Prerequisite</h3><p>To get the most out of this guide, you should have an AWS account and have a basic understanding of the AWS Management Console and AWS services. The service used in this guide is eligible for the <a href="https://aws.amazon.com/free/?all-free-tier.sort-by=item.additionalFields.SortRank&amp;all-free-tier.sort-order=asc&amp;awsf.Free%20Tier%20Types=*all&amp;awsf.Free%20Tier%20Categories=*all">AWS Free Tier</a>.</p><h3>1. Creating an S3 Bucket</h3><p>The first step towards hosting a static website involves creating an S3 bucket.</p><p>Login to your AWS Console. At the top of the Console, click on the search bar and search for <strong><em>S3</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zL8BA_ZPGMeXYNs9DbYETg.png" /></figure><p>In the S3 console, click on <strong><em>Create Bucket</em></strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZJyhsbrbTp68b2Knap9kSw.png" /></figure><p>Give your S3 bucket a unique name. Your S3 Bucket’s name is required to be globally unique otherwise the bucket cannot be successfully created.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*f8teRl-iCZcdnemTTBQO5A.png" /></figure><p>Scroll to the <strong><em>Object Ownership</em></strong> section and select <strong><em>ACLs enabled</em></strong>. Selecting this option ensures that access to your bucket and its contents can be specified using Access Control Lists (ACLs)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Mq5mN-5tnJdQNMVWoN-qAw.png" /></figure><p>Scroll to the <strong><em>Block Public Access settings for this bucket</em></strong> and clear the <strong><em>Block all public access</em></strong> checkbox.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*11bI3n87eKGg-oUeWoNcYA.png" /></figure><p>Make sure to acknowledge the public access settings by selecting the checkbox.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QCI5xxfArwa6eGa0KbiQYQ.png" /></figure><p>Choose <strong><em>Create Bucket</em></strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-V5QiJs6u5DSwTeFoo7w6g.png" /></figure><p>Once your bucket has successfully been created, click on the bucket name.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Kt3E355nUM_pBBlB1Av2KQ.png" /></figure><p>Select the <strong><em>Properties</em></strong> tab.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1017/1*ndc4TD6ZuHjfv8NYBi67lQ.png" /></figure><p>Scroll down to the <strong><em>Static website hosting</em></strong> section.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EPR7lIWwSdXqdM3SEkqucQ.png" /></figure><p>Enable <strong><em>Static Website hosting</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YHy4lxP-_sKK_CuIW3YPhg.png" /></figure><p>Set the <strong><em>Index document</em></strong> as <strong>index.html</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/882/1*mlnd7NhAUXHBlveisxI3KQ.png" /></figure><p>Click on <strong><em>Save Changes</em></strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*f-GLm22rOP3N7U1juwBxKA.png" /></figure><p>You have now created an S3 bucket and configured it to enable static website hosting.</p><h3>2. Uploading Objects to your Bucket</h3><p>The next step involves uploading objects to your newly created bucket.</p><p>In the bucket you’ve created, select the <strong><em>Objects</em></strong> tab.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZEx31KHblD8qXP1otIavow.png" /></figure><p>Click on the <strong><em>Upload</em></strong> button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TzYre6e9VPqFOM2wsMgrSg.png" /></figure><p>Drag and drop the index.html file as well as corresponding its corresponding style-sheet and images. For this guide the files used can be found <a href="https://github.com/wamwangi-mathenge/S3_static_website_hosting">here</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3_ZpA_XkXVFrp66a5QzasA.png" /></figure><p>Click on <strong><em>Upload</em></strong>.</p><p>You have now uploaded the files onto your bucket.</p><h3>3. Enabling Access to the Objects</h3><p>S3 Objects are private by default. To make your website visible, you have to enable public access using ACLs. In the <strong><em>Objects</em></strong> tab, select all the objects you’ve uploaded, click on <strong><em>Actions</em></strong> and select <strong><em>Make public using ACL</em></strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7AxGiucSCW1E6PTqKewCFQ.png" /></figure><p>Finally, to access your static website, select the <strong><em>Properties</em></strong> tab and scroll down to <strong><em>Static website hosting</em></strong> section.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uj2BGVfNCgqMbU0_yi8Bvw.png" /></figure><p>Copy the endpoint displayed and open it on a new browser tab.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FFaKCA1fFLrx57iPzXeeGg.png" /></figure><p>Your static website should now be visible on your browser.</p><h4>Conclusion</h4><p>Congratulations on hosting your static website on Amazon S3. Consider exploring how to use your own domain name to direct users to a static website hosted on Amazon S3. You can use Amazon Route 53 alongside Amazon S3 to accomplish this.</p><p>I hope you found this guide helpful. I will be posting more content on Cloud Computing with greater emphasis on AWS.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aeb8a68f95f3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[JavaScript Essentials: An Introductory Journey into Web Development]]></title>
            <link>https://medium.com/@brian639/javascript-essentials-an-introductory-journey-into-web-development-48557dae3bf7?source=rss-1a88380b4fb2------2</link>
            <guid isPermaLink="false">https://medium.com/p/48557dae3bf7</guid>
            <category><![CDATA[intro-to-javascript]]></category>
            <category><![CDATA[javascript-frameworks]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[javascript-development]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Brian Mathenge]]></dc:creator>
            <pubDate>Tue, 27 Jun 2023 10:30:39 GMT</pubDate>
            <atom:updated>2023-06-30T08:43:50.678Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GujLMJEHRcWkEzpd_aYbaA.jpeg" /><figcaption>Introduction to JavaScript</figcaption></figure><h3>What is JavaScript?</h3><p>JavaScript is a programming language that is used to create dynamic, interactive websites and applications.<br>JavaScript enables users to create modern web applications that allow direct user interaction without repeatedly refreshing the page. It enhances the web application’s interactivity and user-friendliness, allowing for simple website navigation.</p><h4>What Makes JavaScript Popular?</h4><ul><li>There are many resources available for new users to get started with as well as a wealth of existing expertise.</li><li>Unlike languages such as C, JavaScript does not require compilation in order to be run after being written. This makes prototyping a lot quicker.</li><li>JavaScript can be utilized in both front-end and back-end web development.</li><li>JavaScript is a high-level language. In essence, this means that people can read it easily especially if they’ve programmed in other languages.</li><li>Anything you develop using JavaScript will typically operate smoothly on a wide variety of different machines since it is well-optimized.</li><li>Thanks to a ‘library’ of functions that can be added as needed, JavaScript has a vast array of supplementary functionality. JavaScript may therefore be used for almost anything.</li><li>It’s typically not difficult to add new material to a website created entirely in another computer language using JavaScript.</li></ul><h4>What are the most common uses of JavaScript?</h4><ol><li>Web applications: JavaScript communicates directly with web browsers allowing programmers to create quick web applications.</li><li>Web development: JavaScript is used to create web pages. It enables us to add dynamic behavior and additional effects to the website.</li><li>Mobile applications: Cross-platform mobile applications for iOS and Android can be created using JavaScript. React Native is one of the most popular JavaScript frameworks for mobile apps.</li><li>Web servers: JavaScript can be used to build web servers when combined with the Node JS framework.</li><li>Game development: JavaScript may be used to make games when combined with HTML5.</li><li>Presentations: All current web browsers support interactive slide shows and presentations made with the JavaScript libraries Reveal JS and Bespoke JS.</li></ol><h3>Basic JavaScript Syntax</h3><p>JavaScript syntax is the set of guidelines that govern how JavaScript programs are written.</p><h3>JavaScript Variables</h3><p>Data values are stored in variables.<br>Variable declaration is done using the keywords <strong><em>var</em></strong>, <strong><em>let</em></strong> and <strong><em>const</em></strong>.<br>Values are assigned to variables using the equal (=) sign.</p><pre>// How to create variables:<br>var a;<br>let b;<br>const c;<br><br>// How to use variables;<br>a = 2;<br>b = 3;<br>c = 5;</pre><h3>Data Types in JavaScript</h3><p>Data types define the sort of data that can be manipulated and saved by a program.<br>In JavaScript, there are 8 fundamental data types: <strong><em>string</em></strong>, <strong><em>number</em></strong>, <strong><em>bigint</em></strong>, <strong><em>boolean</em></strong>, <strong><em>undefined</em></strong>, <strong><em>null</em></strong>, <strong><em>symbol</em></strong> and <strong><em>object</em></strong>.</p><h4>1. String</h4><p>A string is an assortment of characters. Strings in JavaScript can be enclosed in single quotes, double quotes or backticks.</p><pre>// Using single quotes<br>const greeting1 = &#39;Hello JavaScript&#39;<br><br>// Using double quotes<br>const greeting2 = &quot;Hello JavaScript&quot;<br><br>// Using backticks<br>const greeting3 = `Hello JavaScript`</pre><h4>2. Number</h4><p>All numbers in JavaScript are stored as floating-point decimal values. You can write numbers either with or without decimals.</p><pre>// With decimals<br>const x = 3.69;<br><br>// Without decimals<br>const y = 69;</pre><h4>3. Bigint</h4><p>All integers in JavaScript are kept in a 64-bit floating-point representation. JavaScript BigInt can be used to store integer values that are too large to fit into a standard JavaScript Number.</p><pre>// BigInt Value<br>const bigint1 = 7235659267167105478n</pre><h4>4. Boolean</h4><p>A boolean only has two possible values: true or false.</p><pre>const a = 2;<br>const b = 2;<br>const c = 3;<br><br>(a == b) // Returns true<br>(a == c) // Returns false</pre><h4>5. Undefined</h4><p>The undefined data type represents an unassigned value. A variable’s value will be defined if it is declared but its value is not yet assigned. For instance:</p><pre>let animal;<br>console.log(animal); // undefined</pre><h4>6. Null</h4><p>The unique value null stands for an empty or undefined value. For instance:</p><pre>let number = null;</pre><h4>7. Symbol</h4><p>A symbol is a singular, immutable primitive value. For instance:</p><pre>let value1 = Symbol(&#39;hello&#39;);</pre><h4>8. Object</h4><p>An object data type enables us to store data collections. Object properties are represented using name: value pairs, separated by commas.</p><pre>const dog = {<br>    name: &quot;Rex&quot;,<br>    breed: &quot;German Shepherd&quot;,<br>    age: 5<br>};</pre><p>Visit <a href="https://www.w3schools.com/js/js_datatypes.asp">W3schools</a>, <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures">MDN Docs</a>, <a href="https://www.programiz.com/javascript/data-types">Programiz</a>, and <a href="https://www.javatpoint.com/javascript-data-types">JavaTPoint</a> to learn more about the data types in JavaScript and to go deeper into each one.</p><h3>JavaScript Functions</h3><p>A JavaScript function is a block of code created to carry out a certain task.<br>The procedure must accept input and provide an output in order to be considered a function.</p><p>Declaring a function uses the following syntax:</p><pre>function titleOfFunction () {<br>    // body<br>}</pre><p>For example:</p><pre>function greeting() {<br>    console.log(&quot;Hello JavaScript&quot;);<br>}</pre><p>A function called <em>greeting()</em> has been declared in the program mentioned above. We must call that function in order to utilize it.</p><pre>// calling the function<br>greeting();</pre><p>This was only a quick introduction to functions. You can find out more information about them at <a href="https://www.w3schools.com/js/js_functions.asp">w3schools</a>, <a href="https://www.programiz.com/javascript/function">programiz</a>, <a href="https://www.freecodecamp.org/news/understanding-functions-in-javascript/">freecodecamp</a>, among many other online sites.</p><h3>Manipulating the DOM</h3><p>In your brief experience with JavaScript, you may have encountered the acronym DOM and wondered what it meant.<br>The Document Object Model (DOM), which looks like a tree, depicts the hierarchical relationships between different HTML elements.<br>It can simply be described as a tree of nodes produced by the browser. JavaScript allows for the modification of each node’s particular attributes and methods.<br>When building a web application with HTML and JavaScript, DOM manipulation is a crucial component. To alter or modify an HTML document that will be shown in a web browser, one must interact with the DOM API. This HTML document is editable, meaning that elements can be added, removed, updated, rearranged, etc.<br>By modifying the DOM, we can build web applications that can change the layout of a web page without refreshing it and update the data on it without doing so. Items in the document can be removed, moved, or rearranged at any time.</p><h4>How to Select an Element in the DOM</h4><p>You must choose a specific element in the DOM before you can alter or modify it. There are 6 ways to choose an element from a document using JavaScript’s DOM manipulation:</p><ul><li>getElementById: returns an element whose id corresponds to a string argument. This method of selecting an element is the quickest because element ids are all distinct.</li><li>getElementByClassName: returns a collection of HTML elements with the specified class name in it.</li><li>getElementsByTagName: returns a list of all the components in the document that have the specified tag name, listed in the order of appearance.</li><li>getElementsByName: returns a collection of the elements in which the provided string matches the value of the name attribute.</li><li>querySelector: returns the document’s first element that matches the provided selector. Only the element that matches one, more or all of the specific CSS selectors is returned.</li><li>querySelectorAll: returns a static list of all the elements that match one or more selectors. An empty list is returned if there are no matching elements.</li></ul><p>Visit <a href="https://www.w3schools.com/js/js_htmldom.asp">W3schools</a>, <a href="https://www.freecodecamp.org/news/how-to-manipulate-the-dom-beginners-guide/">freecodecamp</a>, and <a href="https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Client-side_web_APIs/Manipulating_documents">MDN Docs</a> to find out more about using JavaScript to access and edit elements on a web page.</p><h3>JavaScript Libraries and Frameworks</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YKNsJtc9x-kgST6JIYXzKA.png" /><figcaption>JavaScript Libraries and Frameworks</figcaption></figure><p>The front end of the majority of web applications is not written entirely in vanilla JavaScript. One of the growing numbers of open-source JS frameworks and libraries is used by at least 80% of apps created using JavaScript.<br>The React library is by far the most popular of these front-end technologies. The commercial popularity of the Angular and Vue.js frameworks is likewise high.<br>JavaScript libraries and frameworks make it easier to create online apps uisng JavaScript. You can build dynamic, interactive and responsive applications with the help of ready-made components and templates that they offer.<br>The fact that JavaScript libraries and frameworks save you time and effort is one of their key advantages. They offer you code snippets, functions and modules that you can reuse and customize, so you don’t have to build everything from scratch.<br>As they eliminate the distinctions between browsers and devices, they also provide compatibility and cross-browser support.</p><h3>Conclusion</h3><p>We discussed JavaScript’s essential role in web development in this article. We discovered some of JavaScript’s most typical applications as well as what makes it so popular. We covered JavaScript’s fundamental syntax, including variables and data types. Additionally, we discussed the purpose of functions and how to declare and call them. We described the fundamentals of the DOM and it interacts with JavaScript. Finally, we quickly discussed some of the most well-known JavaScript frameworks and libraries and showed how they help streamline development processes and improve functionality.</p><p>However, this article only covers some fundamental concepts in learning JavaScript. Check out the resources at <a href="https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/">freecodecamp</a>, <a href="https://www.w3schools.com/js/">W3schools</a> and <a href="https://www.codecademy.com/catalog/language/javascript">codecademy</a>, among many other online programming resources, to improve your JavaScript skills.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=48557dae3bf7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Technical Writing 101: The Ultimate Guide to Technical Writing]]></title>
            <link>https://medium.com/@brian639/technical-writing-101-the-ultimate-guide-to-technical-writing-e1cbc9ea8c10?source=rss-1a88380b4fb2------2</link>
            <guid isPermaLink="false">https://medium.com/p/e1cbc9ea8c10</guid>
            <category><![CDATA[writing-process]]></category>
            <category><![CDATA[technical-writing]]></category>
            <category><![CDATA[audience-analysis]]></category>
            <category><![CDATA[technical-communication]]></category>
            <category><![CDATA[technical-writing-guide]]></category>
            <dc:creator><![CDATA[Brian Mathenge]]></dc:creator>
            <pubDate>Mon, 19 Jun 2023 13:28:17 GMT</pubDate>
            <atom:updated>2023-06-19T13:28:17.779Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Y2ZwUkjyLf2Yq73NlWhvGA.jpeg" /><figcaption>Technical writing</figcaption></figure><h3>Introduction</h3><p>Technical writing is writing about a particular subject requiring direction, instruction, explanation or clarification. It is a method of communication used by experts and professionals to convey knowledge on specialist subjects.</p><p>The main goal of technical writing is to break down difficult concepts and information and convey it to readers in a way they can easily understand.</p><p>Effective communication is a requirement for good technical writing, and the writer must have a clear idea of the communication process to get the intended response from the reader.</p><h3>Understanding the Writing Process</h3><p>Understanding the problem you are attempting to tackle is a necessary first step in the writing process. This is also known as “Task Analysis”.</p><p>In professional settings, you should think about your target audience, the purpose of their reading, their needs and any documentation requirements.</p><p>Although there are steps and stages, you don’t always move chronologically from one to the next. These processes are frequently iterative, so you might occasionally go back to earlier steps.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*c8DE1vfJiy7UN5Y5UvyA1A.png" /><figcaption>M.J. Curry and A. Hewings “Approaches to teaching writing,” in <em>Teaching Academic Writing: A Toolkit for Higher Education</em>. New York: Routledge, 2003. Used with permission.</figcaption></figure><ul><li>Prewriting: This stage is for coming up with ideas, comprehending other people’s ideas and gathering data.</li><li>Planning: This involves emphasizing and structuring ideas. This could entail mind maps, clustering, lists and outline creation.</li><li>Drafting: This stage involves composing rough drafts of a document with a primary emphasis on the growth, arrangement and elaboration of ideas.</li><li>Reflection: You can set the work aside during the reflection phase and return to it later. Before moving on, you might return to drafting a reflection a few times.</li><li>Peer/tutor review: You can now obtain opinions from others. You may have to go back to the drafting and reflecting stages to address this.</li><li>Revision: In this stage, you are expanding on and making ideas and the text’s structure is more clear. You may have to go back to the drafting and reflecting stages to address this. Return to the planning stage if more research or idea generation is necessary for the project.</li><li>Editing and proofreading: This entails looking for spelling, grammar and punctuation errors.</li></ul><p>When writing, you should “generate ideas” first. Why? You should first assess what you already know as well as your opinions on a topic. Second, you should try to think up some ideas on your own. There are several techniques for coming up with ideas, including brainstorming, free-writing and web research.</p><h3>Audience Analysis</h3><p>The audience is typically considered the most crucial factor during the design, writing and reviewing phases of a technical article. The demands, interests, and backgrounds of the readers of your work should be taken into account as you “adapt” your writing to suit them.</p><p>One of the main issues encountered in professional and technical documents — particularly instructions, where it manifests itself most obviously — is a lack of audience analysis and adaptation.</p><p>In technical writing, an audience analysis aims to identify the traits, requirements and expectations of the readers so that the content can be tailored to match those needs and be easily understood. With the help of audience analysis, a writer can decide on the right level of detail, vocabulary and structure to employ in their writing.</p><p>Your audience’s needs and expectations can be determined and prioritized in four steps:</p><h4>1. Define your audience</h4><p>First, identify your audience and what they expect from your communication. You may have one or more audiences. These include primary, secondary or tertiary, depending on your goal and scope. Primary audiences are the people who utilize or act on your information directly, such as consumers, managers, or decision-makers. Secondary audiences include reviewers, helpers and regulators, as well as anyone who indirectly supports or uses your material. Tertiary audiences are those with a general interest in or stake in your information, such as the media or the general public. You should determine the key attributes of each audience, including their demographics, backgrounds, knowledge, attitudes, and motivations.</p><h4>2. Research your audience</h4><p>Researching your audience involves gathering pertinent and trustworthy information about their wants and expectations. Information can be gathered through a variety of techniques including surveys, interviews, observations and analytics. What are the primary concerns and aspirations of the audience? What are their advantages and disadvantages? How do they interpret and assess your data? What can you do to surpass or satisfy their expectations?</p><h4>3. Analyze your audience</h4><p>To evaluate and arrange the information you gathered, you must analyze your audience. You can examine your data using a variety of methods and tools including SWOT analysis, personas and empathy maps. Finding patterns, trends, gaps and possibilities in your audience’s requirements and expectations is the aim of your analysis. What are the primary concerns and aspirations of the audience? What are their advantages and disadvantages? How do they interpret and assess your data? What can you do to surpass or satisfy their expectations?</p><h4>4. Adapt your communication</h4><p>Finally, adjust your communication to fit your audience’s wants and expectations. Create and deliver information that is clear, pertinent, helpful and entertaining for your audience. What are your communication’s main points and justifications? What voice and manner should you use in your communication? What are some ways to evaluate and enhance your communication?</p><h3>Precise and Concise Communication</h3><p>Precision and conciseness are two essential elements of expert technical communication. All aspects of the technical article, including the general organization, paragraphing, sentence structure, word choice and punctuation, must demonstrate this clarity and precision.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*I-3rHZ7JydBbZJGMshs12g.png" /><figcaption>Created by Alyssa Zicari and Jenna Hildemann</figcaption></figure><p>The 7 C’s of professional communication, when used, will produce writing that is:</p><p>• <strong>Clear: </strong>The reader can immediately understand the goal of a document when it is written clearly. Clear writing also fits vocabulary to the audience, minimizing unneeded jargon and technical terminology while yet being exact</p><p>• <strong>Coherent: </strong>The reader will be able to follow your ideas and your line of reasoning if your writing is coherent. One concept should logically lead to the next.</p><p>• <strong>Concise: </strong>Make use of the fewest words necessary to express the most thought while keeping the writing clear. Refrain from adding extra space, being imprecise, and using unnecessary repetition and redundancy.</p><p>• <strong>Concrete: </strong>Describe your thoughts in detail and utilize precise language to help your audience see what you are trying to convey.</p><p>• <strong>Correct:</strong> Use standard English language and punctuation. Give accurate information and use the proper format and document type for your writing.</p><p>•<strong> Complete:</strong> Provide all the necessary details and respond to all pertinent queries. Your document is more likely to be complete if you are more precise and concrete.</p><p>• <strong>Courteous: </strong>Use a reader-friendly, simple-to-read document. Use considerate language, and an audience-appropriate approach and avoid potentially objectionable vocabulary, usage and tone.</p><h3>Organizing Information Logically and Coherently</h3><p>Studies have shown that people read technical documents most frequently to find quick solutions. As a result, the structure of technical content is essential for readers to swiftly and easily find what they need.</p><p>You can use these guidelines to create well-organized technical documentation:</p><ol><li>Categorize the information into distinct subjects according to the types of content so that users will know what to expect.</li><li>Tasks are typically executed in a specific order, therefore you should also organize them by order of use.</li><li>Separate contextual information from other kinds of information.</li><li>Prioritize primary ideas and subordinate ideas. For instance, you can use repetition or reinforcement to maintain the reader’s attention on the main idea.</li></ol><h3>Review and Revision Process</h3><h4>Peer Review and Feedback</h4><p>Providing comments, ideas and feedback amongst peers is common practice in technical writing. It may be an excellent resource for education, growth and improvement.</p><p>Peer review can help you sharpen your writing abilities, discover fresh viewpoints, and cultivate critical thinking. You can gain insight into the accomplishments and areas for improvement of other writers by reading and assessing their work.</p><p>You can also compare various methods and approaches. You can improve your ideas, supporting evidence, and organizational structure by asking for input from your peers.</p><p>You can also receive constructive criticism, new perspectives, and alternative solutions. As writers share their thoughts, opinions, and experiences, peer feedback can also encourage a sense of community, communication, and collaboration.</p><h4>Self-editing and Proofreading</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/696/1*SbQHBsWFOrx9rXu8gezvfQ.jpeg" /><figcaption>Self-editing and proofreading</figcaption></figure><p>Before publication, proofread your final draft to catch typos, grammatical errors and other writing errors.</p><p>Proofreading is primarily concerned with the technical aspects of writing, whereas editing concentrates on logical flow, tone, readability, and style.</p><p>Whereas it can take time to proofread your work, there are online tools such as Grammarly that can help you swiftly correct typos, incorrect grammar, inconsistent formatting and more.</p><h3>Conclusion</h3><p>Technical writing simplifies the complex. It enables the communication of certain concepts, beliefs, practices, or methods in a way that makes them simple to comprehend or carry out.</p><p>Technical writing is still a highly sought-after ability in the business. Like many other skills, writing requires years of practice to perfect. Technical writers are required to be knowledgeable in the subject matter they are writing about, hence becoming lifelong learners.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e1cbc9ea8c10" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Master the Art of Prompting in ChatGPT]]></title>
            <link>https://medium.com/@brian639/master-the-art-of-prompting-in-chatgpt-e2e790724efc?source=rss-1a88380b4fb2------2</link>
            <guid isPermaLink="false">https://medium.com/p/e2e790724efc</guid>
            <category><![CDATA[prompt]]></category>
            <category><![CDATA[chatgpt-prompting]]></category>
            <category><![CDATA[prompt-engineering]]></category>
            <category><![CDATA[large-language-models]]></category>
            <category><![CDATA[chatgpt]]></category>
            <dc:creator><![CDATA[Brian Mathenge]]></dc:creator>
            <pubDate>Sat, 27 May 2023 12:43:37 GMT</pubDate>
            <atom:updated>2023-05-27T12:43:37.642Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jOkehSgojDKKD1lQIcrYlg.png" /></figure><h3>The Genesis of ChatGPT</h3><p><a href="https://openai.com/">Open AI</a> released the first version of ChatGPT on November 30th 2022.</p><p>ChatGPT is a Large Language Model (LLM) based artificial intelligence chat-bot that was created using OpenAI’s earlier LLMs as a foundation.</p><p>The chatbot that first gained popularity after its release has since been used by millions of people worldwide for a variety of jobs, ushering in a new era of artificial intelligence.</p><h3>What are LLMs?</h3><p>Wikipedia defines a Large Language Model (LLM) as follows:</p><blockquote>A large language model (LLM) is a language model consisting of a neural network with many parameters (typically billions of weights or more), trained on large quantities of unlabeled text using self-supervised learning or semi-supervised learning.</blockquote><p>There are 2 types of LLMs</p><h4>1. Base LLM</h4><p>A base LLM predicts the next word based on text training data.</p><p>Prompt:<em> Once upon a time, there was a young lion called Simba…</em></p><p>Response: …who is to succeed his father Mufasa as King of the Pride Lands.</p><h4>2. Instruction Tuned LLM</h4><p>An instruction based LLM is trained to follow a set of instructions and fine-tunes based on the instructions given.</p><p>The model is refined using a technique known as Reinforcement Learning with Human Feedback (RLHF)</p><p>Prompt: <em>What is the capital of Kenya?</em></p><p>Response: <em>The capital of Kenya is Nairobi.</em></p><p>Instruction tuned LLMs are trained to be benevolent, trustworthy and harmless.</p><h3>Guidelines for Prompting</h3><p><a href="https://openai.com/">OpenAI</a> and <a href="https://www.deeplearning.ai/">DeepLearning.AI</a> suggest 2 principles for effective prompting:</p><ol><li>Write clear and specific instructions.</li><li>Give the model time to think.</li></ol><h3>Writing Clear and Specific Instructions</h3><p>Give directions that are as precise and clear as you can be to convey what you want a model to perform.</p><p>This will help the model provide the intended results and reduce the possibility that you will receive incorrect or irrelevant responses.</p><p>Writing a short prompt should however not be confused with writing a clear prompt.</p><p>Longer prompts typically give the model greater context and clarity, which might result in output that is more specific and pertinent.</p><h4>Tactics to Help Write Clear and Specific Instructions</h4><ol><li>Use delimiters to show distinct input portions. Delimiters include: triple quotes, triple brackets, triple dashes, angle brackets and XML tags. A delimiter is any distinct punctuation that separates some text fragments form the rest of the prompt. Delimiters are also a useful tool for attempting to prevent prompt injections.</li><li>Request for organized output in formats like HTML or JSON to make interpreting the result easier.</li><li>Ask the model to determine if the conditions given are met. Consider possible edge cases and how the model should respond to them to prevent unexpected errors or outcomes.</li><li>Give instances of tasks that were successfully completed, then have the model carry out the task.</li></ol><h3>Give the Model Time to Think</h3><p>Try rephrasing the question to ask for a chain or sequence of pertinent arguments if a model is erroneously arriving at the wrong decision.</p><p>Imagine it as a person attempting to answer a challenging math problem. They are more likely to make a mistake if they don’t have time to think out the solution first.</p><h4>Tactics to Use that Give the Model Time to Think.</h4><ol><li>Describe how to carry out a task.</li><li>Instruct the model to come up with its own solution before making assumptions.</li></ol><h3>Model Limitations</h3><p>Despite being exposed to a great quantity of knowledge during its training process, the language model has not properly memorized the information it has been exposed to. As a result, the model is not fully aware of the limits of its knowledge.</p><p>The model may attempt to address questions about obscure topics and may invent ideas that appear plausible but are untrue.</p><p>These made-up concepts are referred to as hallucinations.</p><h3>Conclusion</h3><p>In conclusion, we have investigated the different types of Large Language Models. Effective prompting techniques must be used in order to maximize the potential of LLMs.</p><p>Two major rules come into play when prompting LLMs. It is crucial to provide the model with explicit and detailed instructions. The possibility of confusing or undesirable outputs is reduced by clear instructions.</p><p>Secondly, we need to accord the model enough time to reflect and come up with a thoughtful solution. By doing this, the model can use its vast knowledge base to deliver answers that are more accurate and well informed.</p><p>These recommendations can help us improve the caliber and potency of our interactions with LLMs. A thoughtful approach to prompting can produce great results and encourage interesting dialogues, whether it involves utilizing prompt engineering techniques or tailoring instructions for certain jobs.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e2e790724efc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Exploring Subqueries in SQL for Data Analytics]]></title>
            <link>https://medium.com/@brian639/exploring-subqueries-in-sql-for-data-analytics-254c6ece1104?source=rss-1a88380b4fb2------2</link>
            <guid isPermaLink="false">https://medium.com/p/254c6ece1104</guid>
            <category><![CDATA[query]]></category>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[subquery]]></category>
            <category><![CDATA[querying]]></category>
            <category><![CDATA[data-analysis]]></category>
            <dc:creator><![CDATA[Brian Mathenge]]></dc:creator>
            <pubDate>Sat, 20 May 2023 13:49:47 GMT</pubDate>
            <atom:updated>2023-05-20T13:49:47.596Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Q2wcAhHaV8BFH0-P39CwzA.png" /></figure><h3>Introduction</h3><p>In <a href="https://medium.com/@brian639/get-started-with-sql-a-beginners-guide-to-querying-databases-ab757e033360">Getting Started with SQL: A Beginner’s Guide to Querying Databases</a>, we looked at how data is retrieved and filtered from databases using queries.</p><p>We can go deeper into queries and look at how we can perform complex and flexible data retrieval procedures by nesting a query inside another query.</p><h3>What are Subqueries?</h3><p>A subquery is a SQL query that is embedded inside another query.</p><p>Subqueries are also known as nested queries or inner queries.</p><p>Thanks to the idea of subqueries, one can utilize the results of one query as input for another query thus enabling you to perform adaptable data procedures.</p><h3>Subqueries with the SELECT statement</h3><p>Subqueries are mostly utilised with the SELECT statement.</p><h4>Basic syntax</h4><pre>SELECT column_name<br>FROM table_name<br>WHERE column_name OPERATOR (<br>   SELECT column_name<br>   FROM table_name<br>   WHERE condition<br>);</pre><p>Breaking down the syntax:</p><ul><li>The outer query which includes the subquery, retrieves data from the table defined in the FROM clause.</li><li>Additional phrases like WHERE, GROUP BY, ORDER BY etc can be added to the outer query.</li><li>The subquery is enclosed within parentheses.</li><li>Depending on the functionality required, the subquery may be included in the WHERE, FROM, SELECT or HAVING clauses of the outer query.</li><li>The subquery begins with the SELECT statement.</li><li>The subquery’s SELECT statement specifies the table columns to be retrieved.</li><li>The subquery is used for data retrieval based on a criterion or comparison.</li><li>The subquery is used for data retrieval based on a criterion or comparison specified using operators such as =, &lt;, &gt;, IN, EXISTS etc.</li><li>When required, the condition in the subquery can refer to columns from the outer query.</li></ul><h4>Example</h4><p>Using the data behind <a href="https://github.com/fivethirtyeight/data/tree/master/college-majors">The Economic Guide to Picking A College Major</a>, we can get the Majors in which the unemployment rate is greater than the average rate of unemployment.</p><pre>SELECT<br>  Major,<br>  Unemployment_rate<br>FROM recent_grads<br>WHERE Unemployment_rate &gt; (<br>  SELECT AVG(Unemployment_rate) AS Average_unemployment<br>  FROM recent_grads<br>)</pre><h3>The IN Operator</h3><p>The IN Operator can be used in place of comparison operators when comparing a value against a list of values.</p><h4>Basic Syntax</h4><pre>SELECT column_name<br>FROM table_name<br>WHERE column_name IN (<br>  SELECT column_name<br>  FROM table_name<br>  WHERE condition<br>);</pre><h3>The EXISTS Operator</h3><p>The EXISTS operator is used to check for the existence of any record in a subquery.</p><p>The operator returns TRUE if the subquery returns one or more records and FALSE otherwise.</p><h4>Basic Syntax</h4><pre>SELECT column_name<br>FROM table_name<br>WHERE EXISTS (<br>  SELECT column_name<br>  FROM table_name<br>  WHERE condition<br>);</pre><h3>The ANY and ALL Operators</h3><p>The ANY and ALL operators are used to compare a single column value and a range of other values.</p><p>The ALL operator compares a value with all values in the result set and returns TRUE if ALL of the subquery values meet the criterion.</p><h4>Basic Syntax</h4><pre>SELECT column_name<br>FROM table_name<br>WHERE column_name OPERATOR ALL (<br>  SELECT column_name<br>  FROM table_name<br>  WHERE condition<br>);</pre><p>The ANY operator compares a value with any value in the result set and returns TRUE if ANY of the subquery values meet the criterion.</p><h4>Basic Syntax</h4><pre>SELECT column_name<br>FROM table_name<br>WHERE column_name OPERATOR ANY (<br>  SELECT column_name<br>  FROM table_name<br>  WHERE condition<br>);</pre><h3>The LIKE Operator</h3><p>The LIKE operator is used to look for a specific pattern in a column</p><p>The LIKE operator is typically used in a WHERE clause.</p><h4>Basic Syntax</h4><pre>SELECT column_name<br>FROM table_name<br>WHERE column_name LIKE (<br>  SELECT column_name<br>  FROM table_name<br>  WHERE condition<br>);</pre><h3>Advantages of using Subqueries</h3><ol><li>Complex logic can be expressed in a way that is easier to understand. Subqueries simplify the SQL code by dissecting a problem into smaller parts.</li><li>Through subqueries, you can reuse queries in multiple contexts by encapsulating functionality in distinct queries. This encourages code modularity and reduces redundancy.</li><li>Subqueries offer flexibility when retrieving data since you can create conditions on the fly based on the outcomes of other queries.</li><li>Through subqueries, you can express sophisticated conditions involving calculations, comparisons and aggregates.</li></ol><h3>Limitations of using Subqueries</h3><ol><li>Subqueries can lead to slower query performance especially when dealing with large datasets or complex logic.</li><li>Multiple levels of nested subqueries can make SQL code more difficult to read and understand.</li><li>Subqueries can lead to code duplication if the same subquery is required in multiple parts of the application.</li><li>There may be variances in the specific syntax and functionality among various database systems. Different database systems may have restrictions on how subqueries can be used or optimized.</li><li>Subqueries cannot be used to directly alter or update database data. To modify data, SQL constructs such as INSERT or UPDATE are needed.</li></ol><p>Subqueries remain a valuable asset in SQL despite these limitations which can be mitigated using effective optimization techniques and carefully considering the query needs.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=254c6ece1104" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Beyond Queries: Empowering Your SQL Skills with Summary and Group Statistics]]></title>
            <link>https://medium.com/@brian639/beyond-queries-empowering-your-sql-skills-with-summary-and-group-statistics-b8cfeff49489?source=rss-1a88380b4fb2------2</link>
            <guid isPermaLink="false">https://medium.com/p/b8cfeff49489</guid>
            <category><![CDATA[statistics]]></category>
            <category><![CDATA[relational-databases]]></category>
            <category><![CDATA[sql-queries]]></category>
            <category><![CDATA[summary-statistics]]></category>
            <category><![CDATA[sql]]></category>
            <dc:creator><![CDATA[Brian Mathenge]]></dc:creator>
            <pubDate>Tue, 16 May 2023 05:10:03 GMT</pubDate>
            <atom:updated>2023-05-16T05:10:51.570Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YSJTewixpGPJDMFWzsR77Q.png" /></figure><h3>INTRODUCTION</h3><p>Data can be sought and acquired from a database through querying. However, a fundamental question of how to interpret the collected data arises.</p><p>This article goes into greater detail on how summary and group statistics can help us understand our data in meaningful and helpful ways.</p><h3>Summary Statistics</h3><p>Summary statistics in SQL offer insights about data and enable users to understand key aspects of the dataset.</p><p>They include basic aggregate functions such as MAX, MIN, SUM, COUNT and AVG.</p><p>We’ll use the data behind <a href="https://github.com/fivethirtyeight/data/tree/master/college-majors">The Economic Guide To Picking A College Major</a> to demonstrate these concepts which will help us understand important aspects of the data.</p><h3>Basic Aggregation Functions</h3><h4>MAX</h4><p>MAX returns the maximum value in a table field.</p><pre>SELECT MAX(column_name)<br>FROM table_name;</pre><p>For example, we can determine the <em>Major</em> with the highest unemployment rate as follows:</p><pre>SELECT Major, MAX(Unemployment_rate)<br>FROM recent_grads;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/556/1*lnD5bL6Jxil_GpJFDv2Jjw.png" /></figure><h4>MIN</h4><p>MIN returns the minimum value in a table field.</p><pre>SELECT MIN(column_name)<br>FROM table_name;</pre><p>For example, we can determine the <em>Major</em> with the lowest unemployment rate as follows:</p><pre>SELECT Major, MIN(Unemployment_rate)<br>FROM recent_grads;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/706/1*npEg8CluK_vLIrkguIuDwA.png" /></figure><h4>SUM</h4><p>SUM returns the total sum of values in a given column.</p><pre>SELECT SUM(column_name)<br>FROM table_name;</pre><p>For example, we can determine the total number of unemployed in the Engineering major category as follows:</p><pre>SELECT SUM(Unemployed)<br>FROM recent_grads<br>WHERE Major_category == &quot;Engineering&quot;;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/215/1*5HuV6RyV4J6Fz_pV5CAPaQ.png" /></figure><h4>COUNT</h4><p>COUNT returns the number of non_null values in a given column.</p><pre>SELECT COUNT(column_name)<br>FROM table_name;</pre><p>For example, we can determine the number of non-null values in the <em>Sample_size</em> column as follows:</p><pre>SELECT COUNT(Sample_size)<br>FROM recent_grads;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/236/1*cBZM19o4aimBpv6VawyXvQ.png" /></figure><h4>AVG</h4><p>AVG returns the mean value of a given column.</p><pre>SELECT AVG(column_name);<br>FROM table_name;</pre><p>For example, we can determine the average sample size used in the dataset as follows</p><pre>SELECT AVG(Sample_size)<br>FROM recent_grads;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/228/1*9jGV_N4bGRyCV0Sh3n8AGg.png" /></figure><h3>Results Customization with AS</h3><p>AS is used to rename the column headers of the result set.</p><p>It assists users in providing more meaningful column names in the results table.</p><pre>SELECT column_name AS new_column_name;<br>FROM table_name;</pre><p>For example:</p><pre>SELECT SUM(Unemployed) AS Total_Unemployed<br>FROM recent_grads<br>WHERE Major_category == &quot;Engineering&quot;;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/217/1*kX4cShY0XD1hy0oCcK45aQ.png" /></figure><h3>Missing Values</h3><p>In some instances, some cells in a database table may not have any values (missing values).</p><p>NULL can be used alongside WHERE to filter records with missing values.</p><pre>SELECT *<br>FROM recent_grads<br>WHERE Unemployment_rate is NULL;</pre><p>The above code returns the column(s) with a missing value in the <em>Unemployment_rate</em> column.</p><h3>Arithmetic Operations in SQL</h3><p>SQL allows you to perform calculations on numeric values in your database.</p><p>SQL supports arithmetic operators such as: Addition(+), Subtraction(-), Multiplication(*), Division(/) and Modulo(%)</p><p>For example, we can calculate the female percentage from the <em>ShareWomen</em> column as follows:</p><pre>SELECT ShareWomen * 100 AS Female_percent;<br>FROM recent_grads;</pre><h3>Group Statistics</h3><p>Group statistics involve calculations performed on data that is grouped by one or more columns.</p><h4>IF/THEN LOGIC</h4><p>The IF/THEN logic is used to perform conditional operations on your data.</p><p>It is used alongside the CASE statement to perform data transformations.</p><pre>SELECT column1, column2,<br>  CASE<br>    WHEN condition1 THEN value1<br>    WHEN condition2 THEN value2<br>    ELSE result3<br>END AS result_column<br>FROM table_name;</pre><p>where:</p><ul><li>CASE =&gt; Start of the conditional statement</li><li>WHEN =&gt; Tests the given condition</li><li>THEN =&gt; Returns the given value if the condition was TRUE</li><li>ELSE =&gt; Fall value in case all conditions above it fail</li><li>END =&gt; End of the conditional statement</li></ul><p>Example 1:</p><p>Suppose we want to indicate whether a Major has a LOW, MEDIUM or HIGH share of women as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/324/1*XDyxF9lP5JnjSBBMetpHxw.png" /></figure><pre>SELECT<br>  ShareWomen,<br>  CASE<br>    WHEN ShareWomen &lt; 0.2 THEN &quot;LOW&quot;<br>    WHEN ShareWomen &lt; 0.5 THEN &quot;MEDIUM&quot;<br>    ELSE &quot;HIGH&quot;<br>  END AS &quot;ShareWomenGroup&quot;<br>FROM recent_grads;</pre><p>Example 2:</p><p>We can write a query that displays with the alias <em>Sample_category</em>, the column with values that are a result of the following rules:</p><ul><li><strong>Small</strong> if Sample_size is smaller than 200</li><li><strong>Medium</strong> if Sample_size is equal to or higher than 200, and smaller than 1000</li><li><strong>Large</strong> if Sample_size is equal to or higher than 1000.</li></ul><pre>SELECT<br>  Major,<br>  Sample_size,<br>  CASE<br>    WHEN Sample_size &lt; 200 THEN &quot;Small&quot;<br>    WHEN Sample_size &lt; 1000 THEN &quot;Medium&quot;<br>    ELSE &quot;Large&quot;<br>  END AS Sample_category<br>FROM recent_grads;</pre><h3>Grouping Data with GROUP BY</h3><p>The GROUP BY clause is used to group rows based on one or more columns.</p><p>GROUP BY enables you to summarize data by creating groups based on a unique category in the column.</p><pre>SELECT column1, column2, aggregate_function(column3)<br>FROM table_name<br>GROUP BY column1, column2;</pre><p>Example</p><p>To get the total number of unemployed for each <em>Major_category</em>:</p><pre>SELECT<br>  Major_category,<br>  SUM(Unemployed) AS Total_unemployed<br>FROM recent_grads<br>GROUP BY Major_category;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/569/1*9nK1NP7nJswpaDjFhaeWaA.png" /></figure><p>We can also calculate multiple statistics for each group. In addition to the total number of unemployed, we can obtain the total number of graduates for each <em>Major_category</em> as well:</p><pre>SELECT<br>  Major_category,<br>  SUM(Unemployed) AS Total_unemployed,<br>  SUM(Total) AS Total_graduates<br>FROM recent_grads<br>GROUP BY Major_catgeory;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/756/1*tTXccYZrG11axLQ4hsVT7w.png" /></figure><h3>Filtering by Aggregate Columns</h3><p>When we want to filter our results based on an aggregate function, we cannot use the WHERE clause due to the <a href="https://www.sisense.com/blog/sql-query-order-of-operations/">order of execution</a>.</p><p>WHERE is always executed before the aggregation takes place.</p><p>We can however use the HAVING clause to group data by an aggregate.</p><pre>SELECT column1, aggregate_function(column2)<br>FROM table_name<br>GROUP BY column1<br>HAVING aggregate_function(column2) &gt; value;</pre><p>Example:</p><p>We can obtain the major categories from our dataset where the total number of unemployed graduates is less than 10000 as follows:</p><pre>SELECT<br>  Major_category,<br>  SUM(Unemployed) AS Total_unemployed<br>FROM recent_grads<br>GROUP BY Major_category<br>HAVING Total_unemployed &lt; 10000;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/537/1*tmo9vu2prpRt8_mREm8Tdg.png" /></figure><h3>CONCLUSION</h3><p>In conclusion, knowing how to use summary statistics in SQL can empower your data analysis skills.</p><p>This article touched on various aspects of summary statistics including aggregate functions such as MAX, MIN, SUM, COUNT and AVG which can be used to calculate key metrics.</p><p>We also looked at applying conditional operations on data using the IF/THEN logic alongside the CASE statement.</p><p>The GROUP BY clause groups data based on one or more columns. Alongside aggregate functions, the GROUP BY clause generates group statistics that shed light on the data properties in each group.</p><p>The HAVING clause allows us to filter the results depending on aggregate columns.</p><p>These concepts in SQL are important in undertaking effective data analysis.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b8cfeff49489" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Get Started with SQL: A Beginner’s Guide to Querying Databases]]></title>
            <link>https://medium.com/@brian639/get-started-with-sql-a-beginners-guide-to-querying-databases-ab757e033360?source=rss-1a88380b4fb2------2</link>
            <guid isPermaLink="false">https://medium.com/p/ab757e033360</guid>
            <category><![CDATA[sql-queries]]></category>
            <category><![CDATA[sqlite]]></category>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[data-analysis]]></category>
            <category><![CDATA[introduction-to-sql]]></category>
            <dc:creator><![CDATA[Brian Mathenge]]></dc:creator>
            <pubDate>Mon, 08 May 2023 11:27:10 GMT</pubDate>
            <atom:updated>2023-05-08T11:27:10.454Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ERxcAG38BXt-sbmBomhSvA.jpeg" /><figcaption>SQL Query</figcaption></figure><p>SQL is used to interact with relational databases. Data is retrieved and filtered from databases using queries.</p><p>Through SQL, specified data can be requested and obtained from a database through a process known as <strong>Querying</strong>.</p><p>We’ll use the data behind <a href="https://github.com/fivethirtyeight/data/tree/master/college-majors">The Economic Guide To Picking A College Major</a> to demonstrate the concepts of SQL Querying.</p><h3>SELECT</h3><p>SELECT is the most fundamental query in SQL.</p><p>We retrieve data from a database using the SELECT query.</p><pre>SELECT *<br>  FROM table_name;</pre><p>For example:</p><pre>SELECT * <br>  FROM recent_grads;</pre><p>In the above query:</p><ol><li><em>SELECT * </em>selects all the columns</li><li><em>FROM recent_grads </em>identifies the table we want to select from.</li></ol><p>NOTE: Whereas we can write the two lines of code in one line, <a href="https://www.sqlshack.com/learn-sql-naming-conventions/">SQL convention</a> dictates that the query should be written in two separate lines with the second line indented.</p><h4>SELECTING SPECIFIC COLUMNS</h4><p>We can also retrieve data from specific columns using the SELECT statement.</p><pre>SELECT column1, column2<br>  FROM table_name;</pre><p>For example:</p><pre>SELECT Total, Major <br>  FROM recent_grads;</pre><p>The above query returns the ‘<em>Total’ and </em>‘<em>Major’ </em>columns from the ‘<em>recent_grads’</em> table .</p><h3>LIMIT</h3><p>The LIMIT query restricts the number of rows that a SELECT column can return.</p><p>LIMIT is ideal when working with large databases as it makes queries run faster while also saving on-screen space.</p><pre>SELECT column1 <br>  FROM table_name<br>LIMIT number_of_rows;</pre><p>For example:</p><pre>SELECT * <br>  FROM recent_grads <br>LIMIT 5;</pre><p>The above query returns the first 5 rows from the ‘<em>recent_grads’</em> table.</p><h3>WHERE</h3><p>The WHERE query filters a SELECT statement’s data based on given criteria.</p><p>The WHERE keyword is used to specify the criteria which the data must satisfy in order for it to be returned.</p><pre>SELECT column1 <br>  FROM table_name <br>  WHERE criteria;</pre><p>For example:</p><pre>SELECT Major<br>  FROM recent_grads <br>  WHERE Total &lt; 1000;</pre><p>The above query will return the <em>‘Major’</em> column from the ‘<em>recent_grads’</em> table where the total number is less than 1000.</p><p>The <a href="https://dev.mysql.com/doc/refman/8.0/en/comparison-operators.html">comparison operators</a> that can be used alongside the WHERE clause include the following:</p><ol><li>Less than (&lt;)</li><li>Greater than (&gt;)</li><li>Less than or equal to (≤)</li><li>Greater than or equal to (≥)</li><li>Equal to (=)</li><li>Not equal to (!=) or (&lt;&gt;)</li></ol><h4><strong><em>MULTIPLE FILTER CRITERIA</em></strong></h4><p>We can combine multiple filter conditions using <a href="https://dev.mysql.com/doc/refman/8.0/en/logical-operators.html">Logical Operators</a>.</p><pre>SELECT Major <br>  FROM recent_grads <br>  WHERE Major_category = &quot;Engineering&quot; AND ShareWomen &lt; 0.5;</pre><p>The above query will return the <em>‘Major’</em> column from the ‘<em>recent_grads’</em> table whose Major is Engineering and with a less proportion of women than men.</p><p>Some of the most common used logical operators include AND, OR as well as NOT.</p><h3>ORDER BY</h3><p>The ORDER BY query sorts a SELECT statement’s data in ascending or descending order based on one or more columns.</p><pre>SELECT column1<br>  FROM table_name<br>  ORDER BY column_name [ASC|DESC];</pre><p>For example:</p><pre>SELECT Major, Major_category, Unemployed<br>  FROM  recent_grads<br>  ORDER BY Unemployed DESC;</pre><p>The above query will retrieve the ‘<em>Major’</em>, ‘<em>Major_category’</em> and ‘<em>Unemployed’ </em>columns from the ‘<em>recent_grads’</em> table and order them by the number of ‘<em>Unemployed’</em> in descending order.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ab757e033360" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>