<?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 Antrameca  Mathis ( Ann-Trah-Mee-Kah) on Medium]]></title>
        <description><![CDATA[Stories by Antrameca  Mathis ( Ann-Trah-Mee-Kah) on Medium]]></description>
        <link>https://medium.com/@antramecalmathis?source=rss-c914038d4ace------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*-mw7rHreGIOyaL8DPpmAfg.jpeg</url>
            <title>Stories by Antrameca  Mathis ( Ann-Trah-Mee-Kah) on Medium</title>
            <link>https://medium.com/@antramecalmathis?source=rss-c914038d4ace------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 11:20:16 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@antramecalmathis/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[JOURNEY OF A LIFETIME: Deploying a Highly Available Infrastructure through an Apache Webserver with…]]></title>
            <link>https://medium.com/@antramecalmathis/week-21-project-scenario-fa62c04532c?source=rss-c914038d4ace------2</link>
            <guid isPermaLink="false">https://medium.com/p/fa62c04532c</guid>
            <category><![CDATA[autoloading]]></category>
            <category><![CDATA[autoscaling]]></category>
            <category><![CDATA[terraform]]></category>
            <dc:creator><![CDATA[Antrameca  Mathis ( Ann-Trah-Mee-Kah)]]></dc:creator>
            <pubDate>Tue, 25 Jul 2023 02:31:39 GMT</pubDate>
            <atom:updated>2023-07-25T09:57:45.996Z</atom:updated>
            <content:encoded><![CDATA[<h3>JOURNEY OF A LIFETIME: Deploying a Highly Available Infrastructure through an Apache Webserver with AWS Terraform</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/970/0*5wGQifmDV9E-cT_x.jpg" /></figure><h3>WEEK 21 PROJECT SCENARIO:</h3><p>An e-commerce company needs to handle a surge in traffic during the holiday season. The company wants to ensure that their website remains available and responsive to customers even during high traffic periods.</p><p>The project can be used to launch an Auto Scaling group that spans two subnets in the default VPC, ensuring high availability and fault tolerance. The Auto Scaling group will automatically scale up or down based on traffic, ensuring that the website remains responsive to customers at all times.</p><p>To ensure that the instances in the Auto Scaling group are secure, a security group is created that allows traffic from the internet and associates it with the instances. Additionally, a script is included in the user data to launch an Apache web server, ensuring that the website is available to customers.</p><p>To ensure that the Auto Scaling group has the appropriate capacity, it is set to have a minimum of two instances and a maximum of five. This ensures that the website can handle a surge in traffic during the holiday season, while also minimizing costs during periods of low traffic.</p><p>To verify that everything is working correctly, the public IP addresses of the two instances are checked. One of the instances is manually terminated to verify that another one spins up to meet the minimum requirement of two instances.</p><p>Finally, to ensure that the infrastructure is reliable and can be easily managed, an S3 bucket is created and set as the remote backend for Terraform. This ensures that the infrastructure is versioned and can be easily rolled back if necessary.</p><p><strong>Be sure to use Variables where you feel appropriate to make your code as reusable as possible. Generally if it’s a value you think could change in the future or if it’s a value that’s repeated, then it should be a variable.</strong></p><h3>OBJECTIVES:</h3><ol><li>Launch an Auto Scaling group that spans 2 subnets in your default vpc.</li><li>Create a security group that allows traffic from the internet and associate it with the Auto Scaling group instances.</li><li>Include a script in your user data to launch an apache webserver. The Auto Scaling group should have a min of 2 and max of 5.</li><li>To verify everything is working check the public IP addresses of the two instances. Manually terminate one of the instances to verify that another one spins up to meet the minimum requirement of 2 instances.</li><li>Create an S3 bucket and set it as your remote backend.</li></ol><h3>PREQUISITES:</h3><ul><li>AWS Account with IAM Role</li><li>GitHub Account</li><li>Basic Knowledge of Terraform</li><li>Knowledge of EC2 Instances</li><li>Basic Knowledge of Cloud9</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/608/1*Qk3Q5sijCWO82o75VWDDjA.png" /></figure><h3>DEFINITION:</h3><p>Apache, an open-source Web server created by American software developer Robert McCool. Apache was released in 1995. In the early 2020s, Apache servers deployed about 30 percent of the Internet’s content, second only to Nginx.<br>As a Web server, Apache is responsible for accepting directory (HTTP) requests from Internet users and sending them their desired information in the form of files and Web pages. Much of the Web’s software and code is designed to work along with Apache’s features. <a href="https://www.britannica.com/technology/Apache-Web-server">LINK</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/473/1*oUrADwll1OPYnbX88WR70w.png" /></figure><h4>STEP 1: In GitHub, Create a New Public Repository (Repo), a New Branch Protection Rule &amp; a New Token for this Project.</h4><p>I have already completed this step in the Week 20 Project.</p><ul><li><a href="https://medium.com/@antramecalmathis/constructing-a-foundation-for-automation-using-terraform-to-create-a-jenkins-server-on-an-ec2-28e2b9b473a2">Link</a> to create a GitHub Repo, Branch Protection Rule and Token for this Project (<em>see STEP 1.</em>)</li></ul><h4>STEP 2: Create a new CLOUD9 Integrated Development Environment (IDE). Then, Clone the GitHub Repo to the Cloud9 IDE, Create a New Branch and then Commit the Repo to the New Branch in the Cloud9 IDE.</h4><ul><li><a href="https://medium.com/@antramecalmathis/constructing-a-foundation-for-automation-using-terraform-to-create-a-jenkins-server-on-an-ec2-28e2b9b473a2">Link</a> to create a new CLOUD9 IDE (<em>see STEP 2.</em>)</li><li><a href="https://medium.com/@antramecalmathis/constructing-a-foundation-for-automation-using-terraform-to-create-a-jenkins-server-on-an-ec2-28e2b9b473a2">Link </a>To Clone the GITHUB Repo to Cloud9 IDE, create a new branch, and then commit the Repo to the new branch in the Cloud9 IDE. (<em>See STEP 7</em>)</li></ul><pre># cd into the branch. <br><br>cd &lt;Repo name&gt;<br><br># Create Main file for Terraform<br>touch main.tf<br><br># Check Terraform version<br>terraform version<br></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/567/1*-ChoWnEjvlMDsZMCaOC3DQ.png" /><figcaption>I know my file is named “week20project.” Disregard my naming mistake 😁😁😁</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/474/1*K2Tj3lrADcycJjRKgc0QdA.png" /></figure><h4>STEP 3: Create an S3 bucket and set it as your remote backend.</h4><p>Create a <strong>terraform.tf file</strong>. To create an S3 bucket using Terraform, you can define the necessary configuration in your Terraform configuration file. Define the configuration for the S3 bucket in the <strong>terraform.tf</strong> file.</p><p><strong>Note: </strong>In Cloud9 CLI, type in the command to create the S3 bucket. See box below for code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1001/1*_yNBdlAaw9w1WMKOrTbmzQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/977/1*Lg-Tjy2FsSJu14pVU0UvfQ.png" /></figure><p>To store the Terraform state file in an S3 bucket, you need to define the backend configuration. This configuration tells Terraform where to store the state. Open your<strong> terraform.tf </strong>file and add the following code to configure the S3 backend:</p><pre># CLOUD9 CLI Command to Create the S3 Bucket: <br>aws s3api create-bucket --bucket &lt;your buckets name&gt; --region &lt;your-preferred-region&gt;<br><br># MyCLOUD9 CLI Command to Create the S3 Bucket: <br>aws s3api create-bucket --bucket week21project-bucket --region us-east-1<br><br><br># In terraform.tf file<br># Configure the Backend for Terraform State<br>terraform {<br>  backend &quot;s3&quot; {<br>    bucket         = &quot;your-s3-bucket-name&quot;<br>    key            = &quot;terraform.tfstate&quot;<br>    region         = &quot;your-preferred-region&quot;    <br>  }<br>}<br>_____________________<br># My Configuration for the Backend for Terraform State:<br>terraform {<br>  backend &quot;s3&quot; {<br>    bucket = &quot;week21project_bucket-&quot;<br>    key    = &quot;terraform.tfstate&quot;<br>    region = &quot;us-east-1&quot;<br>  }<br>}<br>resource &quot;aws_s3_bucket&quot; &quot;my_bucket&quot; {<br>  bucket = &quot;week21project_bucket&quot;<br>  acl    = &quot;private&quot;<br>}<br><br># Create random number name  for S3 bucket name<br>resource &quot;random_id&quot; &quot;randomness&quot; {<br>  byte_length = 4<br>}</pre><p>After defining the Terraform configuration, navigate to the <strong>directory</strong> containing your <strong>terraform.tf </strong>file using the terminal and then initiate terraform. The <strong><em>terraform init</em></strong> command initializes the Terraform configuration and sets up the backend using the configurations specified in the terraform block. The terraform apply command will create the S3 bucket based on the resource block definition.</p><ul><li>Terraform will prompt you to confirm the changes. Type “yes” and press Enter to proceed with the creation of the S3 bucket.</li></ul><p>After Terraform applies the changes successfully, the S3 bucket should be created on the backend. You can check the AWS Management Console or use the AWS CLI to verify the bucket’s existence.</p><pre># Initialize Terraform and Apply Changes<br>terraform init<br>terraform apply</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/586/1*g8kg7yg91M72b26WmY7x4g.png" /></figure><h4>STEP 4: Create an Auto Scaling Group that spans 2 Subnets in your Default VPC. The Auto Scaling group should have a min of 2 and max of 5.</h4><p>Create the Terraform Configuration File, <strong>autoscaling.tf</strong>, inside of this project’s directory. Configure the AWS Provider in the<strong> autoscaling.tf</strong> file by adding the block below to set up the provider. Replace <em>your-preferred-region </em>with the AWS region where you want to create the Auto Scaling group.</p><pre># Configure the AWS Provider<br>provider &quot;aws&quot; {<br>  region = &quot;your-preferred-region&quot;<br>}<br>__________<br><br>#My AWS Provider Configuration<br>provider &quot;aws&quot; {<br>  region = &quot;us-east-1&quot;<br>}<br></pre><p>Create the default VPC Data Source, retrieve information about the default VPC in the specified region. Add the following data source block to the <strong>autoscaling.tf</strong> file:</p><pre># Create Default VPC Data Source<br>data &quot;aws_vpc&quot; &quot;default&quot; {<br>  default = true<br>}<br><br>resource &quot;aws_vpc&quot; &quot;default_vpc&quot; {<br>  cidr_block = &quot;10.0.0.0/16&quot;</pre><p><em>Create Security Group for Instances:</em> Define a security group that will be attached to the instances launched by the Auto Scaling group. Customize the security group’s inbound and outbound rules as per the requirements.</p><pre># Create Security Group for Instance<br>resource &quot;aws_security_group&quot; &quot;instance_sg&quot; {<br>  name_prefix = &quot;instance-sg-&quot;<br>  vpc_id      = data.aws_vpc.default.id<br><br>  # Add inbound and outbound rules as needed<br>}<br><br>__________________________<br># My Created and assigned Security Group to the EC2 instance with inbound and outbound rules<br>resource &quot;aws_security_group&quot; &quot;instance_sg_last&quot; {<br>  name_prefix = &quot;instance-sg-last&quot;<br>  vpc_id      = data.aws_vpc.default.id<br>  <br>    # Allow incoming TCP on port 22<br>  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>  }<br><br>  # Allow incoming TCP on port 8080<br>  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>  }<br><br>  # Allow incoming TCP requests on port 443 HTTPS<br>  ingress {<br>    from_port   = 443<br>    to_port     = 443<br>    protocol    = &quot;tcp&quot;<br>    cidr_blocks = [&quot;0.0.0.0/0&quot;]<br>  }<br><br><br>  # Allow outbound<br>  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>    ipv6_cidr_blocks = [&quot;::/0&quot;]<br>  }<br><br>  tags = {<br>    Name = &quot;sg_last&quot;<br>  }<br>}<br></pre><p><em>Create Launch Configuration:</em> Create a launch configuration that specifies the instance type, AMI, security groups, and other configurations for the instances launched by the Auto Scaling group. Replace <em>your-ami-id</em> with the ID of the Amazon Machine Image (AMI) you want to use for the instances.</p><pre># Create Launch Configuration.<br><br>resource &quot;aws_launch_configuration&quot; &quot;example&quot; {<br>  name_prefix = &quot;example-lc-&quot;<br>  image_id    = &quot;your-ami-id&quot;<br>  instance_type = &quot;t2.micro&quot;<br>  security_groups = [aws_security_group.instance_sg.id]<br>  # Add more configurations if needed<br>}<br>_____________________________________<br>#My Launch Configuration. I did not include my ami number.<br>resource &quot;aws_launch_configuration&quot; &quot;week21project&quot; {<br>  name_prefix = &quot;wek21project&quot;<br>  image_id    = &quot;ami-XXXXXXX&quot;<br>  instance_type = &quot;t2.micro&quot;<br>  security_groups = [aws_security_group.instance_sg.id]<br>}</pre><p><em>Create Auto Scaling Group:</em> Finally, create the Auto Scaling group, specifying the subnets, desired capacity, minimum and maximum size, and linking it to the launch configuration: In this example, we are using the first two subnets from the default VPC. You can adjust the <em>vpc_zone_identifier</em> with the desired subnet IDs accordingly.</p><pre><br># Create Auto Scaling Group: <br><br>resource &quot;aws_autoscaling_group&quot; &quot;example&quot; {<br>  name = &quot;example-asg&quot;<br>  vpc_zone_identifier = [data.aws_vpc.default.subnet_ids[0], data.aws_vpc.default.subnet_ids[1]]<br>  launch_configuration = aws_launch_configuration.example.name<br>  min_size = 1<br>  max_size = 3<br>  desired_capacity = 2<br>  # Add more configurations if needed<br>  }<br><br><br># Create Subnets<br>resource &quot;aws_subnet&quot; &quot;public_subnet_1&quot; {<br>  vpc_id     = aws_vpc.example_vpc.id<br>  cidr_block = &quot;10.0.1.0/24&quot;<br>  availability_zone = &quot;your-preferred-availability-zone-1&quot;<br>  tags = {<br>    Name = &quot;Public Subnet 1&quot;<br>  }<br>}<br><br>resource &quot;aws_subnet&quot; &quot;public_subnet_2&quot; {<br>  vpc_id     = aws_vpc.example_vpc.id<br>  cidr_block = &quot;10.0.2.0/24&quot;<br>  availability_zone = &quot;your-preferred-availability-zone-2&quot;<br>  tags = {<br>    Name = &quot;Public Subnet 2&quot;<br>  }<br>}<br>______________________________<br><br>#My Subnet Data Resource<br>resource &quot;aws_subnet&quot; &quot;public_subnet1&quot; {<br>  vpc_id     = aws_vpc.default_vpc.id<br>  cidr_block = &quot;172.31.80.0/20&quot;<br>  availability_zone = &quot;us-east-1a&quot;<br>  tags = {<br>    Name = &quot;PublicSubnet1&quot;<br>  }<br>}<br><br>resource &quot;aws_subnet&quot; &quot;public_subnet2&quot; {<br>  vpc_id     = aws_vpc.default_vpc.id<br>  cidr_block = &quot;172.31.16.0/20&quot;<br>  availability_zone = &quot;us-east-1b&quot;<br>  tags = {<br>    Name = &quot;PublicSubnet2&quot;<br>  }<br>}<br><br># My Auto Scaling Group<br><br>resource &quot;aws_autoscaling_group&quot; &quot;as21&quot; {<br>  name = &quot;example-asg&quot;<br>  vpc_zone_identifier = [data.aws_vpc.default.subnet1_ids[0], data.aws_vpc.default.subnet2_ids[1]]<br>  launch_configuration = aws_launch_configuration.example.name<br>  min_size = 2<br>  max_size = 5<br>  desired_capacity = 2<br> # Add more configurations if needed<br>}<br>resource &quot;aws_vpc&quot; &quot;wk21project&quot; {<br>  cidr_block = &quot;10.0.0.0/16&quot;<br>  tags = {<br>    Name = &quot;wk21project&quot;<br>  }<br>}</pre><p><em>Initialize Terraform and Apply Changes:</em> After defining the Terraform configuration, <em>cd</em> into the directory containing your <em>autoscaling.tf</em> file using the terminal. Run the Terraform commands in the box below. Terraform will prompt you to confirm the changes. Type “yes” and press Enter to create the Auto Scaling group.</p><p>Terraform will create the Auto Scaling group and associated launch configuration along with the specified security group in the default VPC using the subnets you provided. The instances launched by the Auto Scaling group will automatically span across the two subnets.</p><pre># Initialize Terraform and Apply Changes<br>terraform init<br>terraform apply</pre><h4>STEP 5: Include a Script in your User Data to Launch an Apache Webserver.</h4><p>To include a script in your user data to launch an Apache web server in Terraform, you can modify the AWS Launch Configuration or AWS Launch Template resource to pass the script to the EC2 instances at launch. Here’s how you can do it:</p><p><em>Create a Script for Apache Installation:</em> Create a shell script that installs Apache on the EC2 instance. Create a file named <strong>apache_install.sh</strong> or <strong>userdata.sh</strong> and input the content from the box below. This script will update the package index, install Apache (httpd), start the Apache service, and configure it to start automatically on boot.</p><pre>#!/bin/bash<br><br># Update package index and install Apache<br>yum update -y<br>yum install httpd -y<br>_____________<br># Start Apache web server<br>service httpd start<br><br># Set Apache to start on boot<br>chkconfig httpd on</pre><p><em>Initialize Terraform and Apply Changes:</em> After defining the Terraform configuration, navigate to the directory containing your main.tf file using the terminal. Run the following commands: Terraform will prompt you to confirm the changes. Type “yes” and press Enter to create the Auto Scaling group with the specified Launch Configuration that includes the Apache installation script.</p><pre>terraform init<br>terraform validate<br>terraform fmt<br>terraform apply</pre><p><strong>Verify Apache Installation: </strong>Once Terraform completes the provisioning, the EC2 instances launched by the Auto Scaling group will automatically have Apache installed and running. You can verify this by connecting to the instances and checking the Apache service status.</p><p>Keep in mind that the user data script is executed only once during the instance launch. If you need to make changes to the script or update Apache configuration, you may need to create a new launch configuration or template and update the Auto Scaling group accordingly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/595/1*xq58EbYSgBR5OCwpcTlv3Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*asAX_-4FzTsHGoLj" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fa62c04532c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Kubernetes Deployments with NGINX Server]]></title>
            <link>https://medium.com/@antramecalmathis/kubernetes-deployments-with-nginx-server-b730cb667b06?source=rss-c914038d4ace------2</link>
            <guid isPermaLink="false">https://medium.com/p/b730cb667b06</guid>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[nginx]]></category>
            <category><![CDATA[deployment]]></category>
            <dc:creator><![CDATA[Antrameca  Mathis ( Ann-Trah-Mee-Kah)]]></dc:creator>
            <pubDate>Sun, 23 Jul 2023 03:56:57 GMT</pubDate>
            <atom:updated>2023-07-23T16:06:09.641Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*AHCdQVH9yetWwchw" /></figure><p>Week 18 Project’s is an awesome scenario. This week’s project deals with using Kubernetes to create two deployments with Nginx containers with a YAML file.</p><h3>SCENARIO:</h3><p>A company needs to host multiple websites or web applications using a single IP address and port. This could be a cost-effective solution for smaller businesses that cannot afford to have separate servers for each website or application.</p><p>For example, let’s say that a small e-commerce business wants to launch two separate websites: one for selling clothes and accessories, and another for selling home decor items. Instead of purchasing two separate servers, the business could host both websites on a single server using two separate deployments.</p><p>The first deployment could contain two pods running the nginx image with a custom index.html page that displays “This is Deployment One” acting as the clothing and accessories website. The second deployment could contain two pods running the nginx image with a custom index.html page that displays “This is Deployment Two” acting as the home decor website.</p><p>By using a service that points to both deployments, customers can access both websites using the same IP address and port number. This will make it easier for customers to remember the website address and also make it easier for the business to manage the websites.</p><p>The curl command can be used to validate that both websites are accessible using the same IP address and port number. This will ensure that customers can access both websites without any issues and that the business is providing a reliable service.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*fDB5aSaC3j9egWaO.png" /></figure><h3>OBJECTIVES:</h3><p>1. Spin up two deployments.</p><ul><li>One deployment contains 2 <strong>pods</strong> running the nginx image. Include a <strong>ConfigMap </strong>that points to a custom index.html page that contains the line “This is Deployment One”.</li><li>The other deployment contains 2 <strong>pods</strong> running the nginx image. Include a ConfigMap that points to a custom index.html page that contains the line “This is Deployment Two”.</li></ul><p>2. Create a service that points to both deployments. You should be able to access both deployments using the same IP address and port number.</p><p>3. Use the curl command to validate that you eventual see the index.html pages from both Deployment 1 and Deployment 2.</p><p><strong><em>Note the example: curl service_ip_address:service_port</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/468/1*Q7bo9C7uOQVIrwJElNtI1Q.png" /></figure><p><strong>Kubernetes</strong> is a portable, extensible, open source platform for managing containerized workloads and services, that facilitates both declarative configuration and automation.<a href="https://kubernetes.io/docs/concepts/overview/"> Link</a></p><p><strong>Dockerhub </strong>a hosted repository service provided by Docker for finding and sharing container images with your team. Key features include: Private Repositories: Push and pull container images.</p><p><strong>ConfigMap</strong> is an API [application programming interface is a set of defined rules that enable different applications to communicate with each other. <a href="https://www.ibm.com/topics/api">Link</a>] object used to store non-confidential data in key-value pairs. <a href="https://kubernetes.io/docs/concepts/configuration/configmap/">Link</a></p><ul><li><strong>Pods</strong> can consume ConfigMaps as environment variables, command-line arguments, or as configuration files in a volume. <em>Pods</em> are the smallest deployable units of computing that you can create and manage in Kubernetes. A Pod (as in a pod of whales or pea pod) is a group of one or more <a href="https://kubernetes.io/docs/concepts/containers/">containers</a>, with shared storage and network resources, and a specification for how to run the containers. A Pod’s contents are always co-located and co-scheduled, and run in a shared context. e are analogous to cloud applications executed on the same logical host. <a href="https://kubernetes.io/docs/concepts/workloads/pods/">Link</a></li></ul><p><strong>NGINX</strong> is open-source web server software used for reverse proxy, load balancing, and caching. It provides HTTPS server capabilities and is mainly designed for maximum performance and stability. <a href="https://www.papertrail.com/solution/guides/nginx/#:~:text=NGINX%20is%20open%2Dsource%20web,IMAP%2C%20POP3%2C%20and%20SMTP..">Link</a></p><p><em>Benefits of </em><strong><em>NGINX</em></strong><em>:</em></p><ul><li>Low Latency in Website loading: Reduces the waiting time to load a website.</li><li>Good Browsing experience: Speeds up performance by routing traffic to web servers in a way that increases the overall speed.</li><li>Acts as an inexpensive and robust load balancer.</li><li>Offers scalability and the ability to handle concurrent requests.</li><li>Allows on-the-fly upgrades without downtime.</li></ul><p><strong>YAML</strong> is a human-readable data serialization language that is often used for writing configuration files. YAML is a popular programming language because it is designed to be easy to read and understand. It can also be used in conjunction with other programming languages. A benefit of using YAML is that YAML files can be added to source control, such as Github, so that changes can be tracked and audited. <a href="https://www.redhat.com/en/topics/automation/what-is-yaml#yaml-uses">Link</a></p><p>Prerequisites</p><ul><li>Basic Understanding of CLI</li><li>Basic knowledge of Visual Studio Code</li><li>Basic knowledge of Kubernetes</li><li>Basic Understanding of YAML files</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*FuBL5y3sOz09vOB7.gif" /></figure><p><strong><em>Note:</em></strong><em> After several trial and errors, I decided to try Visual Studio Code (VSCode) as the IDE for this projec</em>t<em>. VS Code is similar to Cloud9 setup. Download Docker Desktop and VS Code to your desktop. Docker has already been installed.</em></p><h4>STEP 1: Create a new Directory, Check Docker version, and then Install K8 and check the version.</h4><p>Docker was already installed:</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*92pEGvD4cgVU_yOXSu1lVw.gif" /></figure><pre># Check the Docker Version<br>docker version</pre><p>Create a new local directory in VS Code:</p><pre>mkdir &lt;your file name&gt;<br>cd into your file    </pre><p>Install K8 and check the version:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/842/1*nYOS7ZhWFT7hyDZaYokmAQ.png" /><figcaption>Kubernetes Installation</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_7Y0a5IqBtOt4s5RpLEVnQ.png" /><figcaption>K8 Version</figcaption></figure><pre># Check K8 Version<br><br>kubectl version<br>kubectl cluster-info</pre><h4>STEP 2 : Create TWO <strong>ConfigMaps </strong>that point to two separate custom index.html pages in which the first ConFigMap’s page contains the line “This is Deployment One” and the Second ConfigMap’s page contains “This is Deployment Two.”</h4><p>Create two separate YAML files for the ConfigMaps, and make sure to save the files as YAML or YML. Use VIM to create the codes for the files. Also, your title does not have to match mine, so you can create a unique title for your own title for the page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/843/1*SEH01V5NDmH3V_f7NHIqTA.png" /><figcaption>ConfigMap One</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/835/1*dvR8P-ByeqP_SuwgzEYYlA.png" /><figcaption>ConfigMap Two</figcaption></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/38d94a0c9b22a1f907618d26032f6851/href">https://medium.com/media/38d94a0c9b22a1f907618d26032f6851/href</a></iframe><p>For clarity, below is my entire VSCode Screen. Notice that the environment is very similar to AWS Cloud9.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/818/1*gZL1arw31KNDrEfeTAHHdA.png" /><figcaption><strong>Create your terminal</strong> under the<strong> Terminal </strong>tab.</figcaption></figure><p>Create ConfigMap1 and ConfigMap2 with the code below. Also, to verify that the ConfigMaps were created, you will use the command below to list all the ConfigMaps (configuration data) available in the current Kubernetes cluster’s namespace.</p><pre># Create ConfigMaps<br>kubectl apply -f [name of YAML file]<br><br># My code to create my ConfigMaps and apply to Kubernetes<br>kubectl apply -f ConfigMap1.yaml<br>kubectl apply -f ConfigMap2.yaml<br><br># Verfiy that the ConfigMaps were created<br>kubectl get configmap</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/595/1*Q6QVotD95ki3jEwGfaj-Wg.png" /><figcaption>Creation of the ConfigMaps and Confirmation of their Creation</figcaption></figure><h4>STEP 3: Create TWO Deployments that each contains 2 <strong>pods</strong> running the nginx image.</h4><p>Create two Deployment YAML files: deployment1.yaml and deployment2.yaml. Input the codes for the deployments in each one. Make note of the difference in names. <strong><em>Note: Make sure that the “name” in the code is lowercased and the file name is lowercased.</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/558/1*voq16nolnxrtcRGr7UTKdQ.png" /><figcaption>Deployment One.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/556/1*FgWTBG3XRUJ-y9xN-ppIuA.png" /><figcaption>Deployment Two</figcaption></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ba54eb39b30a36fc99bb7549e18b66c9/href">https://medium.com/media/ba54eb39b30a36fc99bb7549e18b66c9/href</a></iframe><p>The command &lt;<em>kubectl apply -f [name of YAML file]&gt;</em> is commonly used to create or update resources like Deployments, Services, ConfigMaps, and more. For this exercise, we will use this command to create deployments 1 and 2 with two pods each.</p><pre># Create Deployments with Pods<br>kubectl apply -f [name of YAML file]<br><br># My code to create my Deployments with Pods<br>kubectl apply -f deployment1.yaml<br>kubectl apply -f deployment2.yaml<br><br># Verfiy that the Pods were created with the Deployments<br>kubectl get pods</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/569/1*l_DKcyQHLO1on4EAcxbEUg.png" /><figcaption>Deployment One has been created.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/583/1*x0otlyVy_CLhg2ZFJGjsEw.png" /><figcaption>Deployment Two has been created.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*pjCYBunMbo0NWivSpLGPMA.png" /><figcaption>Each deployment has 2 pods created!!!</figcaption></figure><h4>STEP 4: Create a service that points to both deployments.</h4><p>Now, create the service.yaml file, and input the code in the file that contains the correct configuration for the Service, including the correct selector to target the desired pods and the appropriate port mappings. Incorrect configurations may lead to issues with the network connectivity of your applications. In the CLI, input the command to list all the Services in the VSCode, and you should see the newly applied Service in the list. Always review the YAML file and test the Service after applying it to ensure it meets your requirements.</p><pre><br>vim service.yaml<br><br># Apply the Service <br>kubectl apply -f service.yaml<br><br>#Verify was Service created<br>kubectl get service</pre><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7e18db5d4282910bd273196c1a1e4ee0/href">https://medium.com/media/7e18db5d4282910bd273196c1a1e4ee0/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/546/1*yy5Eb8lHa3drYgorVZJX0Q.png" /><figcaption>Code to apply to Service</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/567/1*kCkcsNLvf-ymgOLI4SByjw.png" /><figcaption>The Service has been created and verified.</figcaption></figure><h4>STEP 4: Access both deployments using the same IP address and port number. Use the curl command to validate that you eventual see the index.html pages from both Deployment 1 and Deployment 2.</h4><p><strong><em>Note the example: curl service_ip_address:service_port</em></strong></p><p>Now, use the command <em>curl localhost:&lt;port number&gt;</em> to make a web request to a specific port on the local machine. Curl is a CLI tool commonly used to transfer data with URLs, and it supports various protocols like HTTP, HTTPS, FTP, and more. Make sure to replace <em>&lt;port number&gt;</em> with the actual port number you want to connect to. For example, if you want to make a request to port 80, you would use curl localhost:80.</p><pre># Curl to make a web request<br>Invoke-WebRequest -Uri http://localhost:&lt;port number&gt;<br><br>OR<br><br>curl -Uri http://localhost:&lt;port number&gt; <br><br>#My curl to make a web request to access web page. Use port 80 since that is the port that we used earlier for the project.<br>curl -Uri http://localhost:80<br><br>OR<br><br>Invoke-WebRequest -Uri http://localhost:80</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/951/1*l0Bo5ho08_sOmThGODC2QA.png" /><figcaption>Deployment One: First way to make web request</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/664/1*wtRk2p1JMkBY7JM9XxgS9A.png" /><figcaption>Deployment 1: Second way to make a web request</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/356/1*JVJCJFv4-68KN94Fvkyg8A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/1*IOsOWZKxfeeYq9xDivgoxg.png" /><figcaption>Deployment Two</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/365/1*SuD4Zzl2-wo2ru4fxdB8YQ.png" /></figure><p>Congratulations! You have completed the assignment!!!!</p><p><strong>STEP 5: Stop the Service and Kubernetes</strong></p><pre>kubectl delete deployments --all<br>kubectl delete services --all</pre><p>See you next time!!!!!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/360/0*tvWS-7JXmiZH8HtG.jpg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b730cb667b06" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Whale of a Tale: Creating A Docker Swarm in AWS & Deploying it through Various Tiered…]]></title>
            <link>https://medium.com/@antramecalmathis/week-17-project-using-aws-to-create-a-docker-swarm-that-consists-of-one-manager-and-three-worker-124a32fedb92?source=rss-c914038d4ace------2</link>
            <guid isPermaLink="false">https://medium.com/p/124a32fedb92</guid>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[docker-swarm]]></category>
            <category><![CDATA[cli]]></category>
            <dc:creator><![CDATA[Antrameca  Mathis ( Ann-Trah-Mee-Kah)]]></dc:creator>
            <pubDate>Wed, 05 Jul 2023 04:59:38 GMT</pubDate>
            <atom:updated>2023-07-05T05:13:11.551Z</atom:updated>
            <content:encoded><![CDATA[<h3>A Whale of a Tale: Creating A Docker Swarm in AWS &amp; Deploying it through Various Tiered Architectures</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/839/0*oCpw8pCkDxZpTVuO.png" /></figure><p>Week 17 Project: Using AWS to create a Docker Swarm that consists of one manager and three worker nodes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/356/1*_Fdhu_A3VYBnpv6Vu7TppA.png" /></figure><p>Verify the cluster is working by deploying the following tiered architecture:</p><ol><li>A service based on the Redis docker image with 4 replicas</li></ol><p>2. A service based on the Apache docker image with 10 replicas</p><p>3. A service based on the Postgres docker image with 1 replica</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/324/1*Whqe2fvMFLYRPp3L7wZs_A.png" /></figure><ul><li>AWS account</li><li>Basic knowledge of Docker</li><li>Docker Hub account</li><li>· Basic knowlegde of AWS</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/274/1*xVqVIDq-IMVyVwTprbum4A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/377/1*atRmYDbdIEciIZucKJAwtg.png" /></figure><p><strong><em>APACHE: </em></strong>Apache, an open-source Web server released in 1995. By the early 2020s, Apache servers deployed about 30 percent of the Internet’s content, second only to Nginx. As a Web server, Apache is responsible for accepting directory (HTTP) requests from Internet users and sending them their desired information in the form of files and Web pages. Much of the Web’s software and code is designed to work along with Apache’s features. Apache also has a safe and secure file-sharing feature, allowing users to put files into the root directory of their Apache software and share them with other users. <a href="https://www.britannica.com/technology/Apache-Web-server">Link</a></p><p><strong><em>DOCKER SWARM: </em></strong>A container orchestration tool running the Docker application. It has been configured to join together in a cluster. The activities of the cluster are controlled by a swarm manager, and machines that have joined the cluster are referred to as nodes. Docker Swarm has two types of services: replicated and global.</p><ul><li><strong><em>Replicated services</em></strong>: Swarm mode replicated services functions based on a specified number of replica tasks for the swarm manager to assign to available nodes.</li><li><strong><em>Global services</em></strong>: Global services function by using the swam manager to schedule one task to each available node that meets the services constraints and resource requirements. <a href="https://www.sumologic.com/glossary/docker-swarm/#:~:text=with%20Sumo%20Logic-,What%20is%20a%20Docker%20Swarm%3F,are%20referred%20to%20as%20nodes.">Link</a></li></ul><p><strong><em>DOCKER SWARM NODES:</em></strong> A Docker Swarm is comprised of a group of physical or virtual machines operating in a cluster. When a machine joins the cluster, it becomes a node in that swarm. In a Docker Swarm, there are typically several worker nodes and at least one manager node that is responsible for handling the worker nodes’ resources efficiently and ensuring that the cluster operates efficiently. Docker Swarm’s load balancer runs on every node and is capable of balancing load requests across multiple containers and hosts.<br>The docker swarm function recognizes three different types of nodes, each with a different role within the docker swarm ecosystem:</p><ul><li><strong><em>MANAGER NODE: </em></strong>The primary function of manager nodes is to assign tasks to worker nodes in the swarm. Manager nodes also help to carry out some of the managerial tasks needed to operate the swarm. Docker recommends a maximum of seven manager nodes for a swarm.</li><li><strong>WORKER NODE: </strong>In a docker swarm with numerous hosts, each worker node functions by receiving and executing the tasks that are allocated to it by manager nodes. By default, all manager modes are also worker nodes and are capable of executing tasks when they have the resources available to do so. <a href="https://www.sumologic.com/glossary/docker-swarm/#:~:text=with%20Sumo%20Logic-,What%20is%20a%20Docker%20Swarm%3F,are%20referred%20to%20as%20nodes.">Link</a></li></ul><p><strong><em>Postgres</em></strong>: Commonly referred to “<a href="https://hub.docker.com/_/postgres">Postgre</a>SOL”, is an open source relational database that supports both SQL (relational) and JSON (non-relational) querying. It is a highly stable database management <a href="https://aws.amazon.com/rds/postgresql/">system</a>. PostgreSQL is used as the primary data store or data warehouse for many web, mobile, geospatial, and analytics applications. As a database server, its primary function is to store data, securely and supporting best practices, and retrieve it later, as requested by other software applications, be it those on the same computer or those running on another computer across a network (including the Internet). It can handle workloads ranging from small single-machine applications to large Internet-facing applications with many concurrent users. <a href="https://hub.docker.com/_/postgres">Link</a></p><p><strong><em>REDIS: </em></strong>An open source (BSD licensed), in-memory data structure store used as a database, cache, message broker, and streaming engine. Redis provides data structures such as strings, hashes, lists, sets, sorted sets with range queries, bitmaps, hyperloglogs, geospatial indexes, and streams. Redis has built-in replication, Lua scripting, LRU eviction, transactions, and different levels of on-disk persistence, and provides high availability via Redis Sentinel and automatic partitioning with Redis Cluster. <a href="https://redis.io/docs/about/">Link</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*Z66pXTerRAUbgW1G.png" /></figure><h3><strong>Step 1: Create Security Group for Manager Node in AWS.</strong></h3><p><strong>I. Create the manager Security group: </strong>On EC2 console, click<em> EC2 — Security Groups — Create security group</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/677/1*u-9IQ9hJk9R-ojk5b_Z2JQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/292/1*lvdUsA3kuHZSNit-fNorNw.png" /></figure><p>On security group page, make sure to put “manager” in the security group’s name to identify the group separate from the worker security group. Use default VPC.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/677/1*kSh7UaVzewzyEQWs_jqq0w.png" /></figure><p><strong>II. Create Inbound Rules:</strong></p><p>Inbound Traffic for Swarm Management utilizing firewall ports (<a href="https://www.bretfisher.com/docker-swarm-firewall-ports/">Link</a>):</p><ul><li><em>TCP port 2377 for cluster management &amp; raft sync communications; communication with and between manager nodes.</em></li><li><em>TCP and UDP port 7946 for “control plane” gossip discovery communication between all nodes; for overlay network node discovery.</em></li><li><em>UDP port 4789 for “data plane” VXLAN overlay network traffic; </em>configurable.</li><li><em>IP Protocol 50 (ESP) if you plan on using overlay network with the encryption option.</em></li></ul><p><strong>Note</strong>: Make sure that the Source is IPv4 for all ports.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*o_TbuxRjM-v4gQ3unrlxfQ.png" /></figure><p>Click <em>create security group.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/256/1*3bCAMasT5BAylcm9MyM7hw.png" /></figure><h3>Step 2: Create a Security Group for Worker Nodes in AWS.</h3><p><strong>Create the Worker Security group: </strong>On EC2 console, click <em>EC2 — Security Groups — Create security group</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*lvdUsA3kuHZSNit-fNorNw.png" /></figure><p>On security group page, make sure to put “worker” in the security group’s name to identify the group separate from the manager security group. Use default VPC.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/638/1*pOIJrIKZzo4EJod-IWg5zg.png" /></figure><p><strong>II. Create Inbound Rules:</strong></p><p>Regarding the Inbound Rules, the Security Group for the worker nodes will include all of the same firewall ports, except for the TCP 2377 port, because the TCP 2377 port is reserved for communication with and between manager nodes.</p><p><strong>Note</strong>: Make sure that the Source is IPv4 for all ports.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*meO-LDUyqlX7EHL1Sj8leg.png" /></figure><p>Click <em>create security group.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*3bCAMasT5BAylcm9MyM7hw.png" /></figure><p>Security groups for both the manager and worker nodes have been created!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/370/1*Hlq--0ewryxNLIXRK0rzaA.png" /></figure><h3>STEP 3: Create an Instance for the Manager Node.</h3><p>On the EC2 console click <em>launch instances</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/745/1*cCwXwktzemc5rDVrGiaKDw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/829/1*1ZUgxwujWyOV8HGCd2UfGw.png" /><figcaption>Name the instance and include the name “manager” to identify the instance.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/691/1*qT8Z12MAK0ZCVyDykZtBRA.png" /><figcaption>Choose <strong>Amazon Linux</strong> which is free tier eligible.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/715/1*R9EiqU67tupzta4gAJ72rA.png" /><figcaption>For <strong>Instance type</strong>, choose <strong>t2.micro </strong>(free tier eligible) and create a <strong>key pair.</strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/692/1*GCcZfY68ezHLLzLLtpbVTw.png" /><figcaption>Under <strong>Network Setting</strong>, choose <strong>Select existing security group — manager_Wk17Project </strong>(the manager security group created for this project).</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/520/1*kBvaLGpb5Ax37AaeaFBiZg.png" /><figcaption>Under<strong> Advance Details</strong>, under <strong>User Data</strong>, input a <strong>bash script</strong> to bootstrap the instance to <strong>update the instance, install docker and automatically start docker</strong> at the launch of the instance.</figcaption></figure><pre>#!/bin/bash<br><br>sudo yum update -y<br><br>sudo yum install -y docker<br><br>sudo usermod -a -G docker ec2-user<br><br>sudo systemctl start docker.service<br><br>sudo systemctl enable docker.service<br><br>docker version<br><br>docker info</pre><p>Click <em>Launch instance</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/317/1*CovqfHUJP1iEzoel-LklWQ.png" /></figure><h3>STEP 4: Create Three Instances for the Worker Nodes.</h3><p>Repeat the process for instance creation, make sure to name each worker instance according to its number 1–3 and attached the “worker” security group created in this project. Keep the same key pair.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*cCwXwktzemc5rDVrGiaKDw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/819/1*gqNVkkRmObE77VTl3z7IIw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*qT8Z12MAK0ZCVyDykZtBRA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*R9EiqU67tupzta4gAJ72rA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/766/1*HA9KQ0pj7Y_HWWqLCY1XEQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*kBvaLGpb5Ax37AaeaFBiZg.png" /></figure><pre><br>#!/bin/bash<br><br>sudo yum update -y<br><br>sudo yum install -y docker<br><br>sudo usermod -a -G docker ec2-user<br><br>sudo systemctl start docker.service<br><br>sudo systemctl enable docker.service<br><br>docker version<br><br>docker info</pre><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*CovqfHUJP1iEzoel-LklWQ.png" /></figure><p>All 4 of the instances have been created: 1 for the Manager Node and 3 for the Worker Node.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m2quQ-sRrP9Fm2dngTHKHA.png" /></figure><p>All instances have successfully been created and bootstrapped for Docker!!!!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/259/0*LE84Zx3u_F1_BTrK" /></figure><h3>STEP 5: SSH in the Manager Instance.</h3><p>First,<em> cd </em>into the file that holds the key pair. Then, ssh into the Manager Instance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/993/1*tOiWJ3QXBbcj9xitkm31FA.png" /></figure><p>Check to make sure that Docker had been installed via the code that had been input into the user data.</p><pre>docker version</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/556/1*9PLGcbCTR1hJ9i3ZHd9oiw.png" /></figure><p>Switch to the root user by typing the command <em>sudo su </em>and then start the swarm by typing the command <em>docker swarm init</em>.</p><pre>sudo su<br>docker swarm init<br></pre><p>Copy the CLI line that contains the token and save it [press Ctrl + c]. You will use this command to connect each Worker Node to the Swarm/Cluster.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/495/1*xg2t6AvQuxS6nJgi25MHYg.png" /></figure><h3>STEP 6: SSH into Each Instance and use the Token from the Manager Node to Connect each Worker Node to the Swarm/Cluster.</h3><p><strong>Worker Node 1</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/276/1*tI1c0H0miWKs2qBLC0G_Lw.png" /></figure><p><strong>Worker Node 2</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/404/1*AamLkFNtXS6Uk5tysDH0BQ.png" /></figure><p><strong>Worker Node 3</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/404/1*AamLkFNtXS6Uk5tysDH0BQ.png" /></figure><p>Verify that each Worker Node has been joined to the Swarm and the Manager Node is the leader of the Swarm.</p><pre>docker node ls</pre><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*C9XS_qHpo3hQOEcR3p1iXg.png" /></figure><p>The Manager Node has successfully been created, and each Worker Node was successfully been joined to the Swarm.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/0*A-YcyyIUpG5anCzJ.gif" /></figure><h3>STEP 7: In the Manager Node, Verify the Cluster is Working by Deploying the Redis Tiered Architecture: A Service Based on the Redis docker Image with 4 Replicas.</h3><pre>docker service create --name redis --replicas 4 redis:latest</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/867/1*lpvJv5IdUNWpQW66JiNo9Q.png" /></figure><h3>STEP 8: In the Manager Node, Verify the Cluster is working by Deploying the Apache Tiered Architecture: A service based on the Apache Docker Image with 10 Replicas.</h3><pre>docker service create --name apache --replicas 10 httpd:latest</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/881/1*sSA-2xeNW26WL5D0mkVw-g.png" /></figure><h3>STEP 9: In the Manager Node, Verify the Cluster is Working by Deploying the Postgres Tiered Architecture: A Service Based on the Postgres Docker Image with 1 Replica.</h3><pre>docker service create --name postgres_service --replicas 1 -e POSTGRES_PASSWORD=mypasswd postgres</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/825/1*Td2qrWtc8bK6urC2yYlf3A.png" /></figure><h3>STEP 10: In the Manager Node, Verify that the Docker Containers are Running.</h3><pre>sudo docker container ps</pre><p>The command will display a table of information about the running containers, including details such as the container ID, image name, status, ports, and names.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/842/1*j8B07F5KBljJ_v0wwBg4gQ.png" /></figure><h3>STEP 11: In Each Node, Destroy its Connection with the Docker Swarm/Cluster.</h3><pre>docker swarm leave --force</pre><p>This command forcefully causes a node to leave a Docker swarm, regardless of its current state or role. The node immediately leaves the swarm. It will no longer participate in the swarm, and any running services or tasks on that node will be removed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/562/1*aXkIWRw1_s-Bgm4YBLyiAw.png" /></figure><h3>STEP 12: Stop the Instance in AWS.</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iN9YDbGb4FrOobpkWAEwHg.png" /></figure><p>Congratulations! You have successfully completed this week’s project!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/336/0*ZRPeVhJbavYPyfdO.gif" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*skIVcx_gZsOepVtO.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=124a32fedb92" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Whale of a Chance: Building Multiple Docker Containers and Connecting Each to a Different…]]></title>
            <link>https://medium.com/@antramecalmathis/whale-of-a-chance-building-multiple-docker-containers-and-connecting-each-to-a-different-6ce12f4cf768?source=rss-c914038d4ace------2</link>
            <guid isPermaLink="false">https://medium.com/p/6ce12f4cf768</guid>
            <category><![CDATA[cloud9]]></category>
            <category><![CDATA[bind]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[ide]]></category>
            <dc:creator><![CDATA[Antrameca  Mathis ( Ann-Trah-Mee-Kah)]]></dc:creator>
            <pubDate>Sun, 25 Jun 2023 05:56:54 GMT</pubDate>
            <atom:updated>2023-07-16T22:33:10.035Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/540/1*Wa1_qrrYAt47nfWWBEaThQ.png" /></figure><h3>Whale of a Chance: Building Multiple Docker Containers and Connecting Each to a Different Repository with a Bind Mount</h3><p>Hi Readers! We are working on the LUIT Week 16 Project where we will be focusing on containerization.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/0*nEIpG55lYW09JAjw.gif" /></figure><h3>SCENARIO:</h3><p>A software development team is working on a Python-based application. The team needs to simplify their development environment setup and ensure consistent execution of their code across different machines.</p><p>The team can create a Dockerfile for Boto3/Python that utilizes either the Ubuntu or Python official images available on Dockerhub. The Dockerfile can be customized to include any necessary libraries or dependencies required by the team’s Python application.</p><p>The team can then download three repositories to their local host and create three Ubuntu containers using the customized Dockerfile. Each container can be configured with a bind mount to one of the repo directories, allowing the team to easily access the code and make changes as needed.</p><p>Finally, team members can log into each container and verify access to each repo directory, ensuring that the containers have been properly configured and that the team can effectively collaborate on their codebase. By utilizing Docker, the team can also ensure that their development environment is portable and can be easily replicated on different machines, streamlining their workflow and enabling efficient collaboration.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*SQ861XU4LstHvfzV.gif" /></figure><h3>OJECTIVES:</h3><ul><li>Build docker file for Boto3 / Python</li><li>Use either the Ubuntu or Python official images on Dockerhub</li><li>Download any three repositories from GitHub to local host</li><li>Create three Ubuntu containers</li><li>Each container should have a bind mount to one of the repo directories</li><li>Log into each container and verify access to each repo directory</li></ul><h3>PREREQUISITES:</h3><ul><li>Laptop with internet access</li><li>Knowledge of AWS Cloud9</li><li>Knowledge of CLI</li><li>Github account</li><li>Knowledge of Docker</li><li>Docker Hub account</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/318/0*pLXykxvhRwIEdVEX.gif" /><figcaption>A school of Definitions😂</figcaption></figure><h3>DEFINITIONS:</h3><p><a href="https://docs.docker.com/get-started/overview/"><strong><em>Containers</em></strong></a><strong><em>:</em></strong> A runnable instance of an image. You can create, start, stop, move, or delete a container using the Docker API or CLI. By default, a container is relatively well isolated from other containers and its host machine. A container is defined by its image as well as any configuration options you provide to it when you create or start it. When a container is removed, any changes to its state that are not stored in persistent storage disappear.</p><p><a href="https://docs.docker.com/get-started/overview/"><strong><em>Docker</em></strong></a><strong><em>: </em></strong>An open platform for developing, shipping, and running applications. Docker enables you to separate your applications from your infrastructure so you can deliver software quickly. With Docker, you can manage your infrastructure in the same ways you manage your applications. By taking advantage of Docker’s methodologies for shipping, testing, and deploying code quickly, you can significantly reduce the delay between writing code and running it in production.</p><p><strong><em>Docker File</em></strong>: Allows the user to create their application images. This file describes the instructions that specify what environment to use and which commands to run to execute the user’s file. Additional resources can be found at this <a href="https://www.educative.io/answers/how-to-create-a-dockerfile-for-running-a-python-application">link</a>.</p><p><a href="https://docs.docker.com/get-started/06_bind_mounts/"><strong><em>Bind Mount</em></strong></a><strong><em>: </em></strong>A type of mount, which lets you share a directory from the host’s filesystem into the container. When working on an application, you can use a bind mount to mount source code into the container. The container sees the changes you make to the code immediately, as soon as you save a file. This means that you can run processes in the container that watch for filesystem changes and respond to them. When you use a bind mount, a file or directory on the <em>host machine</em> is mounted into a container. The file or directory is referenced by its absolute path on the host machine.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*21l3o8OEigKdaBvf.gif" /><figcaption>Let’s take one whale of a step at a time…</figcaption></figure><h4>STEP 1: Create three repositories in GitHub and create a Cloud9 environment in AWS. Create a directory in Cloud9 and Docker File for this week’s project. Download the three repositories from GitHub to local host.</h4><p>To create three repositories in GitHub, and a Cloud9 environment click this <a href="https://medium.com/@antramecalmathis/constructing-a-foundation-for-automation-using-terraform-to-create-a-jenkins-server-on-an-ec2-28e2b9b473a2">link</a> and follow <strong><em>STEP 1</em></strong> &amp; <strong><em>STEP 2</em></strong>.</p><p>To create the directory in Cloud9 for this week’s project type <em>mkdir (name of directory). </em>Then, to load into the directory, type <em>cd (name of directory).</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/536/1*V2Q1XQUrPZaNy9g7tRhT4A.png" /></figure><p>To create a Docker file in the new directory, create a file with the name, Dockerfile, without any extension.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/469/1*-5GkpUYtLAUZmNMcpNKI_g.png" /></figure><p>The file has successfully been created.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/241/1*MjbqsWO4EEKbacdrAsVGwA.png" /></figure><p>To download the three repositories from GitHub to Cloud9 local host directory that you have created for this project, click the green <em>code </em>button and copy the HTTPS code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*4dea19Uw0hR6h31NLcfT_g.png" /></figure><p>In Cloud9 on the CLI, type<em> git clone</em> &lt;<em>Github_Repo_URL</em>&gt;. Repeat the process for the other two repositories.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*0iETkRLNEo1b-JJszQs_cg.png" /></figure><p>Verify that they respository have successfully been cloned into the Cloud9 directory, type <em>ls -1.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/674/1*NfE86wdpPDHse7CTlnHFQg.png" /></figure><p>The repositories have successfully been cloned into this project’s directory.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/271/1*vo1DZP2rU0GljWi73V5f3g.png" /></figure><p>Next, you must create a new branch in Cloud9, because you never want to commit to the main branch. In Cloud9 click <em>main — create new branch — </em>type the name of the new branch in the CLI above — press <em>enter. </em>The name of the branch will change at the bottom of the screen.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*lLXBa0iZxsCKtwmYvu8quw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*2lBmANiqg-Pf_ydWljOVZw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*9RYeBnDrdAWgEweO8vVvrA.png" /></figure><h4><strong>STEP 2: Install Docker into Cloud9 Environment</strong></h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b8b4662036582c7b121078fc4a8db4ba/href">https://medium.com/media/b8b4662036582c7b121078fc4a8db4ba/href</a></iframe><p>Check the docker version, type <em>docker version. </em>Below are the results for Docker Installation and version check:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*I5cL2f3f9GRoAD5h7EODhg.gif" /></figure><h4>STEP 3: Build a Docker file for Boto3/Python. Use either the Ubuntu or Python official images on Dockerhub. (We are using Python for this project)</h4><p>There are four <a href="https://www.educative.io/answers/how-to-create-a-dockerfile-for-running-a-python-application"><em>ACTIONS</em> to take to dockerize any application:</a></p><p><em>Action 1</em>: Create the docker file [<em>Completed in Step 1 of this project</em>]</p><p><em>Action 2</em>: Create the desired application to dockerize</p><p>Search Docker Hub for Python.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1020/1*7RRaeu2LRSYhGA9ZAeSrQg.png" /></figure><p>Here is the<a href="https://hub.docker.com/_/python"> link</a> for the Docker Hub webpage that contains the code. Make sure to modify the code to suit your coding needs. Docker file format requires <strong>FROM</strong>, <strong>RUN, </strong>and <strong>CMD</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/681/1*WTeVDoV1MzUYqpwq46mQpw.png" /></figure><p><strong><em>DOCKER FILE FORMAT</em></strong>: Docker file must begin with a FROM instruction. The <strong>FROM</strong> instruction initializes a new build stage and sets the Base Image for subsequent instructions. The<strong> RUN</strong> instruction will execute any commands in a new layer on top of the current image and commit the results. The resulting committed image will be used for the next step in the Dockerfile. There can only be one <strong>CMD </strong>instruction in a Dockerfile. If you list more than one <strong>CMD</strong> then only the last<strong> CMD</strong> will take effect. The main purpose of a <strong>CMD </strong>is to provide defaults for an executing container. These defaults can include an executable, or they can omit the executable, in which case you must specify an ENTRYPOINT instruction as well. For this project, we are using an executable CMD. <a href="https://docs.docker.com/engine/reference/builder/">Info Link</a></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d09608c82dfe9c58cc8a764d3e5cee24/href">https://medium.com/media/d09608c82dfe9c58cc8a764d3e5cee24/href</a></iframe><p><strong>NOTE</strong>: Make sure to save your code in CLoud9. I continuously forget to complete this step which causes errors when running CLI commands.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/439/1*55eLkjW7eh3MPQoaR3s2iA.png" /></figure><p><em>Action 3</em>: Build an image using the docker file.</p><p>Type <em>docker build -t (image name) .</em></p><p><strong>Note</strong>: Make sure to include the period “.” in your command.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*jPKR9Unljg5Te9Tnzv6VTw.gif" /></figure><p><em>Action 4</em>: Run the image</p><p>Verify that the image works, type <em>docker images.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/481/1*q054zE_L8fsVE6Sijik71A.png" /></figure><h4>STEP 4: Create three Ubuntu containers with each container having a bind mount to one of the repository (repo) directories.</h4><p>Prior to creating the containers with bind mounts, you must first log into your Docker Hub account via the CLI in Cloud9. Make sure that you are in the correct directory. The <em>docker login</em> command will prompt you to give your username and password.</p><pre>docker login</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/631/1*ciWUCJ4eEqnvRoVoNdKqSw.png" /></figure><p>Now, to create each container with a bind mount for this project, we will use a single docker run command with the bind mount and modify the command for each container.</p><pre>docker run -dt --name &lt;container_name&gt; -v &quot;$(pwd)&quot;/&lt;repo_name&gt;:/&lt;dir_name&gt; &lt;image_name&gt;</pre><p>Explanation the modified command:</p><ul><li>-dt: The -d flag runs the container in detached mode (in the background), and the -t flag allocates a pseudo-TTY for interaction.</li><li>--name &lt;container_name&gt;: Specifies the desired name for the container.</li><li>-v &quot;$(pwd)&quot;/&lt;repo_name&gt;:/&lt;dir_name&gt;: Mounts the local directory, represented by $(pwd) (the current working directory), followed by &lt;repo_name&gt;, to the container&#39;s &lt;dir_name&gt;.</li><li>&lt;image_name&gt;: Refers to the name of the Docker image you want to run.</li></ul><p><em>Make sure to replace </em><em>&lt;container_name&gt; with the desired name for your container, </em><em>&lt;repo_name&gt; with the name of your local directory/repository, </em><em>&lt;dir_name&gt; with the desired directory path inside the container, and </em><em>&lt;image_name&gt; with the name of the Docker image you wish to run.</em></p><p>This modified command will create and start a Docker container with the specified bind mount. The contents of the local directory/repository will be accessible inside the container at the specified mount point, and any changes made in either location will be synchronized.</p><p>For my codes, <em>&lt;container_name&gt; </em>is the name I created for each container. I kept it simple container1, container2 and container3. My<em>&lt;repo_name&gt; </em>is for each repo that I cloned from Git Hub. My <em>&lt;dir_name≥</em>is ProjectWk16, which I created in Cloud9 in STEP 1 of this project. <em>The </em><em>&lt;image_name&gt;</em> is the image created earlier in this project in STEP 3.</p><pre>docker run -dt --name container1 -v &quot;$(pwd)&quot;/Wk16DockerProject1:/ProjectWk16 wk16_project<br><br>docker run -dt --name container2 -v &quot;$(pwd)&quot;/Wk16DockerProject2:/ProjectWk16 wk16_project<br><br>docker run -dt --name container3 -v &quot;$(pwd)&quot;/Wk16DockerProject3:/ProjectWk16 wk16_project</pre><p>We have successfully created the containers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/592/1*hAXZ37LrtDTUGTiMwpF1Yg.png" /></figure><p>Verify that the containers run.</p><pre>docker container ps</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mem7qeGr78_gH2hMQ3bozg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/495/1*owtiJOs1JzEPWvQne_mLFQ.png" /><figcaption>We are almost to the goal!!!!</figcaption></figure><h4>STEP 5: Verify that each container has a bind mount to one of the repository (repo) directories. Log into each container and verify access to each repo directory.</h4><p>To verify that each container has a bind mount to one of the repository (repo) directories.</p><pre>docker container inspect &lt;Container_Name&gt;</pre><p>container1</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/667/1*55bdjFCJwviYKsi2AOnqdw.png" /></figure><p>container2</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/677/1*sNpS_ODgfrob_hJ_bs0Qng.png" /></figure><p>container3</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/667/1*NrUTHEQbndYzNy3Zgg0FTA.png" /></figure><p>The docker exec command allows you to run a command inside a running Docker container. Replace &lt;container_name_or_id&gt; with the name or ID of the container you want to access. This command starts an interactive shell session (bash) within the specified container.</p><p>You should see <strong>root @</strong> after running each command. This indicates that you are in the shell prompt inside the container, where you can run commands and interact with the container’s environment.</p><p>Then, type <em>ls </em>to display the content of each container and then type <em>exit</em> to exit the container.</p><pre>docker exec -it &lt;container_name_or_id&gt; bash</pre><pre>ls</pre><pre>exit</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/623/1*qv2vG2ZSskqLmxBQ1nyXVg.png" /></figure><h4>STEP 6: Push each repo to GitHub. Merge the branch to the main branch in GitHub. (optional)</h4><p>For each repository, right click and select <em>create a new branch. </em>Type the branch name on the line above and press <em>enter</em>. When you cd into each repository, you will see the branch name in ().</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/673/1*NL_vS7d5MHK3muUx_CMT_A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/702/1*2UvoqnnUVCrHELsxSPGdlg.png" /></figure><p>Although there is not anything to push to Git Hub, I find it very satisfying to perform the process in Cloud9 and stay in the habit.</p><pre>cd &lt;name of one of the repos&gt;<br>git push --set-upstream origin &lt;Name of one of the repos&gt;<br>&lt;Git Hub username&gt;<br>&lt;Git Hub password&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*mveT0Yj7I_83sI01PnaYng.gif" /></figure><p>Since there is nothing to commit, there is nothing in the branches to merge to the <em>main</em> branch in Git Hub.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/954/1*UiYbjc4OLgUAvG6Yb21eqQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*HqHk1V3WYPY_D-R_y0I9oA.png" /></figure><h4><strong>STEP 7: Stop and Destroy the containers.</strong></h4><pre><br># Stop running the containers. Enter multiple by entering a space between each name. <br>docker container stop &lt;container_name or container_ID&gt;<br><br># Verify that the containers have stopped. The status should indicate &quot;Exited&quot;<br>docker container ls -a</pre><p>Containers have stopped.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0ahGp4brmECQeNaCnAAo6A.png" /></figure><p>Destroy/ delete the containers.</p><pre># Destroy/ delete all of the containers.<br>docker container prune<br><br># Verify that the containers no longer exist.<br>docker container ls -a</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/722/1*5KnGeyipqdOocRoARpFLjg.png" /></figure><p>The containers are nonexistent.</p><p>Congratulations!!! You have successfully completed this project!! What a whale of a time😁!!!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/0*UrhWJQWVBkqdGxj8.gif" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6ce12f4cf768" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Constructing a Foundation for Automation: Using Terraform to Create a Jenkins Server on an EC2…]]></title>
            <link>https://medium.com/@antramecalmathis/constructing-a-foundation-for-automation-using-terraform-to-create-a-jenkins-server-on-an-ec2-28e2b9b473a2?source=rss-c914038d4ace------2</link>
            <guid isPermaLink="false">https://medium.com/p/28e2b9b473a2</guid>
            <category><![CDATA[terraform]]></category>
            <category><![CDATA[cloud9]]></category>
            <category><![CDATA[jenkins-pipeline]]></category>
            <category><![CDATA[jenkins]]></category>
            <dc:creator><![CDATA[Antrameca  Mathis ( Ann-Trah-Mee-Kah)]]></dc:creator>
            <pubDate>Tue, 13 Jun 2023 08:05:52 GMT</pubDate>
            <atom:updated>2023-07-17T03:27:27.580Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*PlzGZGZ6P2RHn1eH4rESYQ.png" /></figure><h3>Constructing a Foundation for Automation: Using Terraform to Create a Jenkins Server on an EC2 Instance</h3><p>I am very excited to get back to DevOps (Software Development and Operations). Today, we have an awesome Week 20 Project scenario with objectives to accomplish!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_C229kNHrLID-ST8g9Ao_g.gif" /></figure><p><strong>SCENARIO:</strong> 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 <a href="http://main.tf/">main.tf</a> 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><p><strong>OBJECTIVE 1:</strong> Deploy one EC2 Instances in your Default VPC.</p><p><strong>OBJECTIVE 2:</strong> 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/">Information Link</a></p><p><strong>OBJECTIVE 3:</strong> Create and assign a Security Group to the Jenkins Security Group that allows traffic on port 22 from the IP and allows traffic from port 8080.</p><p><strong>OBJECTIVE 4: </strong>Create a S3 bucket for the Jenkins Artifacts that is not open to the public.</p><p><strong>OBJECTIVE 5: </strong>Verify that you can reach that Jenkins install via port 8080 in the browser. Be sure to include a screenshot of the Jenkins login screen in the documentation.</p><p><strong>NOTE:</strong> Push the code to GitHub and include the link in the write up.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1hT23VteSYhRbOaUtCcuEg.gif" /></figure><h3>DEFINITIONS:</h3><p><strong>JENKINS</strong> is a platform for creating a Continuous Integration/Continuous Delivery (CI/CD) environment. The system offers many different tools, languages, and automation tasks to aid in pipeline creation when developing and deploying programs. Jenkins is an automation server written in Java that helps build, test, and continually deploy software. The open-source system is currently one of the leading automation servers.</p><p><strong>CI/CD PIPELINE </strong>(Continuous Integration and Continuous Deployment) pipeline is a series of steps that must be performed in order to deliver a new version of software. CI/CD pipelines improve software delivery throughout the software development life cycle via automation. By automating CI/CD throughout development, testing, production, and monitoring phases of the software development lifecycle, organizations are able to develop higher quality code, faster. <a href="https://www.redhat.com/en/topics/devops/what-cicd-pipeline">Information Link</a></p><p><strong>BOOTSTRAPPING in AWS </strong>means to execute some commands during boot up(launch). Execution can easily occur by loading script in user data section during EC2 launch. Bootstrap scripts run only once — when the instance is instantiated for the 1st time. <a href="https://www.coachdevops.com/2022/09/how-to-setup-jenkins-using-bootstrap.html">Information Link</a></p><p><strong>TERRAFORM</strong> is an infrastructure as code (IAC) tool that allows users to automate various infrastructure tasks. It also allows users to define both cloud and on-premises resources in human-readable configuration files that users can version, reuse, and share. Users can then use a consistent workflow to provision and manage all infrastructure throughout its lifecycle. <a href="https://developer.hashicorp.com/terraform/intro">Information Link</a></p><p><strong>IAC </strong>allows developers to codify infrastructure in a way that makes provisioning automated, faster, and repeatable. It’s a key component of Agile and DevOps practices such as version control, continuous integration, and continuous deployment. <a href="https://www.ibm.com/topics/terraform">Information Link</a></p><p><strong>AMI, </strong>Amazon Machine Image, is a template for Amazon EC2 instances, created from an Amazon EC2 instance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*19ieCc7swyCxUNt_Qs2dMQ.gif" /></figure><h3>PREREQUISITES:</h3><ul><li>AWS Account with IAM Role</li><li>GitHub Account</li><li>Basic Knowledge of Jenkins Server</li><li>Basic Knowledge of Terraform</li><li>Knowledge of EC2 Instances</li><li>Basic Knowledge of Cloud9</li></ul><figure><img alt="LET’S GET STARTED!!!" src="https://cdn-images-1.medium.com/max/500/1*VTJI3TX1m9Ray4tyCEphuw.gif" /><figcaption><strong>LET’S GET STARTED!!!</strong></figcaption></figure><h4><strong>STEP 1: In GitHub, Create a New Public Repository, a New Branch Protection Rule &amp; a New Token for this Project.</strong></h4><p>You will need to <strong><em>create a new repository (repo) </em></strong>in which to save your Terraform Project. To create a new public GitHub Repository, select the “+” sign — Select New repository — Under repository name, name the repository and give it a description — select Public — Under Add.gitignore Terraform — Create repository.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/653/1*biVemgacOPo1lMmi-lTR1g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WXx7SjkYvjAk1s9TfdWVLw.png" /></figure><p>You will need to <strong><em>add branch protection </em></strong>for your new repository’s branches in order to protect your branch(es) from unwanted changes by others and your own mistakes.</p><p>Click <em>Settings </em>— Click<em> Branches i</em>n left column — Click <em>Add branch protection rule</em> — The name of the branch pattern is “main” — see the boxes to check below — Click <em>create</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/592/1*dZQdgrxyH4ydbwfFokEpDA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/598/1*A5_QpCoh-wgF1KotWnWjDw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*fQEaEBybcV6AZDBTjKnsUQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/577/1*GShsVm_bNH5b8qWdY_wC_A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/636/1*7Eafob6bidOnl04OtmU1ag.png" /></figure><p>You need to <strong><em>create a new token </em></strong><em>to protect your account and work. Make sure to save your token as your may need it, again. These tokens are account specific and not repo specific.</em></p><p>From the main selection panel, select Settings — In left column, select Developer <em>settings</em> — In the left column, under Personal access tokens, click <em>Tokens (classic)</em> — Click Generate token — Click <em>Generate new token (classic) </em>— For new Personal access tokens (classic), under Note, <em>enter a name for the token —</em> Select a<em> number expiration days</em> — Click <em>repo</em> — Click <em>Generate token</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/206/1*gcPSiH0oxND-v8GnCJZ_mw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/241/1*wPrBGgatprxfpRmmP7G2PQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/412/1*lzzGcBQ03b1EyjGPlyhwGw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/636/1*tk9aWjD3gAzf-yaAv0NSlA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/613/1*5FR4a9SHvOI1UzG2ELGkmA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/308/1*Ili_M69f4R10dHJuk50SeQ.png" /></figure><p><strong>REMEMBER TO SAVE YOUR PASSWORD!!! YOU WILL NOT SEE IT AGAIN!!!</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*w_OS290O_1t9s-Wvvjq6Zg.gif" /></figure><h4>STEP 2: Create a new CLOUD9 IDE.</h4><p>Now, let’s create a new Cloud 9 environment. In AWS, type <em>Cloud9</em> in the CLI — Click <em>Create environment</em> — On the Create environment page, in the Details Section, under Name<em> enter a name for your new environment</em> — Under Description, <em>enter a description</em> — Under Environment type, click <em>New EC2 instance</em> — In the New EC2 Instance section, under Instance type click <em>t2.micro</em> — Under Platform select the <em>Amazon Linux 2</em> — Under Timeout, select <em>30 minutes </em>— In the Network Settings section, under Connections click <em>AWS Systems Manager (SSM</em>) — Under Amazon VPC, select the <em>default VPC — </em>Click <em>Create</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/513/1*ajEUBasCF1WLkmqH5KeBHA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/688/1*a_EY58UfPANF4S7Rqb1B1g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/678/1*Jon3JNro9ZZbkpUYqk5gZQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/889/1*q5E-XV8eEkh83mtwQXeHeQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/212/1*7-pApWtzNpLFPqnmjS9q_A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1023/1*_2BOweVgIP04U5eb0iUH2g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/574/1*ZiZbjn-b9q_wVAM7hyg9TA.png" /></figure><h4><strong>STEP 3: Create a New Directory in Cloud9 and several Terraform files for this project.</strong></h4><p>Below is the code for creating the new directory:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2747100dfbc9be52475a2a090a9bcb94/href">https://medium.com/media/2747100dfbc9be52475a2a090a9bcb94/href</a></iframe><p>In the new directory, create new folders with the <strong>.tf </strong>and .<strong>sh </strong><em>extensions.</em></p><h4>STEP 4: Deploy a New EC2 Instance in the Default VPC. Bootstrap the EC2 Instance with a Script that will Install and Start Jenkins.</h4><p>In the <strong>main.tf</strong> file — <em>Install Terraform</em> <em>(If you need to install Terraform)</em>— <em>Configure the AWS Provider </em>— <em>Create an EC2 instance in Cloud9 using Terraform</em></p><p><strong>NOTE:</strong> I retrieve my AMI by pseudo-launching an instance and grabbing the AMI. I did not complete the process of launching the instance, I just clicked into the process to grab the AMI, then I cancelled the process.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cc5f9c37ab0a4d2e95d9db86cede81df/href">https://medium.com/media/cc5f9c37ab0a4d2e95d9db86cede81df/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/451/1*JRjpq7FG67SiKAGKxL3FuQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*ooafwnh2Z1Y1tNbJlS248g.png" /></figure><p><strong>main.tf</strong> folder — <em>Bootstrap the EC2 instance with a script that will install and start Jenkins</em></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a7ae59b90f946de83024950ba4d81f87/href">https://medium.com/media/a7ae59b90f946de83024950ba4d81f87/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/637/1*yTunkNyGCNr_GwXnCb5S_g.png" /></figure><h4>STEP 5: Create and Assign a Security Group to the Jenkins Security Group that allows Traffic on Port 22 from the IP and allows traffic from Port 8080.</h4><p><strong>main.tf</strong> folder — <em>Create and assign a security group to the Jenkins EC2 instance that allows traffic on port 22 from your IP address and allows traffic from port 8080. Input your VPC in this script.</em></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/040527aaf9da32887985550329700792/href">https://medium.com/media/040527aaf9da32887985550329700792/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/352/1*36DcH_P-d3LYT7cFOAW18g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/274/1*8U4LMEu0T1_1JTgyWe4NmA.png" /></figure><h4>STEP 6: Create an S3 Bucket for the Jenkins Artifacts that is not open to the public.</h4><p><strong>main.tf </strong>—<em> Create Terraform configuration to create an S3 bucket for Jenkins Artifacts that is not open to the public</em></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e057fd45e0c53262d46e0da1a368469c/href">https://medium.com/media/e057fd45e0c53262d46e0da1a368469c/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/401/1*wHWehJuCjtivuZj70dIVEA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/276/1*eFdQ6o2ExYHn7crGn3hydw.png" /></figure><h4><strong>STEP 7: Verify that the Jenkins Install is reachable via Port 8080 in the browser. Include a screenshot of the Jenkins login screen in the documentation.</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*5WNGDa6B0K6-4vXe.png" /></figure><p><strong>Write</strong> —Stage to create changes to the code. (Not in illustration)</p><p><strong>Init</strong> —Stage to initialize the code to download the requirements mentioned in your code. Type t<em>erraform Init</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*ot2DKIFsYS0bl8r0TrS8lA.png" /></figure><p>Validate- Stage to validate the configuration files in a directory, referring only to the configuration and not accessing any remote services. Type t<em>erraform validate</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/334/1*9OCSV1vkuDZTvs3ylrwvvA.png" /></figure><p><strong>Plan</strong> — Stage to review changes and choose whether to accept the changes. Type <em>terraform plan</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/485/1*ie_WXoB9z5QKt2yzw2QuzQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/375/1*wIRIgdy0Zh-vXoY-kAMURg.png" /></figure><p>Type <em>terraform fmt</em> this command is used to rewrite Terraform configuration files to a canonical format and style</p><p>Type <em>terraform plan -out=myplan.out</em><br>The “-out” option in Terraform is used to save a generated execution plan to a file. This allows you to apply the plan at a later time or share it with others. To use this option, simply include the “-out” flag followed by the filename where you want to save the plan. For example, “terraform plan -out=myplan.out” will save the generated plan to a file named “myplan.out”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/946/1*j0v1bv_hZYUsG5BoLN-V5A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/949/1*D4tRfDQ29MerhO9xJhJHAA.png" /></figure><p><strong>Apply</strong> — Stage to accept changes and apply the changes against real infrastructure. Type terraform a<em>pply</em></p><p>Verify Jenkins install IS REACHABLE via port 8080 in your browser. Enter the command below to reach your Jenkins server.</p><p><a href="http://myipaddress:8080/">http://myipaddress:8080</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gYesVutCknmhh0f1mhOHDg.png" /></figure><p><strong>Destroy</strong> — Stage to destroy all created infrastructure. Type <em>terraform destroy.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/537/1*3cArcVNrxX2t8wqdPqVMHg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/344/1*1N8XCo3Pz-hntV6ZlZA0iw.png" /></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/90ad3581dd3eafaed103897e95102f9f/href">https://medium.com/media/90ad3581dd3eafaed103897e95102f9f/href</a></iframe><h4>STEP 7: Push to code to GitHub Account and include the link in the write up.</h4><p>Create a branch. I like to use the date that I initiate a project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/309/1*AwhzAXypo802tvGYTQo5lg.png" /></figure><pre># Clone GitHub Repository and then cd into the repo.<br><br>git clone &lt;git hub http&gt;<br><br># Commit the Repo to the branch and then cd into the branch. <br><br>cd &lt;Repo name&gt;<br></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/739/1*KXiJGvqWDmQK1Eh2TYwhOg.png" /></figure><pre># Check Status files to be committed<br>git status</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/694/1*8BV1yyxf8kF7dv8HXauVng.png" /></figure><pre>Add files to the repo and check status again after you have committed. Files should be green.<br>git add .<br>git status</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/636/1*dx_i7xsy-z8hyj3bafUksw.png" /></figure><pre># To commit files<br>git commit -m &quot;Give a description&quot;<br></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/818/1*x0iyzaQfql0Hgfy41MpqqQ.png" /><figcaption><strong>You will have to give your username and email for this action.</strong></figcaption></figure><pre># To push to file GitHub repo that was cloned<br>git push origin<br><br>or <br><br>git push &lt;repo http&gt;<br></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/665/1*zD68_Hi7tqz3LayxRPbSVA.png" /></figure><p>In GitHub, commit the new changes to the <em>main branch.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aacF0HLbVKRSDDFM8lRHKA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/898/1*rJyRfZ4do3-CF-kyEyUtaQ.png" /></figure><p>Merger branches then deleted the branch. Keep the main branch.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/909/1*dfaoJEAq11ZNxtqUduAuVg.png" /></figure><p>My<a href="https://github.com/almathis81/TerraformProjects"> GITHUB link</a> to this project.</p><h3>Congratulations!</h3><p>You have successfully created a Jenkins Server on an EC2 Instance using Terraform and pushed the code to your GitHub Account!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*m1RPi2GoQuVuSy8LVs7jfg.gif" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=28e2b9b473a2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Send a Message to the SQS Queue through Lambda with an API Gateway]]></title>
            <link>https://medium.com/@antramecalmathis/send-a-message-to-the-sqs-queue-through-lambda-with-an-api-gateway-9ce6095812e2?source=rss-c914038d4ace------2</link>
            <guid isPermaLink="false">https://medium.com/p/9ce6095812e2</guid>
            <category><![CDATA[api-gateway]]></category>
            <category><![CDATA[lambda]]></category>
            <category><![CDATA[sqs]]></category>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[lambda-function]]></category>
            <dc:creator><![CDATA[Antrameca  Mathis ( Ann-Trah-Mee-Kah)]]></dc:creator>
            <pubDate>Sun, 28 May 2023 05:29:06 GMT</pubDate>
            <atom:updated>2023-07-16T17:16:07.062Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/773/1*jOUZGNThjfIFad5AfFJqGQ.png" /></figure><p>Today, we are working on week 15 Project with a designated scenario and objectives.</p><h3><strong><em>SCENARIO:</em></strong></h3><p>A company wants to create a system that can track customer orders and send notifications when orders have been shipped. They want to use AWS services to build the system. They have decided to use SQS, Lambda, and Python for the project.</p><p><strong>OBJECTIVE 1: </strong>Create a Simple SQS Queue using Python.</p><p><strong>OBJECTIVE 2: </strong>Create a Lambda function in the console with a Python 3.7 or higher runtime.</p><p><strong>OBJECTIVE 3: </strong>Modify the Lambda to send a current time message to the SQS queue. You can use the built-in test function for testing.</p><p><strong>OBJECTIVE 4:</strong> Create an API gateway HTTP API type trigger.</p><p><strong>OBJECTIVE 5:</strong> Test the trigger to verify the message was sent.</p><p><strong>OBJECTIVE 6:</strong> Push your code to GitHub and include the link in your write up.</p><p><strong>NOTE:</strong> All code should be inline commented.*Be sure to reference the Boto3 Documentation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/238/1*VhB8hOscOY5DAQLqbO5AvQ.png" /></figure><h3>DEFINITIONS:</h3><p><strong><em>AMAZON API GATEWAY</em></strong> is a fully managed service that makes it easy for developers to create, publish, maintain, monitor, and secure APIs at any scale. APIs act as the “front door” for applications to access data, business logic, or functionality from your backend services.</p><p><strong><em>AWS LAMBDA</em></strong> is a compute service that lets you run code without provisioning or managing servers. Lambda runs your code on a high-availability compute infrastructure and performs all of the administration of the compute resources, including server and operating system maintenance, capacity provisioning and automatic scaling, and logging.</p><p><strong><em>AMAZON SIMPLE SQS QUEUE (</em></strong>Amazon SQS) offers a secure, durable, and available hosted queue that lets you integrate and decouple distributed software systems and components.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/238/1*VhB8hOscOY5DAQLqbO5AvQ.png" /></figure><h3>PREREQUISITES:</h3><ul><li>Computer</li><li>Basic Python Programming knowledge</li><li>Basic Cloud9 knowledge, an IDE (interactive development environment) of choice configured with AWS CLI, Python, and boto3 installed.</li><li>Basic Lambda Knowledge</li><li>AWS Account with IAM user</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/238/1*VhB8hOscOY5DAQLqbO5AvQ.png" /></figure><h4><strong>STEP 1: </strong>Create an SQS Queue using Python.</h4><p>To create the Python script needed for this project use the Boto3 document use this <a href="https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/sqs/client/create_queue.html">link</a>. These codes will assist in creating the SQS queue.</p><p>Create a new file in Cloud9: Select File — New From Template — Python File — Save As (name the file and keep the <strong>.py</strong> extension). Click RUN.</p><p>Enter the code below:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/169879b59f358678df7944520ff3c4b3/href">https://medium.com/media/169879b59f358678df7944520ff3c4b3/href</a></iframe><p>You will know that the coding is successful when you see that the SQS Queue URL is displayed at the bottom of the screen. Copy and save the url. You will need it late in the project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/577/1*jbeP59YXVQpzrQ7am0EJPQ.png" /></figure><p>Verify in the AWS Console that the SQS QUEUE creation was successful.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/677/1*GpSWjA8bCoCH6hfNXAwkaQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*VhB8hOscOY5DAQLqbO5AvQ.png" /></figure><h4><strong>STEP 2: Create a Lambda function in the console with a Python 3.7 or higher runtime. This Lambda function will push the message to the SQS Queue when triggered.</strong></h4><p>To create a Lambda function in the AWS console — Type <em>Lambda</em> in the CLI — Click <em>Create a function — </em>Click the box <em>Author from scratch</em> — Under Function Name type a name — Under Runtime <em>Python 3.7</em> — Under Architecture click <em>x86_64 — </em>Under Execution role click <em>Create a new role with basic Lambda permissions</em> — Click <em>Create function</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/830/1*6hgoozxUh7okwZ9W7B9hDQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/903/1*47DLBPfmH0FNZoGQAwh4kQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ab4bzdCX9JwmLPYRaK4MpQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kIFnBMsy1k39xRjWz9f78Q.png" /></figure><p>The Lambda function has successfully been created.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9RW6YBNGNUrISMwfzIEX6Q.png" /></figure><p>Now, update the permissions for the role and attach it to the Lambda function. Scroll down the page to middle of the page. Under Configuration click <em>Permissions</em> in the left-side column — Under Role name, click role name that is in blue</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7LYfccDTnP_WNf8n5eWO1A.png" /></figure><p>On the IAM page, click<em> Add permissions</em> — Click <em>Attach policies</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*373MGv_Qcnm3IWWgU5eO_A.png" /></figure><p>Under Other permissions policies type <em>SQS</em> — Click the box for <em>AmazonSQSFullAccess </em>— Click <em>Add permission</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/552/1*qHl7xBtGzPjXnkA1CQRvDw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*El9EMLhIChJqiiyCk9tg1w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/545/1*ir9GlDXTyrzYFwjGhaKA2A.png" /></figure><p>Now that the policy has successfully been attached to the role, add the SQS queue as a destination of the Lambda function. Go to Lambda Function — Click <em>Functions </em>— Click the name of the function — Click <em>Add destination</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/829/1*w9Ff6IBA17x6tZwCOtplsA.png" /></figure><p>On the Add destination page, under Destination configuration, under Source click <em>Asynchronous invocation — </em>Under Condition click <em>On success — </em>Under Destination type click SQS queue — Under Destination choose the SQS queue created for this project — Click <em>save</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/671/1*-5FEvFEZYJKNML4uX0kk-A.png" /></figure><p>The SQS queue has successfully been added as a destination of the Lambda function.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/834/1*KFWnx8HULpVbzcfIcQMRIg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*VhB8hOscOY5DAQLqbO5AvQ.png" /></figure><h4>STEP 3: Modify the Lambda to send a current time message to the SQS queue. Use the built-in test function for testing in Lambda. Now, deploy the code that will allow a current message time to the queue.</h4><p>The code below is for testing Lambda to send a current time message to the SQS queue:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5ccc721813cca5ba02db26c1e4230c90/href">https://medium.com/media/5ccc721813cca5ba02db26c1e4230c90/href</a></iframe><p>The test was successful! The message was sent.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QjGB6Ii42SuCH8BRyI42zw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*VhB8hOscOY5DAQLqbO5AvQ.png" /></figure><h4><strong>STEP 4: </strong>Create an API gateway HTTP API type trigger and test the trigger to verify the message was sent.</h4><p>To add the API gateway HTTP API as a trigger to the Lambda function. Go to Lambda Function — Click <em>Functions </em>— Click the name of the function — Click <em>Add trigger</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jdGNs0GL1Ibvr5h-lFRj2Q.png" /></figure><p>Under Trigger configuration select <em>API Gateway</em> — Under Intent <em>Create a new AP</em>I — Under API type click <em>HTTP API</em> — Under Security select <em>Open — </em>Click <em>Add</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/614/1*r8U7V-Ulm-zROe-f5QeuvQ.png" /></figure><p>The API Gateway was successfully added as a trigger for the Lambda function.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/809/1*OdcyEQsGoZa0y8np5hF6wA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Qd5Bh3RfARqMCjmcp9FxPw.png" /></figure><p>Go to the Amazon SQS Queue that was created for this project. Click <em>Send and receive message.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gG-iWPVyTy-UA04Io_mHwg.png" /></figure><p>Type a message to be sent to the queue and press send message. It was successful.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*X08ISCspvRJLlxLo8cM2dg.png" /></figure><p>Click Poll for messages to verify that the Lambda function sent a message to the que. It was successful!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CLCT1h8SR-qP5uG83exQIA.png" /></figure><p>Congratulations! You are able to send a current time message to an SQS Queue by using an API Gateway to trigger a Lambda function!</p><h4><a href="https://github.com/almathis81/boto3_python_script">GitHub Link to my repository.</a></h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9ce6095812e2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Creating and Managing a DynamoDB Table using Boto3 and Python in a Cloud9 Environment]]></title>
            <link>https://medium.com/@antramecalmathis/creating-and-managing-a-dynamodb-table-using-boto3-cloud9-and-python-ec12235ebc11?source=rss-c914038d4ace------2</link>
            <guid isPermaLink="false">https://medium.com/p/ec12235ebc11</guid>
            <category><![CDATA[cloud9]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[dynamodb]]></category>
            <category><![CDATA[boto3]]></category>
            <category><![CDATA[python-programming]]></category>
            <dc:creator><![CDATA[Antrameca  Mathis ( Ann-Trah-Mee-Kah)]]></dc:creator>
            <pubDate>Fri, 26 May 2023 20:23:49 GMT</pubDate>
            <atom:updated>2023-07-16T17:19:32.818Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*rBclpe7OtFR2juWx.jpg" /></figure><p>Today , for the Week 14 Project we will create, modify and delete a DynamoDB table of my favorite retro cartoons from the 80s and 90s. I am a genuine fan of cartoon artistry from the golden age of the daily after-school cartoon series.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/685/1*E_IwzKTLY1zkF0arw-Ma8Q.png" /></figure><h3><strong>OBJECTIVES: </strong>All code should be inline commented.</h3><ol><li>Create a DynamoDB table for your favorite retro cartoons.</li><li>Using the 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>Push the code to GitHub and include the link in the write up.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/678/1*eq70jX83qoj9WmFA8b0ArA.png" /><figcaption>Before we rewind time let’s look at definitions!</figcaption></figure><h3>DEFINITIONS:</h3><p><strong><em>Boto3</em></strong><em> </em>is the Amazon Web Services (AWS) Software Development Kit (SDK) for Python, which allows Python developers to write software that makes use of services like Amazon S3 and Amazon EC2. It allows you to directly create, update, and delete AWS resources from your Python scripts. At its core, all that Boto3 does is call AWS APIs on your behalf.</p><p><strong><em>Cloud9</em></strong> an AWS cloud-based integrated development environment (IDE) that lets users write, run, and debug code with just a browser without needing to install or maintain a local IDE. It includes a code editor, debugger, and terminal. Cloud9 comes prepackaged with essential tools for popular programming languages, including JavaScript, Python, PHP, and more. Cloud9 also enable users to switch between local and remote execution of serverless applications. It provides flexibility to run a development environment on a managed Amazon EC2 instance or any existing Linux server that supports SSH. The Cloud9 terminal provides a browser-based shell experience enabling you to install additional software, do a git push, or enter commands.</p><p><strong><em>Amazon DynamoDB</em></strong> is a fully managed NoSQL database service that provides fast and predictable performance with seamless scalability. DynamoDB also offers encryption at rest, which eliminates the operational burden and complexity involved in protecting sensitive data. The DynamoDB tables can store and retrieve any amount of data and serve any level of request traffic. Users can scale up or scale down their tables’ throughput capacity without downtime or performance degradation.</p><p><strong><em>Python </em></strong>is a computer programming language often used to build websites and software, automate tasks, and conduct data analysis. Python is a general-purpose language, meaning it can be used to create a variety of different programs and isn’t specialized for any specific problems. This versatility, along with its beginner-friendliness, has made it one of the most-used programming languages today. Python supports modules and packages, which encourages program modularity and code reuse.</p><h3>PREREQUISITES:</h3><ul><li>AWS Account with IAM user</li><li>Basic Knowledge of Boto3</li><li>Basic Knowledge of Cloud9</li><li>Computer</li><li>Basic Knowledge of DynamoDB</li><li>Basic Knowledge of Cloud9</li><li>Basic Knowledge of Python</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/341/1*9sBwxfSelmImB7MTMQXnBA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*ARWWyz4xclnR3E_AfH5hlQ.gif" /></figure><h4><strong>Step 1</strong>: Prepare your Cloud9 environment.</h4><p>Install boto3 into the environment with code <em>pip3 install boto3</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/984/1*o9YU-ajc5FMclvuRxq8jeg.png" /></figure><h4><strong>STEP 2:</strong> Using the Python codes below in the Cloud9 environment, create the DynamoDB Table. Make sure to click RUN in Cloud9.</h4><p>Run the Python codes below to create the DynamoDB table. The inline comments are just for explanation purposes of this lesson. Make sure to copy codes to GitHub Gist.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ad5b51e8baffff2b6d9ef35493fa9d41/href">https://medium.com/media/ad5b51e8baffff2b6d9ef35493fa9d41/href</a></iframe><p>The Dynamodb table creation in AWS was successful!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/505/1*wYQEB6apZcxh9m3JYihJog.png" /></figure><h4><strong>STEP 3</strong>: Using the Python codes below in the Cloud9 environment, add 10 items to the table and then click <em>RUN</em>. Then, copy codes to GitHub Gist.</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b6cde169910f7fa6e9b56937f880762d/href">https://medium.com/media/b6cde169910f7fa6e9b56937f880762d/href</a></iframe><p>Now that the update was successful, in AWS go to DynamoDB &gt; update settings &gt; Explore table items.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u_ng_mHtxsunMevFHYaQ1Q.png" /></figure><p>Great job! The items are listed in the table.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/381/1*nXs7STgWwOE5XyS7cM_pPA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/220/1*6ubsyfYVUoK4iOcDFDfwdQ.gif" /></figure><h4>STEP 4: Using the Python codes below in the Cloud9 environment, write code to scan the table and capture the listed items. Click RUN.</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7f0ccceb39084b450024a8d9b824ab00/href">https://medium.com/media/7f0ccceb39084b450024a8d9b824ab00/href</a></iframe><p>Below is the result of the table scan.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/282/1*EL7ffo29NrlHY1KKsolIGg.png" /></figure><h4>STEP 5: Using the Python codes below in the Cloud9 environment, write code to delete the table. Click RUN.</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ca67319c65c6e97f1344d41bd8a5bdfa/href">https://medium.com/media/ca67319c65c6e97f1344d41bd8a5bdfa/href</a></iframe><p>Verify that table has been deleted.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xPuWxAtefoRidl5xto1kHA.png" /></figure><p>Refresh the page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Onz9nj0jB60dOPEoZUnWQA.png" /></figure><p>Congratulations you have successfully used Python in Cloud9 to create, modify, scan and delete a DynamoDB table!!!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/220/1*CaAoECiC5cJU5vdCx3Dr_w.gif" /></figure><p><a href="https://github.com/almathis81/boto3_python_script">Link to my GITHUB Repository.</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ec12235ebc11" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Create and Run a Python Script to Extract File Name and Size in Cloud9]]></title>
            <link>https://medium.com/@antramecalmathis/create-and-run-a-python-script-to-extract-file-name-and-size-in-cloud9-525e98dc849d?source=rss-c914038d4ace------2</link>
            <guid isPermaLink="false">https://medium.com/p/525e98dc849d</guid>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[github-gist]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[cloud9]]></category>
            <dc:creator><![CDATA[Antrameca  Mathis ( Ann-Trah-Mee-Kah)]]></dc:creator>
            <pubDate>Wed, 24 May 2023 04:28:20 GMT</pubDate>
            <atom:updated>2023-06-25T06:18:51.638Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*3--4ERwiBpE-Hvwq" /></figure><p>In this Week 13 Project article, we will use Python to build a script that extracts information, such as name and size, from files in a working directory and stores it in a list of dictionaries. We will use AWS Cloud9 to complete this project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/212/1*paR1yGSTUrijKeYe69IqEw.png" /><figcaption>Let’s get started with DEFINITIONS!</figcaption></figure><h4>AWS CLOUD9:</h4><p>A cloud-based integrated development environment (IDE) that lets you write, run, and debug your code with just a browser. AWS Cloud9 gives you the flexibility to run your development environment on a managed Amazon EC2 instance or any existing Linux server that supports SSH. This means that you can write, run, and debug applications with just a browser, without needing to install or maintain a local IDE.</p><h4>PYTHON:</h4><p>Python is a computer programming language often used to build websites and software, automate tasks, and conduct data analysis. Python is a general-purpose language, meaning it can be used to create a variety of different programs and isn’t specialized for any specific problems.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*paR1yGSTUrijKeYe69IqEw.png" /><figcaption>GOAL OBJECTIVES</figcaption></figure><p><strong>OBJECTIVE #1</strong>: Create a script to that generates a list of dictionaries about files in the working directory. Then print the list.</p><p><strong>OBJECTIVE #2</strong>: Push the code to GitHub and include the link in the write up.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*paR1yGSTUrijKeYe69IqEw.png" /><figcaption>PREREQUISITES</figcaption></figure><ul><li>AWS CLI Knowledge</li><li>CLOUD9 Environment Created in an AWS Account as an IAM User Single Account. Otherwise, create an account by using this <a href="https://docs.aws.amazon.com/cloud9/latest/user-guide/sample-python.html">link</a>.</li><li>Computer or laptop</li><li>Python Programming Knowledge</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*paR1yGSTUrijKeYe69IqEw.png" /><figcaption>Let’s CREATE A SCRIPT USING PYTHON</figcaption></figure><p>In AWS, using the CLI to search CLOUD9 and click <em>open</em>. It may take a few minutes to load.</p><p>Once in the CLOUD9, create a new file. Click in the following sequence, <em>FILE, New From Template, Python File, Save As </em>and then name the file while keeping the <strong>.py</strong> extension.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/362/1*arX0tjMp4hZ06_62614qjQ.png" /></figure><p>Enter the codes below and see their purpose:</p><p><strong>import os</strong></p><p>The OS module in Python is a part of the standard library of the programming language. When imported, it lets the user interact with the native OS Python is currently running on. In simple terms, it provides an easy way for the user to interact with several os functions</p><p><strong>path = “.”</strong></p><p>Sets the path variable to the current working directory <strong>(‘.’)</strong></p><p><strong>files = os.listdir(path)</strong></p><p>Code collects the list of files present in the current working directory.</p><p><strong>for file in files:</strong></p><p>This is a Python For Loop is used for iterating over a sequence (that is either a list, a tuple, a dictionary, a set, or a string). This is less like the for keyword in other programming languages, and works more like an iterator method as found in other object-orientated programming languages. With the For Loop we can execute a set of statements, once for each item in a list, tuple, set etc.</p><p><strong>file_path = os.path.join(path, file)</strong></p><p>This code combines components of a file path into a complete path.</p><p><strong>file_size = os.path.getsize (file_path)</strong></p><p>This code in Python is used to check the size of specified path. It returns the size of specified path in bytes.</p><p><strong>print (“Path: {}, File:{}, Size: {} bytes”.format(file_path, file, file_size))</strong></p><p>This code is used to print the file to see the list of dictionaries with name and size specified.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*_Xz-TcXdQxKhnwRbxhmp-Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*paR1yGSTUrijKeYe69IqEw.png" /><figcaption>Use GitHUB Gist for the Code</figcaption></figure><p>Enter the code in GitHub Gist. The gist can be public or private.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/995/1*Vpp6fJ3ZAW4w2mJytI2nmw.png" /></figure><p>Run the code in CLOUD9.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/495/1*wiWc437ToDw39MJPM-3AVA.png" /></figure><p>You did it! Congratulations. The script has been run in Python and it has produced a list of a directories with file name and size included for each file in the working directory.</p><p>Here is my shareable GitHub Gist link: <a href="https://gist.github.com/almathis81/e02c4b3c009ba94c40eb8788a8b17cf7">https://gist.github.com/almathis81/e02c4b3c009ba94c40eb8788a8b17cf7</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=525e98dc849d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[3-Tier Architecture with High Availability]]></title>
            <link>https://medium.com/@antramecalmathis/3-tier-architecture-with-high-availability-8e62ab24e401?source=rss-c914038d4ace------2</link>
            <guid isPermaLink="false">https://medium.com/p/8e62ab24e401</guid>
            <category><![CDATA[3-tier-architecture]]></category>
            <dc:creator><![CDATA[Antrameca  Mathis ( Ann-Trah-Mee-Kah)]]></dc:creator>
            <pubDate>Sun, 30 Apr 2023 14:49:14 GMT</pubDate>
            <atom:updated>2023-06-25T06:19:56.247Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/701/1*HdijO8VsZzmJx_9Gwn1qjg.jpeg" /></figure><h3>Initiative:</h3><p><em>Week 9 Project. Design and create a highly available 3-Tier architecture for a new web application.</em></p><h4>Layer 1: Web Tier</h4><ol><li>2 public subnets</li><li>Minimum of 2 EC2 instances with an OS of your choice (free tier) in an Auto Scaling Group.</li><li>EC2 Web Server Security Group allowing inbound permission from the internet.</li><li>Boot strap static web page or create a custom AMI that already includes the static web page.</li><li>Create a public route table and associate the 2 public subnets.</li></ol><h4>Layer 2: Application Tier</h4><ol><li>2 private subnets</li><li>Minimum of 2 EC2 instances with an OS of your choice (free tier) in an Auto Scaling Group.</li><li>EC2 Application Server Security Group allowing inbound permission from the Web Server Security Group.</li><li>Associate with private route table.<br>Note: This is not a true application tier as we don’t have any provided code to run on the EC2 instances.</li></ol><h4>Layer 3: Database Tier</h4><ol><li>Use a free Tier MySql RDS Database.</li><li>The Database Security Group should allow inbound traffic for MySQL from the Application Server Security Group.</li><li>2 private subnets.</li><li>Associate with private route table.<br>Note: No need to use Multi-AZ but be sure to document how you would add it</li><li>Remember that when diagraming this tier you are only creating one RDS instance in one subnet even though you are creating two subnets. If you use multi-az or a read replica then and only then should you have a second instance. Make sure to label accordingly.</li></ol><h3>Define Stages of 3-Tier Architecture:</h3><h4>*Presentation/Web Tier</h4><p><em>In this tier, the user interface and communication layer of the application, where the end user interacts with the application. Its main purpose is to display information to and collect information from the user.</em></p><h4><em>*Application/Logic/Middle Tier</em></h4><p><em>In this tier, information collected in the presentation tier is processed. The application tier can also add, delete or modify data in the data tier.</em></p><h4>*Data/Database Tier</h4><p><em>In this tier, the information processed by the application is stored and managed. This can be a relational database management system or in a NoSQL Database server.</em></p><h3><strong>Prerequisites:</strong></h3><p><em>AWS Account * Knowledge of AWS and CLI * Computer</em></p><h3><strong>Step 1:</strong> Log into your IAM Role for your AWS Account</h3><h3><strong>Step 2:</strong> Create a VPC</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/601/1*EF3TD5LSKyxjsEb-9o8JRg.png" /></figure><p>Create your VPC name, manually enter your IPv4 CIDR block, and then click “Create VPC.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/520/1*_lKy8RzXpNUDX9shZ08wkw.png" /></figure><p>Success!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WLfpIURJGE1RXWjOD3pfUw.png" /></figure><h3><strong>Step 3: Create 6 Subnets: 2 public subnets and 4 private subnets.</strong></h3><p>Select “Create Subnet” under the subnets category and choose he VPC your created for this project.</p><h4><em>Two Public Subnets will be created for the Web Tier:</em></h4><p><em>Subnet #1:</em> WebTierPublicSubnet1 * AZ us-east-1a * IPv4 CIDR block 10.0.1.0/24</p><p><em>Subnet #2:</em> WebTierPublicSubnet2 * AZ us-east-1b * IPv4 CIDR block 10.0.2.0/24</p><h4>Two Private Subnets will be created for the Application Tier:</h4><p><em>Subnet #3:</em> AppTierPrivateSubnet1 * AZ us-east-1a * IPv4 CIDR block 10.0.3.0/24</p><p><em>Subnet #4:</em> AppTierPrivateSubnet2 * AZ us-east-1b * IPv4 CIDR block 10.0.4.0/24</p><h4>Two Private Subnets will be created for the Database Tier:</h4><p><em>Subnet #5: </em>DBTierPrivateSubnet1 * AZ us-east-1a * IPv4 CIDR block 10.0.5.0/24</p><p><em>Subnet #6:</em> DBTierPrivateSubnet2 * AZ us-east-1b * IPv4 CIDR block 10.0.6.0/24</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LQ8pqqdZ3ujrFNKLBNPS5Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/838/1*bQrPp6gbE43tI0djn_PQhA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/558/1*Z2LZedaLqPBplxdwGlbCtg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/566/1*vrMwQv-AKPbTGkVZUSD3cA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/567/1*1YKOufVSlf6eGcF1KPXbFQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/557/1*Ft00P8uaosL_KBwLJ0UGFQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/561/1*k9p2bf4Vux1k0pjQN0G_gQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/560/1*8TjtW7wyrMl8JllnVKLYig.png" /></figure><p>Select each public subnet one at a time, and under “Actions” click “Edit Subnet Settings.” Then, Enable auto-assign public IPv4 address for both the public subnets and click “save.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/651/1*8_hYGC7TiLkMIqe0haqVrg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/595/1*ZzncYHq9afSu8YBTdtz9tg.png" /></figure><h3>Step 4: Create an Internet Gateway</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fXlnNJCUU60AFDaGTmzThA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/656/1*zBAOYYLncIb5lx4iPsHpJA.png" /></figure><p>Attach the VPC you created for this project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uZrzvXVGU5IlR3pafTRDYQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/677/1*vY11388TJNRYQKwvgrrXdA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*obi7lPBeuFVySuel82YGMw.png" /></figure><p>Success! The internet gateway has been created and the VPC has been attached.</p><h3>Step 5: Create 2 route tables</h3><p>Create 1 public route table and associate the two public subnets. Then, create 1 private route table and associate the four private subnets. Also, associate both route tables with the VPC for this project. When each route table has been created successfully, then under “Actions” select “Edit subnet associations.” Click “Save Associations.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*C4d_nOM35wQS7lTvcGkpAw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/660/1*5HzXRjsPoDOwqWgQkFJ1Ww.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bxmzt57R_6dGnKB8yXgUwg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5xLQGuowvg2Rd91PCPesnw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/664/1*-BBVEhBNEiCZt_eCUeUBPQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fpBotFR6e3zRqvc8T02D2Q.png" /></figure><h3>Step 6: Create 2 NAT Gateway</h3><p>Create NAT Gateway and associate the Web Tier Public Subnet #1 that you create for this project . Then, select “Ellocate Elastic IP” Click “Create NAT Gateway.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eEblR8quDyE5OOcwY8B0ew.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/733/1*Zsjw5buAowc_9AkkP5qdrw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/702/1*bmpWBf9fUmti5PH3VBssKA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/749/1*wLeHD97aXYHZdmfmb93cxg.png" /></figure><h3>Step 7: Associate the Public Route Table with the Internet Gateway</h3><p>Select public route table that you created for this project. Under “Actions” Select “Edit Routes.” Then, click “Add route.” Under Target, select the Internet Gateway that you created for this project. Click, “Save Changes.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*o52Y0OLyQKIefBMAybzLUQ.png" /></figure><p>Successful association!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nOnQozlVcMbojC1_2Har4g.png" /></figure><h3>Step 8: Associate the Private Route Table with the NAT Gateway</h3><p>Select private route table that you created for this project. Under “Actions” Select “Edit Routes.” Then, click “Add route.” Under Target, select the NAT Gateway that you created for this project. Click, “Save Changes.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_ONLrduxy3KuvsaOgOPxeQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rEPvuBFNhUiehYqeUc7bGw.png" /></figure><h3>Step 9: Create Launch Templates For Web Tier and Application Tier</h3><p><strong>For Web Tier, Search “EC2 Launch Template” in the search box and select “Create launch template.”</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/998/1*E0nQGHBMLSOjwKaaFn0MJA.png" /></figure><p>Name the template and version description. Select “Provide guidance to help me set up a template that I can use with EC2 Auto Scaling.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/715/1*RuHXVKgo3E0vSLvNMJtVDA.png" /><figcaption>p</figcaption></figure><p>Under Quick Start, choose Amazon Linux 2023 AMI.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/651/1*pNBhEaUiggYu4rwivhxhgA.png" /></figure><p>Under Instance type, choose t2.micro Free tier eligible. For key pair, make a new or use one that you already created.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/726/1*0ZPqmP2kEXRrsivSJl6Kng.png" /></figure><p>Under Network settings, choose “Create security group,” name the Security group and give it a description. Choose the VPC that you created for this project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*XZandDPeGNMIjbtTFgS_nA.png" /></figure><p>Click “Add Security group rule.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/675/1*cKL8fLXltXvdNwzQ_SHFWQ.png" /></figure><p>To create a static web page, under the User Data section, enter the script below. Then, click “Create template.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/532/1*mcft2YqJ2I0t3IfHGZODbA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/549/1*l7tS4vmSTn3mwNooxpEZ0Q.png" /></figure><h4>For Application Tier, repeat the steps to create a Launch template. The difference will be the change in the security group.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/582/1*mxQRkRtOW6LJ7GCDTql7nA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/655/1*Fnx2PMY-reWQi0SC6schew.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/690/1*oM62Kw6VY-UUJi2EahqlZQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/683/1*e4cwkMYmVSN6WNm_EklIew.png" /></figure><p>Security Group Rule 1 choose for Type: SSH and Source: Your Public Security Group that you created for this project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/694/1*x5MG_1eeXMBskOxMzb9yIA.png" /></figure><p>For Security Groups Rule 2 choose for Type: ALL ICMP and Source: 0.0.0.0/0</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/691/1*BFHiz9TNo2cZxd7GN1iT1A.png" /></figure><p>Click, “Create launch template.” It the App Tier Launch Template was a success.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*ITE-DIy5csIk7V1G7R66TA.png" /></figure><h3><strong>Step 10: Create an Auto Scaling Group and Application Load Balancer for Web Tier and Application Tier</strong></h3><p>Go to Launch Template. Under “Actions,” click “Create Autoscaling group.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8fXUSWrMe2vZ62VdrqK3pw.png" /></figure><p>Create a name for the Auto Scaling group and use your launch template. Click “Next.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/737/1*qx-PYIibH5wufyttT9_YdA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/633/1*LqcBGE7Ktp2mR9wsud-wJw.png" /></figure><p>Select the VPC and Web Tier from subnets created earlier in the project. Then, select “Next.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/690/1*V7pdIJf82C0BFDKVhzgTBA.png" /></figure><p>For Load balancing, select “Attach to a new load balancer”. Then select, “Application Load Balancer.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/735/1*lnFS4t8s8l8DH2wqhO9D5Q.png" /></figure><p>Create a name for the autoscaling group. Click “Internet-facing.” Select the VPC and Web Tier subnets created earlier in the project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/713/1*crraiUXA_ClL_klJt3bnTA.png" /></figure><p>Select “Create a target group.” Then select “Next.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/701/1*KVnrl4z7jLTDzc64yhJFLg.png" /></figure><p>For Group Size, choose 2 as the desired capacity, minimum, and maximum capacity. Click “Next” through each screen until you get to “Create Auto Scaling Group” button and click it .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/732/1*HdJ3E2cJKgC1Xai9uGNVyg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/558/1*gKdYPTXXdhGSMPZv9MIwww.png" /></figure><p>Successful Auto Scaling Group creation for the Web Tier!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qvqTBSXSwEFei6Ar18U9yw.png" /></figure><p>For Application Tier, go to Launch Template. Under “Actions,” click “Create Autoscaling group.” Create a name for the Auto Scaling group and use the App Tier launch template. Click “Next.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/743/1*EM5KHlV2m3-kLz3tMRfKFQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/738/1*ge10aaeAkRm5xB4aR0Ywuw.png" /></figure><p>Select the Project VPC and Application Tier subnets created earlier in the project. Then, select “Next.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/691/1*7MeiRBexOK_MUahSljnFXg.png" /></figure><p>For Load balancing, select “Attach to a new load balancer”. Then select, “Application Load Balancer.” Create a name for the autoscaling group. Click “Internet-facing.” Select the VPC and Application Tier subnets created earlier in the project. Select “Create a target group.” Then select “Next.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/744/1*Uiu7gMNnR2YHUkto03PVIA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/701/1*0hlqk54T8hhlG41j-Adtig.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/687/1*BwmrMqg1YQwwvi4agFSWAg.png" /></figure><p>For Group Size, choose 2 for the desired capacity and minimum, and 4 for maximum capacity. Click “Next” through each screen until you get to “Create Auto Scaling Group” button and click it .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/745/1*OM05Qo9oVtOjOj4UBnMDfw.png" /></figure><p>Launch Template and ASG creation were successful</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/688/1*XGB7FsM2AeET9Z3YBTrP5A.png" /></figure><h3>Step 11: Create the Database Tier</h3><p>Search “RDS,” click “Create database.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/517/1*wVSj9B1ZZF_FyIviyj4h9A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/574/1*BJ1o4aABeyBXUFmujgnHKA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/562/1*4q58VaA2jMP3UuOWaZWE7A.png" /></figure><p>Master username is “admin” and create a Master password.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/562/1*6MtQBwtuBgeooUJMhgPakQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/473/1*ZrkLZn92riq28fqKf3Aa4g.png" /></figure><p>For Connectivity, choose the VPC for this project and subnet group. Don’t allow Public access.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/568/1*zErP_J_7fLR97VzMA3Dr2Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/556/1*5hz2QPsOhP81b7uGY1YRtw.png" /></figure><p>Database port chooses 3306 automatically. Click “Create database.” It may take a few minutes to create the database.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/581/1*BspO5L2k4n8ObiXi6mug7Q.png" /></figure><p>Database has successfully been created.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/903/1*NCGSLRDqGMc7RPXRmhm5fw.png" /></figure><h3>Step 12: Connect Security Group to Database</h3><p>Search “Security Groups” and select the Database Security Group that you created for this project. Under Action, select Edit inbound rules.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/616/1*FD7OBNRkUJmOf3M6zcJDrA.png" /></figure><p>Click “Add rule.” For “custom,” click the 3 Tier Database Security Group that you created for this project and delete the default security group rule. Click “Save rules.” Now, let’s move on to testing, because you cannot ping the Application Tier without it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9PWng3vxdszOVzxIy46ISg.png" /></figure><p>Add Security Group to Application Tier in order to ping the instance from the Web Tier.</p><h3>FINAL STEP: TIME TO TEST!!!</h3><p>Test #1: Web Tier instance Public IP Address. Copy the IPV4 address from one of the Web Tier instances into your web browser.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/462/1*-srrLS5k5vXBK-OKs4h-fA.png" /></figure><p>Test #2: Access Web Tier via the CLI. SSH into the terminal with keypair path and use the command [curl http://localhost]</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*96ZWWTeS-larSSvu0eI51Q.png" /></figure><p>Test #3: Ping the Application Tier via the CLI. Type [ping &lt;private IPV4 address&gt;]. Type Ctrl + c to stop the pinging. When you see the pinging such as the one below, then it is successful.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/558/1*VXx5_V0aggK9uXW4I5_Hhw.png" /></figure><p>You have officially succeeded in passing all three tests. Most importantly, you have built the 3-Tier Architecture.</p><p><strong><em>Now to prevent incurring charges, you must delete/stop the components of the 3 Tier Architecture: NAT Gateways, Elastic IPs, and ALBs and EC2.</em></strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8e62ab24e401" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A DynamoDB Table, an IAM Role Permission, & an EC2 Instance Connect]]></title>
            <link>https://medium.com/@antramecalmathis/create-a-dynamodb-table-in-aws-dc3f8d6b3f3d?source=rss-c914038d4ace------2</link>
            <guid isPermaLink="false">https://medium.com/p/dc3f8d6b3f3d</guid>
            <dc:creator><![CDATA[Antrameca  Mathis ( Ann-Trah-Mee-Kah)]]></dc:creator>
            <pubDate>Sun, 05 Mar 2023 10:35:45 GMT</pubDate>
            <atom:updated>2023-03-05T10:45:58.089Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/438/1*oj8POV3sFN_KyOTm2TSR-w.png" /></figure><p>HI IT World! Today, we are buildings a DynamoDB table in AWS, creating an IAM Role with Read Only Permission, &amp; Utilizing an EC2 Instance to Connect to the Internet.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/866/1*aGzio1KQFwCBNdO6m4VoHA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/603/1*Kbzsz-2bCtPfClSrfFcqFg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/493/1*Y9EE9dtMMbiG9PgWoFLnXQ.png" /></figure><p><strong>Amazon DynamoDB </strong>is a fully managed, serverless, key-value NoSQL database designed to run high-performance applications at any scale. DynamoDB offers built-in security, continuous backups, automated multi-Region replication, in-memory caching, and data import and export tools.</p><p><strong>Amazon EC2</strong> (Amazon Elastic Compute Cloud) is a web service that provides secure, resizable compute capacity in the cloud.</p><p><strong>AWS CLI </strong>(AWS Command Line Interface) is a unified tool to manage AWS services.</p><p><strong>IAM Role </strong>is an IAM identity that you can create in your account that has specific permissions. An IAM role is similar to an IAM user, in that it is an AWS identity with permission policies that determine what the identity can and cannot do in AWS. A role is not associated with one person, instead it is intended to be assumable by anyone who needs it. Also, a role does not have standard long-term credentials such as a password or access keys associated with it. Instead, when you assume a role, it provides you with temporary security credentials for your role session.</p><p><strong>Partition Key </strong>is the simple primary key that uniquely identifies each item in an Amazon DynamoDB table.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/523/1*J0Cx6hGQhdjBJcWOGxFndA.png" /></figure><p><strong>STEP 1: CREATE A DynamoDB TABLE &amp; ADD 10 ITEMS TO THE TABLE.</strong></p><p>After logging into your IAM account, type <em>DynamoDB</em> in the search bar and click <em>Create table</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/945/1*xPqbAWXzedKO0ojo_9yM5Q.png" /></figure><p>Create names for the Table and Partition key. Under Table settings, keep the Default settings, and we are not adding Tags for this exercise.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/648/1*II4ruQ4HuNZsDI66W6umzw.png" /></figure><p>Click <em>Create table.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/182/1*Klna5BMpCfdhZvXNlCNKjQ.png" /></figure><p>You have successfully created the DynamoDB table! Now, let’s add my ten FAVORITE U.S. CITIES!!! Or, input whatever items you want to list into the table.</p><p>Click the name of your table.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Os6gs3NE4t1vwY4Vke8rTQ.png" /></figure><p>Click <em>Explore table items.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/784/1*FZrcreGwD6cVnabdvXHvLQ.png" /></figure><p>Click <em>Create item.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/636/1*Ee7Fizz408Z_jz6i5FbkQA.png" /></figure><p>Set the <em>value</em> of your <em>partition key</em>. How many more attributes do you want to create? For this exercise, I am creating two additional string attributes, <em>State</em> and <em>City</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/647/1*phgGW2TuIpQgycqV_uZyFg.png" /></figure><p>After inputting your information for this one item, click <em>Create item. </em>Then, repeat the process nine more times.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DM6sVUxaZOLKNHCkVs6Y6A.png" /></figure><p>After creating the 10 items, you have successfully created your DynamoDB table. For this exercise, I have created a table of my FAVORITE U.S. Cities.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/786/1*E0JOPYpQywYGJmyAKYxHTg.png" /></figure><p><strong>STEP 2: CREATE A T.2Micro EC2 INSTANCE. THEN, USE AN IAM ROLE &amp; THE PRINCIPLE OF LEAST PRIVILEGE TO GRANT THE EC2 INSTANCE READ ACCESS TO DynamoDB.</strong></p><p>Type <em>IAM</em> in the search bar. Then, click <em>Roles </em>in the left column.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/193/1*N85IHDpm4gA6LWZ1CLIkpg.png" /></figure><p>Click <em>Create role.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/655/1*Mdm5xDNbsMjm7WuLoiTBrg.png" /></figure><p>Under Select trusted entity, click <em>AWS service.</em> Under <em>Use case</em>, click <em>EC2. </em>Then, click <em>next.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/562/1*LA26IwNta6FQLe81Pc7moA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/567/1*sDM_D-DDkFipsbAN2HyVFw.png" /></figure><p>Under Add permissions, type <em>DynamoDB</em> in the search bar. Click the <em>AmazonDynamoDBReadOnlyAccess</em><strong><em> </em></strong>permission. Click <em>next.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/664/1*6DdCVWDF9z-8yXqBDpcg6w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/657/1*ORlz1ixYjgPbbLUSw1r0hA.png" /></figure><p>Create the Role’s name and description. Then, click <em>Create role.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/653/1*ni1_D288SJvWompvGYosmQ.png" /></figure><p>You have successfully created the IAM role!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*42235Nh4nE7pu0S0SedcIA.png" /></figure><p><strong>STEP 3: USE THE AWS CLI IN THE EC2 INSTANCE TO SCAN THE DynamoDB TABLE AND VALIDATE THAT YOU CANNOT WRITE AN ITEM TO THE DYNAMODB TABLE.</strong></p><p>To attach the role to the an EC2 instance, type <em>EC2</em> in the search bar, make sure that you are registered in the region nearest you, and click <em>Launch instance.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/334/1*e5TCHLTtTFkJGin_ObCXsA.png" /></figure><p>Name the Instance and click <em>Amazon Linux 2 AM</em>I, and <em>t2.micro.</em><strong><em> </em></strong>Then, either create a new key pair or select one that you have already created.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/798/1*ADmwjxywDROWObqnoCGF-w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/747/1*jazy2yBQ2SIyFOyQYJaOVw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/756/1*9t6Bm86SKJH_NN8yNzIHKw.png" /></figure><p>Under Network Settings, click <em>Create security group, allow SSH traffic from (Anywhere </em>in the pull down bar), and <em>Allow HTTP traffic from the internet.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/754/1*r1oCfiMxpZnzm7CshQM8Xw.png" /></figure><p>Under Advanced details, for the IAM instance profile click the role that you created earlier in this exercise. Then, click <em>Launch instance.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/769/1*OISnQF7FYVxEB-JSVjV8Gg.png" /></figure><p>You have successfully created the EC2 instance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/528/1*0Q7TP5ht2rrQXfImPmHEFA.png" /></figure><p>Now that we have connected the IAM role to the EC2 instance, we must use the CLI in the EC2 instance to scan the DynamoDB table.</p><p>Go to your EC2 Dashboard, click <em>instances.</em><strong><em> </em></strong>Select your instance created in this exercise, then click <em>Connect.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/668/1*TVv9ycIcc0PxZE5qWQxDTA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/732/1*OCw6NSCy1xWtIRyABQfpZw.png" /></figure><p>Successful Connection via the EC2 Instance!!!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/451/1*AQ-4MDK0bgfSrSXDQCSskQ.png" /></figure><p>To scan the DynamoDB table using the AWS CLI, we must list the table using the command &lt; <em>aws dynamodb list-tables --region us-east-1 </em>&gt;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/599/1*bE-srv6cPhas-QrtyJ4QPA.png" /></figure><p>Then, scan the table using the command &lt; <em>aws dynamodb scan --table-name Cities-W8-Project-Table --region us-east-1</em> &gt;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/849/1*lu3NFF6YEfMUVf6cfMlERw.png" /></figure><p>The scan was successful!!!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/213/1*w0_dK1sNNRkLsxZzmKY2tg.png" /></figure><p>Lastly, verify that you cannot write or modify the table. Type &lt; <em>aws dynamodb put-item — table-name Cities-W8-Project-Table — item ‘{“City-pk”: {“S”: “12”},”State”: {“S”: “Arizona”}}’ — region us-east-1</em> &gt;</p><h3>Here is the command to fill in the blanks:</h3><p><strong><em>aws dynamodb put-item — table-name &lt;table_name&gt; — item ‘{“&lt;partition_key&gt;”: {“S”: “&lt;value&gt;”},”&lt;sort_key&gt;”: {“S”: “&lt;value&gt;”}}’ — region us-east-1</em></strong></p><p>The error message signifies that the DynamoDB table that we created is READ ONLY!!! Congratulations!!!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/957/1*XdndfonxcCn2VtrWGrO8kA.png" /></figure><p>The End.. Well, almost… go stop your instances!!!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/261/1*o-2eRkpqLMTwTRbhs7RQDA.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dc3f8d6b3f3d" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>