<?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 Jesus Egui on Medium]]></title>
        <description><![CDATA[Stories by Jesus Egui on Medium]]></description>
        <link>https://medium.com/@13jesusegui?source=rss-5ad137ec7bb6------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*hiau3IJ6c7u_NH6tNA_uNw.png</url>
            <title>Stories by Jesus Egui on Medium</title>
            <link>https://medium.com/@13jesusegui?source=rss-5ad137ec7bb6------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 16:42:23 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@13jesusegui/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[Python Coding Cloud Pixels: DynamoDB for Gamers on AWS]]></title>
            <link>https://medium.com/@13jesusegui/python-coding-cloud-pixels-dynamodb-for-gamers-on-aws-da98c060421d?source=rss-5ad137ec7bb6------2</link>
            <guid isPermaLink="false">https://medium.com/p/da98c060421d</guid>
            <category><![CDATA[tech]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[cloud]]></category>
            <dc:creator><![CDATA[Jesus Egui]]></dc:creator>
            <pubDate>Mon, 20 Nov 2023 04:59:32 GMT</pubDate>
            <atom:updated>2023-11-20T05:19:08.852Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/744/1*Vcm5qEYgDn-03KCFs_fG6g.png" /></figure><h4>Practical Scenario: Scenario:</h4><p>TechSolutions has decided to modernize its infrastructure and adopt cloud services to improve scalability and efficiency. Your team, the LUIT Team, has been assigned to create a video game catalog in the cloud using AWS. As part of this task, the team is expected to gain basic knowledge of cloud computing, AWS, and specific services such as DynamoDB.</p><p>The direction of the project is to create a video game catalog management system using DynamoDB as a cloud database. The team’s main objective is to learn how to work with cloud services, specifically AWS, and gain experience using tools such as Cloud9, boto3, and DynamoDB.</p><h4>Project Essentials:</h4><ul><li>Create AWS account</li><li>Basic Cloud Computing Knowledge</li><li>Create an environment on cloud9</li></ul><h4>Key terms:</h4><p>It helps you to understand the project easily:</p><ul><li><strong>Cloud9: </strong>Explanation: Imagine Cloud9 as your cloud programming playspace. It’s like having a virtual console where you can write, run, and debug your code without having to worry about installing anything on your computer.</li><li><strong>Python: </strong>Python is the “programming language hero.” It’s easy to understand and its syntax is so friendly that it feels like the code is speaking in a language that everyone can understand.</li><li><strong>Boto3: </strong>Boto3 is like the magic assistant that helps you communicate with AWS services using Python. Think of it as commanding your cloud services with Python’s magic wand.</li><li><strong>Dynamo DB: </strong>DynamoDB is like having a magical notebook where you can write and save information about your favorite games. You don’t need to worry about organizing the pages, you just write and the notebook (or in this case, DynamoDB) takes care of the rest</li></ul><h4>Guidance:</h4><ul><li>Create an IAM user with Administrator permissions</li></ul><p><strong>Foundational:</strong></p><ol><li>Create a DynamoDB table for something you choose (e.g. movies, food, games).</li><li>Using Gist (<a href="https://gist.github.com/zaireali649/0ec6b90155120cf508223788b7b86efc">https://gist.github.com/zaireali649/0ec6b90155120cf508223788b7b86efc</a>) as a starting point, use boto3 and Python to add 10 or more items to the table.</li><li>Use boto3 and Python to scan the DynamoDB table.</li><li>Submit your code to GitHub and include the link in your article.</li></ol><p><strong><em>Let’s start with this project:</em></strong></p><p>The first thing we will do is create a DynamoDB table that will be called <strong>“GameCatalog”</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dt4vlmzBgMvdJaUH_gI4oA.png" /></figure><p>Then we will create an environment in Cloud9, we must install boto3 using the following commands:</p><pre>pip install boto3<br>pip3 install boto3<br></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NyUOQhgrOnEQA-Thv17ggg.png" /></figure><p>We will add the credentials of an IAM user that we have and has administrator permissions as follows using nano</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/615/1*7r8xi7ohrNXZAaEIUQqOSg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_Z-BRyVQZ5xgiwk5IcHV6g.png" /></figure><p>Now we will create a file called script.py (you can use whatever name you want) using nano and inside the script.py file we will add the following specifications:</p><ul><li>Import boto3: Python library on AWS</li><li>start the DynamoDB client which would be dynamo</li><li>table_name = ‘GameCatalog’</li><li>Define the games you want to add</li><li>choose the region in which you will work</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/872/1*5BnBW41ebIS9X069T5ZtWA.png" /></figure><p>Now we are going to add the following specifications that will be shown in our Dynamo table for each game we add:</p><p><strong>title<br> created<br> Genre<br>Rating</strong></p><p>Now we will add our games:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/676/1*1-fqAE2cfMM7_qYFO2P2gw.png" /></figure><p>To finish we must create a list of PutRequests for batch writing, we must also divide the put_requests list into batches of 25 elements and perform the batch writing, we must also perform batch writing operation:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/769/1*QGYWPzG-gGd5FfKlTOt9hA.png" /></figure><p>As a real last step, we must verify if all the elements were added successfully and print the result:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/531/1*CeUy_1Of_wDvBYDuDD5wBQ.png" /></figure><p>This is the final code:</p><pre>import boto3<br><br># Declare the profile name and region<br>session = boto3.Session(profile_name=&#39;AlexTerraform&#39;, region_name=&#39;us-east-2&#39;)<br><br># Initialize a DynamoDB client<br>dynamodb = session.client(&#39;dynamodb&#39;)<br><br># Specify the table name<br>table_name = &#39;GameCatalog&#39;<br><br># Define the games you want to add<br>games = [<br>    {<br>        &quot;title&quot;: {&quot;S&quot;: &quot;Halo: Combat Evolved&quot;},<br>        &quot;created&quot;: {&quot;S&quot;: &quot;2001-11-15&quot;},<br>        &quot;Genre&quot;: {&quot;S&quot;: &quot;First-Person Shooter&quot;},<br>        &quot;Rating&quot;: {&quot;S&quot;: &quot;Mature&quot;},<br>    },<br>    {<br>        &quot;title&quot;: {&quot;S&quot;: &quot;Grand Theft Auto: Vice City&quot;},<br>        &quot;created&quot;: {&quot;S&quot;: &quot;2002-10-29&quot;},<br>        &quot;Genre&quot;: {&quot;S&quot;: &quot;Action-Adventure&quot;},<br>        &quot;Rating&quot;: {&quot;S&quot;: &quot;Mature&quot;},<br>    },<br>    {<br>        &quot;title&quot;: {&quot;S&quot;: &quot;The Elder Scrolls III: Morrowind&quot;},<br>        &quot;created&quot;: {&quot;S&quot;: &quot;2002-06-06&quot;},<br>        &quot;Genre&quot;: {&quot;S&quot;: &quot;Action RPG&quot;},<br>        &quot;Rating&quot;: {&quot;S&quot;: &quot;Mature&quot;},<br>    },<br>    {<br>        &quot;title&quot;: {&quot;S&quot;: &quot;Final Fantasy X&quot;},<br>        &quot;created&quot;: {&quot;S&quot;: &quot;2001-12-17&quot;},<br>        &quot;Genre&quot;: {&quot;S&quot;: &quot;Role-Playing Game&quot;}, <br>    },<br>    {<br>        &quot;title&quot;: {&quot;S&quot;: &quot;Metal Gear Solid 2: Sons of Liberty&quot;},<br>        &quot;created&quot;: {&quot;S&quot;: &quot;2001-11-12&quot;},<br>        &quot;Genre&quot;: {&quot;S&quot;: &quot;Stealth Action&quot;},<br>        &quot;Rating&quot;: {&quot;S&quot;: &quot;Mature&quot;},<br>    },<br>    {<br>        &quot;title&quot;: {&quot;S&quot;: &quot;Super Smash Bros. Melee&quot;},<br>        &quot;created&quot;: {&quot;S&quot;: &quot;2001-11-21&quot;},<br>        &quot;Genre&quot;: {&quot;S&quot;: &quot;Fighting&quot;},<br>        &quot;Rating&quot;: {&quot;S&quot;: &quot;Everyone&quot;},<br>    },<br>    {<br>        &quot;title&quot;: {&quot;S&quot;: &quot;Diablo II&quot;},<br>        &quot;created&quot;: {&quot;S&quot;: &quot;2000-06-29&quot;},<br>        &quot;Genre&quot;: {&quot;S&quot;: &quot;Action RPG&quot;},<br>        &quot;Rating&quot;: {&quot;S&quot;: &quot;Mature&quot;},<br>    },<br>    {<br>        &quot;title&quot;: {&quot;S&quot;: &quot;Tony Hawk&#39;s Pro Skater 2&quot;},<br>        &quot;created&quot;: {&quot;S&quot;: &quot;2000-09-20&quot;},<br>        &quot;Genre&quot;: {&quot;S&quot;: &quot;Sports&quot;},<br>        &quot;Rating&quot;: {&quot;S&quot;: &quot;Teen&quot;},<br>    },<br>    {<br>        &quot;title&quot;: {&quot;S&quot;: &quot;Half-Life 2&quot;},<br>        &quot;created&quot;: {&quot;S&quot;: &quot;2004-11-16&quot;},<br>        &quot;Genre&quot;: {&quot;S&quot;: &quot;First-Person Shooter&quot;},<br>        &quot;Rating&quot;: {&quot;S&quot;: &quot;Mature&quot;},<br>    },<br>    {<br>        &quot;title&quot;: {&quot;S&quot;: &quot;Counter-Strike: Source&quot;},<br>        &quot;created&quot;: {&quot;S&quot;: &quot;2004-11-01&quot;},<br>        &quot;Genre&quot;: {&quot;S&quot;: &quot;First-Person Shooter&quot;},<br>        &quot;Rating&quot;: {&quot;S&quot;: &quot;Mature&quot;},<br>    },<br>]<br><br># Create a list of PutRequests for batch writing<br>put_requests = [{&#39;PutRequest&#39;: {&#39;Item&#39;: game}} for game in games]<br><br># Split the put_requests list into batches of 25 items (DynamoDB batch write limit)<br>for batch in [put_requests[i:i + 25] for i in range(0, len(put_requests), 25)]:<br>    request_items = {table_name: batch}<br>    <br>    # Perform the batch write operation<br>    response = dynamodb.batch_write_item(RequestItems=request_items)<br><br># Check if all items were successfully added<br>if no response. get(&#39;UnprocessedItems&#39;):<br>    print(&quot;All Ready LUIT Team!!!!!!!&quot;)<br>else:<br>    print(&quot;Problems adding elements.&quot;)<br></pre><p>Now we run it, using the Python command. If everything goes well we should see the message that says:</p><p><strong>“ALL Ready Team!!!!!!”</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/386/1*8kiFL-Tq4y6wKM_qW99Uqw.png" /></figure><p>Now let’s check our DynamoDB table:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*U-EBvqk2rpy9OdCmpe05RA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WjrNN-ijHzWa7g60H2Mcbw.png" /></figure><p>Everything is perfect, and another project completed!!!</p><p><strong>Conclusion:</strong></p><p>We have successfully managed to create a video game catalog in the cloud using AWS. With tools like Cloud9, Boto3, and DynamoDB, we explore and apply the magic of cloud programming. From setting up IAM to writing data with Python and Boto3, every step was a learning opportunity. Envisioning Cloud9 as our cloud gaming space made the process seamless. This project not only strengthened our skills in AWS and cloud services but also highlighted the power of Python and the efficiency of DynamoDB.</p><p>You can find our repository on Github <a href="https://github.com/JesusEgui/DynamoGamesProject.git">Here</a>❤</p><h4>Connect with Me on Social Media:</h4><p>Github: <a href="https://github.com/JesusEgui">https://github.com/JesusEgui</a></p><p>LinkeIn: <a href="http://www.linkedin.com/in/jesusegui">www.linkedin.com/in/jesusegui</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=da98c060421d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Terraform Dominion: Commanding Two-Tier AWS Architecture :’)]]></title>
            <link>https://medium.com/@13jesusegui/terraform-dominion-commanding-two-tier-aws-architecture-ed9317f9b0b4?source=rss-5ad137ec7bb6------2</link>
            <guid isPermaLink="false">https://medium.com/p/ed9317f9b0b4</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[tech]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[terraform]]></category>
            <dc:creator><![CDATA[Jesus Egui]]></dc:creator>
            <pubDate>Sat, 18 Nov 2023 06:46:01 GMT</pubDate>
            <atom:updated>2023-11-18T06:46:01.792Z</atom:updated>
            <content:encoded><![CDATA[<h3>Terraform Dominion: Commanding Two-Tier AWS Architecture :’)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*_6wnU9u8LpmjB1MXzO6IrA.png" /></figure><h4><strong>Preview:</strong></h4><p>This project aims to implement a highly available two-tier architecture on Amazon Web Services (AWS) using Terraform as an infrastructure as code (IaC) tool. The infrastructure consists of a customized Virtual Private Cloud (VPC) with two tiers: one for public web servers and another for a private MySQL database instance.</p><h4>Key Terms:</h4><ul><li><strong>Infrastructure as Code (IaC): </strong>A methodology involving managing and provisioning computing infrastructure through machine-readable script files, instead of relying on physical hardware configuration or interactive configuration tools.</li><li><strong>Continuous Integration (CI): </strong>The practice of automatically integrating code changes from multiple contributors into a shared repository. It involves automatically testing and validating the changes to ensure they do not break the existing codebase.</li><li><strong>Terraform:</strong> Terraform is an open-source infrastructure as code (IaC) tool that allows users to define and provision a data center infrastructure using a declarative configuration language. It enables automation of infrastructure deployment, making it more scalable and maintainable.</li><li><strong>Two-Tier Architecture: </strong>A design approach for infrastructure that separates applications into two main layers: the presentation layer (front-end) and the business logic and data layer (back-end).</li></ul><p><strong>FOUNDATIONAL:</strong></p><ol><li>Create a highly available two-tier AWS architecture containing the following:</li><li>Custom VPC with:</li><li>2 Public Subnets for the Web Server Tier</li><li>2 Private Subnets for the RDS Tier</li><li>Appropriate route tables</li><li>Launch an EC2 Instance with your choice of webserver in each public web tier subnet (apache, NGINX, etc).</li><li>One RDS MySQL Instance (micro) in the private RDS subnets</li><li>Security Groups properly configured for needed resources ( web servers, RDS)</li><li>Deploy this using Terraform Cloud as a CI/CD tool to check your build.</li><li>Push your code to GitHub and include the link in your write-up.</li></ol><p><strong>NOTE: DO NOT FORGET TO SET YOUR ACCESS KEY, SECRET ACCESS KEY AND REGION ENVIRONMENT VARIABLES IN THE TERRAFORM CLOUD</strong></p><p><strong><em>Let’s start with this project:</em></strong></p><p>The entire project will be done from AWS cloud9:</p><p>Here I show how I already created my environment and also that we already created our directory and our main.tf file</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Wh0hc096SrHSGtkCruDp4g.png" /></figure><p><strong>FOUNDATIONAL:</strong></p><ol><li>Create a highly available two-tier AWS architecture containing the following:</li><li>Custom VPC with:</li><li>2 Public Subnets for the Web Server Tier</li><li>2 Private Subnets for the RDS Tier</li></ol><pre># vpc.tf<br>resource &quot;aws_vpc&quot; &quot;alex_custom_vpc&quot; {<br>  cidr_block           = &quot;10.0.0.0/16&quot;<br>  enable_dns_support   = true<br>  enable_dns_hostnames = true<br>}<br><br># public_subnets.tf<br>resource &quot;aws_subnet&quot; &quot;alex_public_subnet_1&quot; {<br>  vpc_id                  = aws_vpc.alex_custom_vpc.id<br>  cidr_block              = &quot;10.0.1.0/24&quot;<br>  availability_zone       = &quot;us-east-1a&quot;<br>  map_public_ip_on_launch = true<br>}<br><br>resource &quot;aws_subnet&quot; &quot;alex_public_subnet_2&quot; {<br>  vpc_id                  = aws_vpc.alex_custom_vpc.id<br>  cidr_block              = &quot;10.0.2.0/24&quot;<br>  availability_zone       = &quot;us-east-1b&quot;<br>  map_public_ip_on_launch = true<br>}<br><br># private_subnets.tf<br>resource &quot;aws_subnet&quot; &quot;alex_private_subnet_1&quot; {<br>  vpc_id                  = aws_vpc.alex_custom_vpc.id<br>  cidr_block              = &quot;10.0.3.0/24&quot;<br>  availability_zone       = &quot;us-east-1a&quot;<br>}<br><br>resource &quot;aws_subnet&quot; &quot;alex_private_subnet_2&quot; {<br>  vpc_id                  = aws_vpc.alex_custom_vpc.id<br>  cidr_block              = &quot;10.0.4.0/24&quot;<br>  availability_zone       = &quot;us-east-1b&quot;<br>}</pre><p>5. Appropriate route tables and internet gateway:</p><pre>resource &quot;aws_internet_gateway&quot; &quot;alex_igw&quot; {<br>  vpc_id = aws_vpc.alex_custom_vpc.id<br>}<br><br># route_table.tf<br>resource &quot;aws_route_table&quot; &quot;alex_route_table&quot; {<br>  vpc_id = aws_vpc.alex_custom_vpc.id<br>}<br><br>resource &quot;aws_route&quot; &quot;alex_route&quot; {<br>  route_table_id         = aws_route_table.alex_route_table.id<br>  destination_cidr_block = &quot;0.0.0.0/0&quot;<br>  gateway_id             = aws_internet_gateway.alex_igw.id<br>}</pre><p>6. Launch an EC2 Instance with your choice of webserver in each public web tier subnet (Apache, NGINX, etc).</p><p>7. One RDS MySQL Instance (micro) in the private RDS subnets</p><p>8. Security Groups properly configured for needed resources ( web servers, RDS):</p><pre># ec2_instances.tf<br>resource &quot;aws_instance&quot; &quot;alex_web_server_1&quot; {<br>  ami                    = &quot;ami-067d1e60475437da2&quot;<br>  instance_type          = &quot;t2.micro&quot;<br>  subnet_id              = aws_subnet.alex_public_subnet_1.id<br>  vpc_security_group_ids = [aws_security_group.alex_web_security_group.id]<br>  key_name               = aws_key_pair.alex_key_pair.key_name<br>}<br><br>resource &quot;aws_instance&quot; &quot;alex_web_server_2&quot; {<br>  ami                    = &quot;ami-067d1e60475437da2&quot;<br>  instance_type          = &quot;t2.micro&quot;<br>  subnet_id              = aws_subnet.alex_public_subnet_2.id<br>  vpc_security_group_ids = [aws_security_group.alex_web_security_group.id]<br>  key_name               = aws_key_pair.alex_key_pair.key_name<br>}<br><br># rds.tf<br>resource &quot;aws_db_subnet_group&quot; &quot;alex_db_subnet_group&quot; {<br>  name       = &quot;mydb-subnet-group&quot;<br>  subnet_ids = [aws_subnet.alex_private_subnet_1.id, aws_subnet.alex_private_subnet_2.id]<br>}<br><br>resource &quot;aws_db_instance&quot; &quot;alex_rds_instance&quot; {<br>  allocated_storage    = 20<br>  storage_type         = &quot;gp2&quot;<br>  engine               = &quot;mysql&quot;<br>  engine_version       = &quot;5.7&quot;<br>  instance_class       = &quot;db.t2.micro&quot;<br>  identifier           = &quot;mydatabase&quot;<br>  username             = &quot;admin&quot;<br>  password             = &quot;password&quot;<br>  vpc_security_group_ids = [aws_security_group.alex_rds_security_group.id]<br>  db_subnet_group_name  = aws_db_subnet_group.alex_db_subnet_group.name<br>}<br><br># security_groups.tf<br>resource &quot;aws_security_group&quot; &quot;alex_web_security_group&quot; {<br>  vpc_id = aws_vpc.alex_custom_vpc.id<br>  # Configura las reglas de seguridad para las instancias de servidor web según sea necesario<br>}<br><br>resource &quot;aws_security_group&quot; &quot;alex_rds_security_group&quot; {<br>  vpc_id = aws_vpc.alex_custom_vpc.id<br>  # Configura las reglas de seguridad para la instancia de RDS según sea necesario<br>}</pre><p>My main.tf file:</p><pre>provider &quot;aws&quot; {<br>  region = &quot;us-east-1&quot;<br>}<br><br>resource &quot;tls_private_key&quot; &quot;alex_key_pair&quot; {<br>  algorithm = &quot;RSA&quot;<br>}<br><br>resource &quot;aws_key_pair&quot; &quot;alex_key_pair&quot; {<br>  key_name   = &quot;alex-key-pair&quot;<br>  public_key = tls_private_key.alex_key_pair.public_key_openssh<br>}<br><br>resource &quot;aws_vpc&quot; &quot;alex_custom_vpc&quot; {<br>  cidr_block           = &quot;10.0.0.0/16&quot;<br>  enable_dns_support   = true<br>  enable_dns_hostnames = true<br>}<br><br>resource &quot;aws_subnet&quot; &quot;alex_public_subnet_1&quot; {<br>  vpc_id                  = aws_vpc.alex_custom_vpc.id<br>  cidr_block              = &quot;10.0.1.0/24&quot;<br>  availability_zone       = &quot;us-east-1a&quot;<br>  map_public_ip_on_launch = true<br>}<br><br>resource &quot;aws_subnet&quot; &quot;alex_public_subnet_2&quot; {<br>  vpc_id                  = aws_vpc.alex_custom_vpc.id<br>  cidr_block              = &quot;10.0.2.0/24&quot;<br>  availability_zone       = &quot;us-east-1b&quot;<br>  map_public_ip_on_launch = true<br>}<br><br>resource &quot;aws_subnet&quot; &quot;alex_private_subnet_1&quot; {<br>  vpc_id                  = aws_vpc.alex_custom_vpc.id<br>  cidr_block              = &quot;10.0.3.0/24&quot;<br>  availability_zone       = &quot;us-east-1a&quot;<br>}<br><br>resource &quot;aws_subnet&quot; &quot;alex_private_subnet_2&quot; {<br>  vpc_id                  = aws_vpc.alex_custom_vpc.id<br>  cidr_block              = &quot;10.0.4.0/24&quot;<br>  availability_zone       = &quot;us-east-1b&quot;<br>}<br><br>resource &quot;aws_internet_gateway&quot; &quot;alex_igw&quot; {<br>  vpc_id = aws_vpc.alex_custom_vpc.id<br>}<br><br>resource &quot;aws_route_table&quot; &quot;alex_route_table&quot; {<br>  vpc_id = aws_vpc.alex_custom_vpc.id<br>}<br><br>resource &quot;aws_route&quot; &quot;alex_route&quot; {<br>  route_table_id         = aws_route_table.alex_route_table.id<br>  destination_cidr_block = &quot;0.0.0.0/0&quot;<br>  gateway_id             = aws_internet_gateway.alex_igw.id<br>}<br><br>resource &quot;aws_instance&quot; &quot;alex_web_server_1&quot; {<br>  ami                    = &quot;ami-067d1e60475437da2&quot;<br>  instance_type          = &quot;t2.micro&quot;<br>  subnet_id              = aws_subnet.alex_public_subnet_1.id<br>  vpc_security_group_ids = [aws_security_group.alex_web_security_group.id]<br>  key_name               = aws_key_pair.alex_key_pair.key_name<br>}<br><br>resource &quot;aws_instance&quot; &quot;alex_web_server_2&quot; {<br>  ami                    = &quot;ami-067d1e60475437da2&quot;<br>  instance_type          = &quot;t2.micro&quot;<br>  subnet_id              = aws_subnet.alex_public_subnet_2.id<br>  vpc_security_group_ids = [aws_security_group.alex_web_security_group.id]<br>  key_name               = aws_key_pair.alex_key_pair.key_name<br>}<br><br>resource &quot;aws_db_subnet_group&quot; &quot;alex_db_subnet_group&quot; {<br>  name       = &quot;mydb-subnet-group&quot;<br>  subnet_ids = [aws_subnet.alex_private_subnet_1.id, aws_subnet.alex_private_subnet_2.id]<br>}<br><br>resource &quot;aws_db_instance&quot; &quot;alex_rds_instance&quot; {<br>  allocated_storage    = 20<br>  storage_type         = &quot;gp2&quot;<br>  engine               = &quot;mysql&quot;<br>  engine_version       = &quot;5.7&quot;<br>  instance_class       = &quot;db.t2.micro&quot;<br>  identifier           = &quot;mydatabase&quot;<br>  username             = &quot;admin&quot;<br>  password             = &quot;password&quot;<br>  vpc_security_group_ids = [aws_security_group.alex_rds_security_group.id]<br>  db_subnet_group_name  = aws_db_subnet_group.alex_db_subnet_group.name<br>}<br><br>resource &quot;aws_security_group&quot; &quot;alex_web_security_group&quot; {<br>  vpc_id = aws_vpc.alex_custom_vpc.id<br>}<br><br>resource &quot;aws_security_group&quot; &quot;alex_rds_security_group&quot; {<br>  vpc_id = aws_vpc.alex_custom_vpc.id<br>}</pre><p><strong>Now we will use the following commands to run our instance:</strong></p><ol><li>terraform fmt: Formats Terraform configuration files.</li><li>terraform validate: Validates the syntax and configuration of Terraform files.</li><li>terraform init: Initializes a Terraform working directory.</li><li>terraform apply: Applies changes defined in the Terraform configuration.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/853/1*8RjLmpxxjChyYPAx66Gdzw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FrYxu3rm82syqdW2JHd-tA.png" /><figcaption><strong>It works</strong></figcaption></figure><p>Now in terraform cloud we must create an organization and a workspace</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1007/1*Np1PkX_WHpWLEnXvSCw7ww.jpeg" /></figure><p>In the next screen, we are going to select<strong> CLI-driven</strong> <strong>workflow.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JM7IyVAZFVHOV7LCH3MDmw.png" /></figure><p>For the Workspace Name i am going with<strong> levelupbank-prod</strong> then click <strong>Create workspace</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/818/1*tgksm3Fda02A5b8i7c4AAQ.png" /></figure><p>We need to generate a token so we go to user setting, click on “generate token” and a token will be created to be able to start a section in our cloud9 environment</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tT9xgY-DlJSZ48C6bttkeg.png" /></figure><p>Now let’s go to cloud9, use the “terraform login” command, copy and paste our token and if we did it correctly it should look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Dgkjre_a_PScEJ6kODedow.png" /></figure><p>here we have the code</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*biAwfqvHMpo-v85eVd0PVg.png" /></figure><p>We add our code to our main.tf file</p><pre>provider &quot;aws&quot; {<br>  region = &quot;us-east-1&quot;<br>}<br><br>terraform {<br>  cloud {<br>    organization = &quot;Terraform-project-11&quot;<br><br>    workspaces {<br>      name = &quot;Workspace&quot;<br>    }<br>  }<br>}<br><br>resource &quot;tls_private_key&quot; &quot;alex_key_pair&quot; {<br>  algorithm = &quot;RSA&quot;<br>}<br><br>resource &quot;aws_key_pair&quot; &quot;alex_key_pair&quot; {<br>  key_name   = &quot;alex-key-pair&quot;<br>  public_key = tls_private_key.alex_key_pair.public_key_openssh<br>}<br><br>resource &quot;aws_vpc&quot; &quot;alex_custom_vpc&quot; {<br>  cidr_block           = &quot;10.0.0.0/16&quot;<br>  enable_dns_support   = true<br>  enable_dns_hostnames = true<br>}<br><br>resource &quot;aws_subnet&quot; &quot;alex_public_subnet_1&quot; {<br>  vpc_id                  = aws_vpc.alex_custom_vpc.id<br>  cidr_block              = &quot;10.0.1.0/24&quot;<br>  availability_zone       = &quot;us-east-1a&quot;<br>  map_public_ip_on_launch = true<br>}<br><br>resource &quot;aws_subnet&quot; &quot;alex_public_subnet_2&quot; {<br>  vpc_id                  = aws_vpc.alex_custom_vpc.id<br>  cidr_block              = &quot;10.0.2.0/24&quot;<br>  availability_zone       = &quot;us-east-1b&quot;<br>  map_public_ip_on_launch = true<br>}<br><br>resource &quot;aws_subnet&quot; &quot;alex_private_subnet_1&quot; {<br>  vpc_id                  = aws_vpc.alex_custom_vpc.id<br>  cidr_block              = &quot;10.0.3.0/24&quot;<br>  availability_zone       = &quot;us-east-1a&quot;<br>}<br><br>resource &quot;aws_subnet&quot; &quot;alex_private_subnet_2&quot; {<br>  vpc_id                  = aws_vpc.alex_custom_vpc.id<br>  cidr_block              = &quot;10.0.4.0/24&quot;<br>  availability_zone       = &quot;us-east-1b&quot;<br>}<br><br>resource &quot;aws_internet_gateway&quot; &quot;alex_igw&quot; {<br>  vpc_id = aws_vpc.alex_custom_vpc.id<br>}<br><br>resource &quot;aws_route_table&quot; &quot;alex_route_table&quot; {<br>  vpc_id = aws_vpc.alex_custom_vpc.id<br>}<br><br>resource &quot;aws_route&quot; &quot;alex_route&quot; {<br>  route_table_id         = aws_route_table.alex_route_table.id<br>  destination_cidr_block = &quot;0.0.0.0/0&quot;<br>  gateway_id             = aws_internet_gateway.alex_igw.id<br>}<br><br>resource &quot;aws_instance&quot; &quot;alex_web_server_1&quot; {<br>  ami                    = &quot;ami-067d1e60475437da2&quot;<br>  instance_type          = &quot;t2.micro&quot;<br>  subnet_id              = aws_subnet.alex_public_subnet_1.id<br>  vpc_security_group_ids = [aws_security_group.alex_web_security_group.id]<br>  key_name               = aws_key_pair.alex_key_pair.key_name<br>}<br><br>resource &quot;aws_instance&quot; &quot;alex_web_server_2&quot; {<br>  ami                    = &quot;ami-067d1e60475437da2&quot;<br>  instance_type          = &quot;t2.micro&quot;<br>  subnet_id              = aws_subnet.alex_public_subnet_2.id<br>  vpc_security_group_ids = [aws_security_group.alex_web_security_group.id]<br>  key_name               = aws_key_pair.alex_key_pair.key_name<br>}<br><br>resource &quot;aws_db_subnet_group&quot; &quot;alex_db_subnet_group&quot; {<br>  name       = &quot;mydb-subnet-group&quot;<br>  subnet_ids = [aws_subnet.alex_private_subnet_1.id, aws_subnet.alex_private_subnet_2.id]<br>}<br><br>resource &quot;aws_db_instance&quot; &quot;alex_rds_instance&quot; {<br>  allocated_storage      = 20<br>  storage_type           = &quot;gp2&quot;<br>  engine                 = &quot;mysql&quot;<br>  engine_version         = &quot;5.7&quot;<br>  instance_class         = &quot;db.t2.micro&quot;<br>  identifier             = &quot;mydatabase&quot;<br>  username               = &quot;admin&quot;<br>  password               = &quot;password&quot;<br>  vpc_security_group_ids = [aws_security_group.alex_rds_security_group.id]<br>  db_subnet_group_name   = aws_db_subnet_group.alex_db_subnet_group.name<br>}<br><br>resource &quot;aws_security_group&quot; &quot;alex_web_security_group&quot; {<br>  vpc_id = aws_vpc.alex_custom_vpc.id<br>}<br><br>resource &quot;aws_security_group&quot; &quot;alex_rds_security_group&quot; {<br>  vpc_id = aws_vpc.alex_custom_vpc.id<br>}</pre><p>We use the terraform init command and the terraform apply command again:<br>It will give us an error when trying to run terraform apply because we do not have the credentials added yet</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/954/1*ATg_K1hXdf05PsUYexIDBg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VVWGOhOfwxNPy1pRXikPIA.png" /></figure><p>Create two environment variables which are the access key and the secret key</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Oisp_Mr9DQN3Foo4aS7yzQ.png" /></figure><p>For the last time we must run our famous <strong>terraform init and terraform apply</strong> commands to see if we have any changes</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XdhObTvUt-gvgXAF96Pp-Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kUgiVNpa4e-vvfSNdBH1tw.png" /></figure><p><strong>IT WORKSSSSS!!!!!!!!!!!! :’)</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i4e9FSTAw9EwmlLuEpqWFQ.png" /></figure><p><strong>Terraform project ready!!!!</strong></p><h4>Conclusion:</h4><p>Terraform Dominion has successfully implemented a two-tier architecture on AWS using Terraform, featuring efficient automation, design in line with best practices, seamless integration with Terraform Cloud for CI/CD, secure configuration of security groups, clear documentation on GitHub, and attention to security in credentials configuration. This establishes a robust foundation for future developments and effective collaboration.</p><h4>Contact With Me on Social Media:</h4><p>Github: <a href="https://github.com/JesusEgui">https://github.com/JesusEgui</a></p><p>LinkeIn: <a href="http://www.linkedin.com/in/jesusegui">www.linkedin.com/in/jesusegui</a></p><p><strong>ADVANCED: Coming soon</strong></p><ol><li>Internet-facing Application Load Balancer targeting web servers.</li><li>ALB Security Group with needed permissions and modifications needed to Web Servers SG to reflect the new architecture.</li></ol><p><strong>COMPLEX: Coming Soon</strong></p><ol><li>Use the code you’ve already built out for the ADVANCED.</li><li>Modify the EC2 User Data script to deploy Wordpress instead.</li><li>Connect your Wordpress to your RDS MySQL. This can be done two ways. One way is after deployment, logging into each Wordpress server and manually configuring or the second option of adding the configuration to your bootstrap script.</li><li>Be sure to use the Wordpress documentation to find out more about installation and database connections.</li><li>Also think about why it’s better to use RDS when you have multiple servers instead of installing the database on the EC2 instance itself.Recommendations:</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ed9317f9b0b4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Jenkins in the Cloud: A Terraform-powered Deployment :’)]]></title>
            <link>https://medium.com/@13jesusegui/jenkins-in-the-cloud-a-terraform-powered-deployment-75c603f530df?source=rss-5ad137ec7bb6------2</link>
            <guid isPermaLink="false">https://medium.com/p/75c603f530df</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[terraform]]></category>
            <category><![CDATA[jenkins]]></category>
            <category><![CDATA[technology]]></category>
            <dc:creator><![CDATA[Jesus Egui]]></dc:creator>
            <pubDate>Thu, 16 Nov 2023 16:12:47 GMT</pubDate>
            <atom:updated>2023-11-18T21:27:14.932Z</atom:updated>
            <content:encoded><![CDATA[<h3>Jenkins in the Cloud: A Terraform-powered Deployment :’)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KzXV6y9uuD75jAn64VCKRQ.png" /></figure><h4>Everyday Situation Analysis:</h4><p>Your team would like to start using Jenkins as their CI/CD tool to create pipelines for DevOps projects. They need you to create the Jenkins server using Terraform so that it can be used in other environments and so that changes to the environment are better tracked. For the Foundational project, you are allowed to have all your code in a single main.tf file (known as a monolith) with hardcoded data. Push all your code to GitHub and include the link to your repo in your documentation.‌</p><h4>Key Terms:</h4><ul><li><strong>Infrastructure as Code (IaC): </strong>A methodology that involves managing and provisioning computing infrastructure through machine-readable script files, rather than through physical hardware configuration or interactive configuration tools.</li><li><strong>Continuous Integration (CI): </strong>The practice of automatically integrating code changes from multiple contributors into a shared repository. It involves automatically testing and validating the changes to ensure they do not break the existing codebase.</li><li><strong>Continuous Delivery (CD): </strong>An extension of CI, where code changes are automatically prepared for a production release. This involves automating the entire software release process.</li><li><strong>Security Group: </strong>A set of firewall rules that control inbound and outbound traffic to instances in Amazon’s Virtual Private Cloud (VPC).</li><li><strong>Amazon S3 (Simple Storage Service):</strong> A scalable object storage service that allows users to store and retrieve any amount of data from anywhere on the web.</li><li><strong>IAM Role (Identity and Access Management Role):</strong> The AWS Identity and Access Management (IAM) role is an AWS Identity with permission policies that determine what the identity can and cannot do in AWS.</li><li><strong>Terraform:</strong> Terraform is an open-source infrastructure as code (IaC) tool that allows users to define and provision a data center infrastructure using a declarative configuration language. It enables automation of infrastructure deployment, making it more scalable and maintainable.</li><li><strong>Jenkins: </strong>Jenkins is an open-source automation server used for building, testing, and deploying code. It facilitates continuous integration and continuous delivery (CI/CD) by automating various stages of the software development lifecycle.</li></ul><h4>Recommendations:</h4><ul><li>Implement IAM Role for secure S3 access.</li><li>Enhance user data script for Jenkins installation by parameterizing variables.</li><li>Explore Jenkins pipeline integration for CI/CD automation.</li></ul><h4>FOUNDATIONAL:</h4><ol><li>Deploy 1 EC2 Instance in your Default VPC.</li><li>Bootstrap the EC2 instance with a script that will install and start Jenkins. Review the official Jenkins Documentation for more information: <a href="https://www.jenkins.io/doc/book/installing/linux/">Linux</a></li><li>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.</li><li>Create a S3 bucket for your Jenkins Artifacts that is not open to the public.</li><li>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.</li><li>Push your code to GitHub and include the link in your write-up.</li></ol><p><strong><em>Let’s start with this project:</em></strong></p><p>First, we must create the environment where we are going to work, which in this case will be Cloud9. Here we will create a directory where we will create configuration files to be able to deploy our instance using the CLI.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7u4rtzhTu-KCUdj3Y-M02A.png" /></figure><p>The name of the environment will be 1 Super Jenkins which is the directory where we will work</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yHRDUtBcBYlTFcxK8123jQ.png" /><figcaption><strong>Directory: 1SuperJenkins</strong></figcaption></figure><p>Then we need to create a main.tf file which in this case would be a new root file where we will add the specifications for our deployment of our instance and everything that makes it up such as VPC, Key pair, Security Group</p><p>In this case, we will use the nano editor and with the following command our main.tf file will be automatically created and we will be able to edit it</p><pre>nano main.tf</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/926/1*PzYYSYs3VTsMMnjvuDetWQ.png" /></figure><p><strong>Note:</strong> this project has very basic specifications because the idea of this is not to skip anything and that everything is reflected on the screen.</p><p>We will create a few more things but they will be to be able to use the IP address as an IGW and a Route Table</p><ol><li>Deploy 1 EC2 Instance in your Default VPC.</li></ol><ul><li>Configuring the AWS Provider and Creating a VPC:</li></ul><pre>provider &quot;aws&quot; {   region = &quot;us-east-1&quot; }</pre><pre>resource &quot;aws_vpc&quot; &quot;JenkinsVPC&quot; {<br>  cidr_block           = &quot;10.0.0.0/16&quot;<br>  enable_dns_support   = true<br>  enable_dns_hostnames = true</pre><pre>  tags = {<br>    Name = &quot;JenkinsVPC&quot;<br>  }<br>}</pre><p>2. Creating an Internet Gateway:</p><pre>resource &quot;aws_internet_gateway&quot; &quot;IGWJenkins&quot; {<br>  vpc_id = aws_vpc.JenkinsVPC.id<br>}</pre><p>3. Creating a Route Table and Association of the Route Table with the Subnet:</p><pre>resource &quot;aws_route_table&quot; &quot;RTJenkins&quot; {<br>  vpc_id = aws_vpc.JenkinsVPC.id</pre><pre>  route {<br>    cidr_block = &quot;0.0.0.0/0&quot;<br>    gateway_id = aws_internet_gateway.IGWJenkins.id<br>  }<br>}</pre><pre># Associate the Route Table with the Subnet<br>resource &quot;aws_route_table_association&quot; &quot;Jenkins-rt-assoc&quot; {<br>  subnet_id      = aws_subnet.SubnetJenkins.id<br>  route_table_id = aws_route_table.RTJenkins.id<br>}}</pre><p>4. Creating a Subnet within the VPC:</p><pre>resource &quot;aws_subnet&quot; &quot;SubnetJenkins&quot; {<br>  vpc_id                  = aws_vpc.JenkinsVPC.id<br>  cidr_block              = &quot;10.0.0.0/24&quot;<br>  availability_zone       = &quot;us-east-1a&quot;<br>  map_public_ip_on_launch = true</pre><pre>  tags = {<br>    Name = &quot;SubnetJenkins&quot;<br>  }</pre><p>5. Generating an SSH key pair:</p><pre>resource &quot;tls_private_key&quot; &quot;jenkins-key&quot; {<br>  algorithm = &quot;RSA&quot;<br>}</pre><pre>resource &quot;aws_key_pair&quot; &quot;jenkins-key&quot; {<br>  key_name   = &quot;jenkins-key&quot;<br>  public_key = tls_private_key.jenkins-key.public_key_openssh<br>}</pre><p>6. Creating an EC2 instance (AlexJenkins):</p><pre>resource &quot;aws_instance&quot; &quot;AlexJenkins&quot; {   ami           = &quot;ami-067d1e60475437da2&quot;   instance_type = &quot;t2.micro&quot;   key_name      = aws_key_pair.jenkins-key.key_name   user_data     = &lt;&lt;-EOF     #!/bin/bash     sudo yum update -y     # ... (script de instalación de Jenkins)   EOF    tags = {     Name = &quot;AlexJenkins&quot;   }   vpc_security_group_ids = [aws_security_group.alex_security_group.id]   subnet_id              = aws_subnet.SubnetJenkins.id }</pre><p>7. Creating a security group (alex_security_group):</p><pre>resource &quot;aws_security_group&quot; &quot;alex_security_group&quot; {<br>  name        = &quot;alex_security_group&quot;<br>  description = &quot;Allow incoming web traffic from port 80 and 22&quot;<br>  vpc_id      = aws_vpc.JenkinsVPC.id</pre><pre>  ingress {<br>    from_port   = 8080<br>    to_port     = 8080<br>    protocol    = &quot;tcp&quot;<br>    cidr_blocks = [&quot;0.0.0.0/0&quot;]<br>  }</pre><pre>  ingress {<br>    from_port   = 22<br>    to_port     = 22<br>    protocol    = &quot;tcp&quot;<br>    cidr_blocks = [&quot;0.0.0.0/0&quot;]<br>  }</pre><pre>  egress {<br>    from_port   = 0<br>    to_port     = 0<br>    protocol    = &quot;-1&quot;<br>    cidr_blocks = [&quot;0.0.0.0/0&quot;]<br>  }</pre><pre>  tags = {<br>    Name = &quot;alex_security_group&quot;<br>  }<br>}</pre><p>8. Create an S3 bucket for Jenkins Artifacts</p><pre>resource &quot;aws_s3_bucket&quot; &quot;jenkins_artifacts_bucket&quot; {<br>  bucket = &quot;bucket-artifacts-alex&quot;  # Cambiado el nombre del bucket para cumplir con las reglas de AWS<br>  acl    = &quot;private&quot;</pre><pre>  tags = {<br>    Name = &quot;Jenkins Artifacts Bucket&quot;<br>  }<br>}</pre><p>9. Bootstrap the EC2 instance with a script that will install and start Jenkins. Review the official Jenkins Documentation for more information: <a href="https://www.jenkins.io/doc/book/installing/linux/">Linux</a></p><pre>user_data     = &lt;&lt;-EOF<br>    #!/bin/bash<br>    sudo yum update -y<br>    sudo wget -O /etc/yum.repos.d/jenkins.repo \<br>      https://pkg.jenkins.io/redhat-stable/jenkins.repo<br>    sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io-2023.key<br>    sudo yum upgrade -y<br>    sudo amazon-linux-extras install java-openjdk11 -y<br>    sudo dnf install java-11-amazon-corretto -y<br>    sudo yum install jenkins -y<br>    sudo systemctl enable jenkins<br>    sudo systemctl start jenkins<br>    sudo systemctl status jenkins<br>  EOF<br>}</pre><p>Now this is what our main.tf code should look like:</p><pre># Configure AWS Provider<br>provider &quot;aws&quot; {<br>  region = &quot;us-east-1&quot;<br>}</pre><pre># Create VPC<br>resource &quot;aws_vpc&quot; &quot;JenkinsVPC&quot; {<br>  cidr_block           = &quot;10.0.0.0/16&quot;<br>  enable_dns_support   = true<br>  enable_dns_hostnames = true</pre><pre>  tags = {<br>    Name = &quot;JenkinsVPC&quot;<br>  }<br>}</pre><pre># Create Internet Gateway<br>resource &quot;aws_internet_gateway&quot; &quot;IGWJenkins&quot; {<br>  vpc_id = aws_vpc.JenkinsVPC.id<br>}</pre><pre># Create a Route Table<br>resource &quot;aws_route_table&quot; &quot;RTJenkins&quot; {<br>  vpc_id = aws_vpc.JenkinsVPC.id</pre><pre>  route {<br>    cidr_block = &quot;0.0.0.0/0&quot;<br>    gateway_id = aws_internet_gateway.IGWJenkins.id<br>  }<br>}</pre><pre># Associate the Route Table with the Subnet<br>resource &quot;aws_route_table_association&quot; &quot;jenkins-rt-assoc&quot; {<br>  subnet_id      = aws_subnet.SubnetJenkins.id<br>  route_table_id = aws_route_table.RTJenkins.id<br>}</pre><pre># Create a Subnet within the VPC<br>resource &quot;aws_subnet&quot; &quot;SubnetJenkins&quot; {<br>  vpc_id                  = aws_vpc.JenkinsVPC.id<br>  cidr_block              = &quot;10.0.0.0/24&quot;<br>  availability_zone       = &quot;us-east-1a&quot;<br>  map_public_ip_on_launch = true</pre><pre>  tags = {<br>    Name = &quot;SubnetJenkins&quot;<br>  }<br>}</pre><pre># Generate SSH key pair<br>resource &quot;tls_private_key&quot; &quot;jenkins-key&quot; {<br>  algorithm = &quot;RSA&quot;<br>}</pre><pre>resource &quot;aws_key_pair&quot; &quot;jenkins-key&quot; {<br>  key_name   = &quot;jenkins-key&quot;<br>  public_key = tls_private_key.jenkins-key.public_key_openssh<br>}</pre><pre># Resource Block To Build EC2 instance<br>resource &quot;aws_instance&quot; &quot;AlexJenkins&quot; {<br>  ami           = &quot;ami-067d1e60475437da2&quot;<br>  instance_type = &quot;t2.micro&quot;<br>  key_name      = aws_key_pair.jenkins-key.key_name<br>  user_data     = &lt;&lt;-EOF<br>    #!/bin/bash<br>    sudo yum update -y<br>    sudo wget -O /etc/yum.repos.d/jenkins.repo \<br>      <a href="https://pkg.jenkins.io/redhat-stable/jenkins.repo">https://pkg.jenkins.io/redhat-stable/jenkins.repo</a><br>    sudo rpm --import <a href="https://pkg.jenkins.io/redhat-stable/jenkins.io-2023.key">https://pkg.jenkins.io/redhat-stable/jenkins.io-2023.key</a><br>    sudo yum upgrade -y<br>    sudo amazon-linux-extras install java-openjdk11 -y<br>    sudo dnf install java-11-amazon-corretto -y<br>    sudo yum install jenkins -y<br>    sudo systemctl enable jenkins<br>    sudo systemctl start jenkins<br>    sudo systemctl status jenkins<br>  EOF</pre><pre>  tags = {<br>    Name = &quot;AlexJenkins&quot;<br>  }<br>  vpc_security_group_ids = [aws_security_group.alex_security_group.id]<br>  subnet_id              = aws_subnet.SubnetJenkins.id<br>}</pre><pre># Create security group with SSH and web access<br>resource &quot;aws_security_group&quot; &quot;alex_security_group&quot; {<br>  name        = &quot;alex_security_group&quot;<br>  description = &quot;Allow incoming web traffic from port 80 and 22&quot;<br>  vpc_id      = aws_vpc.JenkinsVPC.id</pre><pre>  ingress {<br>    from_port   = 8080<br>    to_port     = 8080<br>    protocol    = &quot;tcp&quot;<br>    cidr_blocks = [&quot;0.0.0.0/0&quot;]<br>  }</pre><pre>  ingress {<br>    from_port   = 22<br>    to_port     = 22<br>    protocol    = &quot;tcp&quot;<br>    cidr_blocks = [&quot;0.0.0.0/0&quot;]<br>  }</pre><pre>  egress {<br>    from_port   = 0<br>    to_port     = 0<br>    protocol    = &quot;-1&quot;<br>    cidr_blocks = [&quot;0.0.0.0/0&quot;]<br>  }</pre><pre>  tags = {<br>    Name = &quot;alex_security_group&quot;<br>  }<br>}</pre><pre># Create an S3 bucket for Jenkins Artifacts<br>resource &quot;aws_s3_bucket&quot; &quot;jenkins_artifacts_bucket&quot; {<br>  bucket = &quot;bucket-artifacts-alex&quot;  # Cambiado el nombre del bucket para cumplir con las reglas de AWS<br>  acl    = &quot;private&quot;</pre><pre>  tags = {<br>    Name = &quot;Jenkins Artifacts Bucket&quot;<br>  }<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/701/1*QKRJYhJ9RiWX0EqrTNY_1g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/731/1*VL7RyYiLLLs7QMgdfd8Qzw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/715/1*5Ira42n9NzQVI5rXABfSaw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/913/1*u7aUs6404T-GhLYgo9RhoA.png" /></figure><p><strong>Now we will use the following commands to run our instance:</strong></p><ol><li>terraform fmt: Formats Terraform configuration files.</li><li>terraform validate: Validates the syntax and configuration of Terraform files.</li><li>terraform init: Initializes a Terraform working directory.</li><li>terraform apply: Applies changes defined in the Terraform configuration.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/714/1*iiUPwSRXspva5xonRNO54A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AZXgYIt5oVGo3AUoCl2ffg.png" /></figure><p>I had already done it so it wouldn’t show me, it gave me a message that there aren’t any changes hahahahahah but that’s fine, it’s just to show that this is the way to make sure what is the way to make it visible, is it worth updating and are deployed</p><p>Now we can see the Bucket that we created and the instance too</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Hnc8ZUprFOBoKdbW5zRmLw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UlAZkYICsUGL_Q2XkpASYw.png" /><figcaption><strong>AlexJenkins</strong></figcaption></figure><p><strong>Last part: </strong>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>For this, we will look for the IP of our instance we copy and paste it on our browser in this way:</p><pre>http://&lt;IP-Instance&gt;:8080</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A15k4feX7FFpwieaKTphsg.png" /></figure><p>Perfect, another project completed</p><p>You can access it to the Repo <a href="https://chat.openai.com/c/Insert%20GitHub%20Repository%20Link">here</a>.</p><h4>Conclusion:</h4><p>This project successfully utilized Terraform and Jenkins to automate the deployment of a Jenkins server on AWS. The infrastructure-as-code approach was employed, providing a scalable and reproducible solution. Key achievements include the creation of AWS resources, Jenkins installation, security considerations, and advanced Terraform features. Future considerations involve IAM Role implementation, script optimization, pipeline integration, and enhanced monitoring solutions for continuous improvement.</p><h4>Connect with Me on Social Media:</h4><p>Github: <a href="https://github.com/JesusEgui">https://github.com/JesusEgui</a></p><p>LinkeIn: <a href="http://www.linkedin.com/in/jesusegui">www.linkedin.com/in/jesusegui</a></p><h4>ADVANCED: Coming Soon</h4><ol><li>Add variables<a href="http://variables.tf/">. tf</a> file and make sure nothing is hardcoded in your <a href="http://main.tf/">main. tf</a>.</li><li>Create a separate file for your <a href="http://providers.tf/">providers. tf</a> if you have not already.</li></ol><h4>COMPLEX: Coming Soon</h4><ol><li>Create an IAM Role that allows S3 read/write access for the Jenkins Server and assign that role to your Jenkins Server EC2 instance.</li><li>You can confirm this by smashing into your instance and without using your credentials test some S3 AWS CLI commands. We’ll leave it up to you to determine which commands you feel are appropriate to validate the permissions.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=75c603f530df" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Docker Swarm Delight: Frontend-Backend Harmony in WordPress :’)]]></title>
            <link>https://medium.com/@13jesusegui/docker-swarm-delight-frontend-backend-harmony-in-wordpress-946fed68eec1?source=rss-5ad137ec7bb6------2</link>
            <guid isPermaLink="false">https://medium.com/p/946fed68eec1</guid>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[wordpress]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <dc:creator><![CDATA[Jesus Egui]]></dc:creator>
            <pubDate>Tue, 14 Nov 2023 16:56:59 GMT</pubDate>
            <atom:updated>2023-11-14T16:56:59.332Z</atom:updated>
            <content:encoded><![CDATA[<h3>Docker Swarm Delight: Frontend-Backend Harmony in WordPress :’)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/495/1*cjf84X3BNYm4E4jfJBx1mA.png" /></figure><h4>Everyday Scenario Example:</h4><p>Level Up Publications is embracing Docker Swarm as its containerization solution, driven by remarkable growth and dynamic digital demands. Docker Swarm streamlines application management, enables efficient scaling, bolsters security, and minimizes downtime through automatic container replacement. This strategic move equips Level Up Publications with the agility to respond to rapidly changing news cycles, efficiently serve their expanding readership, and maintain website availability and security.</p><h4>Command uses:</h4><ul><li>These commands create networks in Docker Swarm to segregate the public and private parts of the application. The `<strong>frontend_Hello</strong>` network is for services exposed to the public, while `<strong>backend_World</strong>` is for internal services.</li></ul><pre>sudo docker network create --driver overlay frontend_Hello and sudo docker network create --driver overlay backend_World.</pre><ul><li>This Docker command creates a MySQL service (`mysql-service`) with one replica, linked to the `backend_World` network, and uses a volume (`THE_NIGHT_VOLUME`) for persistent data.</li></ul><pre>sudo docker service create --name mysql-service --network backend_World --replicas 1 -e MYSQL_ROOT_PASSWORD=LASTNIGHT -e MYSQL_DATABASE=NIGHT_DB -e MYSQL_USER=THE_NIGHT -e MYSQL_PASSWORD=LASTNIGHT --mount type=volume,source=THE_NIGHT_VOLUME,target=/var/lib/mysql mysql:latest</pre><p>This command creates a WordPress service (WordPress-service-night) with three replicas, exposed on port 80, connected to the frontend_Hello network, using MySQL for database connections.</p><pre>sudo docker service create --name wordpress-service-night --network frontend_Hello --replicas 3 -p 80:80 -e WORDPRESS_DB_HOST=mysql-service -e WORDPRESS_DB_USER=THE_NIGHT -e WORDPRESS_DB_PASSWORD=LASTNIGHT -e WORDPRESS_DB_NAME=NIGHT_DB wordpress:latest</pre><ul><li>Obtains the virtual IP address of the WordPress service in the Docker Swarm cluster.</li><li>Second command: Displays the logs for the WordPress service, providing information on its status, initialization, and potential errors.</li></ul><pre>sudo docker service inspect --format &#39;{{range .Endpoint.VirtualIPs}}{{.Addr}}{{end}}&#39; wordpress-service-night<br>sudo docker service logs wordpress-service-night</pre><h4>Essential Vocabulary:</h4><ul><li><strong>WordPress: </strong>WordPress is a widely used open source content management system (CMS) for creating websites and blogs.</li><li><strong>Docker Swarm:</strong> Docker’s native clustering and orchestration solution for managing a cluster of Docker hosts.</li><li><strong>Global Service:</strong> A type of Docker Swarm service that ensures that exactly one task of the service is scheduled on each node in the Swarm.</li><li><strong>Node:</strong> An individual host machine that is part of the Docker Swarm cluster.</li><li><strong>Swarm Initiation:</strong> The process of initializing a Docker Swarm on a host, designating it as the Swarm manager.</li><li><strong>Worker Node:</strong> A node in the Docker Swarm cluster that runs application tasks, managed by the manager node.</li><li><strong>Manager Node: </strong>A node in the Docker Swarm cluster that coordinates and manages cluster operations. Manager nodes are responsible for service scheduling, worker node management, and decision-making within the cluster, such as scalability and fault recovery.</li><li><strong>Docker Swarm Visualizer:</strong> A tool that provides a real-time visual representation of the architecture of a Docker Swarm cluster, making it easy to understand services and nodes.</li><li><strong>Health Checks: </strong>is a periodic assessment to verify the status and proper functioning of a component or system.</li><li><strong>MySQL Service:</strong> A MySQL service refers to running a container based on the MySQL image within a containerization environment like Docker. MySQL is a widely used relational database management system.</li><li><strong>Volumes:</strong> In the context of Docker, volumes are a mechanism for persisting and sharing data between containers and the host system. T hey are crucial for ensuring data persistence in a MySQL service, ensuring that information remains intact even if the container is stopped or restarted.</li></ul><h4>Practical Guidelines:</h4><p>FOUNDATIONAL:</p><p>Using the CLI:</p><ol><li>Deploy a 3-node Docker Swarm cluster.</li><li>Create 2 networks. One for the frontend and another for the backend.</li><li>Create MySQL service</li></ol><p>Associated with the backend network</p><p>Only 1 replica</p><p>To make the database service resilient and its data persistent across container restarts, use Docker Volumes.</p><p>4. Create the WordPress service</p><ul><li>Associated with the frontend network</li><li>Should use port 80</li><li>Accessible from the browser</li><li>3 replicas</li><li>Associated with the MySQL service</li></ul><p><strong><em>Let’s start with this project:</em></strong></p><ol><li>Deploy a 3-node Docker Swarm cluster.</li></ol><p>We already did this a few hours ago in my other project so I’ll leave the link below: <a href="https://medium.com/@13jesusegui/visualizing-efficiency-mastering-docker-swarm-step-by-step-e7958412ec79">https://medium.com/@13jesusegui/visualizing-efficiency-mastering-docker-swarm-step-by-step-e7958412ec79</a></p><p>2. Create 2 networks. One for frontend and another for backend:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-HIS3PO7_wuTruX0sGDazQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ja1zo8p4bUScplQXSLmD-w.png" /></figure><p>3. Create MySQL service: Let’s review the networks we have and we can see that this is “<strong>backend_World” and “frontend_Hello”</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Kh77Qde2zj4GADR_gRHaAw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*80s-DfLrA7_Itkx2YgHChA.png" /></figure><p>Associated with the backend network</p><p>Only 1 replica</p><p>To make the database service resilient and its data persistent across container restarts, use Docker Volumes.</p><p>4. Create the WordPress service with these specifications</p><ul><li>Associated with the frontend network</li><li>Should use port 80</li><li>Accessible from the browser</li><li>3 replicas</li><li>Associated with the MySQL service</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*na6s1wPNTrroZT4mbYyk9g.png" /></figure><p>We should get an error because the ports are not configured correctly, the ports should be 80:80 and not 90:80, to correct this error we will delete that and create it again</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gmNfwpwMqgzrMzXr8kHAEQ.png" /></figure><p>We use rm followed by the service name</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/934/1*TFFU1cvcG57PMhMhxwxT5g.png" /></figure><p>Now we create it again but this time we use 80:80 using our IP address of the instance: <a href="http://3.145.36.93:8080/">http://3.145.36.93:8080/</a> and we will have access to our visualizer with our respective Admin, workers, and our new service.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cSijsvOhkJviuTUTXUs-0A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FnJBxwnNcsdEoO9kReWNBg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P4zggL_seEeiM4gFllcHBw.png" /></figure><p>With the first command, we will obtain the virtual IP address of the WordPress service in Docker Swarm, necessary to access the service. The second command shows us logs that provide details about the status and possible errors of the service, so we can monitor it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6I3fLqSsZJh5PCQbmXNZzQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zgzhs8-A4PlhSaLe4JO9XA.png" /></figure><p>Another project was completed!!!</p><h4>Summary and Recap:</h4><p>We deployed a 3-node Docker Swarm cluster, established networks to segment services, and deployed MySQL and WordPress. Despite some challenges with port configuration in WordPress, we achieved a successful deployment. We examined logs to enhance monitoring and issue resolution. This project reinforces the ability to efficiently manage infrastructure and services in containers.</p><h4>Connect with Me on Social Media:</h4><p>LinkeIn: <a href="http://www.linkedin.com/in/jesusegui">www.linkedin.com/in/jesusegui</a></p><p>Github: <a href="https://github.com/JesusEgui">https://github.com/JesusEgui</a></p><h4>ADVANCED: Coming Soon</h4><p>Do the Foundational, but instead, deploy it using Docker Stack.</p><h4>COMPLEX: Coming Soon</h4><p>To add an extra layer of security, replace the Environment Variables in your Yaml file with Docker secrets.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=946fed68eec1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Visualizing Efficiency: Mastering Docker Swarm -Step by Step :’)]]></title>
            <link>https://medium.com/@13jesusegui/visualizing-efficiency-mastering-docker-swarm-step-by-step-e7958412ec79?source=rss-5ad137ec7bb6------2</link>
            <guid isPermaLink="false">https://medium.com/p/e7958412ec79</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[tech]]></category>
            <category><![CDATA[technology]]></category>
            <dc:creator><![CDATA[Jesus Egui]]></dc:creator>
            <pubDate>Tue, 14 Nov 2023 02:51:31 GMT</pubDate>
            <atom:updated>2023-11-16T16:30:48.622Z</atom:updated>
            <content:encoded><![CDATA[<h3>Visualizing Efficiency: Mastering Docker Swarm -Step by Step :’)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/495/1*cjf84X3BNYm4E4jfJBx1mA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/928/1*sboNYVBU6ChhIibdbFl0kQ.png" /></figure><h4>Containers in Action: Navigating Challenges with Docker Swarm Visualizer</h4><p>Your company is new to using containers and has been having issues with containerized workloads failing for their global shipping application. The company is worried about additional potential data loss as they have no way to reschedule containers that are failing. The company has one week to update its infrastructure and leverage the use of Docker Swarm so that data can be restored for the containers that are no longer in a healthy state. Because they are not familiar with Docker Swarm, they will need a step-by-step guide on setting up a Swarm for their containerized workloads to assist with container orchestration.‌</p><p>The solution should include the use of a global service since the company’s global shipping application is having issues. Your Swarm should be able to launch the containers using a global service. Remember, a service is simply a group of containers of the same image that facilitates the scaling of applications. Your global shipping application will require the use of at least three networked hosts, which should be AWS EC2 Ubuntu 20.04 instances.</p><h4>Node Orchestration and Swarm Setup :</h4><p>Configure Docker Swarm on AWS EC2 instances by installing Docker, verifying the installation, changing hostnames, validating security groups, adding SSH keys, running test containers, creating the Swarm with one master and two worker nodes, deploying a global service for the shipping application, and confirming the Swarm’s healthy status. This step-by-step guide ensures a quick setup for container orchestration, addressing concerns of failing workloads in the global shipping application within a week.</p><h4>Crucial Terminology:</h4><ul><li><strong>Docker Swarm:</strong> Docker Swarm is a Docker orchestration platform that enables the management and scaling of distributed applications across multiple containers.</li><li><strong>Global Service:</strong> A type of service in Docker Swarm that ensures exactly one task of the service is scheduled on each node in the cluster.</li><li><strong>Node:</strong> A node is an individual machine that is part of a Docker Swarm cluster and runs containers.</li><li><strong>Swarm Initiation:</strong> The process of initializing a Docker Swarm on a host, designating it as the Swarm manager.</li><li><strong>Worker Node:</strong> A node in the Docker Swarm cluster that runs application tasks, managed by the manager node.</li><li><strong>Manager Node:</strong> A node in the Docker Swarm cluster that coordinates and manages cluster operations, including service scheduling and worker node management.</li><li><strong>Docker Swarm Visualizer:</strong> A tool that provides a real-time visual representation of the architecture of a Docker Swarm cluster, making it easy to understand services and nodes.</li><li><strong>Docker Daemon:</strong> The Docker daemon is a background process that manages the building, running, and distribution of Docker containers.</li></ul><p>This guide assumes minimal familiarity with Docker and provides a comprehensive step-by-step approach to configuring Docker Swarm for the company’s global shipping application.</p><p>Command Uses:</p><p><strong>Step 1:</strong> Installing Docker on all hosts:</p><pre>curl -fsSL https://get.docker.com -o get-docker.sh <br>sh get-docker.sh</pre><ul><li>Downloads and installs Docker on the current host using the script provided by Docker.</li></ul><p><strong>Step 2:</strong> SSH Configuration File Setup:</p><ul><li>You configured the SSH configuration file (~/.ssh/config) with information such as the user (User), hostname (Hostname), and the private key path (IdentityFile).</li></ul><p><strong>Step 3:</strong> Creating Additional Instances and Configuration:</p><ul><li>You created two additional instances named “Node2” and “Node3.”</li><li>Configured SSH credentials and the hostname for “AdminNode1.”</li></ul><p><strong>Step 4:</strong> Initializing the Swarm:</p><pre>sudo docker swarm init</pre><ul><li>Initializes a node as a manager in the Swarm. Provides a token that will be used to join worker nodes to the Swarm.</li></ul><p>Step 5: Installing Docker on Worker Nodes (Node2 and Node3):</p><pre>sudo apt update<br>sudo apt install -y docker.io</pre><ul><li>Updates the package list and then installs Docker on the worker nodes.</li></ul><p><strong>Step 6:</strong> Setting Up the Swarm Visualizer:</p><pre>sudo git clone https://github.com/dockersamples/docker-swarm-visualizer<br>sudo apt update<br>sudo apt install -y python3-pip<br>sudo pip3 install docker-compose</pre><ul><li>Clones the Swarm visualizer repository, updates the package list, installs pip (Python package manager), and then installs docker-compose.</li></ul><p><strong>Step 7: </strong>Running the Swarm Visualizer:</p><pre>sudo docker-compose up -d</pre><ul><li>Uses docker-compose to bring up the Swarm visualizer service in daemon mode (-d).</li></ul><p><strong>Step 8:</strong> Creating the “SuperViz” Service for the Swarm Visualizer:</p><pre>sudo docker service create \<br>  --name=SuperViz \<br>  --publish=7091:8080/tcp \<br>  --constraint=node.role==manager \<br>  --mount=type=bind,src=/var/run/docker.sock,dst=/var/run/docker.sock \<br>  dockersamples/visualizer</pre><ul><li>Creates a service named “SuperViz” using the Swarm visualizer image. Publishes port 7091 on the host, restricts the service to the manager node and mounts the Docker socket to access the API.</li></ul><p><strong>FOUNDATIONAL:</strong></p><p>As the junior engineer, you are responsible for only configuring Docker Swarm and providing your team with a step-by-step guide to setting up the Swarm. You should assume that there are new team members who may not have Docker installed on their devices. Your swarm creation should include the following steps via your remote SSH terminal in VSCode.</p><h4>Guidelines:</h4><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><em>Let’s start with this project:</em></strong></p><p>We have created an instance with SSH access and configured our security group so as not to have access problems during the project.</p><ul><li>Installing docker on all hosts</li></ul><pre>curl -fsSL https://get.docker.com -o get-docker.sh <br>sh get-docker.sh</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6Z9X0IRIeoi4dVS7rNpcZw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KDncWH4_1VcIeybJvx1aDQ.png" /></figure><p>In the user folders, we must choose our user, choose the .ssh option, and create a “config” folder or whatever name we want to add to it, it would look something like this in my case: “C:\Users\13jes\.ssh\config “ highlighting the config that we have created within the .ssh directory</p><p>To start our instance with docker from VisualCode we need the PATH where the Keypair that was used when we created the instance is located, in this case, it would be “Docker. pem” Without this we will not be able to start the docker<br>We open our “config” file in VisualCode we will look for the user which is defined as “ubuntu” automatically because the AMI that I chose is from Ubuntu, the Hostname would be our Adrees IP of the instance and the Host can be any name we want</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CCaA-QDTuftXlKkqWEGHLA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*b4ANFpwnNVJKflYC1f9YhQ.png" /></figure><p>Now I must create the other two instances and identify them as nodes unlike the main one, (Node2 and Node3) they would be the workers using the same Keypair and the same security group</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aF5ljI1uV8RmsOw-5c9v3A.png" /></figure><p>I am adding the credentials to my <strong>“nodes2 and node3”</strong> and the hostname must be <strong>AdminNode1</strong></p><p>We will add our encrypted information from our keypair (Docker. pem)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/502/1*Dhy5EF8-f-zPeSberyugwA.png" /></figure><p>Now we will create a configuration file called <strong>“config”</strong> for the private IPs of our instances and we will add a new PATH but we will use the same template as in the first <strong>config file</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/501/1*2pVgqtVpGCRf27-zbwGUaA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qtlnuhm4Xe06hMtuxFid6w.png" /></figure><p>We use the SSH command to enter our Nodes called <strong>“Node2” </strong>and<strong> “Node3”</strong> While we also have our admin open you can see that the nodes are in SSH terminals while our admin will always be in “bash”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/737/1*0BH4P-q-n3V5y4hhJ4Pbow.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/737/1*_dPDJllTdGqpWvUTEwJohA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/1*kN1insoMIktdIzHkipVU-Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LsMIqJUpJHpxgrP9MGFT0w.png" /><figcaption><strong>AdminNode1</strong></figcaption></figure><p>To create our swarm we must start it in our Node manager and from there take the token that will be created to be able to use it in the other nodes that we created and they can be joined using the command</p><pre>&quot;sudo docker swarm join --token &quot;our token&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qz648SrQErr2p78t94Jz7g.png" /><figcaption>Node Manager</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4wSXwNHsNKJ3FRRpxvpglQ.png" /><figcaption>Node2</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PgkqO8vgdApHK-06-2XmlQ.png" /><figcaption>Node3</figcaption></figure><p>Then I ran these two commands on both nodes (node2 and node3) and thus had docker installed and updated the packages:</p><pre>sudo apt update<br>sudo apt install -y docker.io</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XraMWH2iA_WAfimlhto5kg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Rgrk8Tu-SrNw0cOGVUc__A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AO2O81L9hAV8klh-4sUP7w.png" /></figure><p>We are almost finished</p><p>For this step, I need to grab a repository from GitHub that contains an image. A visualizer is used to graphically display information about containers, such as their state, resources used, and the general architecture of an application.</p><p>sudo git clone <a href="https://github.com/dockersamples/docker-swarm-visualizer">https://github.com/dockersamples/docker-swarm-visualizer</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RnfIHD9K8oi4hfTqIkS0gg.png" /></figure><p>In this step, we need to update the package list, install pip (Python package manager), and then install docker-compose.</p><pre>sudo apt update<br>sudo apt install -y python3-pip<br>sudo pip3 install docker-compose</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Z2688fiKN33BZeSWoKqqAg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fCzmkBnFtgD1M3U5Jxh6AQ.png" /></figure><ul><li>Utilize <strong>docker-compose up -d</strong> to launch the Swarm Visualizer service in daemon mode in the right directory</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*U0L5FTm7HmFMeiSkq_K2yQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZSeKHdy_IAUpkCWFNzhJeQ.png" /></figure><pre>sudo docker-compose up -d</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jEk2gJLFkKBqyiekwgSe_w.png" /></figure><p>This command establishes a service named “SuperViz,” using the “dockersamples/visualizer” image. This service is restricted to operate exclusively on nodes with the “manager” role in the Swarm cluster. Additionally, it publishes port 8080 from the container to port 7091TCP on the host and mounts the Docker socket to allow the container to access the Docker state on the host.</p><p>This configuration must be the one we have in the security group, otherwise when we run our IP address it will not work and we simply will not find anything, because we will not have access.</p><p>We will create several visualizers to be able to see how they look on our page.</p><pre>sudo docker service create \<br>  --name=SuperViz \<br>  --publish=7091:8080/tcp \<br>  --constraint=node.role==manager \<br>  --mount=type=bind,src=/var/run/docker.sock,dst=/var/run/docker.sock \<br>  dockersamples/visualizer</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EUW25M02Y2UyDclPUHX57Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kpmDLtL3xpsNd3ulLotNQA.png" /></figure><p>We go to our instance, we take our IP Address, we copy and paste it in our browser like this “<a href="http://ip/">http://IP</a> ADDRESS:8088/” or the port we want from any of our visualizer</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iLjlLXo5ZRCvIYA9rKyTug.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/928/1*sboNYVBU6ChhIibdbFl0kQ.png" /></figure><p>Perfect, with this we conclude our Docker-Swarm and visualizers project successfully</p><h4>Summary and Conclusions:</h4><p>The project has been completed, achieving an effective configuration of Docker Swarm and container visualization through Swarm Visualizer. The infrastructure is ready to address container failure issues and provides efficient orchestration for the company’s global shipping application</p><h4>Text me if you want to do this project or if you have any problems with it, I’ll be happy to help you.</h4><h4>Connect with Me on Social Media:</h4><p>Github: <a href="https://github.com/JesusEgui">https://github.com/JesusEgui</a></p><p>LinkeIn: <a href="http://www.linkedin.com/in/jesusegui">www.linkedin.com/in/jesusegui</a></p><p><strong>ADVANCED: Comin soon</strong></p><p>As the lead engineer, you’ve reviewed the Swarm configuration and you are now ready to deploy your services on the Swarm. Consider the following steps as you deploy the service:</p><ul><li>Using only the CLI, SSH into the master node host and run the command to create your service using an Official image of your choice out of the following company-preferred images:</li></ul><ol><li>nginx</li><li>apache</li><li>redis</li><li>python/alpine</li><li>Ubuntu</li></ol><ul><li>Initially only launch 1 replica.</li><li>Run the commands to verify the service has been created and is running</li><li>Since it is a global application that needs to scale, Using the CLI, run the necessary commands to scale the service to 3 replicas.</li><li>Verify that the service has scaled</li></ul><p><strong>COMPLEX: Coming soon</strong></p><p>As the senior engineer, you are looking to make this deployment as seamless as possible, and you’d like to use a more complex approach. Consider the steps for the foundational and advanced sections. Note: You will have to do some research to ensure you have all files required for this deployment.</p><p>Deploy your application via a Stack to your Swarm</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e7958412ec79" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Optimizing Development with Jenkins and Docker]]></title>
            <link>https://medium.com/@13jesusegui/optimizing-development-with-jenkins-and-docker-0e4a488deeae?source=rss-5ad137ec7bb6------2</link>
            <guid isPermaLink="false">https://medium.com/p/0e4a488deeae</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[jenkins]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[tech]]></category>
            <dc:creator><![CDATA[Jesus Egui]]></dc:creator>
            <pubDate>Fri, 10 Nov 2023 17:44:20 GMT</pubDate>
            <atom:updated>2023-11-10T17:44:20.822Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/495/1*cjf84X3BNYm4E4jfJBx1mA.png" /></figure><h4><em>Real-World-Case-Scenario :</em></h4><p>Level Up Solutions, a technology solutions provider, is striving to enhance its software development and deployment processes. They are adopting Docker and Jenkins to create a robust, scalable Continuous Integration and Continuous Deployment (CI/CD) pipeline, emphasizing persistent volumes. This initiative aims to boost productivity by streamlining Jenkins configuration, ensuring consistent and reliable operations through Docker containers, improving scalability, maintaining crucial data with Docker volumes, reducing infrastructure costs, and enabling streamlined version control and updates. By integrating Docker and Jenkins, Level Up Solutions seeks to optimize its software development and deployment procedures, realizing cost savings and ensuring consistency and reliability.</p><h4><strong>Process of our project:</strong></h4><p>In this process, we’ll start by pulling the Jenkins LTS image from Docker Hub. Following that, we’ll set up a Docker volume to ensure persistence of Jenkins data. Next, we’ll run a container, mapping the necessary ports and utilizing the created volume. We’ll retrieve the Admin password, log in, and establish a new user account. To validate the persistence of data, we’ll launch another Jenkins container using the same volume and confirm the successful login with the newly created user, ensuring that data continuity is maintained across container instances. This series of steps aims to illustrate the setup and verification of a Jenkins environment with persistent data using Docker containers.</p><p>Commands Uses:</p><ul><li>Pull the Jenkins LTS image from Docker Hub:</li></ul><pre>docker volume create 1My_VJenkins</pre><ul><li>Create a Docker volume to persist Jenkins data:</li></ul><pre>docker volume create 1My_VJenkins</pre><ul><li>Start the Jenkins container with port mapping, volume mounting, and a specific name:</li></ul><pre>sudo docker run -d -p 9090:8080 -p 51000:50000 -v<br>1My_VJenkins:/var/ --name 1The_Jenkins<br>jenkins/jenkins:lts</pre><ul><li>Retrieve the initial Admin password from the container logs:</li></ul><pre>docker logs 1The_Jenkins</pre><ul><li>Retrieve the Admin password from the container (optional):</li></ul><pre>sudo docker exec 1The_Jenkins cat /var/jenkins_home/secrets/initialAdminPassword</pre><ul><li>Stop and remove the initial Jenkins container:</li></ul><pre>docker stop 1The_Jenkins docker rm 1The_Jenkins</pre><ul><li>Start a new Jenkins container with the same volume:</li></ul><pre>sudo docker run -d -p 9090:8080 -p 51000:50000 -v 1My_VJenkins:/var/jenkins_home --name 1The_Jenkins jenkins/jenkins:lts</pre><h4><em>Essential Definitions:</em></h4><ul><li><strong>Jenkins</strong> is a self-contained, open-source automation server designed for automating various tasks associated with building, testing, and delivering or deploying software. It offers flexibility in installation, allowing deployment through native system packages, Docker, or as a standalone application on any machine equipped with a Java Runtime Environment (JRE).</li><li><strong>Amazon Web Services (AWS)</strong>: AWS is Amazon’s cloud services platform that provides a wide range of online services and resources for hosting applications and storing data in a scalable and cost-effective manner.</li><li><strong>Docker:</strong> Docker is a container technology that allows you to package applications and their dependencies in isolated and portable environments, simplifying consistent deployment across various platforms.</li><li><strong>Ubuntu:</strong> Ubuntu is a widely used Linux-based operating system known for its stability and versatility. It is commonly chosen as the base operating system for Docker containers due to its user-friendliness and compatibility.</li></ul><h4><em>Valuable Tips:</em></h4><ul><li>You can use the configurations you want, but in my case, I am using an IAM user with certain permissions to guarantee the security of my AWS account</li></ul><p><strong>FOUNDATIONAL:</strong></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>Note: You will have to do some research on Jenkins. The best place to start is with the official documentation, but you may also have to do a wider search for some answers: <a href="https://www.jenkins.io/doc/">Jenkins User Documentation</a></p><p><strong><em>Let’s start with this project:</em></strong></p><h4>Step 1: Pull the Jenkins LTS image from Docker Hub.</h4><pre>docker pull jenkins/jenkins:lts</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/966/1*YGfTi-1xXE1sPq-fQTPILA.png" /></figure><h4>Step 2: Create a Docker volume for Jenkins to persist its data.</h4><pre>docker volume create 1My_VJenkins</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/740/1*foon3Jv6lbYypwuGjVkWXA.png" /></figure><h4><strong>3. Run the container with the volume and correct port mapped to the container.</strong></h4><pre>sudo docker run -d -p 9090:8080 -p 51000:50000 -v 1My_VJenkins:/var/jenkins_home --name 1The_Jenkins jenkins/jenkins:lts</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5uXKIAzfEh5i27z2t-Vtvw.png" /></figure><ul><li>-d: Runs the container in the background.</li><li>-p 8080:8080: Maps port 8080 from the host to port 8080 on the container.</li><li>-p 50000:50000: Maps port 50000 from the host to port 50000 on the container.</li><li>-v My_VJenkins:/var/jenkins_home: Mounts the created volume to persist Jenkins data.</li><li>--name 1The_Jenkins: Assigns the name &quot;1The_Jenkins&quot; to the container for easy reference.</li><li>jenkins/jenkins:lts: Specifies the Jenkins LTS image.</li></ul><h3>Step 4: Retrieve the Admin password.</h3><h4>Get the initial admin password from the container logs:</h4><pre>docker logs 1The_Jenkins</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VygpqPxx4Ebg5YBe1A65Qg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*H7YCmoP0AeQxubQtYp_1xQ.png" /></figure><h4>Step 5: Login and create a new user.</h4><ol><li>Open your web browser and go to <a href="http://localhost:8080/">http://localhost:9090</a>, in this case, I’m working with AWS which means that I have to get my IP address from my instance and insert it in as the “localhost”</li><li>Enter the initial administrator password obtained from the logs.</li><li>Follow the instructions to complete the setup.</li><li>Create a new user when prompted.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7A-kzcWsqvUioM0obplmlg.png" /></figure><h3>Step 5:Get the Administrator Password:</h3><p>Get the initial administrator password from the container logs, with this command we will obtain the password:</p><pre>sudo docker run -d -p 9090:8080 -p 51000:50000 -v 1My_VJenkins:/var/jenkins_home --name 1The_Jenkins jenkins/jenkins:lts</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AHVuZmbKuvPCIwS4AIAdgg.png" /></figure><p>We must use it to enter the Jenkins page</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_ihZYl_ZFVBomfqmHlgxuw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R4xsKWWoZlYzVRNLAJGGAw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ipgWhhspcYnUkcvjijTkzg.png" /></figure><p><strong>Create first admin user and the instance configuration:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/990/1*Qk8EMMRJcDHaMHO9czRqvg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/992/1*2aGSMk51FfI_xKMwAoowZg.png" /></figure><h4>Step 6: Launch a new Jenkins container using the same volume and verify that the data has persisted by logging in as the newly created user.</h4><pre>docker stop 1The_Jenkins<br>docker rm 1The_Jenkins<br>sudo docker run -d -p 9090:8080 -p 51000:50000 -v 1My_VJenkins:/var/jenkins_home --name 1The_Jenkins jenkins/jenkins:lts</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KmeXHuNTZXjKbPqbuI0qGg.png" /></figure><p><strong>Now we must test our IP address with our port 8080 again and try to access the page with our information</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MQSUtjvmvDppyV9-sdJMUg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EzRehSAZ0JvKn0u6PLlklQ.png" /></figure><p><strong>Ready, it worked correctly, delete everything and rest. :)</strong></p><p><strong>Note: it’s 1 AM</strong></p><h4>Connect with Me on Social Media.</h4><p><strong>Github: </strong><a href="https://github.com/JesusEgui"><strong>https://github.com/JesusEgui</strong></a></p><p><strong>LinkeIn: </strong><a href="http://www.linkedin.com/in/jesusegui"><strong>www.linkedin.com/in/jesusegui</strong></a></p><h4>Conclusion:</h4><p>In conclusion, integrating Jenkins and Docker at Level Up Solutions has optimized their development processes, enhancing efficiency and scalability. The use of persistent volumes, foundational steps like pulling the Jenkins image, and creating Docker volumes has established a cost-effective and reliable CI/CD pipeline. This successful combination showcases the effectiveness of Jenkins and Docker in streamlining software workflows.</p><p><strong>ADVANCED: coming soon</strong></p><p>Instead, use Docker Compose to do the steps in the Foundational.</p><p><strong>COMPLEX</strong>: <strong>coming soon</strong></p><ol><li>Create a Dockefile that specifies how your Jenkins image should be built. Include the necessary commands within your Dockerfile.</li><li>Create your image from the Dockerfile created in Step 1.</li><li>Create a Docker volume for Jenkins to persist data.</li><li>Map to the correct port.</li><li>Retrieve the Admin password.</li><li>Login and create a new user.</li><li>Remove the newly created container and its associated volume (be sure to think of the image created as well). Note: Think about docker volumes that will sometimes persist after the container is removed to ensure this step is executed successfully.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0e4a488deeae" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Maximizing Web App Efficiency: A Docker Deployment Guide]]></title>
            <link>https://medium.com/@13jesusegui/maximizing-web-app-efficiency-a-docker-deployment-guide-a88abbb73684?source=rss-5ad137ec7bb6------2</link>
            <guid isPermaLink="false">https://medium.com/p/a88abbb73684</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[tech]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[cloud]]></category>
            <category><![CDATA[docker]]></category>
            <dc:creator><![CDATA[Jesus Egui]]></dc:creator>
            <pubDate>Wed, 08 Nov 2023 20:35:50 GMT</pubDate>
            <atom:updated>2023-11-08T20:35:50.153Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/495/1*cjf84X3BNYm4E4jfJBx1mA.png" /></figure><h4><em>Real-Life Application:</em></h4><p>Level Up Solutions, a tech company offering web solutions, has adopted Docker for streamlined web application deployment. Docker ensures consistency, portability, and isolation while simplifying migrations between different environments. It also enhances resource management and reproducibility, ultimately leading to more efficient and reliable web application deployments, and improving their overall development and deployment processes.</p><h4><em>Fundamental Project Elements:</em></h4><p>1. <strong>AWS (Amazon Web Services):</strong> AWS is Amazon’s cloud services platform that provides a wide range of online services and resources for hosting applications and storing data in a scalable and cost-effective manner.</p><p>2.<strong> Docker:</strong> Docker is a container technology that allows you to package applications and their dependencies in isolated and portable environments, simplifying consistent deployment across various platforms.</p><p>3. <strong>Ubuntu:</strong> Ubuntu is a widely used Linux-based operating system known for its stability and versatility. It is commonly chosen as the base operating system for Docker containers due to its user-friendliness and compatibility.</p><h4><em>Crucial Terminology:</em></h4><ul><li>docker pull ubuntu: Downloads Ubuntu image from Docker Hub.</li><li>sudo docker run -d -p 80:80 --name My_Docker_Project -it ubuntu /bin/bash: Runs a detached Ubuntu container with an interactive terminal.</li><li>sudo docker exec -it My_Docker_Project bash: Starts an interactive shell within the container.</li><li>apt update and apt upgrade -y: Update and upgrade packages.</li><li>apt install apache2 -y: Install Apache2 web server.</li><li>sudo docker exec -it My_Docker_Project bash -c &#39;... &gt; /var/www/html/index.html&#39;: Create and add a custom webpage.</li></ul><h4>Guidelines (FOUNDATION Process):</h4><ol><li>Set up an AWS EC2 instance, ensuring Docker is installed.</li><li>Run a detached Docker container with an Ubuntu image on port 80.</li><li>Install Apache2 within the Ubuntu container.</li><li>Add a custom webpage.</li><li>Verify web server access from a browser.</li></ol><p><strong>FOUNDATION:</strong></p><p>We’re going to set up the project, and here’s what we’ll do. First, we need an AWS EC2 instance with specific requirements. We’ll choose an Amazon Machine Image (AMI), like Ubuntu, and make sure it’s a minimum of t2.micro. To allow remote access and let our colleagues see the webpage, we’ll set up inbound rules for SSH and HTTP from our IP addresses and our colleagues’ IPs.</p><p>Step 1: Before we proceed, we’ll confirm that Docker is installed on our system. Depending on the Ubuntu image we choose, we might need to install additional tools that aren’t included by default.</p><p>Now, let’s move on to running a Docker container in detached mode with an Ubuntu image on port 80. We’ll download the Ubuntu image if we haven’t already and then run a Docker container with port 80 mapped to the container’s port. This will be our platform for hosting our webpage. We’ll also ensure any necessary software or dependencies are installed within the container to run our web application.</p><p>In a nutshell, we’re configuring an AWS EC2 instance, installing Docker, and launching a detached Ubuntu container with port 80 mapping. This setup will let us work on and display the webpage we’re planning to create. We’ll also manage the security group settings for our EC2 instance to allow SSH and HTTP access as needed.</p><pre>docker pull ubuntu</pre><pre>sudo docker run -d -p 80:80 --name My_Docker_Project -it ubuntu /bin/bash</pre><p>1. `docker pull ubuntu`: Downloads the Ubuntu image to our local system from Docker Hub.</p><p>2. `sudo docker run -d -p 80:80 — name My_Docker_Project -it ubuntu /bin/bash`: Runs an Ubuntu container in the background, maps port 80, names it “My_Docker_Project,” and opens an interactive command-line terminal within the container.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IDGEhWSzRnh7yxBgJf24LQ.png" /></figure><p>However, in the last step, I mentioned that the container will stop, which is a normal behavior unless the main command has a process running in the background. If you want the container to keep running and not stop, you can use the following command:</p><pre>sudo docker run -d -p 80:80 --name My_Docker_Project -it ubuntu /bin/bash</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cO_WvciwbQi0G-2HdBcITg.png" /></figure><p>Step2. Using BASH install Apache2 in the Ubuntu container.</p><p>Start an interactive shell within the container:</p><pre>sudo docker exec -it My_Docker_Project bash</pre><pre><br>apt update<br>apt upgrade -y<br></pre><p>Update the package repository information using apt update to ensure we have the latest data on available packages.</p><p>Use apt upgrade -y to upgrade installed packages to their latest versions, enhancing the container&#39;s security and performance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FA9TwfNasWffy_EYP0MLVQ.png" /></figure><p>Step 3: Install Apache2 in the Ubuntu container:<br>Once again, using the BASH shell, you can install Apache2 within the container.</p><p>In short, apt install apache2 -y installs the Apache2 web server on an Ubuntu system, automatically accepting any prompts during installation.</p><pre>apt install apache2 -y</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Mey8FVa33kyU-kKxsCG-nA.png" /></figure><p>Step 4: Add a Custom web page.</p><p>Inside the container, we will create a custom webpage and place it in the Apache document directory using the following commands:</p><pre>sudo docker exec -it My_Docker_Project bash -c &#39;echo &quot;&lt;html&gt;&lt;body&gt;&lt;h1&gt;Welcome to Super Docker&lt;/h1&gt;&lt;img src=&#39;https://www.gameinformer.com/sites/default/files/styles/full/public/2023/09/27/03374e4d/supermariobroswonder_scrn_01.jpg&#39;&gt;&lt;/body&gt;&lt;/html&gt;&quot; &gt; /var/www/html/index.html&#39;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R8lVbbREL-OLAVYO7XSByw.png" /></figure><p>Step 5: Verify you can reach the web server from your browser.</p><p>Now we must go to our instance, take the IP Address and paste it into our browser:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GjCN_Ir-v-loxtvWmN6OtA.png" /></figure><p>Now we can see the image and the title that we added, everything turned out perfect</p><h4>Conclusion:</h4><p>This project’s core elements involve setting up an AWS EC2 instance, running a Docker container with Ubuntu, installing Apache2, adding a custom webpage, and verifying web server access. These steps enhance web application efficiency, with Docker serving as a key technology.</p><p>We leveraged Docker to streamline web application deployment effectively. Docker offers benefits like consistency, portability, and isolation, simplifying environment migrations and enhancing resource management. This technology has allowed us to improve the efficiency and reliability of our web application deployments, ensuring smooth and secure operation.</p><h4>Post-scripts:</h4><p>In conclusion, this Docker deployment guide, focusing on web application efficiency, demonstrates the power of containerization in the real world. By utilizing AWS, Docker, and Ubuntu, Level Up Solutions has streamlined its deployment processes, ensuring consistency, portability, and resource management. These fundamental project elements and key commands offer a practical approach to efficient web app deployment, which can benefit various development and deployment scenarios. Docker, as a transformative technology, proves its worth in modern web development.</p><h4>Connect with Me on Social Media:</h4><p>Github: <a href="https://github.com/JesusEgui">https://github.com/JesusEgui</a></p><p>LinkeIn: <a href="http://www.linkedin.com/in/jesusegui">www.linkedin.com/in/jesusegui</a></p><p><strong>ADVANCED: coming soon</strong></p><p>1. Push to Docker Hub.</p><p>2. Pull your new image and run on a different port than 80 while still mapping to 80 on the container. Verify you can reach the web server using the updated port.</p><p><strong>COMPLEX: coming soon</strong></p><p>1Create a new Docker network.</p><p>2. Run the container using the new network.</p><p>3. Use the CLI to verify the container uses the new network, not the bridge network. There’s more than one way to accomplish this. Research and use the option you prefer.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a88abbb73684" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Python File Explorer: Generation and Nesting of File Dictionaries]]></title>
            <link>https://medium.com/@13jesusegui/python-file-explorer-generation-and-nesting-of-file-dictionaries-2c486276f8d6?source=rss-5ad137ec7bb6------2</link>
            <guid isPermaLink="false">https://medium.com/p/2c486276f8d6</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[cloud]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[cloud-services]]></category>
            <category><![CDATA[tech]]></category>
            <dc:creator><![CDATA[Jesus Egui]]></dc:creator>
            <pubDate>Tue, 26 Sep 2023 05:13:33 GMT</pubDate>
            <atom:updated>2023-09-26T05:13:33.205Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/864/1*BRLXIZLEz-LtiyS6il2XKA.png" /></figure><h4>Project Synopsis: File Information Extraction Script for Multiple Machines</h4><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 of the files in the current working directory and stores it in a list of dictionaries.</em></p><p><strong>FOUNDATIONAL‌</strong></p><p>Create a script that generates a list of dictionaries about files in the working directory. Then print the list.</p><p>Push your code to GitHub and include the link in your write-up.‌</p><p><strong>ADVANCED:</strong></p><p>Modify the script into a function such that any path can be passed as a parameter.</p><p>This parameter should be optional and should default to a working directory when the variable is not passed.</p><p>The function should then create a list of dictionaries about files from that path. The function should also return information on files nested in folders (recursive).‌</p><p><strong>COMPLEX (Very Tricky)</strong></p><p>Modify the function to display recursive file information as dictionary of dictionaries.</p><p><strong>Commands used:</strong></p><ul><li>os. listdir(path): Retrieves the list of files and folders in a directory.</li><li>os.path.join(path, filename): Combines the directory and filename to get the full path of a file.</li><li>os.path.isfile(file_path): Checks if an item is a file.</li><li>os.path.getsize(file_path): Retrieves the size of a file in bytes.</li><li>os.walk(path): Recursively traverses a directory and its subdirectories.</li><li>str.split(os.path.sep): Splits a string into segments using the operating system&#39;s directory separator.</li><li>dict.setdefault(key, default): Sets a default value in a dictionary if the key doesn&#39;t exist.</li><li>instance (object, class): Checks if an object is an instance of a specific class.</li><li>Usage of for loops and recursion to iterate and navigate through nested dictionaries.</li></ul><p><strong>Why Python and Pycharm:</strong></p><p>Python: A versatile, high-level, and readable programming language with a vibrant community and applications in various fields.</p><p>PyCharm: A Python-specific Integrated Development Environment (IDE) providing advanced development, debugging, and productivity tools for Python programmers.</p><h4>Fundamental Project Requirements:</h4><ul><li>Basic Python Proficiency: A foundational understanding of Python programming.</li><li>PyCharm Installed</li><li>Python Environment Setup: Have a Python interpreter installed and configured.</li><li>Library Dependencies: Identify and install any Python libraries or packages required for your project.</li></ul><p><strong>Embarking on Our Mini-Project!!!</strong></p><p><strong>FOUNDATIONAL‌</strong></p><ul><li>Task 1: Create a Python script and import the os module.</li><li>Task 2: Generate a list of dictionaries containing file information from the current working directory.</li><li>Task 3: Print the list of file information.</li><li>Task 4: Push your script to GitHub.</li><li>Task 5: Include the GitHub repository link in your documentation.</li></ul><p>Task 1: Create a Python script and import the os module.</p><pre>pythonCopy code</pre><pre>import os</pre><p>In this part, the script imports the os module, which is necessary for performing operations related to the operating system, such as obtaining file and directory information.</p><p>Task 2: Generate a list of dictionaries containing file information from the current working directory.</p><pre>pythonCopy code</pre><pre>def list_files_in_directory(path=&#39;.&#39;):<br>    files_list = os.listdir(path)<br>    file_info_list = []</pre><pre>    for filename in files_list:<br>        file_path = os.path.join(path, filename)<br>        if os.path.isfile(file_path):<br>            file_info = {<br>                &quot;name&quot;: filename,<br>                &quot;size&quot;: os.path.getsize(file_path)<br>            }<br>            file_info_list.append(file_info)</pre><pre>    return file_info_list</pre><p>This is the core of the script. The list_files_in_directory function takes a directory (or the current directory by default) and creates a list of dictionaries containing information about the files in that directory. For each file in the directory, it checks if it&#39;s a file (not a directory) using os.path.isfile(). If it&#39;s a file, it retrieves its name and size and creates a dictionary with this data. Then, the dictionary is added to the file_info_list.</p><p>Task 3: Print the list of file information.</p><pre>pythonCopy code</pre><pre>file_list = list_files_in_directory()<br>print(&quot;NIVEL FOUNDATIONAL:&quot;)<br>print(file_list)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/911/1*B6QwU2Xj4TbS6N-X0a3hAQ.png" /></figure><p>Then mi run it:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_rd5DadcmJsgoRARrJvKcQ.png" /></figure><p>Task 4: Repository on GitHub created</p><p>Task 5: You can find the Github repository <a href="https://github.com/JesusEgui/02-Python-Projects-/blob/main/0001-Fundamentals.py">here</a></p><p><strong>ADVANCED:</strong></p><ul><li>Task 1: Define a function list_files_recursive(path=&#39;.&#39;) with an optional parameter path defaulting to the current working directory.</li><li>Task 2: Initialize a list file_info_list to store file information within the function.</li><li>Task 3: Use os.walk(path) to recursively gather file information and add it to file_info_list.</li><li>Task 4: Return file_info_list at the end of the function.</li><li>Task 5: Test the function with different paths, including the option to leave it blank to use the current working directory.</li></ul><p>Task 1: Define a function list_files_recursive(path=’.’) with an optional parameter path defaulting to the current working directory.</p><p>The script defines a function called list_files_recursive, which accepts an optional parameter path. If path is not provided, it defaults to the current working directory due to the path=&#39;.&#39; default argument in the function definition.</p><pre>pythonCopy code</pre><pre>def list_files_recursive(path=&#39;.&#39;):<br>    # ...</pre><p>Task 2: Initialize a list file_info_list to store file information within the function.</p><p>In this script, a dictionary named file_info_dict is initialized to store file information within the function. This dictionary will hold a hierarchical structure to represent the directory tree and file information.</p><pre>pythonCopy code</pre><pre>file_info_dict = {}</pre><p>Task 3: Use os.walk(path) to recursively gather file information and add it to file_info_list.</p><p>The script utilizes os.walk(path) to recursively traverse the directory and its subdirectories. It then adds file information to the file_info_dict as it iterates through the directory structure.</p><pre>pythonCopy code</pre><pre>for root, dirs, files in os.walk(path):<br>    current_dict = file_info_dict<br>    for dir_name in root.split(os.path.sep):<br>        current_dict = current_dict.setdefault(dir_name, {})<br>    <br>    for filename in files:<br>        file_path = os.path.join(root, filename)<br>        current_dict[filename] = {<br>            &quot;name&quot;: filename,<br>            &quot;size&quot;: os.path.getsize(file_path)<br>        }</pre><p>Task 4: Return file_info_list at the end of the function.</p><p>The script returns the file_info_dict at the end of the function, which contains the recursively gathered file information in a hierarchical structure.</p><pre>pythonCopy code</pre><pre>return file_info_dict</pre><p>Task 5: Test the function with different paths, including the option to leave it blank to use the current working directory.</p><p>The script calls the list_files_recursive function without providing a path, which defaults to using the current working directory. You can also call this function with different directory paths to gather file information recursively for those directories.</p><pre>pythonCopy code</pre><pre>file_dict = list_files_recursive()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/751/1*oUWEtGjwfdfIDbiiAM2MmQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Az5bwySsE5dfnHtF_MCLPg.png" /></figure><p>You can find the Github repository <a href="https://github.com/JesusEgui/02-Python-Projects-/edit/main/001-Advanced.py">here</a></p><p>COMPLEX:</p><ul><li>Task 1: Define the function list_files_recursive_dict(path=&#39;.&#39;) with an optional parameter path that defaults to the current working directory.</li><li>Task 2: Initialize an empty dictionary called file_info_dict.</li><li>Task 3: Use os.walk(path) to recursively gather file information and create a dictionary of dictionaries to represent the directory structure. Append these dictionaries to file_info_dict.</li><li>Task 4: Return file_info_dict, which will contain nested file information as a dictionary of dictionaries.</li><li>Task 5: Test the function with different paths, including the option to use the current working directory.</li></ul><pre>import os<br><br># Function to create a hierarchical data structure of files and directories<br>def list_files_recursive(path=&#39;.&#39;):<br>    file_info_dict = {}<br>    for root, dirs, files in os.walk(path):<br>        current_dict = file_info_dict<br>        for dir_name in root.split(os.path.sep):<br>            current_dict = current_dict.setdefault(dir_name, {})<br>        for filename in files:<br>            file_path = os.path.join(root, filename)<br>            current_dict[filename] = {&quot;name&quot;: filename, &quot;size&quot;: os.path.getsize(file_path)}<br>    return file_info_dict<br><br># Function to display the hierarchical data structure in a readable format<br>def display_recursive_info_as_dict(file_info_dict, level=0):<br>    indentation = &quot;  &quot; * level<br>    for key, value in file_info_dict.items():<br>        if isinstance(value, dict):<br>            print(f&quot;{indentation}{key}/&quot;)<br>            display_recursive_info_as_dict(value, level + 1)<br>        else:<br>            print(f&quot;{indentation}{key}: {value[&#39;size&#39;]} bytes&quot;)</pre><p>You can use these functions as follows:</p><pre>pythonCopy code</pre><pre># Get the hierarchical data structure of files and directories for a specific path<br>file_info = list_files_recursive(&#39;/path/to/explore&#39;)<br><br># Display the hierarchical data structure in a readable format<br>display_recursive_info_as_dict(file_info)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/736/1*TVTWJwNkrU965Vz8xNDa_g.png" /></figure><p>I ran it and we should receive a Blank space</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/955/1*lvown75khGua9a9LpOur1g.png" /></figure><ul><li>Task 5.2: Test the function with different paths, including the option to use the current working directory.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/954/1*Qp-cypantMItnF7ceJ-uFQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/979/1*4BUi1943XmTvqYhY4wMVmg.png" /></figure><p>Task 5.3: Test the function with different paths, including the option to use the current working directory.</p><ul><li>Current Directory:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/904/1*u4q6_dZXYWUMtpi_3eeoDQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/659/1*0qNEs8oM1GamMeEie2Lk2Q.png" /></figure><p><strong>You can find the Github repository </strong><a href="https://github.com/JesusEgui/02-Python-Projects-/blob/main/01-Complex.py"><strong>here</strong></a></p><p>Project Conclusion: Extracting File Details Efficiently</p><p>In response to the company’s need for file information from various machines, we created a Python script that extracts and organizes file details in a list of dictionaries. This script was then enhanced into a versatile function capable of handling user-defined paths and recursive file information retrieval. The function was further advanced to represent file data as a dictionary of dictionaries. Sharing the code on GitHub facilitated collaboration and demonstrated Python’s effectiveness in automating tasks.</p><p>Github: <a href="https://github.com/JesusEgui">https://github.com/JesusEgui</a></p><p>LinkeIn: <a href="http://www.linkedin.com/in/jesusegui">www.linkedin.com/in/jesusegui</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/687/1*jfeH081kVUql2pbX2J1_9w.png" /><figcaption>See you!!!</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2c486276f8d6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Python: Name Generator on Pycharm(Mini Project)]]></title>
            <link>https://medium.com/@13jesusegui/python-name-generator-on-pycharm-mini-project-1963356b5b8d?source=rss-5ad137ec7bb6------2</link>
            <guid isPermaLink="false">https://medium.com/p/1963356b5b8d</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[tech]]></category>
            <category><![CDATA[cloud]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Jesus Egui]]></dc:creator>
            <pubDate>Tue, 19 Sep 2023 05:16:01 GMT</pubDate>
            <atom:updated>2023-11-11T15:19:22.180Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/870/1*ZVi3vmxlPZpUngKXRS18oQ.jpeg" /></figure><h3>Project Summary: Unique EC2 Name Generator for AWS</h3><p>This project focuses on the efficient management of EC2 instances in a shared AWS environment. A unique name generator has been developed using Python to simplify instance identification. Users can input the number of EC2 instances they need to name and their department’s name. The name generator automatically creates unique names that include the department’s name along with random characters and numbers. Furthermore, the name generator is restricted to the Marketing, Accounting, and FinOps departments, with case-insensitive handling of department names.</p><p>This project demonstrates how Python can be leveraged to solve practical challenges in shared cloud environments, enhancing resource identification and tracking.</p><p><strong>Foundational:</strong></p><p>Several departments share an AWS environment. You need to ensure that the EC2s are correctly named and are unique so team members can easily tell who the EC2 instances belong to. Use Python to create your unique EC2 names that the users can then attach to the instances. The Python Script should:<br>1. All the users input how many EC2 instances they want names for and output the same amount of unique names.<br>2. Allow the user to input the name of their department that is used in the unique name.<br>3. Generate random characters and numbers that will be included in the unique name.<br>4. Push your code to GitHub and include the link in your LinkedIn write-up.</p><p>ADVANCED:<br>The only departments that should use this Name Generator are the Marketing, Accounting, and FinOps Departments. List these departments as options and if a user puts another department, print a message that they should not use this Name Generator. Be sure to account for incorrect upper or lowercase letters in the correct department. Example: a user inputs accounting vs. Accounting.</p><p>COMPLEX<br>Add your name with the function the command print, turn the above into a Function, and executes the Function to verify it works,</p><p>What are Python and Pycharm:</p><p>Python is a high-level, interpreted programming language, generally considered a versatile language. It is renowned for its simplicity and code readability, making it a popular choice among programmers of all skill levels.</p><p>PyCharm is an integrated development environment (IDE) designed specifically for Python programmers. It provides an advanced code editor and debugging tools to streamline Python development.</p><h4>Commands:</h4><p>Here is a list of commands without examples along with their explanations :</p><ul><li>print(): Displays information on the standard output, such as on the screen.</li><li>int(input()): Converts user input into an integer.</li><li>input(): Receives user input as a text string.</li><li>random.choice()`: Randomly selects an element from a sequence, such as a letter or a digit.</li><li>f”: Allows string formatting by embedding values within it.</li><li>random.choice()`: Randomly selects an element from a sequence, such as a letter or a digit.</li><li>if: Initiates a conditional control structure for performing a check.</li><li>return: Returns a value from a function, often `None` when no specific return value is specified.</li></ul><h4>Project Essentials:</h4><ul><li>Basic Python Knowledge: A fundamental grasp of Python programming.</li><li>PyCharm Installation</li><li>Python Environment Configuration: Set up and configure a Python interpreter.</li><li>Library Requirements: Identify and install necessary Python libraries/packages for your project.</li></ul><p><em>Let’s start with our mini-project</em></p><h4>Foundational :</h4><ul><li>The first code snippet is the most basic. It takes user input for the number of EC2 instances and the department name and generates random instance names with the given department prefix.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/916/1*0ieLJdycinDQfL9YqtjPHw.png" /></figure><p>When I run it, it will request two things: “How many EC2 instances do you want to name?” and “Enter your department name:” my answers would be a random number “8” and a random name “L.A.M”</p><p>By doing this we’ll receive 8 random names</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/714/1*wzIFkhygy0c0Nq2N0MunuQ.png" /></figure><p>You can find the Github repository <a href="https://github.com/JesusEgui/Python-Projects/blob/main/0001-Fundamentals.py">here</a></p><h4>Advanced :</h4><ul><li>The second code snippet builds upon the basic one. It adds a check to ensure that the entered department is one of the allowed departments (marketing, accounting, FinOps). If the department is not on the allowed list, it prints a message indicating that the Name Generator should not be used for that department.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/867/1*meUSUdQD8imak8hiqxMs7Q.png" /></figure><p>When I ran it, it will request two things: “How many EC2 instances do you want to name?” and “Enter your department name:” my answers would be a random number “10” and a random name “Marketing”</p><p>By doing this we’ll receive 10 random names but in the department “Marketing”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/684/1*Pb-iZG3CkmUOKNy3enqEag.png" /></figure><p>In this case, use lowercase in the word “Marketing” and place “marketing” to show that it would not work with that small difference.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/785/1*nx2dYUn4idmgTfK2ICQa7g.png" /></figure><p>You can find the Github repository <a href="https://github.com/JesusEgui/Python-Projects/blob/main/001-Advanced.py">here</a></p><h4>Complex (Complejo):</h4><ul><li>The third code snippet takes a more modular and organized approach. It defines a function called generate_ec2_names that accepts the number of instances and departments as parameters. It performs the same checks as the advanced version but returns a list of generated EC2 names or None if the department is not allowed. This makes the code more reusable and easier to maintain.</li><li>The main part of the code still takes user input for the number of instances and departments and then calls the generate_ec2_names function to generate and print the unique EC2 instance names.</li><li>Add your name with the function print</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/922/1*czvIQFz8nNiQI6XR1lAguw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/924/1*WDKB1ActkEcTrXqHmo3N_A.png" /></figure><p>We can see our name after running the print command</p><p>When I ran it, it requested two things: “How many EC2 instances do you want to name?” and “Enter your department name:” My answers would be a random number “12” and a random name “Marketing”</p><p>By doing this we’ll receive 10 random names but in the department “Marketing”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/801/1*gNDZu09WKS4T6rXednYFjw.png" /></figure><p>You can find the Github repository <a href="https://github.com/JesusEgui/Python-Projects/blob/main/01-Complex.py">here</a></p><p><strong>Conclusion:</strong></p><p>The EC2 Instance Name Generator is a valuable tool designed for AWS users in the Marketing, Accounting, and FinOps domains. Its core objective is to ensure precise and distinguishable names for EC2 instances. By encapsulating this functionality within a function, it evolves into a versatile and reusable asset for forthcoming endeavors.</p><p>Github: <a href="https://github.com/JesusEgui">https://github.com/JesusEgui</a></p><p>LinkeIn: <a href="http://www.linkedin.com/in/jesusegui">www.linkedin.com/in/jesusegui</a></p><p><strong>Postscript:</strong></p><p>This is the link to the page that I used to create the ASCII “message” <a href="https://patorjk.com/software/taag/#p=display&amp;f=Big%20Money-nw&amp;t=Mini%20Presentation%0A%20Name%20Generator%0A">here</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/773/1*MH0qoxsGITXxGJUEHdxWRw.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1963356b5b8d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AWS 3 Tier Architecture: Designing Efficient and Scalable Applications]]></title>
            <link>https://medium.com/@13jesusegui/aws-3-tier-architecture-designing-efficient-and-scalable-applications-d123d732bd19?source=rss-5ad137ec7bb6------2</link>
            <guid isPermaLink="false">https://medium.com/p/d123d732bd19</guid>
            <category><![CDATA[cloud]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[tech]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[technology]]></category>
            <dc:creator><![CDATA[Jesus Egui]]></dc:creator>
            <pubDate>Wed, 30 Aug 2023 12:34:06 GMT</pubDate>
            <atom:updated>2023-08-30T12:34:06.548Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QaBBFM5KmMk-3znF-8s--Q.jpeg" /></figure><h4>Preview:</h4><ul><li><em>Offering a comprehensive range of tools and services, these resources empower the construction and management of cloud applications. These resources can be harmonized to construct robust, dependable cloud architectures. In the context of this tutorial, your objective is to design and establish a highly available three-tier architecture for your company’s upcoming web application. While this guide is extensive, it ensures a thorough understanding of the process. Bookmark this tutorial for future reference when building the web, application, and data tiers.</em></li></ul><h4>Use Case:</h4><ul><li><em>A compact e-commerce venture embraces a 3-tier architecture, advised by its engineering team. The web tier manages content delivery and requests, backed by an Auto Scaling Group for traffic fluctuations. Public subnets facilitate access to EC2 instances. The application tier oversees business logic, transactions, and database interactions. Security is upheld by situating EC2 instances in private subnets, exclusively reachable through the Web Server Security Group. The database tier holds customer data and transactions. This architectural choice enhances scalability, security, and performance, bolstering the platform’s base.</em></li></ul><h4>Prerequisites:</h4><ul><li>Create AWS account</li><li>Basic Cloud Computing Knowledge</li><li>Create an IAM user with Administrator permissions</li></ul><h4>Background:</h4><h4>What is a 3-Tier Architecture?</h4><ul><li>A 3-Tier Architecture is a software design approach that divides an application into three layers: presentation, application logic, and data storage. This separation enables efficient development, scalability, reliability, and security. The presentation layer handles the user interface, the application logic layer manages functionality, and the data storage layer stores information. Each tier can be scaled independently, enhancing performance, and maintenance is simplified due to the clear separation of roles. This architecture is widely used for creating organized and efficient applications.</li><li>The 3-Tier Architecture offers streamlined development with concurrent teamwork, efficient scaling based on demand, increased resilience through resource distribution, personalized security measures, simplified maintenance procedures, and component reuse for faster development and consistency across various projects.</li></ul><h4>Let’s start with this project:</h4><p>Step 1: Creating the VPC and Subnets</p><ol><li>Log in to your AWS console and navigate to “VPC”.</li><li>Select “VPC and more” and define a name and IP address range (CIDR) for your VPC. For example 10.0.0.0/16.</li><li>Using VPC and more we can choose options such as how many availability zones, public subnets name (2), the number of private subnets (4), Internet gateways, and also Nat gateways.</li><li>We will be able to see a frame that will show us how the connections will be routed to create private and public networks that can be connected through the Internet.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/472/1*caoGu4_6TVP4ef0AIMec4w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qT0KaQRikTKH3j1TkfSWbQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/472/1*caoGu4_6TVP4ef0AIMec4w.png" /></figure><p>If we click on details we can see how all the Subnets, Nat Gateway, etc are being created…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/724/1*w-qa6NxI0Yforo5ipYJT_Q.png" /></figure><p>When all of your VPC resources have finished creating, click <strong>“View VPC.”</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*I3BhSW9nx8GJXY42jFqLSw.png" /></figure><p>Now that we have created everything we must go to the configuration of the subnet and enable the “<strong>Enable Auto-assign public IPV4 Address”</strong> option to do that we follow these steps:</p><ol><li>Let&#39;s go to VPC</li></ol><p>2. We select subnets</p><p>3. Click on Actions</p><p>4. Edit the subnet setting</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/761/1*HDnp0ehGXkB0HZrwq2uyRw.png" /></figure><p><strong><em>First step: The Web Tier</em></strong></p><p>In this segment, we will establish the initial tier responsible for our front-end user interface. Our objective is to create an auto-scaling group comprising EC2 instances that will serve as hosts for a custom webpage.</p><p>We are going to create an instance that can display a message as a first step to make sure that our Web tier will work correctly and we can test it</p><ol><li>We select a name for our instance and select an AMI in this case I will be using Amazon Linux the free tier</li></ol><p>2. we will use T2.Micro</p><p>3. Select a key pair</p><p>4. Select a VPC and I will be using the public subnet that is in the east-1a region.</p><p>5. Click on Enable auto-assign Public ID</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/709/1*sx5eeascpPfB7x-u7ydqmQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/691/1*mOQLVR7KNCN4AMpoWojR6w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/683/1*hXz3am1Fy7LtIiWIllBOJw.png" /></figure><p>We will create a security group that allows<strong> “HTTP SSH</strong> and <strong>HTTPS”</strong> traffic and in the source type we will select from anywhere to allow traffic from anywhere and we can test our instance</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/601/1*ROUQtpV_qlUKSYmZOX_ayw.png" /></figure><p>Then we will go down to the User data configuration and add a message to our instance, with this script we will install and enable the Apache server that will let us display the message <strong>&quot;1Web Tier Testing !!&quot;</strong> and then we can click on launch instance</p><pre>#!/bin/bash</pre><pre>yum update -y<br>yum install -y httpd<br>systemctl start httpd<br>systemctl enable httpd</pre><pre>echo &quot;&lt;h1&gt;1Web Tier Testing !!&lt;/h1&gt;&quot; &gt; /var/www/html/index.html</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/699/1*H4aYJ-f5jmMbWfRoD7p4lA.png" /></figure><p>Now we go to the instance and we take the IP address to run it in our browser and thus verify that the message that we use with the echo command can be displayed without any error.</p><p>This happens because we created an instance that had a VPC, we created a subnet in that VPC, then we routed the Subnet with a Nat gateway so that it can have internet connectivity allowing HTTP traffic from anywhere and the last step would be to test it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/706/1*BXGxUrulXMRrPNTtT-mt7w.png" /></figure><h3>Step 2: Create an Autoscaling group:</h3><p>Given that we have a running EC2 instance and a working website, our next goal is to improve availability and reliability by implementing an autoscaling group.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/730/1*oVrpt1OaVDZFUyk3HdUgvw.png" /></figure><p>Within Launch Templates we can create a template with the desired configurations</p><ol><li>We select a name for our instance that we previously created</li></ol><p>2. we will use T2.Micro</p><p>3. Select a key pair</p><p>4. We will not include a subnet but we will select the previously created security group</p><p>5. Click on Enable auto-assign Public ID</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/732/1*s3eLi8BZ1EVp5dQZyQa42A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/694/1*gp3rEkIcZp6rjgGtQgXlkA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/695/1*GQibuXVnBruaFRM6qx0aaQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/676/1*hi9iW6kx14FC6B8AEQlPiw.png" /></figure><p>We will go to details and we will add the same script as in the last instance but this time we will display another message using the same <strong>echo command and</strong> click on <strong>Create a Launch Template</strong></p><pre>#!/bin/bash</pre><pre>yum update -y<br>yum install -y httpd<br>systemctl start httpd<br>systemctl enable httpd</pre><pre>echo &quot;&lt;h1&gt;Launch Template instances Web Tier Testing!!&lt;/h1&gt;&quot; &gt; /var/www/html/index.html</pre><p>Now that we will create our launch template we will use it in our autoscaling group so that the instance that is created is with the bases and configurations of our template and in an organized way with the correct configurations the instance will be created at the root of the autoscaling group or it could be said that The instance is born with the configurations of our template that we are using in our scaling group to create the necessary instances, which in this case will only be one</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/731/1*JhlDruBx5cxcQkFknVC2og.png" /></figure><p>Step 2: we will add our VPC and choose our public Subnets of us-east-1a and us-east-1b</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/723/1*IHPS7fU5BYoWFF98HVJd2Q.png" /></figure><p>You are now given the option to add a load balancer. A load balancer is a good idea to distribute traffic amongst the instances. Since we haven’t created one yet, we will select “Attach to a new load balancer” and choose “Application Load Balancer” because we use HTTP connections. Give the load balancer a name and select “Internet-facing” for the scheme. This will allow us to communicate on the Internet, not just internally. Under Network mapping, you should see the VPC that you created and the two public subnets in our auto-scaling group. The load balancer needs a listener and target group. We can see HTTP is selected (port 80) and we will create a new target group.</p><p><strong>Step 3 Creation de un Load Balancer:</strong></p><p>We need to create a load balancer to distribute the traffic correctly this traffic will be distributed with the HTTP type we created a name for our load balancer and this will allow us to communicate with the internet</p><p>We will also create a target for our Load Balancer if we do not create a target by copying the DNS of the Load Balancer we will receive an error trying to communicate with the internet through the DNS of our Load Balancer</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/728/1*499ovrhbt3IHUK_88oc8gw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/722/1*91WJ7_T8P1rWgkfnw4QAhQ.png" /></figure><p>Enable health checks and choose “Turn on group metrics collection in CloudWatch”. Both configurations are optional. Once you are ready, proceed to the 4th step</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/753/1*XnPmEcpAEZJcKaDk7lI1lg.png" /></figure><p>In the Group sides, we only need the capacity of one (one instance) the following options would be:</p><ol><li>Desired capacity 1</li><li>Minimum capacity 1</li><li>Maximum Capacity</li><li>the other options can remain as the default ones that are shown on the screen</li></ol><p>This way we make sure that even if the instance is deleted, a new one will be created with the template configurations</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*1efKRMEyapuon65F-45Mgg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/729/1*UDUBZdIATpFCw33YKHHvdA.png" /></figure><p>In the last step, we can see the details we can click on Next and proceed to create our escalation group</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/717/1*vwwyQQ_ai3LlEQDiWNOjiQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/755/1*F8QYlBAhIXEN8kaASVmusw.png" /></figure><h4>Step 3: Testing instance:</h4><p>We need to verify that everything has worked correctly so we will go to EC2, then to instances and we will be able to see that a new instance will be created, after a few minutes, we will select the IP address of the instance, we will paste it in the browser, if all the configurations were made correctly we could see the drop-down message that we created in our Template and that is now in our instance if we do not see any message the most common error is that the security group does not have the necessary permissions that should be HTTP</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/653/1*zAmpBw6rRxTSE4yvZJFCTg.png" /></figure><h3>| Step 4: Updating our Route Tables</h3><p>Step 1: Up to this point in our project, we have successfully set up our web layer. This layer consists of a Virtual Private Cloud (VPC), which includes two public subnets connected to an autoscaling group, a security group, an Internet gateway, and user data that makes it easy to install Apache and create a personalized home page for the company.</p><p>Step 2: To finish configuring our web layer, it&#39;s important to make sure that the route tables are automatically generated when creating the VPC and that the subnets are associated correctly. To do this, we&#39;re going to go back to the VPC dashboard. In the menu located on the left, select the option “Routing tables”.</p><p>Step 3: Once in the<strong> &quot;Routing Tables&quot;</strong> section, locate and select the public routing table assigned to the web layer resources. It then proceeds to review the list of associated subnets. This is where you should find the list of the two public subnets we created for this purpose.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Me_KDUbjjM_rQ8iydj1vPg.png" /></figure><h3>Step 5: Application Tier</h3><p>We will configure the application layer in our infrastructure, using the same VPC and private subnets from the first phase. We&#39;ll create an autoscaling EC2 instance and adjust security to restrict public access.</p><ol><li>Choose the VPC and a private subnet.</li><li>Create an EC2 instance and scale group, as in layer 1.</li><li>Limit public access by adjusting security group permissions.</li><li>Follow the instructions above to launch the instance and complete the application layer.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/703/1*1_mwh3hOLZPRK78Q2P2rhw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/697/1*znn8bloaDvQtN7PDbUEDtg.png" /></figure><p>We are going to strengthen security at the application layer. We will ensure that only authorized traffic from the web layer can access it. Follow these steps:</p><ol><li>Enable SSH, HTTP, and ICMP only from the web layer security group.</li><li>When adding security groups, choose “Custom Source” and select the web layer security group as the source.</li><li>There is no need to assign a public IP, as this layer will be on a private subnet. This improves safety by avoiding unnecessary exposure.</li><li>This time we will not assign any script to the user data</li><li>Launch the instance</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/662/1*e1zPePTPBkpv8eLtVoYIqg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/688/1*c8VUCDxyOWyRJFG6AIkUKg.png" /></figure><h3>We will create a new Autoscaling group with a new template</h3><p>We will use the same specifications and the AMi that we have released recently, that is:</p><ol><li>t2.Micro</li><li>Key pair</li><li>Enable auto-assign IP</li><li>select the Web App security group</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/716/1*-6kLRYuwwxkbM9GqpvQQJA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/614/1*E_oE7_tDye0j6O7gaVklVQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/674/1*doyHWdRBzG7mo_COCeU5BQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/702/1*99d-N6Y10pjBNQTvh4_KRA.png" /></figure><h3>Step 6: Create an auto-scaling group for our App tier:</h3><ol><li>We will create a name for our auto-scaling group.</li><li>We click on refresh and select our last created launch template.</li><li>click on next.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/645/1*pMPItHLdDVBcF9KqvZU5vA.png" /></figure><p>We choose our VPC and select our private subnets in the east-1a and east-1b region and click on Next</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/734/1*dsAIpwyhn0dP6KXvy8keQw.png" /></figure><p>We will create another load balancer but this time we will use the <strong>Internal</strong> option since this time the connection should only be internal and not external as in the other load balancer, we enable the health checks and the monitoring with Cloudwatch</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/731/1*a1KYARqZpiKGQ3w6m7IY6Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/711/1*_m188BZaSseKVHhGkGlFRQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/728/1*x-fTCA2Et69FjCdrI4gsYA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*qLLXNbGzLV41fCfZxEnZ6A.png" /></figure><p>In the Group sides, we only need the capacity of one (one instance) the following options would be:</p><ol><li><strong>Desired capacity 1</strong></li><li><strong>Minimum capacity 1</strong></li><li><strong>Maximum Capacity</strong></li><li>the other options can remain as the default ones that are shown on the screen</li><li>We click on Create autoscaling group</li></ol><p>This way we make sure that even if the instance is deleted, a new one will be created with the template configurations</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*1efKRMEyapuon65F-45Mgg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/535/1*FYenQXWPKIFKKsJ4JcRT_w.png" /></figure><h3>Step 7: We need to update the Route tables configuration of the web tier app:</h3><p>Step 1: Access the VPC control panel and in the menu located on the left side, select <strong>“Routing tables”.</strong></p><p>Step 2: Click on one of your automatically created private routing tables <strong>(mine is called W9webtier-rtb-private1-us-east-1a).</strong></p><p>Step 3: Look at the<strong> “Subnet Associations”</strong>. Make sure this private routing table is associated with two of the private subnets <strong>(I&#39;ve chosen private-1-us-east-1a and private-2-us-east-1b).</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*un-gnmXrf_Eezi7rU9vXfA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*20pn9tA42QzKGkIucWJIEw.png" /></figure><h3>Step 8: Creating a Database Tier</h3><p>In this step, we will use <strong>MYSQL RDS</strong> as a database and we will create a subnet group, we will assign it a name, also a description and we will select our VPC</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_VWiU8cxQziYqomocbrQsA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*51mi_HncOb5ue9_Vj8K0Tg.png" /></figure><p>Step 1: Access the VPC console and choose &quot;Routing Tables&quot; in the menu on the left.</p><p>Step 2 – Select one of the automatically generated private route tables <strong>(for example, 1Web Tier-VPC-private1-us-east-1a).</strong></p><p>Step 3: In the <strong>“Add Subnets”</strong> section, you will need to start by selecting the “Availability zones”.</p><p>Step 4 – If you don&#39;t remember which Availability Zones you used for your third and fourth private subnets, go back to the VPC console.</p><p>Step 5: In the left menu, choose <strong>Subnets</strong>. Then, select the last two private subnets you created <strong>(make sure you don&#39;t choose the subnets you already used in Layer 2).</strong></p><p>Step 6: On the subnets page, you will find information about the Availability Zones that were used.</p><p>By following these steps, you can identify the correct Availability Zones to associate with the private routing table.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Z2y-lxm-Aj0Fifle_T1CCw.png" /></figure><p>After having done that we select our availability zones us-east-1a and us-east-1a, then we will select our subnets of that availability zone and click on create</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/718/1*VLu98JJ0X_JYkcth8RBDGA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mFQrX5EQAQkgfAV3axVmxQ.png" /></figure><h3>Step 9: Create a MySQL Database.</h3><p>Now that we have created the subnet group for the database</p><p>Step 1: Now that you have created the subnet group for the database, go to the RDS console and click on <strong>“Databases”</strong> in the menu on the left.</p><p>Step 2: Then, select <strong>“Create database”.</strong></p><p>Step 3: Opt for <strong>“Standard creation”.</strong></p><p>Step 4: Select <strong>“MySQL”.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/696/1*rB-MBPqH8pejhEKDrKsI4A.png" /></figure><p>Let&#39;s create a cluster using the free tier template, without setting up multiple Availability Zones or secondary DB instances.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/688/1*cF0qW1_yzh8L4GjxL5B_3w.png" /></figure><p>Create a name from the DB instance identifier, create a name for the master username, and create a key</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/678/1*i8e400DZhHl_NHkUVdgnrg.png" /></figure><p>Secure your credentials. Configure the instance (type and storage). Decide on connectivity (EC2 option and IPv4 network). Select the subnet group and prevent public access. Create a new VPC security group. Optionally, consider an RDS Prox</p><p>Step 1: Save your credentials Be sure to save the username and password you use. You will need them later to connect to your database.</p><p>Step 2: Instance Configuration In the Instance Configuration section, you&#39;ll notice that the only option available in the free tier is the “burstable” class, which is already pre-selected by default. If you want, you can change the instance type. In my example, I have chosen db.t2.micro, which is sufficient for a Virtual Private Cloud (VPC). You can also adjust the storage according to your needs, although for this case, I have left the default settings.</p><p>Step 3: Connectivity This is where you find various options. In the <strong>“Compute resource”</strong> section, you can decide if you want to establish a connection to a compute resource (such as an EC2 instance) for this database. This option automatically configures your VPC and network settings to create a secure connection between the EC2 instance and the RDS database. For this example, I have selected “Do not connect to an EC2 compute resource” as I prefer to configure network options manually.</p><p>Step 4: Network Type Select <strong>“IPv4” </strong>as the network type. Then, choose the VPC you&#39;ve been using in this tutorial.</p><p>Step 5: Database subnet group Select the database subnet group <strong>(DB subnet group)</strong> that you created previously. This is essential to establish the proper network locations.</p><p>Step 6: Public access Since this database is for internal company use and should not be publicly available, select <strong>“No”</strong> in the “Public access” option.</p><p>Step 7: VPC Security Group Create a new security group for the VPC. Give the security group a descriptive name and choose a preferred Availability Zone.</p><p>Step 8 – Additional Options You will see the option to create an RDS Proxy, which allows for greater scalability, but note that this incurs additional costs. For this example, we will leave this option unchecked.</p><p>By following these steps, you will be configuring your DB cluster according to the parameters you have selected. Remember that these are the configuration steps based on your needs and preferences.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/604/1*6-Gx1IGiJ6OjrV8VLT_95Q.png" /></figure><p>For database access, you’ve got three choices. You can also set up enhanced monitoring and make more adjustments. When you’re set, just hit the <strong>“Create database”</strong> button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/617/1*gfjl0Q-KIN1jtKDGXF-7cg.png" /></figure><h3>Step 10: SG Data Tiger</h3><p>By following these steps, you will have adjusted your security rules to allow MySQL traffic from the application layer&#39;s security group instead of your IP address, which strengthens security and improves communication between layers.</p><ol><li>Database group security access:</li></ol><ul><li>We created a new security group for the database layer, but we didn&#39;t have the option to adjust the permissions.</li></ul><p>Navigate to the VPC console:</p><ol><li>We created a new security group for the database, but we were unable to adjust the permissions at that time.</li><li>Go to the VPC console.</li><li>Select “Security groups” in the left menu.</li><li>Find the security group you created for the database.</li><li>Remove the default rule that allows MySQL/Aurora traffic on port 3306 from your IP address.</li><li>Add a new rule:</li></ol><ul><li>Click on “Add rule”.</li><li>Choose “MySQL/Aurora” as the Type.</li><li>Select “Custom Origin”.</li><li>Choose the application layer security group.</li><li>Press “Save rules” to confirm the changes.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6kJZaon-YaZpHDm5jHtYAQ.png" /></figure><p>Updating Private Route Tables for Layer 3 We come to the last step of configuring the database layer, and this involves making changes to the route tables that were created automatically. Access the VPC console and look for the “Route tables” option in the menu on the left. Select the private route table you want to link to the private subnets of the database layer. Then, go to the “Subnet associations” tab to check if the associations are correct. If they aren&#39;t, you can edit the subnet associations to add the correct subnets and make sure everything is running smoothly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7dBsGNeh03juBaZxkMr2pA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IuMqUZ5-CUSKAlycV5cDxw.png" /></figure><p>OMG we finished, we created the three tiers now its time to test everything</p><h3>Step 11: use SSH client, to prove our connectivity</h3><p>we should be able to log in using the copied command and answering yes to the prompts shown</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/674/1*OJ72M2wXDlIfYqpHQZlgrw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*84FF-7os24iS-EnblxCZ1g.png" /></figure><h3>Step 13: Web tier 1 check</h3><p>When we decide to go to the public IPv4 address corresponding to layer 1 and we do it by browsing our system, we find the message that we have created in our template using the echo command:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/705/1*wQZNqUd9J91i7vJQe-y7AA.png" /></figure><p>Tier 1 is working healthily!!!!!</p><h3>Step 12: Connection Verification: Pinging from Layer 1 to Layer 2</h3><p>Let&#39;s move on to an essential check. This time, we will test the communication between Layers 1 and 2. Since you are already inside the Layer 1 instance, take the opportunity to ping the Layer 2 private IPv4 address and make sure that connectivity is working smoothly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/775/1*vDPaCUzOg0pcWIl4v_pDAA.png" /></figure><p>The test is also successful, demonstrating that Layers 1 and 2 can communicate effectively. This validates the joint functionality of our system and establishes a solid foundation for data transmission and collaboration between the layers. This robust interaction between the layers is a significant step towards overall system functionality and allows us to confidently move into the next stages of development and deployment.</p><h3>ADVANCED</h3><p>Application Load Balancers should be used for the Web Tiers with the same Security Group considerations. Example The ALB should allow HTTP traffic from 0.0.0.0/0 and the Web Server Security group should allow traffic only from the ALB. Don’t forget to create Target Groups and enable Health Checks.</p><p>Create a name and a description</p><p>Select our vpc</p><p>In inbound select the next options:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AFwA0xU-hLy3ycpR35Caig.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9uKrR1BeEsTvh_obwAuVzQ.png" /></figure><p>We return to the load balancer and change the security group to the default for the one we just created, then we take the <strong>DNS</strong> of our load balancer and paste it into our browser, which should show us the message that we wrote in the User code of the <strong>Web App</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/744/1*zuKXa1EKnLvA5Z28vXGHPw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ujE7JUsPuTM6uu7t1nW8lQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/925/1*TFNFJLSG6_QBn_BPRTjUcw.png" /></figure><p>It works!!!!!!! there you have it — after all the hard work and effort, we’ve wrapped up this big three-tier rewrite project. Everything’s up and running, just like we wanted. It’s been quite the journey, but we made it work. If you’ve got any more questions or need help with anything else, just give me a shout. Cheers to us for pulling off this awesome project!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d123d732bd19" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>