<?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 James Williamson on Medium]]></title>
        <description><![CDATA[Stories by James Williamson on Medium]]></description>
        <link>https://medium.com/@jawilliamson25?source=rss-76b11c604c11------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*S8StVdDmazUmX2dExgtSGQ.jpeg</url>
            <title>Stories by James Williamson on Medium</title>
            <link>https://medium.com/@jawilliamson25?source=rss-76b11c604c11------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 15:18:05 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@jawilliamson25/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[Using Docker Compose for managing a CI/CD Pipeline with Jenkins Containers]]></title>
            <link>https://medium.com/@jawilliamson25/using-docker-compose-for-managing-a-ci-cd-pipeline-with-jenkins-containers-0523832fa9cf?source=rss-76b11c604c11------2</link>
            <guid isPermaLink="false">https://medium.com/p/0523832fa9cf</guid>
            <category><![CDATA[jenkins]]></category>
            <category><![CDATA[ci-cd-pipeline]]></category>
            <category><![CDATA[docker-compose]]></category>
            <category><![CDATA[docker]]></category>
            <dc:creator><![CDATA[James Williamson]]></dc:creator>
            <pubDate>Mon, 11 Mar 2024 02:10:14 GMT</pubDate>
            <atom:updated>2024-03-11T02:10:14.979Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2G5KOQVzqVIbxxxeKECZkA.jpeg" /></figure><p>For this dive into docker, we are going to be learning how to utilize Docker Compose in order to create a Jenkins container with an attached persistent volume so we can build a scalable CI/CD pipeline in order to facilitate frequent and reliable deployment of software updates!</p><p><strong>Prerequisities:</strong></p><ol><li>Basic understand of docker CLI commands</li><li>Basic understanding of the docker compose template and the .yml formatting</li><li>We will be working on an EC2 instance on AWS running Ubuntu, however you may use a local linux distro as well. You will replace the IP address in the url bar with “localhost” rather than the public IP of the EC2 instance if using a local machine.</li><li>If using an AWS EC2 instance you will need an understanding of how to SSH into your instance. We will begin assuming you are already connected. I will be using Visual Studio Code to do so, however you can use Powershell if using windows or your CLI on your machine. Here is a quick video if you’d like to use VSC: <a href="https://www.youtube.com/watch?v=elkL1OF9fxI">https://www.youtube.com/watch?v=elkL1OF9fxI</a></li></ol><p><strong>Section One: Creating our docker compose file</strong></p><p>Once you are in your command line, we are going to quickly create a directory to work out of, as docker compose must be ran out of the location where your compose file is stored. It is easier to just create a test directory to work out of. To do so use the following command:</p><pre>mkdir compose-project &amp;&amp; cd compose-project</pre><p>Adding the &amp;&amp; just saves you from having to use another line to navigate to the directory.</p><p>Now that you are in the proper place, lets use the following command to create our compose file.</p><pre>touch docker-compose.yml</pre><p>Now lets open this file in vim in order to create enter our information into it.</p><pre>vi docker-compose.yml</pre><p>Once in the text editor, we need to do a few things.</p><ol><li>We need to specify out version</li><li>We need to specify our services (in this case it will be Jenkins</li><li>We need to specify the image which will be Jenkins LTS</li><li>We need to open the proper ports in order to connect to our container. These will be 8080 and 50000. 8080 is the port used by Jenkins for the web interface and 50000 is the port use by Jenkins’ for agent connections. You can find port documentation here: <a href="https://hub.docker.com/_/jenkins">https://hub.docker.com/_/jenkins</a></li><li>We need to create a persistent volume that will last even when we stop the container. You can also find the volume path you will need to use in the documentation above. It is /var/jenkins_home</li></ol><p>Try this out your self with your knowledge and see if you can do it!</p><p>Here is an example of what your compose file may look like when completed!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/426/1*BtvseYOlnXjBQ1FBtgF6FA.jpeg" /></figure><p>After this, hit escape and type :wq to save your file.</p><p><strong>Step Two: Running Our Compose File</strong></p><p>Once done, lets run our compose file with the following command:</p><pre>docker compose up</pre><p>or if you want to run it detached you can just use</p><pre>docker compose -d</pre><p>You will see some operations happening and once completed, your CLI should look similar to this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/508/1*TNTjrFKd_4TaRFWH3XmVmA.jpeg" /></figure><p>Next we need to pull the initial admin password from Jenkins in order to log in. In order to do that, run the following command:</p><pre>docker compose exec jenkins cat /var/jenkins_home/secrets/initialAdminPassword</pre><p>Once you run that your terminal should show you a fairly long string. Copy this to your clipboard as we will need it for the following step.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/935/1*1-_tAkxvIb3iZoAo4t5ntw.jpeg" /></figure><p><strong>Step Three: Connecting to our Jenkins Container via the web</strong></p><p>If you are on AWS like me, you will need to head over to the console and obtain your public IP address. If not you will again, just use “localhost”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KuTGfC7P2dPTk1scmoHpdg.jpeg" /></figure><p>Once you have your info, in the url bar, you will put the public IP address followed by the specified port for Jenkins web interface (8080). It will look like this:</p><p>3.86.243.108:8080</p><p>For those not using AWS and using a local machine, it will look like this:</p><p>localhost:8080</p><p>After pressing enter you will see the following showing we are connected!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jNu1AJVWR1ENH2YJHyZ6ig.jpeg" /></figure><p><strong>Step Four: Setting Up Jenkins</strong></p><p>Alright, so remember that long password I told you to copy to your clipboard? Paste in it here.</p><p>After doing so it will bring you to another screen asking about plugin installs. Go ahead and select “install suggested plugins”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZWLC67d-WRAfpk7Rw0GlQQ.jpeg" /></figure><p>After this, it will bring you to a screen with a bunch of fields to set up your user account. Go ahead and enter your info into the fields.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1009/1*fG-wlEsnLL7e7fQ9VqBACw.jpeg" /></figure><p>Once done, you should see the actual Jenkins Menu! Congrats!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SJ1WymgI4NWfbHPVuX1hGA.jpeg" /></figure><p>Step Five: Validate Data Persistence</p><p>Alright so, lets validate our created volume is actually working and will persist over to a new container.</p><p>Back in your CLI use the following command to stop the container and remove it.</p><pre>docker compose down</pre><p>This will both stop the container and remove it. To verify you can use the following command:</p><pre>docker container ps</pre><pre>docker container ps -a</pre><p>Now that we have verified it has stopped, lets start another container up! Again you will use the following command:</p><pre>docker compose up -d</pre><p>It should take a far shorter time to start this time. Once it does, head back over to the url bar and connect the same way we did previously.</p><p>This time it will bring you to the Jenkins login screen.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0tNtNLRZBXqr97iUKyA2OA.jpeg" /></figure><p>If our volume did what it was supposed to do, once you type in the username and password you created last time, you will again be brought to the Jenkins Menu!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L64YEKFJAwdnUsvf9mnExg.jpeg" /></figure><p>And CONGRATS! You have now deployed a Jenkins container using docker compose!</p><p><strong>Step Six: Clean up</strong></p><p>As with start up, cleanup with docker compose is super easy. Back in your CLI, go ahead an run the following command again to stop and remove the containers:</p><pre>docker compose down</pre><p>And if you want to remove your volume as well, you can run the following:</p><pre>docker compose down -v</pre><p><strong>Conclusion:</strong></p><p>As you can see docker compose is simple to use and understand. It allows a quick and easy way to deploy services within a container that allows us build scalable CI/CD pipelines. There are far more configurations and things we can do inside the compose file, and I recommend testing your own things out and playing around with it to see what else you can build.</p><p>I hope this has been helpful to those of you new to Docker! If so, I invite you to follow and share for more helpful cloud computing tips as I continue my own journey!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0523832fa9cf" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The AWS CLI is your key to shortening processes within AWS.]]></title>
            <link>https://medium.com/@jawilliamson25/the-aws-cli-is-your-key-to-shortening-processes-within-aws-367f0c6d9f74?source=rss-76b11c604c11------2</link>
            <guid isPermaLink="false">https://medium.com/p/367f0c6d9f74</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[aws-cli]]></category>
            <category><![CDATA[ec2]]></category>
            <dc:creator><![CDATA[James Williamson]]></dc:creator>
            <pubDate>Tue, 06 Feb 2024 00:11:44 GMT</pubDate>
            <atom:updated>2024-02-06T00:11:44.470Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*oZ73CRgSU1M6Apd17koh_g.jpeg" /><figcaption>Using the AWS CLI to launch an EC2 Instance hosting an Apache Web Server (PowerShell)</figcaption></figure><p>The AWS CLI is your key to shortening processes within AWS. Many of you may be very comfortable using the console with a simple and easy to use interface, however, the CLI speeds things up incredibly once you get the hang of it! We are going to practice doing some simple tasks with it today by creating and EC2 Instance with an Apache Web Server, Creating an AMI Image, and finally launching and testing connection to the instance!</p><p><strong>Prerequisites Needed:</strong></p><ol><li>AWS Account with proper permissions assigned and an access key pair</li><li>Most up to date AWS CLI installed on your local machine. You can find that here: <a href="https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html">https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html</a></li><li>Knowledge of the bash script to update, install, and start an Apache web Server. If you aren’t sure how to create that script, I have it documented below for you to use on your clipboard.</li></ol><pre>#!/bin/bash<br>yum update -y<br>yum install -y httpd<br>systemctl start httpd<br>systemctl enable httpd</pre><p>4. For this tutorial we will be using PowerShell.</p><p><strong>Step by Step Instructions:</strong></p><ol><li>Once the AWS CLI has been installed following the link above in the prerequisite section, open PowerShell as admin and run the “aws confgure” command</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/269/1*PCWtKnWVS21UmZZeBgn2Kg.jpeg" /></figure><p>2. You will be asked to enter your access key id, followed by your secret access key id which you should have created within your IAM role and should have saved somewhere on your computer. If you need a quick refresher on how to create a key pair (incase you lost yours) you can find one here: <a href="https://www.youtube.com/watch?v=HuE-QhrmE1c">https://www.youtube.com/watch?v=HuE-QhrmE1c</a></p><p>You will then be asked to enter your region name, and your output format which you can select between a few (json, yaml, yaml-stream, text, or table).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/337/1*U2CBmn_q0eeY5XP8R1eqgQ.jpeg" /></figure><p>Once done, you can test with a simple command like “aws s3 ls” which will list all of your s3 buckets and show you that you are connected.</p><p>3. Next you will need to create a security group using the following code:</p><pre>aws ec2 create-security-group \<br>--group-name &lt;name_of_group&gt; \<br>--description &quot;My Project SG&quot; \<br>--vpc-id &lt;vpc_id&gt;</pre><p>You will need to ensure you replace the “name_of_group” variable with a name for your security group, you can change the description to remind you of what it’s for, and ensure you replace the “vpc_id” with the VPC you want to create this group within. You can find that on your console by searching VPC, selection “Your VPC’s” from the left hand column and finding them on the VPC ID column of the table.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/568/1*ia8VXNZFo1fuhLfwN4otwA.jpeg" /></figure><p>4. Next we will create a PowerShell Script file using notepad or any text editor. This file will contain the script to create an EC2 and install/run an Apache Web Server.</p><p>The script is as follows:</p><pre># PowerShell Script to Launch an AWS EC2 Instance<br><br># Specify the AMI ID (Choose an AMI that is free tier eligible)<br>$AMI_ID = &quot;AMI-id&quot;<br><br># User data script to update packages, install Apache, and start it<br>$USER_DATA = @&quot;<br>#!/bin/bash<br>yum update -y<br>yum install -y httpd<br>systemctl start httpd<br>systemctl enable httpd<br>&quot;@<br><br># Creating the EC2 instance<br>aws ec2 run-instances `<br>    --image-id $AMI_ID (Don&#39;t re-enter AMI-ID here as this is a reference)`<br>    --count 1 `<br>    --instance-type t2.micro `<br>    --key-name keyname `<br>    --security-group-ids sg-id `<br>    --subnet-id subnet-id `<br>    --user-data $USER_DATA</pre><p>For the following variables you will need to do some searching via the console to find the exact ID’s. Let’s start with the AMI-ID.</p><p>On the EC2 Dashboard, you will see “AMI Catalog” in the left hand column under the “Images” Section. Click on that and you will see the catalog appear on the right hand side where you can search a variety of AMI’s. Find the one that suits you (we will be selecting the free tier only filter for this exercise) and will be choosing the Amazon Linux 2023 AMI.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/862/1*UFX-3ys43oEmc29NY5K7LQ.jpeg" /></figure><p>For the security group id, go back to the EC2 console, click “security groups” on the left menu and find the id there. Take note of the VPC your security group belongs to as you will need that information next.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/728/1*C18sqIC6lZwircmillUaGg.jpeg" /></figure><p>Once done, use the search bar and type “VPC” to navigate to the VPC console. Once there, click “subnets” on the left hand side. Select a the subnet ID that belongs to the same VPC as your security group.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YZvayjiz3AdipQue4nidNQ.jpeg" /></figure><p>Lastly, you will find the name for your keypair on the EC2 console after selecting “Key Pairs” from the menu on the left.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/537/1*lHKbQoKVq6BL6aXnjZVGuQ.jpeg" /></figure><p>5. Once you have filled out all those fields in your file, we are going to save the file as a PowerShell Script by saving it as &lt;FileName.ps1&gt; on our desktop. You can name the file anything as long as the suffix is “.ps1”. This signifies that it is a PowerShell script.</p><p>Once that is done we need to navigate to the folder our script is in on the CLI. That is done with the following command to get to the desktop.</p><pre>cd ~\desktop</pre><p>Once there we will run our script using the following command</p><pre>.\MyScript.ps1</pre><p>Now, here you may run into an error where your machine doesn’t allow you to run scripts on it. If that is the case, use the following command to enable the running of scripts:</p><pre>Set-ExecutionPolicy RemoteSigned</pre><p>A prompt will show up as follows and just type Y for Yes to allow.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/826/1*C3BOV_2l41njxPbCJiIYMg.jpeg" /></figure><p>*****IMPORTANT*******</p><p>Ensure you run this command again when you are done and disable this to ensure proper security on your machine.</p><p>Retype the command to run your script and you should be met with something like this which means your instance has been successfully created.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/516/1*6QgmercrLFczy6VGDaBetA.jpeg" /></figure><p>Let’s confirm our instance is running in the console.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/665/1*H6etGNpfoE3v0bkdcRKxFQ.jpeg" /></figure><p>6. Lastly, lets ensure we can access the Public IP to see if the server is available! Ensure you do this from an incognito tab for reliable results.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/804/1*kg4IuPoS5qh4H1d_MSWtdQ.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/964/1*iCKYoURnfsSOyvYAMwflRw.jpeg" /></figure><p>And there it is!! Congrats!</p><p>7. The last and final step is to terminate your instance. You can either do that via the console or with the following CLI command.</p><pre>aws ec2 stop-instances --instance-ids &lt;instance_id&gt;</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=367f0c6d9f74" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Linux Directories, Groups, and Users: A How To in creation, permission setting, and a bonus bash…]]></title>
            <link>https://medium.com/@jawilliamson25/linux-directories-groups-and-users-a-how-to-in-creation-permission-setting-and-a-bonus-bash-aad4af980b7a?source=rss-76b11c604c11------2</link>
            <guid isPermaLink="false">https://medium.com/p/aad4af980b7a</guid>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[uber]]></category>
            <category><![CDATA[bash-script]]></category>
            <category><![CDATA[linux-tutorial]]></category>
            <category><![CDATA[ec2]]></category>
            <dc:creator><![CDATA[James Williamson]]></dc:creator>
            <pubDate>Mon, 23 Oct 2023 04:08:06 GMT</pubDate>
            <atom:updated>2023-10-23T04:08:06.599Z</atom:updated>
            <content:encoded><![CDATA[<h3>Linux Directories, Groups, and Users: A How To in creation, permission setting, and a bonus bash script to do it all for you. (For Windows users)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/618/1*nDKA_rDESabpB7GhuB9RPw.png" /></figure><p>Today’s tutorial is a fun one to follow along with for all my Linux fans out there! We will need a couple a pre-reqs for this tutorial which are listed below:</p><ol><li>A free tier AWS account/or a computer running Ubuntu as the OS. I suggest a free tier AWS account so you can mess up and just make a new EC2 instance if you break stuff (I know I did)</li><li>Basic CLI understanding in Microsoft PowerShell</li><li>Basic understanding of a few Linux Commands which I will outline.</li></ol><p>Linux Commands and definitions needed for this tutorial:</p><p><strong>mkdir- </strong>creates one or more directories with your specified parameters</p><p><strong>touch- </strong>creates an empty file in a path you specify if the file doesn’t already exist (also updates timestamp)</p><p><strong>groupadd- </strong>adds a group with specified parameters</p><p><strong>useradd- </strong>adds a user with specified parameters</p><p><strong>chown- </strong>changes ownership of a file or path</p><p><strong>chmod- </strong>specifies what can be done when a file is accessed by a user</p><p><strong>sudo- </strong>command that you place before others which allows root user permissions</p><p><strong>cd- </strong>changes your directory to specified path or if by itself brings you back to root directory</p><p><strong>ls- </strong>lists all files in current directory</p><p><strong>finger- </strong>a command allowing you to lookup user information (we will install an application to use this command)</p><p><strong>clear-</strong> clears the terminal screen</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/1*poB9VxgeXk8mtk8ukojocw.gif" /></figure><p><strong>Part One: Instance Creation and Connection</strong></p><p>As in many other tutorials before this, lets head over to our AWS dashboard, open up EC2 and launch an instance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/754/1*BEWMDskaejnDzpFMec-vcQ.png" /></figure><p>I am going to title this instance Project_Bank_Linux but name yours whatever comes to mind.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/787/1*A6ry5zhwmlMsvEZGOXjXxQ.png" /></figure><p>Scrolling down we are going to select ubuntu from the Quick Start section and ensure our AMI is free tier eligible which should be the default option.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/806/1*mtmBMhB-PIDbZh0RsWTK_g.png" /></figure><p>Also ensure our instance type is set to t2.micro for our free tier account.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/782/1*2MBR4usdNA5b7qZ9XbX98w.png" /></figure><p>Since we are going to be using SSH to connect to our instance we need a key pair so select “Create new key pair.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/799/1*iZfMKkFvA_v7CFqXVZ53xQ.png" /></figure><p>Again, name your keys, leave all settings as default and ensure you keep track of the path your keys download into as we will need to work from that path in PowerShell.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/596/1*XQCQA4AeSqREkpiOkE1zIQ.png" /></figure><p>Ensure your security group is created and allows SSH traffic from anywhere. We will not need HTTPS or HTTP traffic this time around.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/788/1*8ZZDAx_Ddi8rvEr9kBuo8Q.png" /></figure><p>Launch your instance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/369/1*qusONJ1lr17BP-ibbT0RXQ.png" /></figure><p>Once your instance has finished loading up, select from your instance dashboard and hit connect. Once in that menu go over to SSH. We will copy the command shown below in a moment to SSH into our instance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/818/1*9iMYBk3idBn7kxUSmPRUyQ.png" /></figure><p>Next let’s open up PowerShell and cd into the path where our keys are. for me that is the downloads folder so I will type:</p><pre>cd downloads</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/858/1*aVO-m-F14WwwnV8_DyBHfA.png" /></figure><p>Once there I will copy the command from the SSH window in AWS above and paste it into the terminal.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/861/1*NMQrT4DgOs1dFUbkH2IkyQ.png" /></figure><p>Ensure you type yes in the option that pops up.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/842/1*Z385JuCLnw6v7oLnBU49Gg.png" /></figure><p>After a couple seconds you should be connected to your instance and your prompt should look something like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/543/1*ou_61o6Od9nXocn8UqqpqQ.png" /></figure><p>Type the command <strong>clear </strong>and you should have a clean terminal to start working from!</p><p><strong>Part Two: Creating Directories, Groups, and Users</strong></p><p>We are going to start with creating a few directories using the <strong>mkdir </strong>command, however, this command requires root permissions meaning we will need to use the root command prior to making our directory so it will look like this:</p><pre>sudo mkdir</pre><p>Our directories will be called Development, Operations, and Analytics. So let’s try this out. In the terminal to create the directories with those names attached we will use the following:</p><pre>sudo mkdir /Development</pre><p>Once you type that in the terminal press enter. Don’t worry that it doesn’t show anything right now, that is perfectly fine and means you encountered no errors. Now create the rest. Once done your terminal will look something like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/567/1*G-H5I3yUJ225mXsM9vh-zQ.png" /></figure><p>Next we are going to create a couple dummy files to go into these directories. For this, we will use the <strong>touch </strong>command. Again we will need to continue using <strong>sudo </strong>prior to the actually command, so it will look like this.</p><pre>sudo touch </pre><p>We also will need to specify the path we want our files created in which will be our newly made directories and the name for our files. That will look like this.</p><pre>sudo touch /Development/file1.txt</pre><p>As you can see the path goes prior to the file name.</p><p>So lets make the rest.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/483/1*L6A4ONLDjllO-VZSAgObMg.png" /></figure><p>Alright so we have two dummy txt files in each location. Let’s check to ensure we did it correctly. Using the <strong>cd </strong>command (don’t need sudo here) let’s go to the development directory and check.</p><pre>cd /Development/</pre><p>Once here type <strong>ls. </strong>You will see both of your files which means we did it correctly!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/417/1*hDx-lT-WVO065J6RZBmjiA.png" /></figure><p>Check the rest of your directories as well before moving on.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/417/1*hDx-lT-WVO065J6RZBmjiA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/397/1*ReLaoob50LPvIT5bGWm3Rw.png" /></figure><p>Next up we need to add a couple groups. The groups will be called Developers, Operations, and DataAnalysts.</p><p>We will use the following commands to add those groups.</p><pre>sudo groupadd Developers<br><br>sudo groupadd Operations<br><br>sudo groupadd DataAnalysts</pre><p>Again, don’t worry that the terminal gives no response when you press enter after each command.</p><p>The final part of this section will involve creating the users. Each user will need certain specifications assigned to them in our command. They need the following:</p><ol><li>Name- Jess Waller, Blake Dorsey, Joey Ewart</li><li>Username- jwaller, bdorsey, jewart</li><li>Email- jwaller@levelupbank.com, bdorsey@levelupbank.com, jewart@levelupbank.com</li><li>Assigned Group- jwaller (Developers), bdorsey (Operations), jewart (DataAnalysts)</li></ol><p>In order to ensure that all of this information is included along with creating the user, we will need to add a few options to our basic <strong>adduser </strong>command as shown below in the command to created a user for Jess Waller.</p><pre>sudo useradd -m -g Developers -c &quot;Jess Waller, jwaller@levelupbank.com&quot; jwaller</pre><p>Here is what some of those options mean or are used for:</p><ul><li><strong>-g</strong>- Option used to assign the user to a specified group</li><li>-<strong>m</strong>- creates a home directory for the user</li><li>-<strong>c</strong>- sets a field called the “gecos” field which allows you to input a users full name, and email address. It can be used to store other info as well such as phone numbers. Its up to the admin normally what to store here.</li></ul><p>Now, although this command works fine, best practice is to also specify the shell for each user. We just need to add -s /bin/bash before the user name in order to do so as shown below.</p><pre>sudo useradd -m -g Developers -c &quot;Jess Waller, jwaller@levelupbank.com&quot; -s /bin/bash jwaller</pre><ul><li><strong>-s</strong>- This signifies you are assigning a specific shell to the user</li></ul><p>Use this to command format to create the rest of your users.</p><p>Before our permissions section where the real <strong>FUN </strong>begins, let’s make sure we can login as the users we just created. For that we will run the following command.</p><pre>sudo su - jwaller(any username works here)</pre><p>Once logged in, let’s cd over to the /Development directory and run the ls command again.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/328/1*Mcrnxoi__DJYBZ6fZnYqhw.png" /></figure><p>Awesome!! We now have users functioning in our system.</p><p><strong>Part Three: YOU SHALL NOT PASS!! Permissions</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/373/1*JyPTYJWBdGUuZK5CIydFBw.gif" /></figure><p>Last but not least, we want to ensure our users have access ONLY to what they need access to use. We can’t have Blake snooping on Jess, so let’s ensure we set all the proper restrictions.</p><p>The first thing we need to do is set the group ownership and permissions over the directories. For that we will run a couple commands. The first will be to make the owners of the directors the groups. That looks like this:</p><pre>sudo chown :Developers /Development</pre><p>Pretty easy right? Go ahead and assign ownership to the rest of the groups and their respective directories.</p><p>Once we have done that, we need to ensure that what can be accessed is also restricted and for that we will use the <strong>chmod </strong>command.</p><pre>chmod 770 /Development</pre><p>The 770 represents digits that align with assigned permissions.</p><p>The first 7 grants the owner full read, write, and execute permissions</p><p>The second 7 grants the group full read, write, and execute permissions</p><p>The 0 grants all others no permissions</p><p>In other words if you aren’t the owner of the directory or part of the group which is assigned to own the directory, you can’t do anything with it!</p><p>Let’s run that command for the remaining two directories.</p><pre>chmod 770 /Operations<br><br>chmod 770 /Analytics</pre><p>So now lets pick a user, login, and see if we can access directories which we are not part of the user group to ensure this all worked! I will log in as Joey Ewart.</p><pre>sudo su - jewart</pre><p>I will then try to cd over to a directory which my group (DataAnalysts) does not have permissions. I will try /Operations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/305/1*sA31LRkOpuLQI3d94V_13Q.png" /></figure><p>And boom…no more access! But let’s make sure we didn’t mess up access to the users own directory!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/334/1*jP2a5qGjlPtrYCvNPNCIdg.png" /></figure><p>And we’re good!</p><p>Let’s try another. This time with Blake Dorsey!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/408/1*OeMcqdBKtSfrWhWJnZnRRw.png" /></figure><p>Good there also!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/1*Q4rRkarQD2IkMHAYBh_sGQ.gif" /></figure><p>Alright, last but not least, lets make sure each of our users can’t access the home directory of our others users. Since the owners of the home directors are by default assigned on creation, we don’t need to run the <strong>chown </strong>command but only need the actually permission command of <strong>chmod. </strong>Also remember our digits? Which digit represent permissions for the owner?</p><p>The command will look like this for Jess Waller:</p><pre>chmod 700 /home/jwaller</pre><p>Again, we give the owner full permissions and use 0’s to ensure no one else has any permissions at the group or others level.</p><p>Let’s run this command for the rest of our users.</p><pre>chmod 700 /home/bdorsey<br><br>chmod 700 /home/jewart</pre><p>Lets try it out! I will login as Jess Waller and see if I can access the home directory for Blake Dorsey.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/337/1*rWUo5kmq-jNbm3NmTiYbUQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*yN6M80x7qlG6TV5dgnAXlw.gif" /></figure><p>Let’s try another.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/308/1*4dz8a1pN9kBaBmc2FB_F0Q.png" /></figure><p>Denied again! Starting to remind me of my high school dating life.</p><p>Great work!! You’ve come this far so now for that bonus you’ve been waiting for. The script that will do all of this for you.</p><p><strong>Part Four: The Script (If you skipped to this section, bad engineer)</strong></p><p>For the script, there are two possibilities we can use here. Option one, and the one you go with if you don’t like inflicting pain on yourself, is using a text editor like nano. Option two, is for people that enjoy pain. This option is creating the script right from the CLI. I will show you both.</p><p>If you are going to do this in nano first we need to install nano onto our instance. Run the following commands:</p><pre>sudo apt update<br><br>sudo apt install nano</pre><p>You can verify its installed and running by using the following command:</p><pre>nano --version</pre><p>Once done we will open a script file by typing the following command:</p><pre>nano projectscript.sh</pre><p>This will open up the editor where you can then paste the commands for your script which are pretty much all the commands we just ran in order. It will like this:</p><pre><br>sudo mkdir /Development<br>sudo mkdir /Operations<br>sudo mkdir /Analytics<br><br><br>sudo touch /Development/file1.txt<br>sudo touch /Development/file2.txt<br>sudo touch /Operations/file1.txt<br>sudo touch /Operations/file2.txt<br>sudo touch /Analytics/file1.txt<br>sudo touch /Analytics/file2.txt<br><br><br>sudo groupadd Developers<br>sudo groupadd Operations<br>sudo groupadd DataAnalysts<br><br><br>sudo useradd -m -g Developers -c &quot;Jess Waller, jwaller@levelupbank.com&quot; -s /bin/bash jwaller<br>sudo useradd -m -g Operations -c &quot;Blake Dorsey, bdorsey@levelupbank.com&quot; -s /bin/bash bdorsey<br>sudo useradd -m -g DataAnalysts -c &quot;Joey Ewart, jewart@levelupbank.com&quot; -s /bin/bash jewart<br><br><br>sudo chown :Developers /Development<br>sudo chown :Operations /Operations<br>sudo chown :DataAnalysts /Analytics<br><br>sudo chmod 770 /Development<br>sudo chmod 770 /Operations<br>sudo chmod 770 /Analytics<br><br><br>sudo chmod 700 /home/jwaller<br>sudo chmod 700 /home/bdorsey<br>sudo chmod 700 /home/jewart<br><br></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/845/1*Zizyxpuhztmy0Pu3cK5scg.png" /></figure><p>To save hit “Ctrl-0” and then exit hit “Ctrl-X”. Press the Y key on the following prompt and then hit enter to save.</p><p>Now we need to run a command to make the script executable. Its looks like this.</p><pre>sudo chmod +x projectscript.sh</pre><p>Finally run your script!</p><pre>./projectscript.sh</pre><p>DONE! Now check all your work like we did before to ensure all permissions and users are correct.</p><p>Now for those not faint of heart. Here is how you do it directly from the CLI.</p><p>There are a lot of similarities, however, a couple differences. We will use the same commands, however will need to add a couple things. The script in the CLI will need to include the <strong>echo </strong>command and some parentheses as well as the file name each command will be created in. It’s ALOT. Don’t do this method if you don’t have to. It will look like this. and yes, you have to type each line individually and press enter after each one.</p><pre>echo &quot;sudo mkdir /Development&quot; &gt; projectscript.sh<br>echo &quot;sudo mkdir /Operations&quot; &gt;&gt; projectscript.sh<br>echo &quot;sudo mkdir /Analytics&quot; &gt;&gt; projectscript.sh<br><br>echo &quot;sudo touch /Development/file1.txt&quot; &gt;&gt; projectscript.sh<br>echo &quot;sudo touch /Development/file2.txt&quot; &gt;&gt; projectscript.sh<br>echo &quot;sudo touch /Operations/file1.txt&quot; &gt;&gt; projectscript.sh<br>echo &quot;sudo touch /Operations/file2.txt&quot; &gt;&gt; projectscript.sh<br>echo &quot;sudo touch /Analytics/file1.txt&quot; &gt;&gt; projectscript.sh<br>echo &quot;sudo touch /Analytics/file2.txt&quot; &gt;&gt; projectscript.sh<br><br>echo &quot;sudo groupadd Developers&quot; &gt;&gt; projectscript.sh<br>echo &quot;sudo groupadd Operations&quot; &gt;&gt; projectscript.sh<br>echo &quot;sudo groupadd DataAnalysts&quot; &gt;&gt; projectscript.sh<br><br>echo &#39;sudo useradd -m -g Developers -c &quot;Jess Waller, jwaller@levelupbank.com&quot; -s /bin/bash jwaller&#39; &gt;&gt; projectscript.sh<br>echo &#39;sudo useradd -m -g Operations -c &quot;Blake Dorsey, bdorsey@levelupbank.com&quot; -s /bin/bash bdorsey&#39; &gt;&gt; projectscript.sh<br>echo &#39;sudo useradd -m -g DataAnalysts -c &quot;Joey Ewart, jewart@levelupbank.com&quot; -s /bin/bash jewart&#39; &gt;&gt; projectscript.sh<br><br>echo &quot;sudo chown :Developers /Development&quot; &gt;&gt; projectscript.sh<br>echo &quot;sudo chown :Operations /Operations&quot; &gt;&gt; projectscript.sh<br>echo &quot;sudo chown :DataAnalysts /Analytics&quot; &gt;&gt; projectscript.sh<br><br>echo &quot;sudo chmod 770 /Development&quot; &gt;&gt; projectscript.sh<br>echo &quot;sudo chmod 770 /Operations&quot; &gt;&gt; projectscript.sh<br>echo &quot;sudo chmod 770 /Analytics&quot; &gt;&gt; projectscript.sh<br><br>echo &quot;sudo chmod 700 /home/jwaller&quot; &gt;&gt; projectscript.sh<br>echo &quot;sudo chmod 700 /home/bdorsey&quot; &gt;&gt; projectscript.sh<br>echo &quot;sudo chmod 700 /home/jewart&quot; &gt;&gt; projectscript.sh</pre><p>As you can see, a lot more work.</p><p><strong>Wrap Up</strong></p><p>So to wrap up, we covered the following topics in this tutorial:</p><ol><li>Basic Commands Used</li><li>Setting up and connect to our ubuntu instance</li><li>Creating directories, groups, and users</li><li>Assigning permissions</li><li>Creating a all in one script</li></ol><p>If tutorials like this pique your interest and you are enjoying the journey, please follow me here and connect with me on LinkedIn!</p><p><a href="https://www.linkedin.com/in/james-williamson-phr/">https://www.linkedin.com/in/james-williamson-phr/</a></p><p>See you next time.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aad4af980b7a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hosting an Apache Web Server via AWS EC2 using CentOS]]></title>
            <link>https://medium.com/@jawilliamson25/hosting-an-apache-web-server-via-aws-ec2-using-centos-e4b7e81b953f?source=rss-76b11c604c11------2</link>
            <guid isPermaLink="false">https://medium.com/p/e4b7e81b953f</guid>
            <category><![CDATA[centos]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[ec2]]></category>
            <category><![CDATA[devops]]></category>
            <dc:creator><![CDATA[James Williamson]]></dc:creator>
            <pubDate>Sat, 21 Oct 2023 05:33:26 GMT</pubDate>
            <atom:updated>2023-10-21T05:33:26.484Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/780/1*7-4S0UOPGnBiIqRiJv9zmg.png" /></figure><p>For this tutorial, we are going to use Amazon EC2 running a CentOS server in order to host an Apache web server!</p><p>Let’s start with what you need in order to do this:</p><ol><li>Free tier AWS account</li></ol><p>2. Basic knowledge of EC2 and SSH Connections (However we will be going through what to do here)</p><p>3. Basic understanding of the CLI on your machine (we will be using PowerShell for Windows)</p><p><strong>Part One: Use Case</strong></p><p>You have been hired by the Level Up Bank to create a new web server using CentOS which will host the bank’s website and provide information about its services as well as allowing customers to access their accounts. Now, we won’t be building out the entire website as we aren’t web developers here, however, we need to create the space in which the developers can create the sight.</p><p>Let’s get started!</p><p><strong>Part Two: Hosting a Website using Apache webserver on CentOS</strong></p><p>The first thing we need to do is create an EC2 instance. Go to your EC2 management console inside of AWS and hit Launch Instance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/738/1*txLd0OwX5KL32LDdhG6TTg.png" /></figure><p>Once done, we will need to select a couple options in order to set up the instance correctly. The first thing we need to do is name our instance. As you can see I will name mine “LUIT_CENTOS_BANK.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/775/1*yiAOzRNr9dEa2G-OSD4uLg.png" /></figure><p>Once done in the AMI search bar, we need to search for the CentOS options available. Type in CentOS as shown above and press enter. This will bring you to a menu where you will select the AWS Marketplace AMI’s section and then find the CentOS Stream 8 (x86_64) distro.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1015/1*QFpg4ula73xZ1WHnpPey3Q.png" /></figure><p>When you click on it, it will bring up additional details and as you can see, this distro is free tier eligible which is perfect.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/571/1*ae_1eYUTbc-dZR7-jq11aQ.png" /></figure><p>Once done, go back and click the orange select button on the right.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/489/1*8_1nmxI_xYOsuSJqIMOS1A.png" /></figure><p>Back on the EC2 setup, you will see the instance type section marked as T2.micro which is perfect for what we will be doing today.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/785/1*MvzY2pU4dCE3nlhtYgB-3g.png" /></figure><p>Next we will need to create a key pair in order to SSH into our instance. Clock on “Create new key pair.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/779/1*ndQ29usvbDKNQ6Y4cAP4Zg.png" /></figure><p>On the key pair menu, name your keys something easy to recognize, for this, I will name mine, CENTOSKEYS. All other options can stay the same. Click on “Create key pair.”</p><p>*<strong>ENSURE YOU KEEP TRACK OF THE FILE PATH YOU SAVE YOUR KEYS TO AS WE WILL NEED THAT INFO FOR THE SSH CONNECTION*</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/591/1*VsKXsdqC3T-6WiRmOe0mtA.png" /></figure><p>We also need to create a security group in order to allow access to our website. Under firewall, configure your settings as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/777/1*Ap9MCchpDbGrf2j_wTEh7g.png" /></figure><p>Now we can launch our instance!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/380/1*6rX0ziBFf7x59bu1fFZsXA.png" /></figure><p>Since this may be your first time with subscribing to the marketplace due to using CentOS it may take a few minutes for the instance to boot up, however once it does, you can select it from your instances management console and hit connect.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oDRbXtWTKWoohddilSSZ2w.png" /></figure><p>Once you are on the connect menu, click over to SSH client and keep in mind again where you stored your keys, and another command on this screen pointed out which we will use to SSH into our instance. It is noted by the second arrow at the bottom.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/803/1*2cnWgzA3faaFMndRcLmgFA.png" /></figure><p>So lets open up PowerShell. We will need to get into the path where we have our keys stored which is in the downloads folder for me. For that I will use the following command:</p><pre>cd downloads</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/865/1*utDlNrl2ITEirbFlVo66cA.png" /></figure><p>Once you are here, you can copy and paste the command from the SSH connect screen noted above by the arrow.</p><p>So here we run into our first problem! It is saying permission denied and doesn’t let you SSH.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3bSryuVHT-5_mTCFvEE4QA.png" /></figure><p>This also caused me some problems, however the solution is simply changing the user in the SSH command as follows:</p><pre>ssh -i &quot;insertkeysname.pem&quot; centos@ec2-3-85-203-186.compute-1.amazonaws.com</pre><p>Ensure you replace the keys file name with your file name AND replace the ec2 instance connection route with your own which you can find on the SSH connection page.</p><p>Leaving the user as ec2-user won’t allow you permission into the instance so changing that portion of the command to “centos” allows us access. Once you have access it will look like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/857/1*_mgRQcalfQ-QTQgx9o4V1A.png" /></figure><p>Alright now that we are here, we need to do a couple things before we can get a website up and running.</p><p>First, we need to update the server with the following command:</p><pre>sudo yum update -y</pre><p>This will take a while the first time you run it so just wait it out or go grab you a soda, water, or my personal favorite, coffee, and come back after a few minutes.</p><p>Next, we will install the Apache Web Server:</p><pre>sudo yum install httpd -y</pre><p>Now, let’s start the Web Server:</p><pre>sudo systemctl start httpd</pre><p>Finally, this command will automate apache to start up on instance launch:</p><pre>sudo systemctl enable httpd</pre><p>Alright! Lets see if what we just did worked! Back in the AWS console find the Public IPv4 address for your instance and copy and paste it into your search bar.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/899/1*IL-TySZY1Pdiga4-RzJNCQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/394/1*r9LyPWPLoptc8CvzvKPD6Q.png" /></figure><p>An BOOM! Our site is UP!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AhRlhSWsObuQIbMhb1ygIg.png" /></figure><p>Let’s do one more thing to kick it up a notch!</p><p><strong>Part Three: Replace the Server test page with a basic html file</strong></p><p>Back over on your CLI, we will first need to install a html editor onto our instance. For this we can choose from a few Linux based options such as nano, vim, or vi. We will use nano for this example. Use the following command to install nano.</p><pre>sudo yum install nano</pre><p>Once you have done this, we will need to use a command in order to get into the file path where we will create our html file with nano. From your CLI type in the following:</p><pre>cd /var/www/html/</pre><p>Once you are in this file path, type the following to open up an editor and create the file name index.html.</p><pre>nano index.html</pre><p>You can copy and paste the following code into that window:</p><pre>&lt;!DOCTYPE html&gt;<br>&lt;html&gt;<br>&lt;head&gt;<br>    &lt;title&gt;Welcome to LUIT!!&lt;/title&gt;<br>&lt;/head&gt;<br>&lt;body&gt;<br>    &lt;h1&gt;Welcome to LUIT - Blue Team&lt;/h1&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;</pre><p>Once done you will press “ctrl 0” to save and then “ctrl x” to exit. Press Y on the first option and then hit enter on the file name.</p><p>Back on the command line to verify your file in now in that file path type the following command to list all files in that path.</p><pre>ls</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/387/1*Z1iSIH4nMkPgEVxxjV1wIg.png" /></figure><p>Lastly we want to ensure the correct user and group are assigned to the overarching directory the file is held in, otherwise the webserver may not pull the html file.</p><p>Run the following command in order to ensure the proper ownership is established.</p><pre>sudo chown -R centos:apache /var/www/</pre><p>Now lets restart our server with the following command</p><pre>sudo systemctl restart httpd</pre><p>Finally, lets head over to our public IP using a web browser to check it out!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/503/1*u2G7RSEmNckxswlCFm38QQ.png" /></figure><p>And there you go!! You now know how to create a basic HTML website using Apache and AWS EC2 with CentOS!!</p><p><strong>Wrap Up</strong></p><p>If tutorials like this pique your interest and you are enjoying the journey, please follow me here and connect with me on LinkedIn!</p><p><a href="https://www.linkedin.com/in/james-williamson-phr/">https://www.linkedin.com/in/james-williamson-phr/</a></p><p>See you next time.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e4b7e81b953f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deploy EC2 Instances using SSH, SSM, and RDP (for Windows OS).]]></title>
            <link>https://medium.com/@jawilliamson25/deploy-ec2-instances-using-ssh-ssm-and-rdp-for-windows-os-e1b7ec4d515d?source=rss-76b11c604c11------2</link>
            <guid isPermaLink="false">https://medium.com/p/e1b7ec4d515d</guid>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[aws-ssm]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[ec2-instance]]></category>
            <dc:creator><![CDATA[James Williamson]]></dc:creator>
            <pubDate>Sun, 01 Oct 2023 06:35:09 GMT</pubDate>
            <atom:updated>2023-10-01T19:05:41.686Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/638/1*1S5Ph57Ek00s6JMGmMEcFA.jpeg" /></figure><p>Welcome back to another “how-to” with your host, HR turned DevOps! Today, we will walk through how to deploy EC2 instances in Linux using SSH and SSM, as well as an EC2 instance in Windows using RDP! We will also run a few fun commands to verify they are working. Strap in, and let&#39;s roll!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3G4rcq8aJh1zpQXO4IIq1w.jpeg" /></figure><p>Let’s start by defining a few terms which will be used throughout the tutorial.</p><p><strong>Amazon EC2- </strong>Allows you to deploy an easily scalable, cloud-based computing environment. Each instance will have its operating system and allocated computing ability.</p><p><strong>SSH- </strong>Known as a Secured Shell Connection, this allows accessing network services securely over an unsecured network</p><p><strong>RDP- </strong>Most are probably familiar with this. However, this just means remote desktop protocol. They are designed to connect to Windows instances.</p><p><strong>SSM- </strong>The abbreviation for AWS Systems Manager. This is a hub for AWS applications and allows us to secure them at scale rather than individually inside each service.</p><p><strong>IAM- </strong>Amazon Application that allows you to manage access to your AWS resources by creating various users, groups, roles, and attached policies.</p><h4><strong>Section One</strong></h4><p>In this first section, we are going to:</p><ul><li>Launch an EC2 instance with a Linux-based OS and Keypair</li><li>Create a Security Group which allows SSH connections</li><li>SSH into the Instance and run the “whoami” command</li></ul><p>From your AWS dashboard, search EC2 and click on the first link.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vXaIp5PSYtS0Qo1uMuRzUw.jpeg" /></figure><p>On the left-hand side, scroll down until you see the “Key Pairs” option and then select it. You will then hit the orange button “Create key pair.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/605/1*tUEXhaoj5irxFZxNcfT4fg.jpeg" /></figure><p>Name your key pair. For this example, I will name mine SSHKeys1. You can keep the RSA option selected. However, you want to ensure you click the .pem option as that is the format for use with SSH.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/718/1*FELN8R4XqDh3tQJhk4QQ9g.jpeg" /></figure><p>Once done, click “Create key pair” at the bottom right of the screen. Upon creation, you will see a download happen: the file with your key pair in it. Ensure you know the file path of where this file is located for later. I will keep it in my downloads folder for now.</p><p>Now that our key pair is created, we need to create the security group in order to connect to the instance via SSH. Scroll down the left-hand side of your menu and find “Security Groups.” As you can see, it&#39;s right near the “Key Pairs” option we just worked on.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/211/1*nwWxrqWU0ndEsfb2FBF2pw.jpeg" /></figure><p>Once inside the Security Groups menu, click the orange button that says “Create security group” in the top right. Do not worry about the default group listed. We will be ignoring that.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/699/1*1eVxreAgVyZYxRAin4sMcw.jpeg" /></figure><p>You will first need to name your security group and add a description. I will use SSH-Access-1 for the name and then copy and paste the name into the description box. You can leave the VPC box as is for now.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/983/1*1hSes8iezjfAdDhB5hIy2g.jpeg" /></figure><p>Once done here, scroll down to “Inbound rules.” This is where we will create a rule to access our instances using SSH. Go ahead and click “Add rule”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/537/1*Rtmqe96vRKR0EZdGqYXhGw.jpeg" /></figure><p>A menu will pop up with a few columns. The first one, called “Type,” is where we will define the connection protocol as SSH. Click the down arrow and scroll through to select SSH. The only other column we will be concerned with in this section is the “Source” column. Find that one and select the “Anywhere — IPV4” option. Your rule should look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sJdYyyPTtLsRH9Ztt4_ubg.jpeg" /></figure><p>Nothing else matters for now, so scroll down and hit the orange “Create security group” button at the bottom right.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/557/1*_tHQczarkk37fRi9OevT9Q.jpeg" /></figure><p>Once this is done, you will see the security group you created in the list.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*z51VA2F5yR5luCR2PuEDFw.jpeg" /></figure><p>Now, let’s launch our EC2 instance. On the left-hand side, scroll back up and click on “Instances.” Hit the orange button in the top right named “Launch Instances.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*U2cnlffFbQkx9z8v0PGalQ.jpeg" /></figure><p>Once in the Menu, you will need to name your EC2 instance. Ensure you name it something you can easily remember that aligns with what we are doing currently. I will title mine SSH-Project-1432.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/802/1*X7SMyDBUhKFVicvHAdhk9Q.jpeg" /></figure><p>We will use the Amazon Linux OS Image that is pre-selected as well as the instance type of T2.micro that is pre-selected.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/780/1*HSDBY00lB4LOVhgP7tSKJg.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/781/1*lnAdrxQeY-QOtlrZOcV5lQ.jpeg" /></figure><p>In the Key pair section, we will select the key pair we created earlier in this tutorial. Hit the down arrow to choose your key pair.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/778/1*mwK6Hg_1q65SNQn8vMkFiA.jpeg" /></figure><p>We need to make some adjustments in the next section as well. In Network settings, you will see an option to “Create security group” or “Select existing security group.” Since we already made one, go ahead and hit “Select security group.” Click the drop-down and choose the group you created.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/810/1*djL0EcW17TypYweSOD7yvA.jpeg" /></figure><p>As a caveat, we could have created our security group while here; however, I wanted to show you the security group menu within EC2, which is why we went over there and created it.</p><p>The rest of the options will leave as default, and we can go ahead and hit the orange button on the right that says “Launch instance.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/384/1*-d8lkIZdL0Ft36qW1aErQQ.jpeg" /></figure><p>Click back to the instances area from your EC2 menu on the left side of the screen. If the menu disappears, click the three lines on the top left, and it will open back up.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/459/1*RUhPLYsBpRCbYc6mKqIMRQ.jpeg" /></figure><p>In your instances menu, after a minute or so, you will see your instance running under the “instance state” column.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/727/1*7IhO5eSfpC8liLN_8GOWDA.jpeg" /></figure><p>It&#39;s time to connect via SSH! Ensure your instance is selected, and then hit the connect button. Once here, click on the “SSH client” option. It will soon become vital that you know where the folder of your key file is located.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/856/1*iAdFnSjI4jHJcjLGHRVwOw.jpeg" /></figure><p>Once here, open your SSH client. As I am using Windows 10, I will use PowerShell. Once your prompt on Windows, use the command cd “insert folder name” to get you to the folder your keys are in. For example, I will use CD downloads. You won&#39;t be able to connect to your instance if you try and connect from any other file path than where your key file is. This is a layer of security for an SSH connection.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/878/1*oqgJoUGkFVZLCnAMQes7Sg.jpeg" /></figure><p>After this, you will copy the last line on the SSH client page back into your AWS Connection tab. Click the copy button on the left side of it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/803/1*GuOlMgf7fxJ6MG2pXu1I1g.jpeg" /></figure><p>Paste that command into your command line. Some text will pop up and ask you if you want to continue. Type yes and hit enter.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/856/1*YznCCEMbP7QAjUnzSqdmYg.jpeg" /></figure><p>After a second, your CLI should look like the following, which means you have successfully connected to your instance! If you had any errors, it could mean that you tried to launch SSH from the wrong file path of where your key file is stored.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/841/1*GkO2ab2vefhmfSX9DFFsEA.jpeg" /></figure><p>Next, we will run the “whoami” command to verify our connection.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/516/1*9TCR3Z4W7UjDznpMHQlSLA.jpeg" /></figure><p>And just like that, you have jumped tank-to-car into launching and SSH connecting into your first EC2 instance on AWS!</p><p>To recap section one, you performed the following tasks:</p><ul><li>Launched an EC2 instance with a Linux-based OS and Keypair</li><li>Created a Security group that allows SSH connections</li><li>SSH connected into the Instance and ran the “whoami” command to verify the connection</li></ul><p>Now, let’s kick it up a notch and add another layer of security with SSM!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*4l71GxGY5NJVJK0zIFkVIw.jpeg" /></figure><p><strong>Section Two</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*I-VkAokilIdbqVRim_UD0Q.jpeg" /></figure><p>In this section, we will:</p><ul><li>Create an IAM role to access the EC2 Instance via SSM</li><li>Ensure SSM is installed on the Instance using our CLI</li><li>Connect the EC2 instance through SSM</li><li>Verify our connection with the “whoami” command</li></ul><p>Go up to your search bar, type in IAM, and click on the first link</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/929/1*1QDobB-AP33dVcMBUm_hqQ.jpeg" /></figure><p>Once you are on the IAM dashboard, select “roles” from the menu on the left side of your monitor.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/280/1*uBW23PyVFUgxox3volinsQ.jpeg" /></figure><p>Click the “Create role” button on the top right of the roles dashboard.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/598/1*-Ff9To7-3kFXj84yfIBdQA.jpeg" /></figure><p>There will be a couple of options we need to ensure we choose on this menu. As the “Trusted entity type,” ensure you choose “AWS service.” This should be pre-selected for you; however, if you were working with other IAM roles, it may default to another choice.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h8vlgSfM8TRjqY1Am9CbNw.jpeg" /></figure><p>For the use case, ensure you select “EC2” from the drop-down menu and that the EC2 option is selected from the list below the drop-down.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/674/1*AKMWvDI5HsuVeC5Pkbr1cg.jpeg" /></figure><p>On the next page, we need to search for the proper permissions to add for this role. In the “Permissions policies” search bar, type AmazonSSMManagedInstaceCore or copy and paste from this article. Once you see that in the list below, select it and hit next.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_1NdO0Br-On7_ZNW_Iv8Jg.jpeg" /></figure><p>On the next screen, we will name our role. You can name it what you prefer; however, try and name it something related to the project. I will call mine “Project-SSM.” You can leave the description alone for now.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/812/1*JrgkZ3SPyagRZTPGkDKWqg.jpeg" /></figure><p>You will see the trust policy below written in a bit of code. This code specifies what is allowed with the permission we set and what isn’t. For now, you don’t have to know how to write this or edit it as Amazon has provided it for us; however, in the future, as you become more advanced, it is good practice to review this area for errors to ensure security.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/918/1*ANkJse8RXznGRhiYuVoOMQ.jpeg" /></figure><p>Go ahead and click “Create role” at the bottom right of the page. You will see a notification in green at the top of your screen that it was successful.</p><p>Let’s return to our EC2 instance to update the settings. Once there, select the instance we created in section one, click the actions button, click “Security,” and then click “Modify IAM role.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/547/1*zowD6E-NIHgmq3EtH81uyQ.jpeg" /></figure><p>On the next screen, you will see a drop-down menu. Select the security group you created, then hit the orange “Update IAM role.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8l_WwfncCX5rw1z7puKgWQ.jpeg" /></figure><p>Before using this method to connect, we must ensure the AWS SSM plugin is installed in our Instance. Due to this being the Amazon Linux, it comes installed. However, we will walk through the steps to check.</p><p>Back to our CLI interface, which we were using for SSH, connect back to your Instance. Once there, run the following command:</p><pre>sudo systemct1 status amazon-ssm-agent</pre><p>This command will verify the SSM plugin is running on your instance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/828/1*VfN6527bE3o5CnUFU4to-w.jpeg" /></figure><p>As you can see, we are good to go!!</p><p>On the instance menu, select your instance again and hit the connect button at the top. This time, we will head over to the session manager tab rather than the SSH tab.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/898/1*f7KAzKT_DiJw9yYOk4I8fg.jpeg" /></figure><p>You can see in the picture above it is currently configuring the Instance to connect via SSM, so the connect button is currently not available to click. The first time takes a while, so be patient!</p><p>As you can see, we are ready to go after a bit of a wait.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/874/1*AgGQZCruTp3tFwmWPgeUnw.jpeg" /></figure><p>After hitting connect, a new tab should open up to the CLI, which looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/918/1*hFCKLlmbc2DTPcNi8x3DZQ.jpeg" /></figure><p>Let&#39;s try running the “whoami” command to verify our connection.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/566/1*hfNfIgQOJi3MnNWdwd8dLQ.jpeg" /></figure><p>And just like that, you have configured your EC2 instance to connect through SSM!</p><p>So, to recap what we accomplished in this section:</p><ul><li>Created an IAM role to access the EC2 Instance via SSM</li><li>Ensured SSM is installed on the Instance using our CLI</li><li>Connected the EC2 instance through SSM</li><li>Verified our connection with the “whoami” command</li></ul><p>Maybe you are a Windows fan saying, “James, come on, man…enough LINUX”! Well, Section Three is for you, and it starts NOW!</p><p><strong>Section Three</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*aSe0aPCs-gKSLQOfOZ-OeQ.jpeg" /></figure><p>In this final section, we will:</p><ul><li>Create a new security group with RDP access</li><li>Launch a new instance with Windows OS</li><li>Decrypt our security key file to allow a view of our password to connect to the Instance</li><li>Connect to RDP using the Windows Remote Desktop Application</li></ul><p>In the previous sections, we talked about how to create an EC2 instance and security group, so we will skip over a couple of parts at the start and cover where some options differ.</p><p>First, let&#39;s create a security group with the proper access. Instead of SSH access this time, we will give it the Inbound rule of RDP from anywhere-IPV4. You can name it what you want. I will call mine MyRDPAccess and copy that into the description as well.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xrkr4z6QgkpvyN6osFMj_A.jpeg" /></figure><p>Once you have created your security group, let&#39;s set up a new instance. We can’t use the one made in section one as we need to change the OS to Windows instead of Amazon Linux.</p><p>In the launch instance menu, ensure you give your instance a name; I will name mine MyWindowsRDP.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/801/1*Aq9EzMIdZ--4PoGl_RcJAw.jpeg" /></figure><p>In the next section of the menu, ensure this time you choose Windows as the OS Image.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/803/1*rCHLxGm4XwNEcIT7TTKu8A.jpeg" /></figure><p>Select the same key pair we created previously.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/783/1*PN3vdF17EG1BpCuUkyMJxQ.jpeg" /></figure><p>Select the security group we just created for RDP access in the Network settings.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/742/1*z_rGurVzLPBXc2Dq5qzKRA.jpeg" /></figure><p>Once that is all done, go ahead and launch your instance.</p><p>On the instance dashboard, you should see your new instance running. If it still says pending, give it a minute or so. Select your Instance and say connect. Once here, click the RDP client option at the top.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1007/1*qd4CMcpeW5E-FOnpzaPhgg.jpeg" /></figure><p>Now, for this, you will need an RDP client. Since we are using Windows, we will use the Remote Desktop Connection application already installed. You can also see a couple of things on this screen that are important for accessing our remote desktop instance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1007/1*kyhx3OOhXieOQAMsML9VVg.jpeg" /></figure><p>As you can see, your username and password will be the information you will need to connect and the DNS name you will need to put into the Remote Desktop Application on your computer. Go ahead and open Remote Desktop by typing remote in the search bar on the bottom left of your screen.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/413/1*RHOY2VYNVaLSrbSup2fL_w.jpeg" /></figure><p>Once you click the app, a menu will ask you to enter some information.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/411/1*BM1dSP8ADhVmxGFa95PiNA.jpeg" /></figure><p>Once here, copy the DNS name from the AWS tab and paste it into the field “Computer:”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/412/1*vNGHs1FickYWrRK-ktnO5Q.jpeg" /></figure><p>Once that is done, type the user name from your AWS tab into the “User name:” field. This should be Administrator as default.</p><p>Once done, hit connect, which will prompt you to enter your password. Back over on the AWS tab, you must decrypt the key file we downloaded earlier. If you did all this too quickly, you will get this screen and will need to wait.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/849/1*pAG4JFYbe4NBHsYKngZ7jA.jpeg" /></figure><p>Once it’s ready, we will need to upload our key file. Click the upload button and then select your key file from your computer. Click “Decrypt password” when done.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/818/1*5mk1qlKjI5tO3LiOWD3fHA.jpeg" /></figure><p>This will bring you back to the RDP menu, and the password will now be available. Copy and paste that into the password prompt on your Remote Desktop app.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/469/1*6WNo68-Ltu3IsloDybKJSw.jpeg" /></figure><p>Click OK to connect and then click Yes on the next screen. The remote desktop should now load up with Windows as your operating system!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_9YZFuGG33f8ygSfkMeAFw.jpeg" /></figure><p>To sum it all up for section three, we:</p><ul><li>Created a new security group with RDP access</li><li>Launched new instances with Windows OS</li><li>Decrypted our security key file to allow a view of our password to connect to the Instance</li><li>Connected to RDP using the Windows Remote Desktop Application</li></ul><p>Last but not least, unless you want to end up like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/622/1*qS5GBja7NUzP-vdCWsOZ1g.png" /></figure><p>Ensure to go back and terminate all your instances!</p><p><strong>Wrap it up</strong></p><p>I hope this tutorial was helpful for all you new AWS beginners out there in assisting you with launching EC2 instances and connecting to them using SSH, SSM, and RDP!</p><p>If tutorials like this pique your interest and you are enjoying the journey, please follow me here and connect with me on LinkedIn!</p><p><a href="https://www.linkedin.com/in/james-williamson-phr/">https://www.linkedin.com/in/james-williamson-phr/</a></p><p>See you next time.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e1b7ec4d515d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Website Hosting Using Amazon CloudFront and S3]]></title>
            <link>https://medium.com/@jawilliamson25/website-hosting-using-amazon-cloudfront-and-s3-c0e6c500cc3f?source=rss-76b11c604c11------2</link>
            <guid isPermaLink="false">https://medium.com/p/c0e6c500cc3f</guid>
            <category><![CDATA[aws-cloudfront]]></category>
            <category><![CDATA[cloudfront-and-s3]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[s3-bucket]]></category>
            <dc:creator><![CDATA[James Williamson]]></dc:creator>
            <pubDate>Mon, 18 Sep 2023 04:01:29 GMT</pubDate>
            <atom:updated>2023-09-20T20:14:50.625Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/525/1*1yUKezKiCIOziotPrPltWw.jpeg" /></figure><h3>Introduction</h3><p>So you took the red pill and stumbled upon this article revealing how easy it can be to host a static website. Throughout this tutorial, I will do my best to provide analogies so you don’t get lost in the matrix (Keeping the theme).</p><p>*This article will assume you already have created an AWS free tier account and have a basic understanding of technology. If you have not created and AWS free tier account, you can find a guide on how to do so here: <a href="https://www.youtube.com/watch?v=SFaSB6vgp8k">https://www.youtube.com/watch?v=SFaSB6vgp8k</a></p><h3><strong>Defining the tools</strong></h3><p>First, we need to define to tools used in this example of hosting a website via AWS which are CloudFront and S3.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/327/1*kplonSWDgCGdbd4NO9DlsQ.jpeg" /></figure><p><strong>Amazon S3: </strong>A cloud-based secure storage service that allows you to store multiple types of objects, such as hosted websites, as discussed in this article, applications, data analytics, and more. Rather than in folders or files within an HDD or SDD on your computer, the data is stored in <strong>S3 Buckets </strong>inside the cloud. Due to the objects being inside these virtual buckets inside the cloud, you can access your data anywhere. A similar product you may have used from a user side is <strong>Dropbox</strong></p><p>If you are still trying to figure out what an <strong>S3 Bucket </strong>is, think of it like you would a storage bin you put up in your attic with holiday decorations. You put stuff in it, you ensure it is sealed properly, and you go up and access it when it is that time of the year, except in this case, you are putting in virtual objects such as those listed above and thankfully don’t have to climb up into the attic to access it. All you need is an internet connection!</p><p><strong>CloudFront: </strong>A service that <strong>caches data </strong>which helps with speed of access to your web-hosted data by allowing users to connect to that data in areas closer to them(edge locations), reducing overall latency and improving performance. The service also helps with security by providing encryption and firewall protection on top of the protection offered by <strong>S3.</strong></p><ul><li>Caching — process of storing data in a temp facility/location for ease of access</li></ul><p>A real world situation to help describe <strong>CloudFront</strong> could be the network of ATM’s you find everywhere. Once you deposit your money into the bank(<strong>S3 Bucket</strong>), you can access your money anywhere at an ATM (even other ATM’s that aren’t your bank) rather than needing to drive all the way back to the exact location where you deposited your money.</p><p>Now that we have defined our tools and what they are in hopefully easy to understand terms, lets start with the fun stuff.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/577/1*YOpnQP6JTU81UwGPT28nVQ.jpeg" /></figure><h3>Hosting a Website using Amazon S3</h3><p>Starting from your AWS console(homepage), type S3 in the search bar at the top and then left-click the link. Be careful not to click S3 Glacier.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*Qic_ZCcJgz2kVvtO" /></figure><p>Once you hit the S3 dashboard, you will see a “create bucket” button on the right-hand side of the screen. Hit it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/603/0*kmcUYe6X7M6mAeeE" /></figure><p>Once here, you will see a menu containing quite a few fields, but let’s start at the top with the “Bucket name” field. This may be populated with a unique name not shared with any other bucket across all AWS. For example, I am naming mine random-static-website2.</p><p>Ensure all letters are lowercase. The AWS region doesn’t matter much for now, as it defaults you to the closest region.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/799/0*z3lw5z5tSY72f6ET" /></figure><p>The following menu we will look at is “Object Ownership.” Ensure you select the option for ACLs to be enabled. This will allow us to open public access to our website later.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/799/0*lBdR0qsbsxo-wwAg" /></figure><p>The following setting we need to ensure is correct: we have unchecked the box “Block all public access.” This will also allow the public to access our website.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/793/0*rGD1m9-hCAv5od46" /></figure><p>All the other options can be left as is! Scroll to the bottom and hit “Create bucket.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/422/0*jRPFiFnjNQ6NFfLt" /></figure><p>Now that we have created our bucket and have enabled settings to allow public access let’s drop in some things that will be our actual website. Now, remember we aren’t working on developing an entire website, just learning how to HOST a website via S3. We will use some premade code for the website in this tutorial.</p><p>Once you have created your bucket, return to your bucket list, find your bucket, and left-click the name.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*5H9xFx3Q1796nna0" /></figure><p>Once inside the bucket, you will see an option to “Upload.” Click it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*ixlamELjoO9p4TY7" /></figure><p>Once you are in his menu, hit Add Files, select your HTML document from the drive on your computer(in my example, you will see index.html), and then hit upload at the bottom of your screen.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*BAgBVaeYWBaeyvp7" /></figure><p>Once complete, you will see your file successfully uploaded into your bucket.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*anXR6pNvSx30AzO3" /></figure><p>Now, we need to enable static website hosting for our bucket.</p><p>Back in your bucket, find the permissions menu near the top of the page and then scroll down to see the “static website hosting” section. Hit the edit button to configure.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*5AY1qtznrEdc_bWR" /></figure><p>In this menu, we need to enable static website hosting and ensure we input our website’s index document (default page). This will be the file we uploaded earlier, which will be index.html. The error document is optional; however, this would be where the website would take you should there be an error (we will ignore it for now). Save these changes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*3bDIoYDD6tkG95Y3" /></figure><p>Once you are done, go back to the top where you are on the permissions tab of the bucket menu and go back over to objects. Now that we are hosting a static website, we must also make the object within the bucket accessible to the public. Once on the thing, select it by checking the box and then hit the actions drop-down at the top right. Select “Make public using <strong>ACL</strong>”.</p><p>Let’s define an <strong>ACL</strong> — This enables you to manage access to buckets and objects within the buckets.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*q69mCqUAkmm7LaeF" /></figure><p>After that, you will be brought to another menu where you must click “Make public.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*qceWFfpHENrRfgNe" /></figure><p>Now to see our website in action!! Go back to the permissions tab and scroll to the bottom again to the static website hosting section. You will see your bucket website endpoint at the bottom in HTTP format. Click the copy button as indicated and paste it into a new browser tab.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*VEylD-svbFpDKrzX" /></figure><p>And BOOM, here is your functioning website hosted by Amazon S3!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*km4edHioa_qhDyUf" /></figure><p>Next we will use CloudFront to ensure low latency and high performance for our website anywhere in the world.</p><h3>How to use CloudFront</h3><p>Similar to how we started before, let’s go up to the search bar and search for <strong>CloudFront</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*Ej-PF4rHXYtn5pPT" /></figure><p>After clicking the link, you will see a button that says Create a <strong>CloudFront</strong> distribution. Click it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/599/0*xo8_WIe5gcOn_nIZ" /></figure><p>Once connected, you will be brought to another menu where we must configure some things.</p><p>First will be the Origin domain. Return to your <strong>S3 </strong>bucket in another tab and scroll down to static website hosting again. Copy the bucket website endpoint, return to your <strong>CloudFront</strong> tab, and paste that link into the Origin domain box. Ensure you delete the HTTP portion of the URL.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*TAyruGf-IQpxUBs1" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/637/0*ojapuXOavUhz6FCl" /></figure><p>Next, scroll down until you see a setting that says viewer protocol policy and select Redirect HTTP to HTTPS. This only allows access via the HTTPS protocol and redirects all HTTP traffic to HTTPS.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*PrbYgw2RPhFtkxG4" /></figure><p>Leave the Web Application Firewall(WAF) disabled for now.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/799/0*KSQMRh32CbD2DsIM" /></figure><p>Once the distribution is created, you will copy the distribution domain name into a new tab, and VIOLA, you have a website that will open in HTTPS with all HTTP traffic diverted. If you try to edit the URL to HTTP, you will see it convert to HTTPS when you press enter.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/525/0*Z3TBIka08O00GJDO" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*MbCIUSz4Uq4guKDB" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/307/0*iVv8tka6yJwe0NRb" /></figure><p>Lastly, let’s verify that <strong>CloudFront</strong> is performing the caching function appropriately. We will start by altering some data in the original HTML document using <strong>Visual Studio Code </strong>and then upload it into our bucket as well. We will call it Index1.html.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/730/0*RGwCLG8IiCMA6w1k" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*kbRH1zeR56D5R0Nk" /></figure><p>After clicking on the object and going to the object URL, access is denied as the caching function on <strong>CloudFront. </strong>We will use the previous version, which still needs updating.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/587/0*sXThZygRIOC9RHnS" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/732/0*3z2QJZQRWT998fem" /></figure><p>Let’s finalize this thing and make it more secure!</p><h3>Establish Access only through CloudFront.</h3><p>Let’s venture back to the <strong>S3 Bucket</strong> and reconfigure some settings.</p><p>Back in the permissions tab, we will enable Block all public access.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*38gWwpEGNOFLH58o" /></figure><p>Now, return to your static website hosting URL and try it again. OOPS doesn’t work anymore. This is what we want.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/667/0*-nuvVBhhVGqe3PBG" /></figure><p>Let’s swap back over to our <strong>CloudFront</strong> Dashboard and go into the distribution we created. Select your Origin and click edit.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*PSMerlcvS12skUU_" /></figure><p>Here is where things change a bit. Remember before we used the static hosting website URL in the Origin domain here and deleted the HTTP portion? We will select our bucket from the drop-down and click it this time. A caution message will come up, and we will ignore it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/678/0*zRiqCe74a5VF0JWA" /></figure><p>Next, we will scroll down to the Origin Access portion and select Origin Access Control settings. This restricts bucket access to only <strong>CloudFront</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/791/0*Ctsdm3YX6jvYyuvU" /></figure><p>We will then need to create a control setting, so click the button to bring up the menu. It will fill in the name and click Do not sign requests for this example. Click Create.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/589/0*3eD26mVjRp615IDe" /></figure><p>Once that is done, we need to edit our bucket policy with the policy generated by <strong>CloudFront</strong>, which it gives us so graciously. You will see a Copy policy button after creating your control setting. Click it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/767/0*xh9-e-KGeusKFgZm" /></figure><p>Let’s go back and perform the final step! Open up permissions in your bucket we made at the start of this tutorial, find Bucket Policy, and click Edit. Paste the Policy into the terminal and hit save changes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/754/0*TkLwcITAT9cDiekM" /></figure><p>Now, let’s go back to your <strong>CloudFront</strong> distribution. Copy the domain name again and paste it into the browser.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/556/0*yoBMRmsMlRJ5vR45" /></figure><p>And now, no one can access the data in your bucket, and you must use <strong>CloudFront</strong> to get to your site! A fantastic layer of security!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*4-CzaFWdJ2gYil3C" /></figure><h3><strong>Conclusion</strong></h3><p>You made it!!</p><p>Here is what we were able to accomplish using this tutorial</p><ul><li>Defined the services used for hosting a static website</li><li>Configured an <strong>S3 </strong>Bucket to host a static website</li><li>Used <strong>CloudFront</strong> to cache our website in edge locations to improve performance</li><li>Added an additional layer of security by allowing access only through <strong>CloudFront.</strong></li></ul><p>As you continue your learning journey along with me here is a great quote from Aristotle to keep in mind:</p><p><strong>“For the things we have to learn before we can do them, we learn by doing them.”</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XyYJlV9G0zZnyKmG_fsePA.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c0e6c500cc3f" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>