<?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 Virgil B Majors II on Medium]]></title>
        <description><![CDATA[Stories by Virgil B Majors II on Medium]]></description>
        <link>https://medium.com/@redslick84?source=rss-a66bc99a7358------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Q6FeLoRS8nrBpwxbvC_pOg.png</url>
            <title>Stories by Virgil B Majors II on Medium</title>
            <link>https://medium.com/@redslick84?source=rss-a66bc99a7358------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 16:48:09 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@redslick84/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[AWS vs Azure vs GCP]]></title>
            <link>https://medium.com/@redslick84/aws-vs-azure-vs-gcp-4933f48aaae4?source=rss-a66bc99a7358------2</link>
            <guid isPermaLink="false">https://medium.com/p/4933f48aaae4</guid>
            <category><![CDATA[gcp]]></category>
            <category><![CDATA[azure]]></category>
            <category><![CDATA[virtual-machine]]></category>
            <category><![CDATA[cloud-services]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Virgil B Majors II]]></dc:creator>
            <pubDate>Wed, 27 Dec 2023 03:00:04 GMT</pubDate>
            <atom:updated>2023-12-27T03:00:04.628Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wQMOBpNNzICJ6LGQGbDvJA.png" /></figure><p>Have you ever wondered what the differences between the cloud goliaths are?</p><p>In this article we will jump into some history, the services and structures of each. and some simple advice on using them.</p><p>First up is AWS</p><h3>AWS:</h3><p>Amazon Web Services (AWS) is the one of the world’s most comprehensive and broadly adopted cloud platform, offering over 200 fully featured services from data centers globally. AWS has by far the largest market share of customers utilizing their services.</p><p>AWS launched in 2006 when it started offering IT infrastructure or cloud computing to businesses.</p><p>Check out this video to dive a little deeper:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2Fa9__D53WsUs%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3Da9__D53WsUs&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2Fa9__D53WsUs%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/2cf819488580c936295e3011e839eb31/href">https://medium.com/media/2cf819488580c936295e3011e839eb31/href</a></iframe><p>Next up we have Azure:</p><p>Microsoft Azure, often referred to as Azure, is a cloud computing platform run by Microsoft. Just like AWS it offers access, management, and the development of applications and services through global data centers.</p><p>Azure also offers more than 200 product to chose from when building out your solutions.</p><p>Microsoft Azure launched in 2010 and is has the 2nd highest market share of customers today.</p><p>Check out this video to dive a little deeper:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FoPSHs71mTVU%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DoPSHs71mTVU&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FoPSHs71mTVU%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/a7de721d01be3665165cbf1953a690bb/href">https://medium.com/media/a7de721d01be3665165cbf1953a690bb/href</a></iframe><p>Last but not least we have the household name that everyone knows…</p><p>Google:</p><p>Google Cloud Platform (GCP) is a suite of cloud computing services that provides a series of modular cloud services including computing, data storage, data analytics, and machine learning, alongside a set of management tools.</p><p>GCP also offers hundred of different cloud solutions to fit the needs of big and small endeavors alike.</p><p>GCP launched in 2008 and is ranked as the 3rd largest cloud platform by market share.</p><p>Check out this video to dive a little deeper:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F4D3X6Xl5c_Y%3Fstart%3D46%26feature%3Doembed%26start%3D46&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D4D3X6Xl5c_Y&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F4D3X6Xl5c_Y%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/676502d66b3e16eb053a44db4e310744/href">https://medium.com/media/676502d66b3e16eb053a44db4e310744/href</a></iframe><p>If you actually visited every launch page, and watched every video synopsis you may have noticed a pattern…</p><h3>THEY ALL DO the same things!</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/0*AW9vRXmpgUGQv0pQ.gif" /></figure><p>I know as developers and cloud engineers we typically get used to the platform we learned on and never look back especially if your employer mandates a certain provider.</p><p>I employ anyone who may be feeling a lack of confidence on applying your skillset within a different cloud platform to just try it out.</p><p>I started with AWS, but found Google and Azure to be just as intuitive.</p><p>I was able to play around with VM’s on GCP’s &amp; Azure’s platform.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/646/1*IXVBuy6FxL4eBNQeGzUdRA.png" /></figure><p>Go try!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*t1pWZAdoFoQBpB7j.gif" /></figure><p>I am technically still using the free tiers on every platform, but I did notice that with GCP, &amp; Azure the billing methods lets you explore and build what if scenarios, where as AWS can be a bit of a guessing game.</p><p>This is by no means an in-depth comparison article, if you want that please read this well written article that has already be done for us! =)</p><p><a href="https://www.coursera.org/articles/aws-vs-azure-vs-google-cloud">What&#39;s the Difference Between AWS vs. Azure vs. Google Cloud?</a></p><p>Please keep following me on my journey as I continue to learn more.</p><p>Don’t forget:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/587/1*E58jo-B5wk72WgYXC8jhTw.jpeg" /></figure><p>Virgil</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4933f48aaae4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deploying EC2's and S3 buckets using Terraform only!]]></title>
            <link>https://medium.com/@redslick84/deploying-ec2s-and-s3-buckets-using-terraform-only-fc55e37223b9?source=rss-a66bc99a7358------2</link>
            <guid isPermaLink="false">https://medium.com/p/fc55e37223b9</guid>
            <category><![CDATA[cloud9]]></category>
            <category><![CDATA[s3]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[terraform]]></category>
            <category><![CDATA[ec2]]></category>
            <dc:creator><![CDATA[Virgil B Majors II]]></dc:creator>
            <pubDate>Thu, 24 Aug 2023 12:36:19 GMT</pubDate>
            <atom:updated>2023-08-25T17:14:05.078Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uBKAOmIhbxkgvRMhUh6eTQ.jpeg" /></figure><p>Good day all, here is my next project assigned by the Level Up In Tech program.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/200/1*of3jn8wz-CfgsOrp7OheDg.png" /><figcaption>LUIT logo</figcaption></figure><p>The assigment…</p><p>Using Terraform:</p><p>Deploy 1 EC2 Instances in your Default VPC.</p><p>Bootstrap the EC2 instance with a script that will install and start Jenkins.</p><p>Review the official Jenkins Documentation for more information: <a href="https://www.jenkins.io/doc/book/installing/linux/">Linux</a></p><p>Create and assign a Security Group to the Jenkins Security Group that allows traffic on port 22 from your ip and allows traffic from port 8080.</p><p>Create a S3 bucket for your Jenkins Artifacts that is not open to the public.</p><p>Verify that you can reach your Jenkins install via port 8080 in your browser. Be sure to include a screenshot of the Jenkins login screen in your documentation.</p><p>Push your code to GitHub.</p><p><strong>Requirements:</strong></p><p>AWS account ( We will be using a Cloud9 environment)</p><p>Knowledge of basic terraform commands and what they do.</p><p>Github account</p><p>Let’s begin!</p><p>First log into your AWS account and create your cloud9 environment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/643/1*qfLY3Fbd-NRbKzgabWU--A.png" /></figure><p>After your cloud9 enviroment is ready if you are not already in the IDE, click open. This will take you here:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OBF5dE7lTAm1MOO65RCKaw.png" /></figure><p>The two webpages that you will most likely use most when buiding out your terraform code are here:</p><p><a href="https://registry.terraform.io/">Terraform Registry</a></p><p><a href="https://developer.hashicorp.com/terraform">Terraform | HashiCorp Developer</a></p><p><strong>Terraform is an infrastructure as code (IAC) tool that lets you build, change, and version control cloud and on-prem resources safely and efficiently.</strong></p><p>Within these webpages you are sure to find the documentation and examples on how to and why…</p><p>In my environment I created a Terraform_practice directory. Within this directory I created another called Week_20_project.</p><p>Create a new file with the<em> .tf </em>extension. This tells our IDE that this is a terraform file.</p><p>I named my file Week_20_project.tf (best practice is to name your project main.tf)</p><p>It is extremely important in terraform that all projects that are not connected or sharing resources be in seperate directories because the terraform init, plan &amp; apply commands in terraform will initialize your working directory and automatically look for all .tf configuration files.</p><p>Terraform is cloud agnostic, meaning that is can run on any cloud platform. We know we are using AWS, so we will navigate to that specific documentation on the terraform registry page. It will be under <strong>AWS provider.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MBOnsOMk6X4J1fKxmUD2JQ.png" /></figure><p>We will copy this code into our <em>.tf </em>file.</p><p>Make any necceassary changes. In my case I use a different region than the one provided in the example.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/464/1*yVVqfQwuepyGTYWMP3izBw.png" /></figure><p>The next step will be to define our resources.</p><p>We were tasked with creating an EC2 instance that install and start jenkins.</p><p>The below documentation tells us how to achieve this in terraform.</p><p><a href="https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/instance">aws_instance | Resources | hashicorp/aws | Terraform | Terraform Registry</a></p><p>My code looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/585/1*L35gpzv8fiDLB3XxfPoXBg.png" /></figure><p>In this block of code I did a few more tasks that were a part of this project…</p><p><em>ami</em>: I copied and pasted the ami-id from the amazon linux2 instance with the AWS console</p><p><em>instance_type</em>: I defined “t2.micro” free tier</p><p><em>key_name</em>: “id_rsa” I defined my public key in another resource block ( we will touch on that later )</p><p><em>count</em>: 1 ( I only need to deploy 1 instance )</p><p><em>vpc_security_group_ids</em>: I used a previously defined security group ID that uses my default VPC and allows ssh (port 22).</p><p>I added an additional rule to allow http traffic from (port 8080).</p><p>You can create a security group and grab the ID from the AWS console.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jqUXmNkREMB_FPvcHkyIQA.png" /></figure><p>After running terraform plan and terraform apply, I check my AWS console and see the Ec2 I created.</p><p>In terraform we can input a user data field using by this command:</p><pre>user_data = &lt;&lt;EOF install / start some thing EOF</pre><p>&lt;&lt;EOF is a Heredoc String that is used to define a multiline script.</p><p>The first attempt to install jenkins failed. I researched the error code</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/802/1*hjrbM-_M5CGydb5RAhkj5Q.png" /></figure><p>Results came back showing that I also need to install java with jenkins.</p><pre>sudo apt install openjdk-11-jre</pre><p>run the jenkins intall again.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hzCh9rmITHpKuBfNA2XVkw.png" /></figure><p>Jenkins has now been succesfully installed.</p><p>We also input the keypair resource</p><p><a href="https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/key_pair">aws_key_pair | Resources | hashicorp/aws | Terraform | Terraform Registry</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/359/1*bcAVcLs_vU1RRHkKYhCj1g.png" /></figure><p>It should be noted that after every resource block, I ran terraform validate followed by terraform plan and terraform apply to make sure everything was working correctly before my code became too large and more complicated to correct errors.</p><p>The next task was to create and s3 bucket that is not open to the public.</p><p><a href="https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket">aws_s3_bucket | Resources | hashicorp/aws | Terraform | Terraform Registry</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/281/1*VAoeiMpZM9bEnKs46YNNLw.png" /></figure><p>We use the <em>acl </em>argument and set it to private. The documentation advised that this argument was deprecated, but is still functional.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/668/1*YsTxp3toUWSJJvI32c9jkA.png" /></figure><p>Run terraform plan &amp; terraform apply.</p><p>Now lets check the AWS console for our s3 bucket</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cwARC12LdW9IZYiNx4keDQ.jpeg" /></figure><p>Success!! And we see the Bucket is not public.</p><p>Lastly lets make sure we can reach can reach our jenkins install on port 8080 in the browser.</p><p>Copy and paste the instance url and add :8080 to specify the port</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/968/1*svUVqTS_jokvNvt28Q58rA.jpeg" /></figure><p>Success!!</p><p>The instructions on how to find your jenkins admin password is included on this page.</p><p>You can cd /var</p><p>Then cat sudo cat /var/lib/jenkins/secrets/initialAdminPassword</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*p55e1v6ytgmL8ejWx7kayw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/992/1*rOBr1Jmg9hMbmV8s4SXFEw.jpeg" /></figure><p>We are all installing jenkins &amp; officially done with this project!</p><p>Here is a link to my github</p><p><a href="https://github.com/Vmajors84/terraform_repo/blob/main/terraform/week_20_project/week_20_project.tf">terraform_repo/terraform/week_20_project/week_20_project.tf at main · Vmajors84/terraform_repo (github.com)</a></p><p>Thanks for reading!!</p><p>Remember…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/587/1*E58jo-B5wk72WgYXC8jhTw.jpeg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fc55e37223b9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Diving into MySQL, Wordpress and Docker Swarm clusters and how they work together.]]></title>
            <link>https://medium.com/@redslick84/diving-into-mysql-wordpress-and-a-docker-swarm-clusters-and-how-they-work-together-ab25ede93bad?source=rss-a66bc99a7358------2</link>
            <guid isPermaLink="false">https://medium.com/p/ab25ede93bad</guid>
            <category><![CDATA[docker-swarm]]></category>
            <category><![CDATA[mysql]]></category>
            <category><![CDATA[wordpress]]></category>
            <dc:creator><![CDATA[Virgil B Majors II]]></dc:creator>
            <pubDate>Tue, 15 Aug 2023 23:40:16 GMT</pubDate>
            <atom:updated>2023-08-16T01:07:44.380Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/910/1*IB390g-d1avy4_FGo8IKfQ.png" /></figure><p>Hello, today we will be building a 3 nodes Docker Swarm cluster and running MySQL and Wordpress containers.</p><p>This was a project assigned be the Level Up In Tech Program</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/200/1*of3jn8wz-CfgsOrp7OheDg.png" /><figcaption>LUIT logo</figcaption></figure><p><strong>The assignment:</strong></p><p>Using the CLI:</p><p>Deploy a 3 node Docker Swarm cluster.</p><p>Create 2 networks. One for frontend and another for backend.</p><p>Create MySQL service associated with the backend network, make only 1 replica.</p><p>Make the database service resilient and its data persistent across container restarts, use Docker Volumes.</p><p>Create the Wordpress service associated with the frontend network.</p><p>Should use port 80.</p><p>Accessible from the browser.</p><p>3 replicas.</p><p>Associate with the MySQL service.</p><p><strong>Requirements:</strong></p><p>You need to have an AWS account.</p><p>Basic understanding of Linux</p><p>You should have a Dockerhub account.</p><p>While not required I recommend using <em>Visual Studio Code</em> for this project.</p><p><em>Visual Studio Code (VS Code) </em>is a source code editor / integrated development environment.</p><p>Most of this process will be done from the command line.</p><p>You should have a basic understanding of the Docker services and commands.</p><p><strong>Let’s begin.</strong></p><p>This project assumes that you have set up your docker swarm environmet.</p><p>First log into AWS and create the 3 instances that we will run our docker swarm on.</p><p>For my instances I selected Ubuntu 22.04 (free tier).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*OjZqFGWTB2eDV_OA.png" /></figure><p>Select your keypair and allow ssh and http from your security group. We will set up all 3 of our instance the same.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/610/0*ZE3YQxSMsYKDik-H.png" /></figure><p>The shortcut for doing so is in the image above.</p><p>Once your instances are running, open up VS code and ssh into your first instance.</p><p>I‌ re-named all the instances to node1, node2 and node3.</p><p>ssh into each instance and run this command</p><pre>sudo hostnamectl set-hostname </pre><p>Node1 will be the manager node, and the other nodes will be the worker nodes.</p><p>Again this project assumes you have docker swarm set up… If you need a walkthrough for that please see my other medium article:</p><p><a href="https://medium.com/@redslick84/setting-up-docker-swarm-with-multiple-nodes-494dc4f23a69">Setting up Docker Swarm with multiple nodes…</a></p><p>Once everything is setup, we begin by creatinh our front end and backend networks.</p><p>There are several options for network creation within Docker.</p><p>Info found here:</p><p><a href="https://docs.docker.com/engine/reference/commandline/network_create/">docker network create | Docker Documentation</a></p><p>Because we are using Docker Swarm, we must use the <em>overlay</em> network driver when we create our frontend and backend networks.</p><p>The <em>overlay</em> network driver creates a distributed network among multiple Docker daemon hosts. This network sits on top of (overlays) the host-specific networks, allowing containers connected to it (including swarm service containers) to communicate securely when encryption is enabled. Docker transparently handles routing of each packet to and from the correct Docker daemon host and the correct destination container.</p><p>We also create the MySQL service by inputing the below command.</p><p>In the last command we are specifying the docker service mysql, specifying the network driver, specifying attached to the backend network, specifying (1) relplica, naming the mysql-database, setting up the password and creating persistent data by creating a volume.</p><p><em>-e</em> is for the environment variables</p><pre>docker network create -d overlay --scope=swarm backend<br>docker network create -d overlay --scope=swarm frontend<br>docker service create --docker network create -d overlay --scope=swarm backend&#39;: docker service create --replicas=1 --network backend --name my-database -e MYSQL_ROOT_PASSWORD=password --mount type=volume,source=mysql_home,destination=/var/mysql_home  mysql<br></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*13NqJx3vR1L_Kr9pb52nWQ.jpeg" /></figure><p>Next we will create our wordpress service:</p><p>This is esstially the same format as above with a few changes.</p><p>Here we published port 8080:80, created 3 replicas, associated the wordpress service to the front end and backend networks and named it.</p><pre>docker service create -p8080:80 --replicas=3 --network frontend --network backend  --name my-wordpress wordpress</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/938/1*AoznSwGSPcCTI6hdvgqg9A.jpeg" /></figure><p>Check your public IP to make sure everything is working as intended.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QDv22iKPkRAyptOElZRcXw.jpeg" /></figure><p>Follow the next set of instructions as you continue.</p><p>Run docker service ls to make sure both created services are running and set to the correct specifications.</p><pre>docker service ls </pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/611/1*lZsQOAw0g3vnWNc67K0ugw.png" /></figure><p>This is also good for obtaining the name and ID to run the next command.</p><p>You find your database host by running docker service inspect</p><pre>docker service inspect &lt;ID&gt; &lt;name&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/537/1*pqHpYZ50alaBkB91nEaHdg.png" /></figure><p>Input your created credentials and log in.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8ciTtzyEsuBJpa6nhgjYYw.jpeg" /></figure><p>After you connect succesfully connect to the wordpress website this project is complete!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QqnSlFL-hxeRmV9hTqjSZQ.jpeg" /></figure><p>Thanks for reading…</p><p>Remeber…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/587/1*E58jo-B5wk72WgYXC8jhTw.jpeg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ab25ede93bad" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Setting up Docker Swarm with multiple nodes…]]></title>
            <link>https://medium.com/@redslick84/setting-up-docker-swarm-with-multiple-nodes-494dc4f23a69?source=rss-a66bc99a7358------2</link>
            <guid isPermaLink="false">https://medium.com/p/494dc4f23a69</guid>
            <category><![CDATA[swarm]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[cli]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Virgil B Majors II]]></dc:creator>
            <pubDate>Mon, 07 Aug 2023 23:55:00 GMT</pubDate>
            <atom:updated>2023-08-08T01:44:31.343Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*n2JAq2_TU-I91-iB_4hRCg.jpeg" /></figure><p>Hello all!</p><p>Here is another project assigned by the Level Up In Tech Program.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/200/1*of3jn8wz-CfgsOrp7OheDg.png" /><figcaption>LUIT Logo</figcaption></figure><p>Today we will set up and deploy another docker service called docker swarm.</p><p><em>Docker Swarm — a mode built into Docker that lets you replicate containers across multiple physical / virtual machines. Swarm mangages the containers through nodes where you specify manager and worker nodes to improve fault talerance.</em></p><p>The assignment:</p><ul><li>Installing docker on all hosts</li><li>Verifying that docker is in an active state</li><li>Change the hostname on each node to identify the master node and the two worker nodes</li><li>Validating the worker nodes all share the same security group as the master node</li><li>Be sure to add your ssh key to each node</li><li>Running the necessary containers using the CLI</li><li>Creating the Swarm using one master node and two worker nodes</li><li>Show your team members the status of the docker nodes</li></ul><p><strong>Requirements:</strong></p><p>You need to have an AWS account.</p><p>Basic understanding of Linux</p><p>You should have a Dockerhub account.</p><p>While not required I recommend using <em>Visual Studio Code</em> for this project.</p><p><em>Visual Studio Code (VS Code) </em>is a source code editor / integrated development environment.</p><p>Most of this process will be done from the command line.</p><p>You need to have a text editor such as <em>VI </em>or <em>VIM</em></p><p>You should have a basic understanding of the Docker services and commands.</p><p><strong>Let’s begin.</strong></p><p>This project assumes that you have set up your docker environmet.</p><p>First log into AWS and create the 3 instances that we will run our docker swarm on.</p><p>For my instances I selected Ubuntu 22.04 (free tier).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/794/1*kQGwb_umJXdahmDOp2h4FQ.png" /></figure><p>Select your keypair and allow ssh from your security group. We will set up all 3 of our instance the same.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/610/1*F3TK_JcEDzSfH6UkUBgRoQ.png" /></figure><p>The shortcut for doing so is in the image above.</p><p>Once your instances are running, open up VS code and ssh into your first instance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/793/1*4ElDfqvZPxgwKnEBC0yT0Q.png" /></figure><p>We will install docker on all 3 instances with this command:</p><pre>curl -fsSL https://get.docker.com -o get-docker.sh</pre><p>To check that docker properly installed run this command on all your instances:</p><pre>docker version</pre><p>If done correctly you should get a screen that looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/325/1*uhCsJhipVWv4OcE-GscLdA.png" /></figure><p>We will change the names of all 3 instances to make life easier.</p><p>To change the names of your nodes run this command inside of each instance:</p><pre>sudo hostnamectl set-hostname </pre><p>I‌ re-named all the instances to node1, node2 and node3.</p><p>Logout and log back in and you should see your updated names.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/527/1*nnrleY3HXZEiStx95n8hAw.jpeg" /></figure><p>In docker swarm you can create a manager node and worker nodes.</p><p>Node1 will serve and the manager node for this project because this is the instance where we will run all of our swarm commands.</p><p>Next lets make sure we can ssh into our other instances from node1.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/540/0*5WiT-ysUJTsVe9Ek.gif" /></figure><p>We can check our current directory by running:</p><pre>pwd</pre><p>We are in /home/ubuntu</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/234/1*y0Ogo8VsAx_nTEx88TDCWg.png" /></figure><p>Next chage directory into the .ssh folder.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/196/1*c-dYwATCyi4jsdHRYnChIw.png" /></figure><p>We check the contents. We need to put the contents of the chosen keypair file into this folder.</p><p>Locate your keypair .pem file in your downloads folder and open it with a text reader application.</p><p>Copy the contents.</p><p>Come back to VS code and open VI or VIM.</p><p>Paste the contents of the keypair file into VI or VIM.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/607/1*R8b6Dh1k-sJCRtGYWsyTwA.png" /></figure><pre>:wq mykeypair</pre><p>Save the file.</p><p>Check the folder again…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/197/1*q78eivuvTG9iLjbJmehepw.png" /></figure><p>We now see the file we created.</p><p>Navigate to the AWS console click on a different instance, copy your ssh connect code and attempt to ssh into the other instance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/815/1*CCWlWK8EDv9pzAju9LN4oA.png" /></figure><p>We got this message explaining that the file we are executing is too open.</p><p>We need to set the permissions for the keypair file.</p><p>The permisions were not restrictive enough, so we now will set the keypair file so that only the owner can execute the file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/435/1*Q_MRaxS-muedxNpFp-81rw.png" /></figure><p>Accommplish this by running this command:</p><pre>chmod 400 mykeypair</pre><p>See the new permissions? We have now restricted the keypair file to the owner.</p><p>Try the ssh command again.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/679/1*ock8j0N2aWfFUnANBGOw-g.png" /></figure><p>We are in!</p><p>Check both other instances to ensure succesful log in.</p><p>Type exit to leave the other instances.</p><p>Once you are back to node1 run this command:</p><pre>sudo su</pre><p>To enter root user CLI</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/213/1*AJawNlfXix8f4uODduDmnQ.png" /></figure><p>Here change directory to root.</p><pre>cd /root</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/103/1*8GxssN2kg8yJCDB5XQMfjg.png" /></figure><p>Copy the .ssh folder recursively (meaning we will copy all the files and sub directories of this folder ):</p><pre>cp -r .ssh</pre><p>Change directory to .ssh and create a config file using VIM</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/338/1*2DEitxOkPRPltHwFwOxg5w.png" /></figure><pre>Host node2<br>  HostName 172.31.33.13<br>  User ubuntu<br>  IdentityFile /root/.ssh/mykeypair<br><br><br>Host node3<br>  Hostname 172.31.46.81<br>  User ubuntu<br>  IdentityFile /root/.ssh/mykeypair</pre><p>This config file sets the Hosts ( Node2 &amp; Node3) ,Hostname (the IP of the hosts), and tells docker where the identity file is /root/.ssh</p><p>We should now be able to ssh into the other intances using the commands</p><pre>ssh node2<br>ssh node3</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/595/1*4jBHOZBGKMSGGSArH4GE8w.png" /></figure><p>It works!</p><p>The last steps of this project will be to initialize docker swarm.</p><p>We run this command from node1:</p><pre>docker swarm init</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/556/1*2bP0_jC4QxAqV9c4hJhocw.png" /></figure><p>You will next be provided with a unique docker swarm join token.</p><p>ssh into the other both other nodes and paste the join token:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/767/1*4Fda_9vd4eOJ4voukMAS9A.png" /></figure><p>After completion exit back out into node1.</p><p>Run this command to check your swarm status:</p><pre>docker node ls</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/694/1*yhBwYl4lBcvbEJeVmCAdGQ.png" /></figure><p>Everything is set up correctly and we have and active docker swarm.</p><p>Thanks for reading!</p><p>Always remember:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/587/1*E58jo-B5wk72WgYXC8jhTw.jpeg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=494dc4f23a69" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Want to know how to use docker Compose? Read this article for the basics…]]></title>
            <link>https://medium.com/@redslick84/want-to-know-how-to-use-docker-compose-read-this-article-for-the-basics-f9b2cb3d453b?source=rss-a66bc99a7358------2</link>
            <guid isPermaLink="false">https://medium.com/p/f9b2cb3d453b</guid>
            <category><![CDATA[ec2]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[jenkins]]></category>
            <category><![CDATA[docker-compose]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Virgil B Majors II]]></dc:creator>
            <pubDate>Mon, 31 Jul 2023 18:44:40 GMT</pubDate>
            <atom:updated>2023-08-08T00:24:59.122Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Idb2SnZmb59AWpeJKcWy9Q.jpeg" /></figure><p>I’m back with another project assigned by the Level up In Tech program.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/200/1*of3jn8wz-CfgsOrp7OheDg.png" /><figcaption>LUIT Logo</figcaption></figure><p>In this article we will cover how to install and run a Jenkins LTS image from docker hub, then we will complete the same project using docker compose.</p><h4>The assignment:</h4><p>Using the CLI</p><ol><li>Pull the Jenkins LTS image from Docker Hub.</li><li>Create a Docker volume for Jenkins to persist its data.</li><li>Run the container with the volume and correct port mapped to the container.</li><li>Retrieve the Admin password.</li><li>Login and create a new user.</li><li>Launch a new Jenkins container using the same volume and verify that the data has persisted by logging in as the newly created user.</li></ol><p><a href="https://www.jenkins.io/doc/">Jenkins User Documentation</a></p><p><strong>Bonus:</strong></p><ol><li>Use Docker Compose to do the above steps.</li></ol><p>Requirements:</p><p>You need to have an AWS account.</p><p>You should have a Dockerhub account.</p><p>While not required I recommend using <em>Visual Studio Code</em> for this project.</p><p><em>Visual Studio Code (VS Code) </em>is a source code editor / integrated development environment.</p><p>Most of this process will be done from the command line.</p><p>You need to have a text editor such as <em>VI </em>or <em>VIM</em></p><p>You should have a basic understanding of how to pull and run docker images.</p><h3>Let’s begin.</h3><p>This project assumes that you have set up your docker environmet.</p><p>First log into AWS and create the instance that we will run docker on.</p><p>For my instance I used the Amazon Linux 2 AMI ( free tier )</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*4PEtCAXStGrlCDW_.png" /></figure><p>Make sure to allow SSH and HTTP in your security rules.</p><p>Once your instance is running, open up VS code and ssh into your instance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/812/1*crGpWAdIc-TekHk4u_OycQ.png" /></figure><p>Next we will search docker hub for the image named jenkins.</p><p><strong>Jenkins</strong> is an open-source automation tool written in Java with plugins built for continuous integration. Jenkins is used to build and test your software projects continuously making it easier for developers to integrate changes to the project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/889/1*8MElQAV6nMiChtRbS0pCMQ.png" /></figure><p>We found the official image page, but there was a deprecation notice attached.</p><p>In this case on docker hub, deprecation means that this original jenkins image is no longer being utilized and has not been updated for more than 2 years. There could be many reasons for this, including obsolete features or functions that no longer work.</p><p>The notice has a link to the image we should be using ( jenkin/jenkins:lts)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/598/1*79nABzcDg_P5Fpn1rVMMWA.png" /></figure><p>run this command:</p><pre>docker pull jenkins/jenkins:lts-jdk11</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/564/1*dYb79Sx1nh7yF9L2dYF0Tw.jpeg" /></figure><p>Next we need to run the container and make sure the data persist.</p><p>We find information on how to achive that here:</p><p><a href="https://github.com/jenkinsci/docker/blob/master/README.md">https://github.com/jenkinsci/docker/blob/master/README.md</a></p><p>run this command:</p><pre>docker run -p 8080/8080 -50000:50000 --restart=on-failure -v jenkins_home:var/jenkins_hom jenkins/jenkins:lts-jdk11<br> </pre><p>Line by line:</p><p><em>docker run </em>— makes the image a container</p><p><em>-p </em>— publishes and exposes the port we specify</p><p>restart=on failure — Always restart the container if it stops. If it is manually stopped, it is restarted only when Docker daemon restarts or the container itself is manually restarted.</p><p><em>-v — (volume) — m</em>aps the directory in the container to the Docker volume</p><p>This will automatically create a ‘jenkins_home’ docker volume on the host machine. Docker volumes retain their content even when the container is stopped, started, or deleted.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eaTJRP87_cNKgkidB1DZ9g.jpeg" /></figure><p>After running this command your jenkins admin password is automatically created and provided.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GxE48WwmjNfb9cMBikJ8ag.jpeg" /></figure><p>Next we will navigate to the ip address of the running container. This will be the public ip address of your Ec2 instance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/833/1*rrwHonmMIL7CWlkCnXGXYQ.png" /></figure><p>Remember we mapped the container to port 8080, so we will edit our url to (18.117.153.72:8080)</p><p>You should arrive here:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*de6P15aW8rJasUNmxHzgUQ.jpeg" /></figure><p>Input the provided admin passcode.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/867/1*_txdFEEpZ-Tu5msVmR5zBw.jpeg" /></figure><p>Install the suggested plugins.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7y69rpde97RFHvvD3x86OQ.jpeg" /></figure><p>Check your progress in the terminal.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/663/1*X0sjP0bholbOjvzY19vxrQ.jpeg" /></figure><p>You can create your other user at this time.</p><p>On the left side navigate to Manage Jenkins, then look for Users.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ne25yuW6ABAfAg5UcZit-w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*n5FZGjiDx5AmFKG21eqsOw.png" /></figure><p>To make sure this data persist, exit out of the container or stop the container. Restart it then try to log back into jenkins.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/573/1*R3lMRFfko9eBChzHqDIXeQ.jpeg" /></figure><p>If you followed this guide you will succesfully be able to log in with your new created user.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/0*6jZarhww_rtRYzVY.gif" /></figure><p>We will build this again using docker compose.</p><p>In the terminal run this command:</p><pre>sudo yum install docker compose</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/564/1*ooot1XF7ChgbdAjFzrvSXA.png" /></figure><p>docker compose is already installed on this instance.</p><p><a href="https://docs.docker.com/compose/"><em>Docker Compose</em></a> is a tool that was developed to help define and share multi-container applications. With Compose, we can create a YAML file to define the services and with a single command, can spin everything up or tear it all down.</p><p>We will be creating a .yml file in the terminal. We will use VIM to create the file.</p><p><em>VIM</em> is a text editor that is widely used for writing and editing scripts, html or other executable files.</p><p><em>YAML</em> is an acronym that stands for “YAML AINT MARKUP LANGUAGE”. It was designed with flexibility and accessibility in mind, so it works with all modern programming languages and is widely used for cross data sharing. The format is also human readable, similar to JSON formatting.</p><p>Run the following command:</p><pre>vim</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/928/1*KPAi-pQbMf5lt6GUBda2NQ.png" /></figure><p><a href="https://github.com/jenkinsci/docker/blob/master/README.md#docker-compose-with-jenkins">docker/README.md at master · jenkinsci/docker</a></p><p>The above repo gives us the correct format and input.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/335/1*2lx3Ew0gn-rJAL8d_ALioQ.png" /></figure><p>Input your specifics using the template above.</p><p>To save the file in VIM press :wq docker-compose.yml</p><p><em>wq — write : quit &lt; file name &gt;</em></p><p>After you saved and exited VIM run this command:</p><pre>docker-compose up</pre><p>If you recieve an error and it looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/352/1*cp_9-EXXUM2BLP_jBZxSmw.png" /></figure><p>Earlier our instance showed us that we had docker compose already installed, but the docker compose commands are not being recognized.</p><p>Documentation here resloves the issue for the Amazon linux 2 AMI</p><p><a href="https://gist.github.com/npearce/6f3c7826c7499587f00957fee62f8ee9">Amazon Linux 2 — install docker &amp; docker-compose using ‘sudo amazon-linux-extras’ command (github.com)</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*E7Itl9amVpxAYH46RpQfYA.png" /></figure><p>We now have docker compose correctly installed and can see the version is <strong>v2.20.2.</strong></p><p>We again run:</p><pre>docker-compose up</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*f65YMr9TySVVHY9X2QKKUQ.png" /></figure><p>success!!</p><p>The same instructions on how to navigate to your jenkins page above will apply.</p><p>Check your work! Stop and restart the container, log in and log out.</p><p>If your username and data persist, your have done this project correctly!</p><p>Thanks for reading!</p><p>Always remember:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/587/1*E58jo-B5wk72WgYXC8jhTw.jpeg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f9b2cb3d453b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to run Apache on a Docker ubuntu container.]]></title>
            <link>https://medium.com/@redslick84/how-to-run-apache-on-a-docker-ubuntu-container-d33e498577df?source=rss-a66bc99a7358------2</link>
            <guid isPermaLink="false">https://medium.com/p/d33e498577df</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[ubuntu]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[apache]]></category>
            <dc:creator><![CDATA[Virgil B Majors II]]></dc:creator>
            <pubDate>Thu, 27 Jul 2023 14:55:23 GMT</pubDate>
            <atom:updated>2023-07-31T13:05:16.630Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vorT2pEHZuH8s7GcXasrEQ.jpeg" /></figure><p>In this project I will show how to run <strong>docker</strong> using VS code.</p><p>I will also create a custom webpage within the <strong>docker</strong> container.</p><p><strong>Docker</strong> is a software platform that allows you to build, test, and deploy applications quickly. Docker is somewhat similar to virtual machines in that it solves the problem of limited physical resources. Docker takes this concept a step further by also unifying the needed application tools / dependancies by keeping them in one place.</p><p>This was a project assigned by the Level up in Tech program.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/200/1*of3jn8wz-CfgsOrp7OheDg.png" /><figcaption>LUIT logo</figcaption></figure><h4>The assignment:</h4><p>1. Run a Docker Ubuntu container running detached and on port 80</p><p>2. Using BASH shell update all packages within the container .</p><p>3. Using BASH install Apache2 on the Ubuntu container.</p><p>4. Add a custom webpage.</p><p>5. Verify you can reach the webserver from your browser.</p><p>The basics:</p><p>You need to have an AWS account.</p><p>Create a Dockerhub account.</p><p>Understand the differenc between images vs containers.</p><p>While not required I recommend using <em>Visual Studio Code</em> for this project.</p><p><em>Visual Studio Code (VS Code) </em>is a source code editor / integrated development environment.</p><p>Most of this process will be done from the command line.</p><p>You should have a basic understanding of how to pull Docker images.</p><h4>Let’s begin.</h4><p>This project assumes that you have set up your Docker environmet.</p><p>First log into AWS and create the instance that we will install Docker on.</p><p>For my instance I used the Amazon Linux 2 AMI ( free tier )</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/785/1*OpsRhw5RzraPIoAJqMHcdQ.png" /></figure><p>Make sure to allow SSH and HTTP in your security rules.</p><p>Once your instance is running, open up VS code and ssh into your instance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1019/1*uvy2OiqAgH1FuTmUAaU6sw.jpeg" /></figure><p>After you ssh into the instance run this command:</p><pre>docker pull ubuntu</pre><p>This command will pull the latest ubuntu image from the docker library / ubuntu repository.</p><p>It should be noted that the difference between images and containers is that a container is the running instance of an image. <em>The image becomes a container once activated.</em></p><p>Next I will run this command:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_IBCfz04GUZaTNs1AqkxBg.jpeg" /></figure><pre>docker run -ti -d -p80:80 ubuntu /bin/bash</pre><p>These commnads tell docker how to run ubuntu.</p><p>We specified -ti, which means run this <em>terminal interactive ( allows us to run commands inside the running container)</em></p><p>We specified -d, which means run this terminal <em>detached ( keeps the process running until we manually stop it)</em></p><p>We specified -p, which publishes the port we choose. ( We typed -p80:80 ) This is a standard http port.</p><p>We called for unbutu to run /bin/bash ( A shell script language )</p><p>Next we run:</p><pre>docker ps</pre><p>This allows us to see all the containers we created. This is important because it will show us the container ID. We will use the container ID when we run docker exec.</p><p>Information about docker exec can be found here.</p><p><a href="https://docs.docker.com/engine/reference/commandline/exec/">https://docs.docker.com/engine/reference/commandline/exec/</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1001/1*2Dkw7RbKH9vgkFYurDkxKw.jpeg" /></figure><p>Copy your container ID and run this command:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/832/1*o5TzgF5g30Bnb_FX1WdUnA.jpeg" /></figure><p>We are now inside the running container.</p><p>We know this because we see ( root@3840699a46e3:/# ) at the CLI</p><p>We also run apt-get update to update all packages.</p><p>Type exit to leave the container</p><pre>exit</pre><p>Next we navigate to the dockerhub website and search the container image library.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bLRRMOutnxEG2W3HO9QStw.png" /></figure><p>Remember to use the image with the verified publisher check mark.</p><p>On the right side of the webpage it shows the exact command to type.</p><pre>docker pull ubuntu/apache2</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/733/1*fp1wFbQpephFtIcG6tbKIQ.jpeg" /></figure><p>By typing docker images we can see both instances that we pulled:</p><pre>docker images</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/453/1*r1oM4GEgCb5tJvBeq8EGIw.png" /></figure><p>By typing docker ps we again will get the conatainer ID’s</p><pre>docker ps</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/953/1*qnbSbaRsPbHdTEurLvjlEA.png" /></figure><p>This returns the image name, the exposed port (80) and the container ID</p><p>docker exec into ubuntu/apache2</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/502/1*hOZHPbbc3lsw4T_jAGKycg.png" /></figure><p>The last step is to edit the html.index file located in the var files.</p><p>Change directories into var, then into www</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/232/1*gEHOZ2gqltXQXq-urd2aYg.png" /></figure><p>The index.html file is located here.</p><p>Before we append the index.html file, the standard apache webpage will show.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LyrYkEwygWcLlep29T9IVA.png" /></figure><p>We will now append a message to the index.html file to create our custom webpage.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/607/1*erWc0S2GTK2BmhAOdIKN0w.png" /></figure><p>Let’s navigate to the public IP of our instance to check our work.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/341/1*lSjnQBIjfQGXki79q0wV-Q.jpeg" /></figure><p>Done!</p><p>Thanks for reading about these docker fundamentals!</p><p>And always remember…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/587/1*E58jo-B5wk72WgYXC8jhTw.jpeg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d33e498577df" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to create a Standard SQS Queue using Python…]]></title>
            <link>https://medium.com/@redslick84/how-to-create-a-standard-sqs-queue-using-python-269201539f72?source=rss-a66bc99a7358------2</link>
            <guid isPermaLink="false">https://medium.com/p/269201539f72</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[boto3]]></category>
            <category><![CDATA[sqs-lambda]]></category>
            <dc:creator><![CDATA[Virgil B Majors II]]></dc:creator>
            <pubDate>Mon, 17 Jul 2023 12:42:11 GMT</pubDate>
            <atom:updated>2023-07-17T12:42:11.495Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rD5GVzAvmqjxl0_W60FEug.jpeg" /></figure><p>Good day!</p><p>Here is my next project with the Level Up In Tech Program.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/200/1*of3jn8wz-CfgsOrp7OheDg.png" /><figcaption>LUIT logo</figcaption></figure><p>The assignment was to:</p><ol><li>Create a Standard SQS Queue using Python: This involves using the Boto3 library (AWS SDK for Python) to programmatically create an SQS queue.</li><li>Create a Lambda function in the console with a Python 3.7 or higher runtime: In the AWS Lambda console, create a new function and configure it to use Python 3.7 or a higher version.</li><li>Modify the Lambda to send a message to the SQS queue: Update the Lambda function code to send a message to the SQS queue. You can use the current time or a random number as the message content. Make sure to use the Boto3 library to interact with SQS.</li><li>Create an API Gateway HTTP API type trigger: Set up an HTTP API trigger for the Lambda function in the API Gateway console. This allows you to invoke the Lambda function through an API endpoint.</li><li>Test the trigger to verify the message was sent: Use a tool like curl or a web browser to send a request to the API endpoint and verify that the Lambda function sends a message to the SQS queue.</li></ol><p><strong>Requirements:</strong></p><p>AWS account</p><p>Knowledge of the CLI</p><p>Python with the Boto3 module installed</p><p>IDE of your choice</p><p>This project was fairly simple especially since the Boto3 documentation has all of it’s example codes published in one place.</p><p>You can find them here — -&gt; <a href="https://boto3.amazonaws.com/v1/documentation/api/latest/index.html">Boto3 1.28.3 documentation (amazonaws.com)</a></p><p>Lets get started!</p><p>The first step was to create a SQS.</p><p><strong>SQS-simple queue services </strong>is Amazon Web Services (AWS) message queuing service that enables decoupling and scaling microservices, distributed systems, and serverless applications. This service allows sending, storing and reciveving messages between softwares at any volume without requiring other services to act.</p><p>The use case for SQS would be:</p><p>A company wants to create a system that can track customer orders and send notifications when orders have been shipped. They want to use AWS services to build the system.</p><p>For step (1) we look into the Boto3 documents under SQS</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/837/1*GnWJ2dwmxGoMpAIkeZw9zA.png" /></figure><p>These commands import the boto3 module into our IDE using a python script.</p><p>We know we will be creating a queue, so we navigate to that option in the boto3 documentation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/807/1*Th06rekRosUjglkOyjP77g.png" /></figure><p>Name your queue.</p><p>We do not need the attibute function for this simple project, because we dont have any attributes that need to list any corresponding values. (<em> ie: Delay seconds, max message size, policy)</em> You can delete that part of the provided code.</p><p>We can leave the tags portion in place.</p><p><strong>Tagging </strong>is useful for organizing and identifying your Amazon SQS queue, especially if you have a large number of queues that you will be monitoring.</p><p>My python code looks like this:</p><pre>import boto3<br>client = boto3.client(&#39;sqs&#39;)<br>response = client.create_queue(<br>    QueueName=&#39;Shipped&#39;,<br>    tags={<br>        &#39;project&#39;: &#39;project_10&#39;,<br>        &#39;source&#39;: &#39;boto3&#39;<br>    }<br>)</pre><p>Run your code!</p><p>Next log into the AWS console.</p><p>Check to see if your SQS queue was created by navigating to SQS in the search bar.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BsHPgb_Wb8mHZqR-p2ZiNA.png" /></figure><p>I found the queue!</p><p>Next step:</p><p>In the search bar type Lambda. On the Lamba homepage click create function.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rdMzaBTSQTMH0tBr95OGBA.png" /></figure><p>You should arrive at this page.</p><p>We will author from scratch and select python 3.7 for our language.</p><p>Click create function.</p><p>You will arrive at a section that is a CLI for you to input your code for the lambda function.</p><p>We chose python as the language so we can still use boto3 here.</p><p>Again start with:</p><pre>import boto3</pre><p>When creating a Lambda function in python we wil use the handler method as outlined here → <a href="https://docs.aws.amazon.com/lambda/latest/dg/python-handler.html">Lambda function handler in Python — AWS Lambda (amazon.com)</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QZM8xFlKxJy0M9AGYH6xZw.png" /></figure><p>Before we set up the “send_message” function we can include a time stamp for the message.</p><p>We do that by importing the python datetime module as found here:</p><p><a href="https://docs.python.org/3/library/datetime.html#strftime-and-strptime-format-codes">datetime — Basic date and time types — Python 3.11.4 documentation</a></p><p>There numerous ways and formats to return your date and time, pick one that you like. The one I used is below.</p><pre>from datetime import datetime<br><br>now = datetime.now()<br>current_time = now.strftime(&quot;%H:%M:%S %p&quot;)</pre><p>Next we will set the commands for sending messages.</p><p>We find the documentation here:</p><p><a href="https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/sqs/client/send_message.html">send_message — Boto3 1.28.3 documentation (amazonaws.com)</a></p><p>Navigate back to your SQS queue and grab the URL from it, we will need it for our code below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DzlK3vMeCFoZHwmaepmmUA.png" /></figure><pre> sqs = boto3.client(&#39;sqs&#39;)<br> sqs.send_message(QueueUrl=&quot;https://sqs.us-east-2.amazonaws.com/383618969847/Shipped&quot;, MessageBody=current_time)</pre><p>We have defined our variables, provided our SQS URL and included a command to return the current date and time.</p><p>Before we run our code we need to enable permissions for our Lambda to run.</p><p>Navigate to IAM in the search bar.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RulO58jby-eTF7ZNKOV9WQ.png" /></figure><p>Find your role</p><p>You can do this by copying the ARN from your SQS details page.</p><p>Once you find your role, grant access to the permissions you need.</p><p>Test the code:</p><p>Here is mine</p><pre>import json<br>import boto3<br>from datetime import datetime<br><br>def lambda_handler(event, context):<br>    # send a message to sqs queue <br>    <br>    <br>    now = datetime.now()<br>    current_time = now.strftime(&quot;%H:%M:%S %p&quot;)<br>    <br>    sqs = boto3.client(&#39;sqs&#39;)<br>    sqs.send_message(QueueUrl=&quot;https://sqs.us-east-2.amazonaws.com/383618969847/Shipped&quot;, <br>    MessageBody=current_time)<br>  <br>    return {<br>        &#39;statusCode&#39;: 200,<br>        &#39;body&#39;: json.dumps(current_time)</pre><p>Next we will create an API Gateway trigger that will invoke the Lamba function when we access the webpage.</p><p>Navigate to triggers under the configuration tab and click add trigger.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TbGno-pNT26qyN2gfrPQhg.png" /></figure><p>Select API gateway as the trigger type. Click create new API. This will create the URL endpoint for testing purposes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rP7Eaa4NVUobRmhf4rdL_w.jpeg" /></figure><p>I see the date and time.</p><p>I refreshed the page many times to test the message queue.</p><p>Navigate to the SNS main page, select the queue you created and click the monitoring tab.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vnC0_hJIq6y6dWNk8xRbBQ.jpeg" /></figure><p>This graph shows the “hits” or messages sent, that were triggered by the API gateway.</p><p>Congrats!</p><p>Everything is working as intended.</p><p>Here is a link to my Github, for the full python codes I used.</p><p><a href="https://github.com/Vmajors84/Black_team2023/blob/main/Tracking_orders_example.py">Black_team2023/Tracking_orders_example.py at main · Vmajors84/Black_team2023 (github.com)</a></p><p><a href="https://github.com/Vmajors84/Black_team2023/blob/feat/black2023/Lambda_message_function.py">Black_team2023/Lambda_message_function.py at feat/black2023 · Vmajors84/Black_team2023 (github.com)</a></p><p>Thanks for reading, and remember…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/587/1*E58jo-B5wk72WgYXC8jhTw.jpeg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=269201539f72" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Commanding a Python script to stop all instances in AWS]]></title>
            <link>https://medium.com/@redslick84/commanding-a-python-script-to-stop-all-instances-in-aws-9eb71008c813?source=rss-a66bc99a7358------2</link>
            <guid isPermaLink="false">https://medium.com/p/9eb71008c813</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[ec2]]></category>
            <dc:creator><![CDATA[Virgil B Majors II]]></dc:creator>
            <pubDate>Mon, 10 Jul 2023 03:08:50 GMT</pubDate>
            <atom:updated>2023-07-10T03:08:50.637Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vO1P2bn2dUBSmGtLpTviiA.jpeg" /></figure><p>Hello, I’m back with another project to highlight some of the things we can do with Python scripts.</p><p>This task was my next assignment with the Level Up In Tech program.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/200/1*of3jn8wz-CfgsOrp7OheDg.png" /><figcaption>Level Up In Tech</figcaption></figure><p>The assignment was to:</p><p><strong>Create a Python script that will stop all instances.</strong></p><p><strong>We will then Push the code to GitHub.</strong></p><p>Requirements:</p><p>AWS account</p><p>Running instances</p><p>Knowledge of the CLI</p><p>Python with the Boto3 module installed</p><p>Github account</p><p>Lets begin</p><p>You can use an IDE of your choice, but for this project I will be using Pycharm.</p><p>The first thing I did was spin up an Ec2 instance within my AWS account.</p><p>Check to insure that the Ec2 instance is running.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/643/1*3eQt3QR1iL5yaw8y8qSa2A.jpeg" /></figure><p>Next we will begin drafting our script</p><ul><li>My Pycharm application is already configured to my AWS account.</li><li>If your IDE has not been configured you must run:</li></ul><pre>aws configure</pre><p>The prompt will ask you for AWS Access key ID, your AWS secret Access key, your region and your ouput format.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/572/1*EYmouYPnukRMlB9s7DKmTg.png" /></figure><p>Input the appropriate responses to continue</p><p>If you have not installed boto3 you must input</p><pre>pip install boto3</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YHREHF4ildcJgp4_C7DRmA.png" /></figure><p>Next create a new .py file in the Pycharm application</p><p>Boto3 has very specific commands for the services you will be utilizing.</p><p>The Boto3 documentation can be found here:</p><p><a href="https://boto3.amazonaws.com/v1/documentation/api/latest/guide/quickstart.html#installation">https://boto3.amazonaws.com/v1/documentation/api/latest/guide/quickstart.html#installation</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*IxRUCchhSxkWurJJW8knPQ.png" /></figure><p>Navigate to the service you will be scripting for and find the proper commands.</p><p>Our first line of code will be to import the boto3 module.</p><p>We accomplish this by typing:</p><pre>import boto3</pre><p>For formatting purposes will will also import json.</p><pre>import json</pre><p>We will define our region and the service we are “commanding”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/436/1*H-l4mtM8DRdODClOwP4VXA.png" /></figure><p>The boto3 documentation webpage shows the code for stopping Ec2 instances:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*smqoeP91UYelbxPSklPB6w.png" /></figure><p>Enter the above code.</p><p>Replace ‘string’ with your instance ID, make your selections for the other options (hibernate, dryrun and force).</p><p>I selected false for all of the options.</p><ul><li><strong>Hibernate</strong> — Hibernates the instance if the instance was enabled for hibernation at launch. If the instance cannot hibernate successfully, a normal shutdown occurs.</li><li><strong>DryRun</strong> — Checks whether you have the required permissions for the action, without actually making the request, and provides an error response. If you have the required permissions, the error response is DryRunOperation. Otherwise, it is UnauthorizedOperation.</li><li><strong>Force </strong>Forces the instances to stop. The instances do not have an opportunity to flush file system caches or file system metadata. If you use this option, you must perform file system check and repair procedures. This option is not recommended for Windows instances.</li></ul><p>Lastly we “pretty print in json format.</p><pre>print(json.dumps(response, indent=2))</pre><p>I successfully ran the code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5tByX8DO8rTLx61wh_OL1A.jpeg" /></figure><p>Within the AWS console I see that my Ec2 instance is stopping.</p><p>My response in the console was:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/533/1*IcLBP98WjBXUBdQWZRk-wA.png" /></figure><p>Next I committed and pushed my code to my Github repo.</p><p>You can see my full code and response text by checking my Github here:</p><p><a href="https://github.com/Vmajors84/Black_team2023/blame/main/Ec2_stop_all_instances.py">Blaming Black_team2023/Ec2_stop_all_instances.py at main · Vmajors84/Black_team2023 · GitHub</a></p><p>Thanks for reading!</p><p>Remember:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/587/1*E58jo-B5wk72WgYXC8jhTw.jpeg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9eb71008c813" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Creating a dictionary script with Python.]]></title>
            <link>https://medium.com/@redslick84/creating-a-dictionary-script-with-python-35a5e72f9c54?source=rss-a66bc99a7358------2</link>
            <guid isPermaLink="false">https://medium.com/p/35a5e72f9c54</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[script]]></category>
            <category><![CDATA[github]]></category>
            <category><![CDATA[json]]></category>
            <dc:creator><![CDATA[Virgil B Majors II]]></dc:creator>
            <pubDate>Mon, 03 Jul 2023 12:31:23 GMT</pubDate>
            <atom:updated>2023-07-03T13:18:49.021Z</atom:updated>
            <content:encoded><![CDATA[<p>We are back with another article!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/935/1*x6P0klwNST7OFRe5eBmovA.png" /></figure><p>In this project I was tasked with creating a script to that generates a list of dictionaries about files in my working directory.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/200/1*of3jn8wz-CfgsOrp7OheDg.png" /><figcaption>LUIT LOGO</figcaption></figure><p>Print the list.</p><p>Push the code to GitHub.</p><p><em>Scenario: Your company needs to learn about the files located on various machines. You have been asked to build a script that extracts information such as the name and size about the files in the current working directory and stores it in a list of dictionaries.</em></p><p>! Please note there are always multiple ways to do things in scripting to reach the same end goal. This article is showing one of the many avenues you can take.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/612/0*TpEvtRo2Fr2m_gDj" /></figure><p>Requirements:</p><p>Access to an IDE of your choice: (we will be using Pycharm for this project)</p><p>Github account.</p><p>Completed a begginners Python coding course or have coding / programming languages knowledge. ( ie: str, variables, int, mutable, immutable, for loops, iterator and tuples )</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/267/1*m2dk2za7SKyNXFjCxgGQuA.gif" /></figure><p>Lets begin:</p><p>Start up your IDE.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/977/1*yUEWnMwIuvReblvbJLl9fw.png" /></figure><p>This is what the Pycharm envirment looks like.</p><p>If you are starting from scratch you will need to clone your Github repo to access it here.</p><p>I created a new .py file called working_directory_dictionaries. (highlighted in green)</p><p>Next we want to use the Pycharm terminal to check our working directory</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/397/1*QgJ4zp4MWPZLh0bkxUwRXA.png" /></figure><p>After opening the terminal I run pwd (print working directory)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/783/1*720uLAP4pBYeRT-jJgTJ4Q.png" /></figure><p>Black_Team2023 is the correct path for this project.</p><p>On to the next step:</p><p>Before we begin scripting we will import the os module. Doing so gives us access to all the features of our current “Operating System”, (OS). This module handles the differences between “Windows”, “Linux”, “Mac” and all the versions.</p><pre>import os</pre><p>Notice I am using Windows =)</p><p>We will also import the json module.</p><p><strong>JSON - </strong>JavaScript Object Notation. Despite its name, JSON is a language agnostic format that is most commonly used to transmit data between systems</p><p><em>In testing the script it ran and returned the expected results, but it came out sort of like a long “run on sentence”.</em></p><p>JSON likes a clean house, and will format our results so we can read them more easily. ( You will see both outputs later to understand why)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/200/0*zHzHsDga8GkKioDJ.gif" /></figure><pre>import json</pre><p>The next step will get our current working directory on this application of python as a string:</p><pre>current_working_directory: str = os.getcwd()</pre><p>Next we will tell the system to scan the current working directory for all entries within.</p><p>We accomplish this by using the scandir method.</p><pre>directory_entries = os.scandir(current_working_directory)</pre><p>Scandir will return a list of (DirEntry). A (DirEntry) is a data structure that has basic information about a file or folder.</p><p>Next we will create an empty python dictionary for storing all of the files in our current working directory.</p><pre>file_dictionary: dict = {}</pre><p>For our *list we will only inlude entries that are files.</p><p>We will accomplish this with a clever (for loop):</p><pre>for entry in directory_entries:<br>   if entry.is_file():<br>       entry_dict: dict = {}<br>       entry_dict:[&#39;name&#39;] = entry.name<br>       entry_dict:[&#39;path&#39;] = entry.path</pre><p>Notice there are 3 different types of brackets within this code.</p><p>() used to specify the order of operations, and for calling a function or creating an instance of a class, or it denotes a tuple.</p><p>{} used to define a dictionary, that maps one value to another.</p><p>[] used to define “list literals,” allowing you to declare a list and its contents in your program.</p><p>Next we will format how our returned response shows us the file size:</p><p>The (DirEntry) fuction gives us access to information like the file size through the stat() method. The stat() tells us detailed information about the file, but here we only care about the file size, so we use stat().st_size.</p><pre>size_in_bytes = entry.stat().st_size</pre><p>We will also convert the response from bytes to kilobytes.</p><p>Your conversion may need to be mb or gb depending on the sizes of your files.</p><pre>size_in_kilobytes = size_in_bytes / 1000<br>entry_dict[&#39;size&#39;] = &quot;{} KB&quot;.format(size_in_kilobytes)</pre><p>We will now add the “entry dictionary” for this file, into our dictionary for all the files, and then go back to the top of the loop if there are more “entries” in this directory.</p><pre>file_dictionary[entry.name] = entry_dict</pre><p>We are ready to see the results from our script:</p><pre>print(&quot;Files in current working directory:\n {}&quot;.format(file_dictionary))</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*quZJWzC37T1NrRaWpKZ3rg.png" /></figure><p>… oh yeah remember that json formatter we imported earlier… this is where it comes in handy…</p><p>json is a file / text interchager that can sort data and make it easier to read.</p><p>The json.dumps() function will convert a subset of Python objects into a json string.</p><p>Here we set the sort_key = true, so that each files will be sort by it’s key/ (name).</p><p>We will set the indent = 2. If indent is higher than 0 then json will print to the output “pretty-printing”.</p><pre>print(json.dumps(file_dictionary, sort_keys=True, indent=2))</pre><p>It looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/694/1*awZDhGfUTbE7D-wFrsVebw.png" /></figure><p>Nice and pretty…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/501/0*J5g67SphaeDQJ182.gif" /></figure><p>We are done!</p><p>Here is my repo.</p><p><a href="https://github.com/Vmajors84/Black_team2023/blob/main/working_directory_dictionaries.py">Black_team2023/working_directory_dictionaries.py at main · Vmajors84/Black_team2023 (github.com)</a></p><p>Thanks for reading and remember…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/587/1*E58jo-B5wk72WgYXC8jhTw.jpeg" /></figure><p>‌</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=35a5e72f9c54" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building out a 3-Tier AWS architecture.]]></title>
            <link>https://medium.com/@redslick84/building-out-a-3-tier-aws-architecture-f53388b73b60?source=rss-a66bc99a7358------2</link>
            <guid isPermaLink="false">https://medium.com/p/f53388b73b60</guid>
            <category><![CDATA[3-tier-architecture]]></category>
            <category><![CDATA[subnet]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Virgil B Majors II]]></dc:creator>
            <pubDate>Fri, 23 Jun 2023 19:20:44 GMT</pubDate>
            <atom:updated>2023-06-23T19:20:44.419Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vmWVoHwYtCS9wQOqTqU6CA.png" /></figure><p>We are back with another project for you to follow along with.</p><p>This 3-Tier AWS architecture will be comprised of a Web Tier, Application Tier and a Database Tier.</p><p>The guidlines/instructions we will follow are below:</p><p><strong>Web Tier</strong></p><ol><li>2 public subnets</li><li>Minimum of 2 EC2 instances with an OS of your choice (free tier) in an Auto Scaling Group.</li><li>EC2 Web Server Security Group allowing inbound permission from the internet.</li><li>Boot strap static web page or create a custom AMI that already includes the static web page.</li><li>Create a public route table and associate the 2 public subnets.</li></ol><p><strong>Application Tier</strong></p><ol><li>2 private subnets</li><li>Minimum of 2 EC2 instances with an OS of your choice (free tier) in an Auto Scaling Group.</li><li>EC2 Application Server Security Group allowing inbound permission from the Web Server Security Group.</li><li>Associate with private route table.<br>Note: This is not a true application tier as we don’t have any provided code to run on the EC2 instances.</li></ol><p><strong>Database Tier</strong></p><ol><li>Use a free Tier MySql RDS Database.</li><li>The Database Security Group should allow inbound traffic for MySQL from the Application Server Security Group.</li><li>2 private subnets.</li><li>Associate with private route table.</li><li>Remember that when diagraming this tier you are only creating one RDS instance in one subnet even though you are creating two subnets. If you use multi-az or a read replica then and only then should you have a second instance. Make sure to label accordingly.</li></ol><p>Use Case:</p><p>Why would we create a 3 Tier architecture?</p><p>If you have a business that will serve customers online, the web tier would be responsible for serving the static content to end-users and handling incoming requests. We add an Auto Scaling Group so the platform can handle sudden spikes in traffic without any manual intervention. The public subnets would allow incoming traffic from the internet to reach the<br>EC2 instances running in the Auto Scaling Group.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*KCVyN6t_nxOU2D3dpqwLqw.gif" /></figure><p>The application tier would handle the business logic of the platform. This tier would be responsible for processing transactions, handling payments, and interacting with the database. By placing the EC2 instances in private subnets and only allowing inbound traffic from the Web Server Security Group, the application tier can be protected from direct access from the internet. Again, using an Auto Scaling Group would ensure that the platform can handle changes in traffic and demand.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*8j1aNR7BO-tBRWkdgOvXtQ.gif" /></figure><p>The database tier would store all of the platform’s data, including customer information, product data, and transaction records. Using a free-tier MySQL RDS database would allow for easy scaling as the platform grows. The database instances would be placed in private subnets and only allow incoming traffic from the Application Server Security Group. Adding Multi-AZ would ensure that the database is highly available and can survive the loss of a single availability zone.</p><p>Overall, this three-tier architecture would provide a scalable and reliable platform that could handle a large number of users and transactions. By using AWS services like Auto Scaling Groups and RDS, the platform could be deployed quickly and easily, with minimal maintenance required.</p><p>Lets start!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*NoFad5a54emBpk7_esHzGA.gif" /></figure><p><strong>Requirements:</strong></p><p>Knowledge of the Amazon Web Services (AWS) console and the different tools available to include EC2’s, Auto Scaling Groups (ASG), target groups, Amazon Machine Image (AMI’s), Load Balancers and Relational databases (RDS).</p><p>Basic networking knowledge, to include an understanding of Virtual Private Cloud (VPC’s), subnets, route tables and security groups.</p><p>Some knowledge of the command line interface (CLI).</p><p><strong>We will start off by creating our VPC.</strong></p><p>In the AWS console search bar type VPC. Click create VPC and specify your parameters.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Kv3e_u1tcx9tbz-j5l2j3g.jpeg" /></figure><p>Using the <strong>VPC and more </strong>creation tool lets you choose how many availability zones and public/private subnets to create.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/504/1*TRfCDADMf09YUX8keQdtyw.jpeg" /></figure><p>After you have set your parameters click create and you should see this screen:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/455/1*n1SoOPHTd0_1160Y83xSHg.jpeg" /></figure><p>This VPC auto creation tool attached the internet gateway, created a NAT gateway and established route tables for the respective public and private route tables.</p><p>Next lets create our EC2 that will host our static webpage.</p><p>I will use Amazon Linux 2 and the T2 micro free tier</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/790/1*8sLGxC7FazTPMoVsD-jZtA.jpeg" /></figure><p>Be sure to select the VPC that you just created, and set your security rules to allow you to SSH connect and allowing internet access from the general public, by allowing HTTP and HTTPS from 0.0.0.0/0 (anywhere)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/614/1*ilB7SZbxrZH6O-bZK0G9sA.jpeg" /></figure><p>Navigate down to the user data field and make a simple bash script for your page.</p><p>Mine looks like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/462/1*XpMciHHzHBCxvtlIxi2lcA.png" /></figure><pre>#!/bin/bash<br>yum update -y<br>yum install -y httpd<br>systemctl start httpd<br>systemctl enable httpd<br><br>cd /var/www/html<br><br>sudo echo &quot;&lt;h1&gt;Levelup In Tech Company Page&lt;/h1&gt;&quot; &gt; index.html</pre><p><strong>Next lets create our Auto scaling group.</strong></p><p>This option is located within the EC2 dashboard at the bottom of the selection panel.</p><p>Click the button and you should arrive here.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-1wwK9LWxqvthpJGznnHKw.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FL-dMAW8eJ2W7TDnAETBKw.jpeg" /></figure><p>When you launch an ASG you will need to specify whether you want to launch it from a template or configuration.</p><p>I choose to launch from template. And selected an AMI that was already in use. ( The EC2 we just created )</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/819/1*zeLuElYEI-1bYPj3RV-xbw.jpeg" /></figure><p>I again selected my VPC, then specified what availability zones (AZ) my ASG can use.</p><p>I choose both of the public subnets that were created when we launched the VPC.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/846/1*O1a5nVUDdNNd1uKoHfenzg.jpeg" /></figure><p>Launch your instance from the ASG page.</p><p>Now let’s create the Load balancer for our Web tier.</p><p>This option is also on the EC2 dashoboard at the bottom of the selection panel.</p><p>When configuring the load balancer make sure to select internet facing, because this portion is for public access from the internet.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/825/1*2_f5A5HmfCCfZH5HPG2lNQ.jpeg" /></figure><p>We need to attach the ASG to a new load balancer.</p><p>We again select our VPC and public subnets.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/785/1*Nw3vmFB9N9Z2g_8j8-T4CQ.jpeg" /></figure><p>Select the rest of your desired options:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/822/1*J24BeG5BBFug1PSV48pz1Q.jpeg" /></figure><p>It is good practice to enable health checks so you can monitor the status of your instances.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2iO5f-hATJEa3RtPAAdVEQ.jpeg" /></figure><p>Set your scaling policies.</p><p>Done.</p><p>Lets check the page from this instance:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/525/1*CD7yFQxlwrn6oNQI_rEKFA.jpeg" /></figure><p>Success!</p><p>Next we will create the application tier</p><p>Follow the same steps that we just completed with a few minor changes.</p><p>When we create the EC2 instances for the Tier we need to edit the inbound security group rules so that it only allows access from the Web Tier security group.</p><p>Outbound rules can be left at default allowing all internet access</p><p>It will look like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*70U8r_CR0jWRBoc_4V9D2A.jpeg" /></figure><p>Allow HTTP, SSH and ICMP all are granted access from the Web tier security group as the source.</p><p>This allows access only from within the Web tier.</p><p>ICMP allows us to ping from within the Web tier EC2 instance</p><p>We SSH into the Web tier instance to check the connection…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m_HptnYrD_HShugOHPytaw.jpeg" /></figure><p>We ping the private IP address and see that packets were received. This mean that the private connection was established correctly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/591/1*OtFcU83XZxsMthh0TFoiBw.jpeg" /></figure><p>Success!</p><p>Next let’s build out the Database Tier…</p><p>In the console search bar type RDS.</p><p>First, we need to create the database tier subnets group:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HXcyMcaaMwH5cXaiWVJOgg.jpeg" /></figure><p>Click create and associate your VPC and subnets</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Yjf5mS4g9vodNwvZ3JO_xg.jpeg" /></figure><p>Next we will create the actual database.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*5tD7jtOt0aTuEafMbX3y7w.jpeg" /></figure><p>We will use standard create and choose MySQL.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/677/1*r6udvanV9dADJrMhQmhmxQ.jpeg" /></figure><p>Name your database tier, select your username and make a password for connection.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/609/1*Mlu4UeN3Afsck_GL2z40bA.jpeg" /></figure><p>We will again select the correct VPC and subnets to launch our DB tier.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/617/1*d1YFbIFcVxu4iAisuj-xmA.jpeg" /></figure><p>After configuring your DB tier click create.</p><p>You should get a screen that looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nrSBOXBdK_1ZqGFlu6ky5A.jpeg" /></figure><p>Now that my database tier is created we need to set up the security rules.</p><p>Just as the application tier can only receive access from the web tier, this database tier will only receive access from the application tier.</p><p>Set up your inbound rules like this:</p><p>Choose MySQL for the type.</p><p>Then choose the Application tier security group you created earlier.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RCKgMP1Dlddi9ZhdyrYfJg.jpeg" /></figure><p>After all is said and done, lets have one more look at our route table.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mcR_tcdt684sz4ZzC-sqpQ.jpeg" /></figure><p>We can see that our project 9 subnet associations are connected to both private and public subnets depending on what tier and what associations we specified.</p><p>This project is now complete.</p><p>This was definitely the most complex project I have comepleted to date, because it had so many different tools that needed to work together to be set up correctly.</p><p>The Level Up in Tech coaches advised us to take it slow and do one piece at a time. I advised you the same</p><p>Thanks for reading…</p><p>And remember…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/587/1*E58jo-B5wk72WgYXC8jhTw.jpeg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f53388b73b60" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>