<?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 Destany Parria on Medium]]></title>
        <description><![CDATA[Stories by Destany Parria on Medium]]></description>
        <link>https://medium.com/@destanyparria?source=rss-b6a964ef08a6------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*M5oVPyvo7-4N-qq3</url>
            <title>Stories by Destany Parria on Medium</title>
            <link>https://medium.com/@destanyparria?source=rss-b6a964ef08a6------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 07:47:25 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@destanyparria/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[Creating a Network Topology Diagram with Cisco Packet Tracer]]></title>
            <link>https://faun.pub/creating-a-network-topology-diagram-with-cisco-packet-tracer-c032783fe7cf?source=rss-b6a964ef08a6------2</link>
            <guid isPermaLink="false">https://medium.com/p/c032783fe7cf</guid>
            <category><![CDATA[switch]]></category>
            <category><![CDATA[router]]></category>
            <category><![CDATA[network-topology]]></category>
            <category><![CDATA[computer-networking]]></category>
            <category><![CDATA[simulation]]></category>
            <dc:creator><![CDATA[Destany Parria]]></dc:creator>
            <pubDate>Mon, 14 Aug 2023 04:09:09 GMT</pubDate>
            <atom:updated>2023-08-31T14:55:42.971Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*eNNdg3pnWrEJWd_G" /></figure><p>Hi there! Today, we will create a very simple network topology diagram to get familiar with using Cisco Packet Tracer. These diagrams provide visual representations that significantly improve troubleshooting and design processes. The best part is that this tool is free to download on Linux, Mac, and Microsoft operating systems. Cisco only requires the user to sign up for the <a href="https://skillsforall.com/course/getting-started-cisco-packet-tracer?utm_source=netacad.com&amp;utm_medium=referral&amp;utm_campaign=packet-tracer&amp;courseLang=en-US&amp;userlogin=0&amp;userlogin=0"><em>free course</em></a>, and then a link is provided in the lessons to download the service.</p><p>A network is simply a connection between resources. A network topology is a method used for how these connected resources are arranged. Check out the image below that shows the different types of Network Topologies!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*QY3QLmnWtkT_y45k.png" /><figcaption>Image Credit to <a href="https://www.dnsstuff.com/what-is-network-topology">DNS Stuf</a>f</figcaption></figure><p>We will keep it simple for our network today while getting familiar with the Cisco Packet Tracer application. Feel free to try adding PC’s into the network once you’re feeling comfortable. Let’s get started!</p><h4>We will complete the following steps:</h4><ol><li>Build the Network Topology Diagram</li><li>Configure the Routers from the CLI</li><li>Configure the Switch</li><li>Simulation to Assess Network Connectivity</li></ol><h4>Step 1: Build the Network Topology</h4><p>Open the application and log in to the service with the same credentials that were used to sign up for the Cisco course. There are icons located at the bottom of the screen for network devices, end devices, and other options to map our network. Click <strong>Network Devices</strong>, <strong>Routers</strong>, and the <strong>4321 Router</strong> to add the icon to our workspace.</p><p><em>Note: The arrow at the top of the screen points to the button to delete resources from the workspace if there is an error.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GLcetwoVu9rIQOwHOMIhpw.png" /></figure><p>Add in another 4321 Router so that there will be two total, click the <strong>switches icon</strong>, select the <strong>3650 24PS switch</strong> to add to our workspace.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SQHfqmbFVXtzYfNArZXqdw.png" /></figure><p>Click the <strong>Connections (lightning bolt) icon</strong>, select <strong>Copper Straight-Through</strong>, click <strong>Router0</strong> in the workspace, and select <strong>GigabitEthernet0/0/0</strong>. Connect this to the switch by clicking the <strong>switch icon</strong> and selecting <strong>GigabitEthernet1/0/1</strong>. Repeat the process but this time to connect the switch with <strong>GigabitEthernet1/0/2 </strong>to Router1 with <strong>GigabitEthernet0/0/0 </strong>using the<strong> </strong>same Copper Straight-Through connection.</p><p><em>Note: If you would like to see the port labels like I have below, click </em><strong><em>Cisco Packet Tracer</em></strong><em> for a list of options, click P</em><strong><em>references</em></strong><em>, and add a check next to Always Show Port Labels in Logical Workspace. Click the </em><strong><em>Font tab</em></strong><em> for options on changing the size of the icons and CLI texts.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8EnpTahIP12d5T-Na--BZQ.png" /></figure><p>Let’s check out Router0 and see if we can add a NIM-2T module to the device. A NIM-2T is a 2 port multi-protocol Synchronous Serial NIM that would be connected to our router. Click <strong>Router0, </strong>select <strong>NIM-2T</strong> located under modules, and drag it until it is in the empty area of our physical router.</p><p>Oh no, we have an error! We need to turn the power off on the router before we can add the NIM-2T module to it. Click <strong>OK</strong> and then click the physical <strong>power button</strong> that I have boxed below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/788/1*lrGSZ-TJrc9JI9H3ZfVerg.png" /></figure><p>The green light for the power button should turn off. Drag our NIM-2T module to the device again and click the <strong>power button</strong> to turn the router back on.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6JfFFr1frHD_5d93u4iUtw.png" /></figure><p>Exit this screen to get back to the workspace. We can see that there are red arrows pointing down indicating that the connection is down. Double click the <strong>switch</strong> icon and we can see that the physical view of our switch device is missing the power supply. Grab and drag the <strong>AC-POWER-SUPPLY</strong> module to the empty space for our switch device.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/842/1*jRUufM0qrh-4FBuseTVwRQ.png" /></figure><p>If we click the CLI or Config tabs, we will see information showing that the switch is booting up.</p><h4>Step 2: Configure the Routers</h4><p>Click the <strong>CLI tab</strong>, type “no” to bypass the option of entering configuration dialog, press <strong>RETURN</strong> (or ENTER), and then we will see that we are now in the user mode on the router. User mode will let us view outputs on the router, but we won’t be able to make changes to it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/698/1*coQBt1fQd-ltIroe2doCkw.png" /></figure><p>Run the show version command to see version type, uptime, and other information about the device.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/698/1*EikjQvf0ckNGN6PdZik71g.png" /></figure><p>Press <strong>ESCAPE</strong> to leave that setting. Run theenable command so that we can gain full administrative priveleges of the device (similar to root privileges in Linux after running the sudo su command). The “#” sign will appear and if we type “?” in the CLI, we will see a list of commands that we are now allowed to use.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/698/1*QUhpIPfwpLCUAFWeUZBOXQ.png" /></figure><p>Press the ESCAPE button and enter each command below to configure our router.</p><pre>#Starts the global configuration mode<br>configure terminal<br><br>#This sets up congiguration for our host name. My hostname will be Router1. <br>hostname Router1<br><br>#Checks to see what gigabits are available for configuration<br>interface gigabitEthernet ?<br><br>#Specifies the Gigabit connection for this router<br>interface gigabitEthernet 0/0/0<br><br>#Opens the connection<br>no shut</pre><p>We can see that the connection is now up and running.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/698/1*ZfFyZEqmsv2grXCERtRUSQ.png" /></figure><p>Our workspace is showing that the arrows are green and pointing up.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/976/1*5c5Cfe2gklRSI5TpoKVA2g.png" /></figure><p>Run the command below to give the router an IP address of 10.1.1.2 and subnet mask of 255.255.255.0.</p><pre>ip address 10.1.1.2 255.255.255.0</pre><p>Run end in the CLI to be brought back to our previous “enable mode”. Next, run the code below to save the configuration.</p><pre>copy running-config startup-config</pre><p>When prompted about the destination file name, push RETURN. I tried to type “yes” initially and it gave me an error.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/819/1*5LMsR7975XWRd9bqOqYAew.png" /></figure><p>Exit the CLI for Router1 and complete the same steps to configure Router0. We will give Router0 a subnet of 10.1.1.1 and a subnet mask of 255.255.255.0. We can see now that all arrows are green and pointing up!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2LLuxn-Kj-sj574zyK_eQQ.png" /></figure><p>Run the end command to go back to privilege mode and let’s try to test our connection! Run ping 10.1.1.1 to test our router. That came back successful! We can also run show ip interface brief to check the configuration of our router and ip address.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/687/1*Wp-RHkNl1CFXguCUVw4I3A.png" /></figure><p>All good so far! Now, lets try to test the connection from Router0 to Router1 by running ping 10.1.1.2 in the CLI. My first test came back with an 80% success rate but there was a 100% success rate after I tried the ping again.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*pj4i-uqBxuYCcI9uqgvZ4g.png" /></figure><p>I also tested the connection from Router1 to Router0 and the ping was 100% successfull on the first attempt.</p><h4>Step 3: Configure the Switch</h4><p>First, let’s give our switch an easier name for us to use when referring to it in the CLI. I named mine “Switch1” by clicking the text of the icon and replacing the name. Click the CLI tab and type in the commands below.</p><pre>enable<br><br>#Gives me global configuration mode<br>configure terminal<br><br>#Gives the host a name<br>hostname Switch1<br><br>#Exits the global config mode<br>end<br></pre><p>We configured the hostname for the switch, now lets just check to to make sure that our routers can still communicate across the network.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/790/1*1Qr7ia6MiVvcK56-upZhbg.png" /></figure><h4>Step 4: Simulation</h4><p>Cisco Packet Tracer offers a Simulation tool that gives us more information about how our devices communicate with each other in a network topology. This can be very useful when trying to detect possibile vulnerabilities and communication issues within a network. Let’s see how it works!</p><p>Click Simulation, click Show All/None, and click Edit Filters. Select only ICMP for the IPv4 tab and select only NTP for the Misc tab. Now, we can send a ping from Router0 to Router1 to get a visual of how our resources will communicate within our network topology.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u5UEeq_eIWrxUShGoil97w.png" /></figure><p>We can also get Protocol Data Unit information for the device!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/453/1*69QNBuISRUwxNM2r15m0lw.png" /></figure><p>That’s it! We have successfully created and simulated a network topology using the Cisco Packet Tracer application. Please leave some claps or a comment if this article was helpful. I’d love to hear from you!</p><p><em>Follow me on LinkedIn at </em><a href="https://www.linkedin.com/in/destanyparria/"><em>https://www.linkedin.com/in/destanyparria/</em></a><em> to follow my journey in tech!</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*uVDW8_uKivGNlps6.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*OPfQ9eJ-3vII6Bjb.png" /></figure><h4>👋 If you find this helpful, please click the clap 👏 button below a few times to show your support for the author 👇</h4><h4>🚀<a href="http://from.faun.to/r/8zxxd">Join FAUN Developer Community &amp; Get Similar Stories in your Inbox Each Week</a></h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c032783fe7cf" width="1" height="1" alt=""><hr><p><a href="https://faun.pub/creating-a-network-topology-diagram-with-cisco-packet-tracer-c032783fe7cf">Creating a Network Topology Diagram with Cisco Packet Tracer</a> was originally published in <a href="https://faun.pub/">FAUN.dev() 🐾</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deploying Highly Scalable Infrastructure with Terraform]]></title>
            <link>https://aws.plainenglish.io/deploying-highly-scalable-infrastructure-with-terraform-baa4c01d265e?source=rss-b6a964ef08a6------2</link>
            <guid isPermaLink="false">https://medium.com/p/baa4c01d265e</guid>
            <category><![CDATA[terraform]]></category>
            <category><![CDATA[apache]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[autoscaling]]></category>
            <category><![CDATA[s3]]></category>
            <dc:creator><![CDATA[Destany Parria]]></dc:creator>
            <pubDate>Mon, 24 Jul 2023 22:12:00 GMT</pubDate>
            <atom:updated>2023-07-25T04:10:35.252Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*yNkcXGVcOacixVkK.png" /></figure><p>Hi everyone! Thank you for joining me as we explore more of Terraform. We are going to be launching an Auto Scaling group that will have an S3 bucket as the backend.</p><p>The Auto Scaling group needs the following:</p><ul><li>Span 2 subnets in our default VPC</li><li>Security group allowing traffic from the internet</li><li>Script to launch an Apache webserver on the EC2&#39;s</li><li>A minimum of 2 and max of 5</li></ul><p>This is the link to my GitHub repository where the code for this project is stored: <a href="https://github.com/destanyparria/terra_gold/tree/60dd38766f51c9bfdd119113d36bb061793dfa0e/week21project">Destany Parria’s GitHub week21project repo</a>.</p><p>Let’s get started!</p><h4>Step 1: Import Default VPC</h4><p>This means that we will need to import our active VPC from AWS into our configuration. Start by setting up your environment with some of the necessary configurations that we will need.</p><p>Create a directory that you will use for your Terraform files and cd into that directory. Create main.tf, variables.tf, and providers.tf files. Copy the code below into the specific files.</p><pre>#This is for the main.tf file<br><br>#Calls to our imported VPC for use<br>resource &quot;aws_default_vpc&quot; &quot;dparria_vpc&quot; {<br>  tags = {<br>    Name = &quot;Default VPC&quot;<br>  }<br>}</pre><pre>#This is for the providers.tf file<br><br># Configure the AWS Provider<br>provider &quot;aws&quot; {<br>  region = var.aws_region<br>}<br><br>terraform {<br>  required_version = &quot;&gt;= 1.4.0&quot;<br>  required_providers {<br>    aws = {<br>      source  = &quot;hashicorp/aws&quot;<br>      version = &quot;~&gt; 4.0&quot;<br>    }<br>    http = {<br>      source  = &quot;hashicorp/http&quot;<br>      version = &quot;3.3.0&quot;<br>    }<br><br>    # This allows us to save files to our local system<br>    local = {<br>      source  = &quot;hashicorp/local&quot;<br>      version = &quot;2.4.0&quot;<br>    }<br>    #this Terraform TLS provider is required to generate an SSH key<br>    tls = {<br>      source  = &quot;hashicorp/tls&quot;<br>      version = &quot;4.0.4&quot;<br>    }<br>  }<br>}</pre><pre>#This is for the variables.tf file<br><br>#Specifies the region for the infrastructure <br>variable &quot;aws_region&quot; {<br>  description = &quot;Region where the environment will be&quot;<br>  type        = string<br>  default     = &quot;us-west-2&quot;<br>}</pre><p>Run the terraform fmt command to format the code and terraform init to bring in all of our providers and initiate the backend.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/641/1*Hmh4_D55TcXqMBIPsyrN4A.png" /></figure><p>Because we already have our VPC resource block in our main.tf file, we can now import our default VPC from AWS by running the code below in the CLI.</p><pre>$ terraform import aws_default_vpc.dparria_vpc &lt;your vpc id&gt;</pre><p>Run the terraform state list command and your VPC should be listed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/641/1*gOpZfV_YkFCL6VBuiYtuUg.png" /></figure><p>Step 2: Set up our Auto Scaling Group</p><p>Add the code below to your files to set up our Auto Scaling group and the S3 bucket that be will eventually set as our backend. We must create the bucket first so that we don’t get an error stating that the S3 bucket hasn’t been created.</p><pre>#This is for the main.tf file<br><br>resource &quot;aws_default_vpc&quot; &quot;dparria_vpc&quot; {<br>  tags = {<br>    Name = &quot;Default VPC&quot;<br>  }<br>}<br><br>resource &quot;aws_launch_configuration&quot; &quot;launch_wk21&quot; {<br>  image_id                    = var.ami<br>  instance_type               = &quot;t2.micro&quot;<br>  security_groups             = [aws_security_group.sg_wk21.id]<br>  user_data                   = base64encode(&quot;${var.apacheboot}&quot;)<br>  associate_public_ip_address = true<br><br>}<br>resource &quot;aws_security_group&quot; &quot;sg_wk21&quot; {<br>  name        = &quot;sg_wk21&quot;<br>  description = &quot;Allow HTTP inbound traffic&quot;<br>  vpc_id      = aws_default_vpc.dparria_vpc.id<br><br>  ingress {<br>    description = &quot;http access&quot;<br>    from_port   = 80<br>    to_port     = 80<br>    protocol    = &quot;tcp&quot;<br>    cidr_blocks = [&quot;0.0.0.0/0&quot;]<br>  }<br><br>  ingress {<br>    description = &quot;https access&quot;<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>  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;allow_http&quot;<br>  }<br>}<br><br><br>data &quot;aws_subnet&quot; &quot;subnet1&quot; {<br>  vpc_id = aws_default_vpc.dparria_vpc.id<br>  filter {<br>    name   = &quot;tag:Name&quot;<br>    values = [&quot;public_subnet_1&quot;]<br>  }<br>}<br><br>data &quot;aws_subnet&quot; &quot;subnet2&quot; {<br>  vpc_id = aws_default_vpc.dparria_vpc.id<br>  filter {<br>    name   = &quot;tag:Name&quot;<br>    values = [&quot;public_subnet_2&quot;]<br>  }<br>}<br><br><br>resource &quot;aws_autoscaling_group&quot; &quot;asg_wk21&quot; {<br>  desired_capacity     = 2<br>  max_size             = 5<br>  min_size             = 2<br>  vpc_zone_identifier  = [<br>  data.aws_subnet.subnet1.id,<br>  data.aws_subnet.subnet2.id<br>  ]<br>  launch_configuration = aws_launch_configuration.launch_wk21.id<br>  tag {<br>    key                 = &quot;Name&quot;<br>    value               = &quot;asg_wk21&quot;<br>    propagate_at_launch = true<br><br>  }<br>}<br><br><br>resource &quot;aws_s3_bucket&quot; &quot;dparrias3wk21&quot; {<br>  bucket = var.dparrias3wk21<br><br>  tags = {<br>    Name = &quot;DParriaS3&quot;<br><br>  }<br>}<br><br>resource &quot;aws_s3_bucket_versioning&quot; &quot;s3version&quot; {<br>  bucket = aws_s3_bucket.dparrias3wk21.id<br><br>  versioning_configuration {<br>    status = &quot;Enabled&quot;<br>  }<br>}<br><br>resource &quot;aws_s3_bucket_ownership_controls&quot; &quot;ownership_s3&quot; {<br>  depends_on = [aws_s3_bucket.dparrias3wk21]<br>  bucket     = aws_s3_bucket.dparrias3wk21.id<br>  rule {<br>    object_ownership = &quot;BucketOwnerPreferred&quot;<br>  }<br>}<br><br>resource &quot;aws_s3_bucket_acl&quot; &quot;s3aclwk21&quot; {<br>  depends_on = [aws_s3_bucket_ownership_controls.ownership_s3]<br><br>  bucket = aws_s3_bucket.dparrias3wk21.id<br>  acl    = &quot;private&quot;<br>}</pre><pre>#This is for the variables.tf file<br><br>variable &quot;ami&quot; {<br>    description = &quot;ami-id&quot;<br>    type = string<br>    default = &quot;ami-0bef6cc322bfff646&quot;<br>}<br><br>variable &quot;apacheboot&quot;{<br>    description = &quot;Bootstraps EC2 with Apache Webserver&quot;<br>    type = string<br>    default = &lt;&lt;-EOF<br>    <br>    #!/bin/bash<br>    sudo yum update -y<br>    sudo yum install -y httpd<br>    sudo systemctl start httpd<br>    sudo systemctl enable httpd<br>    sudo systemctl restart httpd<br>    EOF<br>}<br><br>variable &quot;dparrias3wk21&quot; {<br>  description = &quot;S3 bucket for ASG remote backend&quot;<br>  type        = string<br>  default     = &quot;dparrias3wk21&quot;<br>}<br></pre><p>We should be ready to launch our resources! Run terraform fmt, terraform init, terraform validate, and terraform apply to launch our resources.</p><p>When I initally ran the code, I was having getting an error stating that my launch resource could not be found. After some trouble shooting, I found that my AMI ID was not correct for the image that I was trying to use. I revised the AMI ID and then my launch configuration and auto scaling group were finally deployed with the rest of my resources!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/623/1*rjYMkGLEQUxqB6vv48O1Dw.png" /></figure><p>Our instances are successfully running!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7JHnHgmNwRS34BF5NtTpjQ.png" /></figure><p>Let’s check the instances to make sure that Apache is installed by pasting the IP address of the instance into the internet browser.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*w7f01of745RWl3QFNal6cQ.png" /></figure><p>I tested our auto scaling group by stopping one of the instances. After terminating that instance, another instance was automatically created shortly after!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UnwgR6zN2z-U4DULKuz4QQ.png" /></figure><h4>Step 3: Set the S3 Bucket as the remote backend</h4><p>Add the code below into the providers.tf file.</p><pre>terraform {<br>  backend &quot;s3&quot; {<br>    bucket = &quot;dparrias3wk21&quot;<br>    key = &quot;terraform.tfstate&quot;<br>    region = &quot;us-west-2&quot;<br>  }<br>}</pre><p>Now, run the terraform init command.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/615/1*Jb4vHpUNRLwQagy04NDgVg.png" /></figure><p>Let’s go into S3 to make sure that the information is there.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*F7Hxz5cGC1CT2umJ4z2hYg.png" /></figure><p>Congrats! We launched an Auto Scaling group that has an S3 bucket as the backend. Please leave some claps or a comment if this article was helpful. I’d love to hear from you!</p><p><em>Follow me on LinkedIn at </em><a href="https://www.linkedin.com/in/destanyparria/"><em>https://www.linkedin.com/in/destanyparria/</em></a><em> to follow my journey in tech!</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*Soir0Guc7SV-Mjbe.png" /></figure><p><em>More content at </em><a href="https://plainenglish.io/"><strong><em>PlainEnglish.io</em></strong></a><em>.</em></p><p><em>Sign up for our </em><a href="http://newsletter.plainenglish.io/"><strong><em>free weekly newsletter</em></strong></a><em>. Follow us on </em><a href="https://twitter.com/inPlainEngHQ"><strong><em>Twitter</em></strong></a>, <a href="https://www.linkedin.com/company/inplainenglish/"><strong><em>LinkedIn</em></strong></a><em>, </em><a href="https://www.youtube.com/channel/UCtipWUghju290NWcn8jhyAw"><strong><em>YouTube</em></strong></a><em>, and </em><a href="https://discord.gg/GtDtUAvyhW"><strong><em>Discord</em></strong></a><strong><em>.</em></strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=baa4c01d265e" width="1" height="1" alt=""><hr><p><a href="https://aws.plainenglish.io/deploying-highly-scalable-infrastructure-with-terraform-baa4c01d265e">Deploying Highly Scalable Infrastructure with Terraform</a> was originally published in <a href="https://aws.plainenglish.io/">AWS in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Creating an EC2 and IAM Role to Scan a Serverless Database]]></title>
            <link>https://towardsaws.com/creating-an-ec2-and-iam-role-to-scan-a-serverless-database-586eaa92f782?source=rss-b6a964ef08a6------2</link>
            <guid isPermaLink="false">https://medium.com/p/586eaa92f782</guid>
            <category><![CDATA[dynamodb]]></category>
            <category><![CDATA[database]]></category>
            <category><![CDATA[iam-roles]]></category>
            <category><![CDATA[ec2]]></category>
            <category><![CDATA[ssh]]></category>
            <dc:creator><![CDATA[Destany Parria]]></dc:creator>
            <pubDate>Mon, 24 Jul 2023 00:38:26 GMT</pubDate>
            <atom:updated>2023-08-05T12:32:17.378Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UtC4jqJ6x5JR2oD4pRtFdg.png" /></figure><p>Hi everyone! Thanks for joining me while I dive deeper into DynamoDB and EC2. My DynamoDB table will show some different ways people say hello! It won’t be the typical “Hello World” from testing different types of technology, but it will still be fun!</p><p>Lets get started!</p><h4>Step 1: Create a DynamoDB Table</h4><p>Go to the DynamoDB console and click <strong>Create Table</strong>. Give the table a name, input the name for the Partition Key and Sort Key, and then select the data type in which the items will be stored. The “String” data type will be sufficient for my data, so I will leave that as the default.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R6FjRetwwtKsOBupQU_tHA.png" /></figure><p>Leave the rest of the settings as default and click <strong>Create Table</strong>.</p><h4>Step 2: Add 10 or more items to the table</h4><p>Within the DynamoDB table, click <strong>Actions</strong> and then click <strong>Create items</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1011/1*LkH9V4kIcKaD5QPe3YPIOg.png" /></figure><p>Input all items into the attribute section below and click to create the item.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iV2smTXVuWhKAdPdtu1Ewg.png" /></figure><p>After we add all of the items, click the option to add them to the table, and then they will all show up as data in the table in the DynamoDB console.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/684/1*Ru78NwCh7ll6OK9_qYy4NA.png" /></figure><h4><strong>Step 3: Create an IAM role granting an EC2 read access to the table</strong></h4><p>Go to the IAM console, click <strong>Roles</strong>, click <strong>Create role</strong>, leave AWS Service as the trusted type, click <strong>EC2</strong> for the use case, and click <strong>Next</strong>. Search “dynamodb” in the permissions section below, select the policy with read-only permissions, and click N<strong>ext</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B44ZbXT-nJaqx4Es1zO0bg.png" /></figure><p>Type in the name for the role and click <strong>Create role</strong>.</p><h4><strong>Step 4: Create a t.2micro Ec2 instance</strong></h4><p>Click <strong>Launch instances</strong> in the EC2 console, give the EC2 a name, and keep the AMI and Instance type sections as default. Select your Key pair to SSH into the instance, and click <strong>Create security group</strong>.</p><p><em>NOTE: Make sure your VPN for your IP address is running because we will use the IP address as the only way to SSH into the instance.</em></p><p>Click to allow SSH traffic from our IP address that the VPN created, scroll down to the Advanced details section, and select the DynamoDBReadAccess role from the IAM instance profile.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/573/1*cD63CUgvVLfh7DuQnvg2ow.png" /></figure><p>Click <strong>Launch instance</strong>.</p><h4>Step 5: Use EC2 to access and scan the DynamoDB table.</h4><p>Copy the SSH information for the Connect to instance section of your EC2. The message below shows that we are officially in the EC2 instance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/651/1*DzpXGMGgl_HOgApBuExl9A.png" /></figure><p>Scan the table by entering the code below:</p><pre>aws dynamodb scan --table-name &lt;name_of_dynamodb_table&gt; --region us-east-1</pre><p>We can see below that our scan was successful!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/501/1*nrhC5AGH6hAVnjos4oUP1w.png" /></figure><p>Congrats! You created a serverless database, an EC2 instance, and roles to work with those resources. Please leave some claps or a comment if this article was helpful!</p><p><em>Follow me on LinkedIn at </em><a href="https://www.linkedin.com/in/destanyparria/"><em>https://www.linkedin.com/in/destanyparria/</em></a><em> to follow my journey in tech!</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*C_1JgSlAQ5IuZRgE.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=586eaa92f782" width="1" height="1" alt=""><hr><p><a href="https://towardsaws.com/creating-an-ec2-and-iam-role-to-scan-a-serverless-database-586eaa92f782">Creating an EC2 and IAM Role to Scan a Serverless Database</a> was originally published in <a href="https://towardsaws.com/">Towards AWS</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Auto Scaling and Load Balancing with an Apache Webserver]]></title>
            <link>https://medium.com/@destanyparria/auto-scaling-and-load-balancing-with-an-apache-webserver-9fe2a50223ed?source=rss-b6a964ef08a6------2</link>
            <guid isPermaLink="false">https://medium.com/p/9fe2a50223ed</guid>
            <category><![CDATA[ec2]]></category>
            <category><![CDATA[apache]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[website-development]]></category>
            <category><![CDATA[autoscaling]]></category>
            <dc:creator><![CDATA[Destany Parria]]></dc:creator>
            <pubDate>Sun, 23 Jul 2023 16:43:12 GMT</pubDate>
            <atom:updated>2023-07-23T18:17:57.060Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nAUc0s9JTWAwyKK9SCONQQ.png" /></figure><p>Hi everyone! Thanks for joining while we dive deeper into AWS resources. Make sure to keep an eye out for some gems that are noted throughout this article! Today, we will be using the AWS console to create an Auto-Scaling Group of EC2 instances for high availability. High availability is important to ensure that applications and services hosted on these instances remain accessible and responsive at all times. Let’s take a look at the scenario!</p><h4>Scenario:</h4><p>Your company is moving from on-premise to the cloud and has an e-commerce website that experiences higher traffic during peak shopping hours and lower traffic during regular weekdays. The company would like a dynamic scaling capability to ensure that the application remains responsive, performs optimally, and can handle sudden traffic spikes, providing a reliable experience for customers without the need for manual intervention. The company also stresses the importance of saving on costs during off-peak hours.</p><h4>Steps to Follow:</h4><ol><li>Create a VPC with cidr 10.10.0.0/16</li><li>Create three public subnets with 10.10.1.0/24 &amp; 10.10.2.0/24 &amp; 10.10.3.0/24</li><li>Create an autoscaling group using t2.micro instances. All instances should have Apache installed on each instance with the ability to be able to produce a test page. Ensure the autoscaling group is using the second public subnet that we created.</li><li>The autoscaling min and max should be 2 and 5.</li><li>Create an Application Load Balancer to distribute traffic to the autoscaling group.</li><li>Create web server security group that allows inbound traffic from HTTP from your Application Load Balancer. As a security precaution, no one should be able to use the public ip of your webserver to reach your website. All users should be using the Application Load Balancer.</li><li>Create a load balancer security group that allows inbound traffic from HTTP from 0.0.0.0/0.</li><li>Use the DNS url of the Application Load Balancer in a browser to verify you can reach your site.</li></ol><h4>Step 1: Create a VPC</h4><p>Go to the VPC console in AWS and click <strong>Create VPC</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yqfYRQVaPQ7a-4caNjD9dw.png" /></figure><p>We will focus on only the VPC for this step so click VPC only, give the tag for the VPC a name, and input the IPv4 CIDR of 10.10.0.0/16 that our company requested for us to use.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p2kLz2bT6vNENHxYTlPjSQ.png" /></figure><p>Click <strong>Create VPC</strong> and then we should see that the VPC is in an “Available” state in the VPC console. We will use this VPC throughout the duration of the project.</p><h4>Step 2: Create Three Public Subnets</h4><p>It is important to create these three subnets in different availability zones so that we can use them with the Application Load Balancer (ALB) that we will create later. I initially had my subnets in the same availability zone and it caused errors. I was able to find the solution after reading into the <a href="https://docs.aws.amazon.com/elasticloadbalancing/latest/application/introduction.html">AWS ALB documentation</a>.</p><p><em>Note: </em><a href="https://cidr.xyz/"><em>cidr.xyz</em></a><em> is an interactive IP address and CIDR range visualizer website that can help with networking.</em></p><p>Click <strong>Subnets</strong> in the menu to the left of the VPC console and click <strong>Create subnet</strong>. Select our VPC and use the information below to create our subnets:</p><ul><li>Subnet 1: Use “Public-Subnet-1” as the name, choose us-east-1a for the Availability Zone, and type in “10.10.1.0/24” for the CIDR block. Click <strong>Add new subnet </strong>to create the second subnet.</li><li>Subnet 2: Use “Public-Subnet-2” as the name, choose us-east-1b for the Availability Zone, and type in “10.10.2.0/24” for the CIDR block. Click <strong>Add new subnet </strong>to create the third subnet.</li><li>Subnet 3: Use “Public-Subnet-3” as the name, choose us-east-1c for the Availability Zone, and type in “10.10.3.0/24” for the CIDR block.</li></ul><p>Click <strong>Create subnet</strong> and we can see below that our subnets were successfully created.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dLk3-THNlpeAaJ9UYmtK8g.png" /></figure><p>We included “Public” in the name of our subnets, but are they actually public if they are not attached to an internet gateway? In this case, no! We must create an internet gateway so that the public can reach our subnets.</p><p>In the options on the left of the screen, click <strong>Internet gateways</strong> and click <strong>Create internet gateway</strong> . Give the internet gateway a name and click <strong>Create internet gateway</strong> at the bottom.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*y-yeXKqSHM-WXK1YQepbPg.png" /></figure><p>Next, connect the internet gateway to the VPC. If the “Attach to a VPC” option is not already showing up in the green banner at the top of the screen, click <strong>Actions, </strong>click <strong>Attach to a VPC,</strong> select our VPC and then click <strong>Attach internet gateway</strong>. We can see below that we have successfully created and attached our internet gateway.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*gfMqDVM-0BgliPpzGe7F7Q.png" /></figure><p>Unfortunately, there doesn’t seem to be a connection between the route table and the network connection. Go to the route table, click <strong>Edit routes, </strong>click <strong>Add route</strong>, put 0.0.0.0/0 so that the destination will be anywhere, click <strong>Internet Gateway</strong> in the “Target” section, and click <strong>Save changes</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cRh6z2lbKA-7CMVmYvFHeg.png" /></figure><p>Go to the “Resource map” section of your VPC to check the architecture and configuration of what we have built so far! The map should look similar to what I have below. I renamed my route table so that it will be easily identifiable.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*19814KF1E0q2NthHw-QD9A.png" /></figure><p>Our subnets are officially public! On to the next step!</p><p><em>Note: We can also test this out by using the Reachability Analyzer tool that AWS offers. There will only be a charge of around 10 cents so it can be worth it in some situations!</em></p><h4>Step 3: Create an Auto-Scaling Group</h4><p>Go to the EC2 console, click <strong>Auto Scaling Groups</strong>, and click <strong>Create Auto Scaling group</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XlkwrDeuATgfYcYI0BtlJw.png" /></figure><p>Name of the Auto Scaling group and click <strong>Create a launch template</strong>. The launch template will allow for you to create a saved instance configuration that can be shared and reused.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-N5bN-F7cuMJg0El2zfmSw.png" /></figure><h4><strong>Creating a Launch Template:</strong></h4><ul><li>Type a name and the description for the launch template.</li><li>Select the <strong>Ubuntu Server 20.04 LTS (HVM), SSD </strong>AMI</li><li>Click <strong>t2.micro</strong> in the Instance type section</li><li>Select the key pair that you would like to use to connect to the instance.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/757/1*MVNEdPj5BKcW_y01avlhsw.png" /></figure><ul><li>Go to the Network Settings section and select an existing security group.</li><li>Go to Advanced details, Click <strong>Enable</strong> for Detailed CloudWatch monitoring</li><li>Go to the User data field and input the script to have an Apache web server installed on the EC2 instances.</li></ul><p>The script that I have below is what I will be using in the User data field. This will install Apache and a Python based stress test to test our EC2 instances.</p><pre>#!/bin/bash<br>sudo su<br>apt update -y<br>apt upgrade -y<br>apt-get install -y apache2<br>systemctl start apache2<br>systemctl enable apache2<br><br>apt-get install -y python3-pip<br>pip install s-tui<br>apt-get install stress</pre><p>That should be it! Click <strong>Create launch template</strong> and move back to the Auto Scaling group tab.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NCshUvfoDFFSzOU6rC0yCA.png" /></figure><h4><strong>Back to Creating an Auto Scaling Group!</strong></h4><p>Click to <strong>refresh</strong> the options for launch templates, select the launch template, and click <strong>Next</strong>. Select the VPC, select Public-Subnet-2 for the Availability Zones and subnets, and click <strong>Next</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gBbotqPGJGntVI5SVzkJPg.png" /></figure><p>Click <strong>No load balancer, </strong>go<strong> </strong>to the Additional settings section, and click to <strong>Enable group metrics collection within CloudWatch. </strong>This will allow more visibility of the changes and other details of our Auto Scaling group. Click to<strong> Enable default instance warm up</strong>, and put 30 seconds for the period that CloudWatch will wait before gathering data for instances that are just starting.<strong> </strong>Click <strong>Next</strong> to continue.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/823/1*IQd-Rrit1CZAxKVLYcphQw.png" /></figure><p>Click <strong>Target tracking scaling policies</strong>, give the scaling policy a name, click <strong>Average CPU utilization</strong> as the Metric type, keep 50 as the Target value and keep the default of 30 seconds to warm up before including in metric for testing purposes. Click <strong>Skip to review</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/685/1*mxou4tlq39GVqFMK0o-jEw.png" /></figure><p>Review all of the details of the Auto Scaling group. If everything looks okay, click <strong>Create Auto Scaling group.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/747/1*D-NBQjzhOYVDxj7ipLGFTQ.png" /></figure><p>Our Auto Scaling group was successfully completed and our instance is running!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g0x6q01X9Zrr2C_sj9jzuQ.png" /></figure><p>We’re ready for the next step!</p><h4>Step 4: The Auto Scaling min and max is 2 and 5:</h4><p>Go to the Group details section of the Auto Scaling group and click <strong>Edit</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NLSzF5OJ74MBNrWXLvJTLA.png" /></figure><p>Revise the Desired capacity to be 3, Minimum capacity to be 2, the Maximum capacity to be 5, and then click <strong>Update</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/649/1*UE8jvo9gm__VAI5VLODBmA.png" /></figure><p>The capacity for our ACG was successfully updated!</p><h4>Step 5: Create an Application Load Balancer</h4><p>Go to the EC2 console, click <strong>Load Balancers</strong> within the Resources section, and click <strong>Create Load balancer</strong>. Click <strong>Create</strong> under the Application Load Balancer option.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/983/1*WkYG5DzBSykGQ5OPM4RO9g.png" /></figure><p>Name the load balancer, select <strong>Internet-facing</strong> for the scheme, and click <strong>IPv4</strong> for the IP address type. Select the correct VPC, select the three public subnets that we created, and select a security group.</p><p>The Listeners and routing section is showing HTTP protocol with Port 80 by default, which is exactly what we are needing. Click <strong>Create target group</strong> to create a target for our Load Balancer to distribute traffic to our auto scaling group.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*D0pIt6PXfOCJlo46vvSByg.png" /></figure><p>Click <strong>Instances </strong>for the target type, put in the name for the target group, put <strong>HTTP : 80</strong> as the Protocol, select the correct VPC, select HTTP1 as the Protocol version, click <strong>Next</strong>, and then click <strong>Create Target group</strong>.</p><p>Go back to the Load Balancer console, click the refresh button and the option bar, select the new target.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/984/1*8VUsnFYJ64eE2dN4BCNDHA.png" /></figure><p>Click Create Load Balancer and then we should see a screen showing that the Load Balancer was created!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qQxDSo8EWRdVkyJ-s_uf8w.png" /></figure><h4>Step 6: Create a webserver security group</h4><p>We have to create a webserver that allows inbound traffic from HTTP from your Application Load Balancer. I found this <a href="https://repost.aws/knowledge-center/public-load-balancer-private-ec2">AWS documentation</a> that was great with helping me to better understand and plan how to complete these security group tasks.</p><p>Go to security groups and click Create security group, give it a name and description, and attach the VPC.</p><p>Click Add rule in the Inbound rules section, Select HTTP with 80 as the port range, and select Custom as the source. Copy the security group ID from the Application Load Balancer and paste it into the custom ip area.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7M0sFNKZxtNbp20vyaTaEQ.png" /></figure><h4>Step 7: Create a load balancer security group</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Y5SOvJwp_juf3QDVc-HjJA.png" /></figure><p>That’s it! It’s time to test out our webserver!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Q9bzOJahcQN9mpUz7cEIAg.png" /></figure><p>Congrats! Our Apache web server was successfully created!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9fe2a50223ed" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Creating Security Groups and an EC2 to Host an Apache Web Server]]></title>
            <link>https://aws.plainenglish.io/creating-security-groups-and-an-ec2-to-host-a-apache-web-server-d19d56db23fc?source=rss-b6a964ef08a6------2</link>
            <guid isPermaLink="false">https://medium.com/p/d19d56db23fc</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[apache]]></category>
            <category><![CDATA[ec2]]></category>
            <category><![CDATA[website]]></category>
            <category><![CDATA[linux]]></category>
            <dc:creator><![CDATA[Destany Parria]]></dc:creator>
            <pubDate>Mon, 10 Jul 2023 21:58:52 GMT</pubDate>
            <atom:updated>2023-07-11T04:07:14.396Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BxROwZVpN53IHfSBSv2dKA.png" /></figure><p>Hi there! Today, we’re going to keep it as simple as possible as we dive into AWS to install an EC2 instance and an Apache Web Server. EC2, or Amazon Elastic Compute Cloud, is great to use because it offers reliability, cost-effectiveness, scalability, and flexibility that lives up to its name, so to speak!</p><h4>Scenario:</h4><p>Your company wants to start shifting from using on-premise servers to using servers in the cloud. Rather than purchasing all of the infrastructure in a data center, they ask you to create an EC2 instance in AWS to host their new website.</p><p>Before we get started, let’s review a few key terms that will be referenced in this guide:</p><p><strong><em>EC2 Instance — </em></strong>An EC2 instance is a virtual server in the cloud that runs applications and services while also providing scalable computing.</p><p><strong><em>Apache Web Server </em></strong>— An open source software, meaning that it’s free, that hosts websites and web applications. Apache is known for its stability and reliability, but it is also very secure due to the focus on its security features.</p><p><strong><em>On-Premise Server </em></strong>— A physical server that is personally owned and managed.</p><p><strong><em>AWS Cloud</em></strong> — A service that offers on-demand delivery of IT resources over the Internet with pay-as-you-go pricing.</p><p><strong><em>VPC (Virtual Private Cloud)</em></strong> — A isolated virtual network that you can launch AWS resources into.</p><h4>Prerequisites:</h4><ul><li>Computer with high speed internet</li><li>An AWS Management Console Account (Free tier will suffice)</li><li>An active default Virtual Private Cloud (VPC).</li><li>A public Subnet</li></ul><h4>Steps to Follow:</h4><ol><li>Launch an EC2 Amazon Linux t2.micro (free tier) in a public subnet of your <strong>Default VPC</strong>.</li><li>Create a security group that allows inbound traffic on HTTP for 0.0.0.0/0 and allows inbound traffic on SSH from your ip address.</li><li>SSH into your EC2 instance and install Apache with a custom webpage using a BASH script. (The webpage can be a simple Hello World or something more complex.)</li></ol><h4>Step 1: Launch the EC2</h4><p>We will start by launching an EC2 Amazon Linux t2.micro in a public subnet of the VPC. Go to the EC2 console and click L<strong>aunch Instance</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GecTE8JYCvtIMYzZtANYLg.png" /></figure><p>We will then add the name of our EC2 instance. For this task, I named the instance “Apache_EC2”. Keep the AMI and the architecture as its default. We will also see that the default instance type for the EC2 is t2.micro, which is what our company is requesting for us to use. Select a key pair or click <strong>Create new key pair</strong> if you don’t already have one. You can also view <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/create-key-pairs.html">documentation on how to create a key pair</a> if you need assistance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uIQIjDLHuCir5RXVqvTnkg.png" /></figure><p>Continue to stroll down to the Network Settings section and then we can move on to step 2!</p><h4>Step 2: Create a Security Group</h4><p>Our company is requiring for us to create a security group for the instance that allows inbound traffic on HTTP for 0.0.0.0/0 and allows inbound traffic on SSH from your IP address. In the Network Settings section, click <strong>Select existing security group</strong> and then right click <strong>Security Groups</strong> and open a new tab.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3qbO53pWJzeI8A0UlANMqw.png" /></figure><p>In the new Security Groups tab, click <strong>Create security group</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UF0-F_hT3K1hTSNkJQTlkw.png" /></figure><p>We will then name the security group, give it a description, and make sure that the correct VPC is selected for the security group. Stroll to the Inbound Rules section and input the rules that are required. Fortunately, we only have to click My IP in the source dropdown for our SSH rule and AWS will automatically input our IP address for us. I crossed through the IP address in an effort to protect sensity information.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WS840gExC2NCzGhuaKjGQQ.png" /></figure><p>We can leave the outbound traffic the same as the default and click Create Security Group. Go back to the tab for the EC2 instance and click the drop down to select the security group that we just created.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Z_c9KQ_o0nWrZOFFNTExEQ.png" /></figure><p>Scroll down and click <strong>Launch instance</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xuROdTmuOalYl1suL6n2oQ.png" /></figure><p>We can see in our EC2 console that the instance was created and is running!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7zjUN10Xh5tdOErW4cNoGw.png" /></figure><p>If we click into the EC2’s I<strong>nstance ID</strong>, click <strong>Security</strong>, and then stroll to the Inbound rules section, we can see that our security group was successfully added to the instance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e_vse6QxNUqIpxO55AVPYg.png" /></figure><p>We’re on a roll! Let’s move on to Step 3!</p><h4>Step 3: SSH Into EC2 Instance to Install an Apache Webserver</h4><p>Go to your EC2 instance and copy the Public IP address so that we can use it for our code to SSH into the instance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wYQfhTbuBV3QOtc10Gfk1Q.png" /></figure><p>We will then go into the local CLI and enter the code below. Make sure to update the IP address and the pem file information.</p><pre>ssh -i &lt;file location&gt;/EC2-Destany.pem ec2-user@&lt;EC2 Public IP&gt; </pre><p>After running that command, we will be prompted to accept the connection and then we should see the message below showing that we are in the operating in the EC2.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/691/1*-bSK3FS3P09nO5BCCmIT6w.png" /></figure><p>Run the sudo su command to gain root privileges and run the commands without having to apply sudo each time. You should then see a change where it was ec2-user@&lt;ip_address&gt; to now root@&lt;ip_address&gt; and the “$” changed to “#”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/393/1*r4zRNAO7WwUo4ORg6cIzEA.png" /></figure><p>Run touch &lt;file name&gt; to create a file and then vim &lt;file name&gt; to enter the script below inside of that file. For this assignment, the file will be named apachescript.sh. Check out this <a href="https://sites.radford.edu/~mhtay/CPSC120/VIM_Editor_Commands.htm">Vim cheat sheet</a> if you need any help with moving around the file.</p><pre>#!/bin/bash<br><br>yum update -y<br><br>yum install -y httpd<br><br>systemctl start httpd<br><br>systemctl enable httpd<br></pre><p>Run chmod u+x apachescript.sh in the CLI to grant the permission to exe:cute the bash script file. Now we can run the script to attach the Apache webserver! Run ./apachescript.sh in the CLI to execute the script in your EC2 instance. Now, we will put our EC2’s public IP address into the web browser to see if the Apache webserver is running.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3Dcfzodvait0fwZ4fZl94A.png" /></figure><p>Success! Now, lets spice up our web page with a custom message! Run cd /var/www/html/ in the CLI, create a file by running touch index.html, and open that file for editing by running vim index.html. Input the code below, but feel free to change the message to whatever you like.</p><pre>&lt;html&gt;<br>&lt;body&gt;<br>&lt;h1&gt;Welcome to my Apache web server!&lt;/h1&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;</pre><p>Exit vim and then run systemctl restart httpd for the Apache web server to make the changes. Let’s try out the new message by refreshing our web page in the browser or putting in our IP address again.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vbqWM-w2wUKrkpgx_FeTiQ.png" /></figure><p>Congrats! You have officially created an EC2 instance, created security groups, installed and started an Apache web server on the EC2 host, and spiced up your web page by creating a custom message! Leave some claps or a comment if this article was helpful. I’d love to hear from you!</p><p><em>Follow me on LinkedIn at </em><a href="https://www.linkedin.com/in/destanyparria/"><em>https://www.linkedin.com/in/destanyparria/</em></a><em> to follow my journey in tech!</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*yPFTcH3fLm350gFZ.png" /></figure><p><em>More content at </em><a href="https://plainenglish.io/"><strong><em>PlainEnglish.io</em></strong></a><em>.</em></p><p><em>Sign up for our </em><a href="http://newsletter.plainenglish.io/"><strong><em>free weekly newsletter</em></strong></a><em>. Follow us on </em><a href="https://twitter.com/inPlainEngHQ"><strong><em>Twitter</em></strong></a>, <a href="https://www.linkedin.com/company/inplainenglish/"><strong><em>LinkedIn</em></strong></a><em>, </em><a href="https://www.youtube.com/channel/UCtipWUghju290NWcn8jhyAw"><strong><em>YouTube</em></strong></a><em>, and </em><a href="https://discord.gg/GtDtUAvyhW"><strong><em>Discord</em></strong></a><strong><em>.</em></strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d19d56db23fc" width="1" height="1" alt=""><hr><p><a href="https://aws.plainenglish.io/creating-security-groups-and-an-ec2-to-host-a-apache-web-server-d19d56db23fc">Creating Security Groups and an EC2 to Host an Apache Web Server</a> was originally published in <a href="https://aws.plainenglish.io/">AWS in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using Terraform to Deploy AWS Resources and Set Up Jenkins]]></title>
            <link>https://aws.plainenglish.io/using-terraform-to-deploy-aws-resources-and-set-up-jenkins-4f447efc16b7?source=rss-b6a964ef08a6------2</link>
            <guid isPermaLink="false">https://medium.com/p/4f447efc16b7</guid>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[terraform]]></category>
            <category><![CDATA[jenkins]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[s3]]></category>
            <dc:creator><![CDATA[Destany Parria]]></dc:creator>
            <pubDate>Fri, 07 Jul 2023 20:56:29 GMT</pubDate>
            <atom:updated>2023-07-10T01:04:00.942Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*opw7y9y8iTSqRCH_nGyLGA.png" /></figure><p>Hi everyone! Thank you for joining me as we dive into some of the cool functions that Terraform has to offer. Terraform is an IAC platform, which means that it doesn’t help develop applications but it is a it’s a way to deploy infrastructure. It is important to understand that if you are preparing for the Hashicorp: Terraform Associate exam! Today, we will use Terraform with Jenkins and AWS to deploy and bootstrap an EC2 instance in our active VPC, create security groups, and deploy a private S3 bucket. Let’s review some key terms before jumping into our tasks for today!</p><h4>Key Terms</h4><p><strong>State file</strong> — Terraform uses the terraform.tfstate file to determine the changes to make to your infrastructure so that it will match your configuration file. This file is automatically generated by Terraform and it is used for every configuration regardless of the backend or simplicity of the configuration file. Be aware that this file can hold sensitive information that you may not want public.</p><p><strong>Provider</strong> — A provider is a plugin that allows Terraform to reach the external API to create, manage, and delete resources.</p><p><strong>Jenkins</strong> — An open source automation server.</p><p><strong>Resource Block</strong> — A resource block declares a resource of a certain type and name that will be created or used in your infrastructure. The resource type and name serves as an identifier for the specific resource so it must be unique. <a href="https://developer.hashicorp.com/terraform/language/resources/syntax"><em>Source</em></a></p><p><strong>Variable Block</strong> — Allows you to refer to information that may be used throughout your configuration and easily make changes to one file without having to revise each block and modules that calls the variable.<em> </em><a href="https://developer.hashicorp.com/terraform/language/values/variables"><em>Source</em></a></p><h4>Configuring Terraform with your AWS Account</h4><p>We can use environment variables in the CLI to configure your AWS account to your environment by running the following:</p><pre>export AWS_ACCESS_KEY=&quot;my_access_key&quot;<br>export AWS_SECRET_KEY=&quot;Example&quot;</pre><p>We can also use this code in your terraform file to configure your AWS environment, store your AWS access keys, and still push to GitHub because it only shows the path where the keys are stored, but not the actual keys.</p><pre># Configure the AWS Provider<br>provider &quot;aws&quot; {<br>  region = &quot;&lt;your AWS region&gt;&quot;<br>  #this gives the path to the access key<br>  shared_credentials_file = &quot;/users/example/.aws/creds&quot;<br>  #this points out the profile in the file if there are multiple<br>  profile = &quot;&lt;example-us-east-1&gt;&quot;<br>}</pre><p>We should be all set to take on our challenge now! The <a href="https://registry.terraform.io/browse/providers">Terraform Registry</a> is great to keep handy in an open tab on your browser, as it is the place where we can find all of the information for our resources across AWS and several other services. <a href="https://developer.hashicorp.com/terraform/language">Terraform Documentation</a> will be useful to refer to for how to use the Terraform language for syntax, expressions, and other important information. Because we will be installing Jenkins on our instance, the <a href="https://www.jenkins.io/doc/tutorials/tutorial-for-installing-jenkins-on-AWS/">Jenkins documentation</a> is also useful to have during this tutorial. I also have my GitHub repository shown here if you would like to refer back to my code: <a href="https://github.com/destanyparria/terra_gold/tree/34d4061bf6ffa5d9bfc10c6363e5d6ffd4b3d440/Week20Project">Destany Parria’s Week 20 Terraform GitHub repository</a>.</p><h4>Step 1: Deploy 1 EC2 Instance in your Default VPC</h4><p>We will first have to begin by initializing our terraform configuration file by running the terraform init command. Running this command is what will install all of the required plugins for the providers that we have listed in our terraform block. Now, lets run the terraform validate command to ensure that our configuration file has the correct syntax and that nothing else is needed to move forward. We should get a response stating that the configuration is valid.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fSPnkPrs_eGrr4Kul6wriA.png" /></figure><p>Because we already have our VPC resource block in our main.tf file, we can now import our default VPC from AWS by running the code below in the CLI.</p><pre>$ terraform import aws_default_vpc.dparria_vpc &lt;your vpc id&gt;</pre><p>We should get the message shown below if the import is successful! I crossed through the VPC ID information in the picture below in an effort to protect sensitive information. Please be aware that this information will show in the CLI when running the import command and it will also show in your terraform.tfstate file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3j0Ttm_dL40y48AmO7k6UA.png" /></figure><p>Now that we have our default VPC managed by our Terraform configuration, we’re ready to start building our EC2 instance!</p><p>Input the following code to the configuration file to install the EC2:</p><pre>#Creates our EC2 instance<br>resource &quot;aws_instance&quot; &quot;jenkins_ec2&quot; {<br>  ami           = &quot;ami-0e618811ec643488b&quot;<br>  instance_type = &quot;t2.micro&quot;<br><br>  tags = {<br>    Name = &quot;ThisEC2IsForJenkins&quot;<br>  }<br>}</pre><p>Now, we can run terraform fmt to ensure that our format is correct, terraform validate to ensure that our syntax is correct, terraform init to initialize our configuration, and terraform plan to check out the changes that will be made by our new configuration after comparing it to our terraform.tfstate file. We can see below that there is one resource to add and nothing to change or destroy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AI1DE0S8FbOjR-1L03MYjQ.png" /></figure><p>If we scroll up in our CLI, we can see that the resource that will be created will be the EC2 instance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZdCAvoczJMwsGazMGZRNpQ.png" /></figure><p>Let’s run terraform apply and see if it works out! Terraform apply should also show that you have only the EC2 instance to add and it will prompt you to enter ‘yes’ to confirm that you approve the change. After confirming the change, you should get a message stating that the apply is complete and that one resource was added.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Sg0pV_ZZgCdAOcATkQG5pg.png" /></figure><p>Too good to be true? Let’s check the user interface in AWS to find out!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wd-l1QmKvY1gGbY8fRnHvA.png" /></figure><p>As we can see, the EC2 instance from our Terraform configuration has been successfully created and it is running! Step 1 is complete!</p><h4>Step 2: Bootstrap the EC2 instance to install and start Jenkins</h4><p>Let’s add a key pair to use to connect to our EC2 instance where we will be installing Jenkins. Include the blocks below to generate a key pair, create a local file to store the key pair, and to create a TLS private key.</p><pre># This utilizes the TLS provider to generate an SSH key<br>resource &quot;tls_private_key&quot; &quot;generated&quot; {<br>  algorithm = &quot;RSA&quot;<br>}<br><br># This uses terraform local provider in terraform.tf to save the TLS key to a file called &quot;MyAWSKey.pem&quot; in my local file system.<br>resource &quot;local_file&quot; &quot;private_key_pem&quot; {<br>  content  = tls_private_key.generated.private_key_pem<br>  filename = &quot;MyAWSKey.pem&quot;<br>}<br><br>#Generates a key pair in AWS using the previous TLS key file <br>resource &quot;aws_key_pair&quot; &quot;generated&quot; {<br>  key_name   = &quot;MyAWSKey&quot;<br>  public_key = tls_private_key.generated.public_key_openssh<br><br>  lifecycle {<br>    ignore_changes = [key_name]<br>  }<br>}</pre><p>We’re now ready to add in the information to bootstrap the EC2 instance with a script that will install and start Jenkins. The local-exec provision will revise our security key permissions so that it will securely connect to the virtual machine. The remote-exec provisions will run the commands to install and start Jenkins on the EC2 server. I used the documentation for installing Jenkins on AWS as a guide for the script. <a href="https://www.jenkins.io/doc/tutorials/tutorial-for-installing-jenkins-on-AWS/#downloading-and-installing-jenkins"><em>Source</em></a></p><pre>resource &quot;aws_instance&quot; &quot;jenkins_ec2&quot; {<br>  ami           = &quot;ami-0e618811ec643488b&quot;<br>  instance_type = &quot;t2.micro&quot;<br><br>  #Creates our local-exec provisioner that will change permissions of my private key to connect to the virtual machine.<br>  provisioner &quot;local-exec&quot; {<br>    command = &quot;chmod 600 ${local_file.private_key_pem.filename}&quot;<br>  }<br>  <br>  #Creates the remote-exec provisioner to execute commands on the remote resource after creation<br>  provisioner &quot;remote-exec&quot; {<br>    inline = [<br>      &quot;sudo yum update –y&quot;,<br>      &quot;sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo&quot;,<br>      &quot;sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io-2023.key&quot;,<br>      &quot;sudo yum upgrade&quot;,<br>      &quot;sudo amazon-linux-extras install java-openjdk11 -y&quot;,<br>      &quot;sudo dnf install java-11-amazon-corretto -y&quot;,<br>      &quot;sudo yum install jenkins -y&quot;,<br>      &quot;sudo systemctl enable jenkins&quot;,<br>      &quot;sudo systemctl start jenkins&quot;,<br>      &quot;sudo systemctl status jenkins&quot;<br>    ]<br>  }<br><br>  tags = {<br>    Name = &quot;ThisEC2IsForJenkins&quot;<br>  }<br>  lifecycle {<br>    ignore_changes = [security_groups]<br>  }<br>}</pre><p>After applying the changes, we should see that 3 resources were successfully added!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/761/1*3BpvQgRc6IFEyz0cGcZLkA.png" /></figure><p>We should also see a file in your current working directory that will say MyAWSKey.pem.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/189/1*LHwUHuWzohRHTVsxOdc3rQ.png" /></figure><h4>Step 3: Create and assign a security group to the Jenkins</h4><p>Now, we will create and assign security groups to the instance that will allow traffic on port 22 from your ip and allow traffic from port 8080. Add in the security groups from the code provided below.</p><pre># Creates security group that allows web traffic over the HTTP port &amp; ssh traffic on port 22<br>resource &quot;aws_security_group&quot; &quot;vpc_web_ssh&quot; {<br>  name        = &quot;allow-ssh-web&quot;<br>  vpc_id      = aws_default_vpc.dparria_vpc.id<br>  description = &quot;SSH &amp; 8080 Web Traffic&quot;<br>  ingress {<br>    description = &quot;Allow Port 8080&quot;<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>   ingress {<br>    cidr_blocks = [<br>      &quot;0.0.0.0/0&quot;<br>    ]<br>    from_port = 22<br>    to_port   = 22<br>    protocol  = &quot;tcp&quot;<br>  }<br>  egress {<br>    description = &quot;Allow all ip and ports outbound&quot;<br>    from_port   = 0<br>    to_port     = 0<br>    protocol    = &quot;-1&quot;<br>    cidr_blocks = [&quot;0.0.0.0/0&quot;]<br>  }<br>}</pre><p>We can then also add in the following code into our EC2 instance to reflect the new security groups.</p><pre>  vpc_security_group_ids = [&quot;sg-0cf693afcbe1d3407&quot;]<br>  associate_public_ip_address = true<br>  key_name                    = aws_key_pair.generated.key_name #references my key pair <br>  connection {                                                  #the connection block specifies the user name, ip, and authentication scheme to connect to the server. Must be embedded in the resource block.<br>    user        = &quot;ec2-user&quot;<br>    private_key = tls_private_key.generated.private_key_pem<br>    host        = self.public_ip<br>  }</pre><p>Run terraform fmt and then approve the changes after running the terraform apply to successfully use our security group to make our changes to our EC2 instance. As we can see below, our security group was added to the EC2 instance and Jenkins was successfully installed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*owF0yvmFn5e6hdoQimbeQw.png" /></figure><p>Oh no! The only problem is that the instance doesn’t say that Jenkins is active. Let’s verify that Jenkins was started by SSHing into our EC2 instance! I will SSH into the instance by running the code below in the CLI.</p><pre> ssh -i MyAWSKey.pem ec2-user@13.57.6.214<br><br>#AWSKey.pem is the name of my key<br>#ec2-user is the username that we created with the keypair<br>#After the @, we enter the public IP address of the server that we are sshing into</pre><p>After running sudo systemctl status jenkins in the CLI, the output indicated that Jenkins was inactive. After this error, I made sure to include sudo systemctl start jenkins within the initial script in Terraforms configuration file and I also made sure to include it in GitHub. We can now see below that Jenkins is actively running on our EC2 instance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AeSNA34fl1h4Wx5wZPKSmA.png" /></figure><p>Type exit in the CLI to close the SSH connection with the EC2 instance and return back to your local terraform CLI. We’re now ready for step 4!</p><h4>Step 4: Create a private S3 bucket for your Jenkins Artifacts</h4><p>We can use the <a href="https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket">Terraform S3 bucket documentation</a> to pull the correct code block to get started with creating our private S3 bucket. Copy and paste the code below into your Terraform configuration file. Remember that the unique name that you choose for your S3 bucket can only have lowercase alphanumeric characters and hyphens allowed.</p><pre>#Creates the S3 bucket<br>resource &quot;aws_s3_bucket&quot; &quot;jenkins_artifacts_s3&quot; {<br>  bucket = &quot;week20-s3bucket-dparria&quot; # Set a unique bucket name<br>}<br><br>#Creates the ownership rule for the bucket<br>resource &quot;aws_s3_bucket_ownership_controls&quot; &quot;s3_ownership&quot; {<br>  bucket = aws_s3_bucket.jenkins_artifacts_s3.id<br>  rule {<br>    object_ownership = &quot;BucketOwnerPreferred&quot;<br>  }<br>}<br><br>#Creates the acl that will be used for our private bucket<br>resource &quot;aws_s3_bucket_acl&quot; &quot;jenkins_s3_acl&quot; {<br>  depends_on = [aws_s3_bucket_ownership_controls.s3_ownership]<br><br>  bucket = aws_s3_bucket.jenkins_artifacts_s3.id<br>  acl    = &quot;private&quot;<br>}</pre><p>After running a terraform apply, we will see that there are 3 resources to be added, which is our ownership rule, the ACL, and the S3 bucket. After you approve the changes, you should see a message as shown below!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/965/1*Snb76QkOWaTOVDHnAy0rhQ.png" /></figure><p>Let’s check out our S3 management console to verify that our private S3 bucket was created! As we can see, the bucket is there and the access column is showing that the bucket and objects are not public. This means that we successfully created our private S3 bucket!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xxa0X0nMPcWhGDky4Oyi-Q.png" /></figure><h4>Step 5: Verify that you can reach your Jenkins via port 8080 in your browser</h4><p>Here’s the moment of truth! It’s time to verify that we can reach our Jenkins install via port 8080 in our browser. If the install is successful, we should see a Jenkins login screen. I will use the input my EC2’s public IP address into the browser followed by :8080.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-DkP6mFHoC2DgusjIBf3BQ.png" /></figure><p>Congratulations! We have successfully installed Jenkins to be reached at port 8080! Feel free to hit your happy dance before you check out my code files below!</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Ftenor.com%2Fembed%2F12344509&amp;display_name=Tenor&amp;url=https%3A%2F%2Ftenor.com%2Fview%2Fcelebration-will-smith-price-de-bel-air-danser-bouger-gif-12344509&amp;image=https%3A%2F%2Fmedia.tenor.com%2FOj2nKJiZSU4AAAAC%2Fcelebration-will-smith.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=tenor" width="600" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/2f6bfebfff4126366f01eee48d74874a/href">https://medium.com/media/2f6bfebfff4126366f01eee48d74874a/href</a></iframe><p>I went a step further to also create a <strong>variables.tf</strong> file and a <strong>providers.tf</strong> file to avoid hard coding some of our information in the <strong>main.tf</strong> file. After running a terraform plan, we can confirm that we successfully inputed our variables due to our infrastructure matching our configuration. I also have my GitHub repository shown here: <a href="https://github.com/destanyparria/terra_gold/tree/34d4061bf6ffa5d9bfc10c6363e5d6ffd4b3d440/Week20Project">Destany Parria’s Week 20 Terraform GitHub repository</a>. Check it out!</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d5fd562bd2df76d57bca64f820efb0bd/href">https://medium.com/media/d5fd562bd2df76d57bca64f820efb0bd/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d29b2b1ca7004fd822f6b84ac3ff06bf/href">https://medium.com/media/d29b2b1ca7004fd822f6b84ac3ff06bf/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7365e50be8271597d88fe0351739f8c2/href">https://medium.com/media/7365e50be8271597d88fe0351739f8c2/href</a></iframe><h4>Step 6: DESTROY!</h4><p>Although we took the time to create this beautiful infrastructure, it is now time to destroy what we created to avoid unnecessary changes. Run terraform destroy in the local CLI to ensure that your configuration will be destroyed in AWS. Similarly to the terraform apply command, you will be prompted to approve destroying the resources. You should then see a message showing that the resources were destroyed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/996/1*Ge9lN_YBq89iQAeuvAfl6g.png" /></figure><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Ftenor.com%2Fembed%2F3629581&amp;display_name=Tenor&amp;url=https%3A%2F%2Ftenor.com%2Fview%2Fbuilding-demolition-gif-3629581&amp;image=https%3A%2F%2Fmedia.tenor.com%2FW7CgVOxqMi4AAAAN%2Fbuilding-demolition.png&amp;type=text%2Fhtml&amp;schema=tenor" width="600" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/6578e58fa54d68c97acc10388f4898fd/href">https://medium.com/media/6578e58fa54d68c97acc10388f4898fd/href</a></iframe><p><em>Note: I did go back and check if the </em><em>terraform destroy command had also destroyed my active default VPC. Although my default VPC was imported and managed by my Terraform configuration, my default VPC was not terminated when I ran the </em><em>terraform destroy command. It is still showing active!</em></p><p>That’s it! Thank you so much for following along on this journey through Terraform. Please give some claps or leave a comment if you feel that this tutorial was helpful!</p><p><em>Follow me on LinkedIn at </em><a href="https://www.linkedin.com/in/destanyparria/?source=about_page-------------------------------------"><em>https://www.linkedin.com/in/destanyparria/</em></a><em> to follow my journey in tech!</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*8pTl2LDnVSqeGqzY.png" /></figure><p><em>More content at </em><a href="https://plainenglish.io/"><strong><em>PlainEnglish.io</em></strong></a><em>.</em></p><p><em>Sign up for our </em><a href="http://newsletter.plainenglish.io/"><strong><em>free weekly newsletter</em></strong></a><em>. Follow us on </em><a href="https://twitter.com/inPlainEngHQ"><strong><em>Twitter</em></strong></a>, <a href="https://www.linkedin.com/company/inplainenglish/"><strong><em>LinkedIn</em></strong></a><em>, </em><a href="https://www.youtube.com/channel/UCtipWUghju290NWcn8jhyAw"><strong><em>YouTube</em></strong></a><em>, and </em><a href="https://discord.gg/GtDtUAvyhW"><strong><em>Discord</em></strong></a><strong><em>.</em></strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4f447efc16b7" width="1" height="1" alt=""><hr><p><a href="https://aws.plainenglish.io/using-terraform-to-deploy-aws-resources-and-set-up-jenkins-4f447efc16b7">Using Terraform to Deploy AWS Resources and Set Up Jenkins</a> was originally published in <a href="https://aws.plainenglish.io/">AWS in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building Dockerfiles, Containers, and Bind Mounts]]></title>
            <link>https://medium.com/@destanyparria/building-dockerfiles-containers-and-bind-mounts-c7ec5e33e436?source=rss-b6a964ef08a6------2</link>
            <guid isPermaLink="false">https://medium.com/p/c7ec5e33e436</guid>
            <category><![CDATA[docker-image]]></category>
            <category><![CDATA[github]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[continuous-deployment]]></category>
            <category><![CDATA[dockerfiles]]></category>
            <dc:creator><![CDATA[Destany Parria]]></dc:creator>
            <pubDate>Wed, 17 May 2023 12:34:57 GMT</pubDate>
            <atom:updated>2023-07-07T21:42:54.101Z</atom:updated>
            <cc:license>http://creativecommons.org/licenses/by/4.0/</cc:license>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/271/0*cX3yobGMtyBSk5bb.png" /></figure><p>Hi everyone! Thank you for joining me as I dive into some of the fundamentals of Docker! This is a great application to build your skills on as it can help developers to simplify their development environment setup and ensure consistent execution of their code across different machines. Not to mention, it creates efficiency due to the elimination of redundancy after your containers are created. Let’s go over some key terms and steps that we will work through for the demo!</p><p><strong>Docker</strong> — An essential part of the continuous deployment process, allowing you to package programs (apps, binaries, libraries) into containers.</p><p><strong>Docker Hub</strong> — A registry for docker images that can be used to create your docker containers.</p><p><strong>Docker Images</strong> — A set of layers that provide the instructions required to create a container. To create an image, you can use a Dockerfile or you can create/run a container via the CLI that will generate a image.</p><p><strong>Docker Containers</strong> — An isolated environment to run any code. It allows you to package and repurpose applications that you would want to use repeatedly. Libraries, code, and files are required for a Docker container.</p><h4>Steps to complete the task:</h4><ul><li>Build docker file for Boto3 / Python</li><li>Use the Python official image on Dockerhub</li><li>Download any three repos 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</li></ul><h4>Prerequisites:</h4><ul><li>A DockerHub account</li><li>Docker Desktop</li><li>Docker installed on your IDE</li><li>A GitHub account</li><li>Basic knowledge of Linux</li></ul><h4>Step 1: Build the Dockerfile for Boto3/Python</h4><p>Dockerfiles are text files that allow us to define an applications environment and it is typically used to create images. First, we will need to create the directory in the CLI by running mkdir &lt;directoryname&gt; and we will go into that directory by running cd &lt;directoryname&gt;.</p><p>Next, create an empty file by running touch Dockerfile and type vim Dockerfilein the CLI to open and input information into the Dockerfile that we will use to build our image. Type the ls -l command and the file should be listed within the directory.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/980/1*_qyi9cbbe5bt-df86DN5lw.png" /></figure><h4>Step 2: Use Python official images on DockerHub to build our image</h4><p>When pulling an image from DockerHub, you will know that the image is official if you see the “DOCKER OFFICIAL IMAGE” message on it that is shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1ekM_2FyB8w3ANaRiojVeA.png" /></figure><p>I will be using this specific version of Python so that I can also have that version of Bullseye in case if I will need certain Debian services. If there is not a specific version that you would like to run, you can just use “python:3” to get the latest version of python that will include boto3.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0f403590d61b1944e8006529d4f48463/href">https://medium.com/media/0f403590d61b1944e8006529d4f48463/href</a></iframe><p>The “<strong>FROM</strong>” section creates a layer from the python:3.12.0a7-bullseye image. The “3.12.0a7-bullseye” part is our tag that represents the specific version of Python that we will be using. The “<strong>RUN</strong>” section installs the application with boto3 but without the cache so that we can save space. The “<strong>CMD</strong>” section specifies the command to run within the container after it has been built.</p><h4><strong>Step 3: Download any three repos to local host</strong></h4><p>There is more than one way to do this, but I will use the git clone &lt;repository_https URL&gt; command to pull my 3 repos.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kHpC-J4rWqPza_nOyBEsqA.png" /></figure><h4>Step 4: Create three Ubuntu containers with a bind mount</h4><p>Keep in mind that we will use a bind mount on each of our containers to connect to one of the repository directories. Although there are different types of mounts, bind mounts are a great option for storing permanent data that will remain on the Docker Volume even if the container is deleted. This is also used in cases where you would want your containers to communicate with one another.</p><p>Let’s now run the following commands to create our docker containers with a bind mount to the repo directories.</p><pre>docker run -d -it --name &lt;container name&gt; -v &quot;$(pwd)/docker_project:/myapp&quot; ubuntu</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SdaP9tmKBj7f7TH9quzsxg.png" /></figure><p>As we can see, our <em>docker_project_c</em> ubuntu container was successfully created. We can also confirm that was created by running the docker container ps command to confirm that our container is listed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oC5Uf1k7rU0acbsS6Coj8Q.png" /></figure><p>Build the other two containers by running a similar command that we used to create this one.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*faqMP6hkqZSAtBz8bTEJWg.png" /></figure><h4>Step 5: Log into each container to confirm access</h4><p>Use the docker exec -it &lt;container_name&gt; &lt;shell&gt; command to log into each container. You can then run the ls command in the bash shell to show that you have access to the file information.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rhekVebDlWX9Dt_OEpxc7Q.png" /><figcaption>Please excuse the typo when I initially typed the stay golden container name.</figcaption></figure><p>Congratulations! You successfully completed all of the tasks for this Docker project!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gSLgf5sW6w9JZ5aWu02RmQ.png" /></figure><p>Follow me on LinkedIn at <a href="https://www.linkedin.com/in/destanyparria/?source=about_page-------------------------------------">https://www.linkedin.com/in/destanyparria/</a> to follow my journey in tech!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c7ec5e33e436" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Integrating with Python, Lambda, & SQS]]></title>
            <link>https://towardsaws.com/integrating-with-python-lambda-and-sqs-e94fcbcacc2e?source=rss-b6a964ef08a6------2</link>
            <guid isPermaLink="false">https://medium.com/p/e94fcbcacc2e</guid>
            <category><![CDATA[serverless]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[lambda]]></category>
            <category><![CDATA[sqs]]></category>
            <dc:creator><![CDATA[Destany Parria]]></dc:creator>
            <pubDate>Sun, 30 Apr 2023 02:21:53 GMT</pubDate>
            <atom:updated>2023-07-12T05:27:32.874Z</atom:updated>
            <content:encoded><![CDATA[<h3>Using Python to Go Serverless with an API Gateway, Lambda, and SQS</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/778/1*Tp1_XIZizqvW0nik1V0fHg.png" /></figure><p>Hi there! Thank you for continuing to join me on my journey of learning to work with key cloud computing services in the tech industry! Together, we will use Python to automate a system using AWS services. Lets check out the scenario and the steps to complete the task!</p><h4>Scenario:</h4><p>You’re working for a company that wants to create a system that can track customer orders and send notifications when orders have been shipped. Your company wants to use AWS services to build the system, and they decided to use SQS, Lambda, and Python for the project.</p><h4>Steps:</h4><p>1) Create a Standard SQS Queue using Python and give permissions<br>2) Create a Lambda function in the console with a Python 3.7 or higher runtime<br>3) Modify the Lambda to send a message to the SQS queue. Your message should contain either the current time or a random number. You can use the built-in test function for testing.<br>4) Create an API gateway HTTP API type trigger.<br>5) Test the trigger to verify the message was sent.</p><p>Not sure what these services are? Check out the key words below that gives some information about the key terms that you will need to know for this project!</p><p><strong>Lambda</strong> - A serverless platform that runs your code without you having to manage a servers infrastructure. Lambda is highly available, fault-tolerant, and scalable. It’s also very cost effective due to the fact that there is only a charge when it is completing a function activity, so you only pay for the compute time that you need!</p><p><strong>Simple Queue Service (SQS)</strong> - A cost effective, highly available service that queues messages and sends data between software applications.</p><p><strong>API Gateway</strong> - A service that is used to create, monitor, and secure REST, HTTP and WebSocket API’s.</p><p><strong>Python:</strong><em> </em>One of the most popular programming languages among developers that is used to build websites and software, automate tasks, and conduct data analysis. Python can be used with many other programs and its easy to learn syntax emphasizes readability, which makes the programming language very attractive to beginners. <em>(</em><a href="https://www.coursera.org/articles/what-is-python-used-for-a-beginners-guide-to-using-python"><em>Source</em></a><em>)</em></p><p><strong>Boto3:</strong> An AWS Software Development Kit for Python that allows you to use Python to create, configure, and manage several of your AWS services. You need at least Python 3.7 or later installed in order to use Boto3. You can install Boto3 by entering pip install boto3 into the command line. You can find out more about installing an using Boto3 by checking out the <a href="https://boto3.amazonaws.com/v1/documentation/api/latest/guide/quickstart.html"><em>AWS documentation</em></a>.</p><h4>Prerequisites:</h4><ul><li>A computer with internet</li><li>Python Version 3.7+</li><li>Basic knowledge of Python</li><li>An Integrated Development Environment (IDE)</li><li>An AWS account</li></ul><h4>Step 1: Create a Standard SQS queue using Python and give permissions</h4><p>Remember when I brought up Boto3 for the key terms? That’s because it’s essential for us to use this AWS SDK to be able to interact and execute tasks in our AWS environment. I have my source code shown below showing the python script to create the Standard SQS queue. Feel free to fork or clone the <a href="https://github.com/destanyparria/stay-golden/blob/main/wk15sqs.py">GitHub repository</a>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/aea00eff7a1dad4c92d9aec0356174de/href">https://medium.com/media/aea00eff7a1dad4c92d9aec0356174de/href</a></iframe><p>Our response below is showing that the script successfully created the SQS queue and provided us the url.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/485/1*bMTQE6DEG0ZWkJ_Z8p5DtA.png" /></figure><p>Now, lets check the AWS SQS console to verify that it is there.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pi1ZmmRfMHrJRBRZWtCLDg.png" /></figure><p>Success! Our SQS queue has been created. Step 1 is complete! Now, we must create a custom IAM role for our Lambda function because our Lambda function will need permission to send messages to the SQS queue. In the IAM console, click <strong>Roles</strong> then <strong>Create role</strong>. You will then see the screen shown below where you should click <strong>AWS Service</strong> for the Trusted entity type, <strong>Lambda</strong> for the Use case, and then click Next.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QH99cikcJTdNoA4CxFu-Uw.png" /></figure><p>Search for <a href="https://docs.aws.amazon.com/lambda/latest/dg/lambda-intro-execution-role.html">AWSLambdaSQSQueueExecutionRole</a> in the search bar because it will have many of the permissions that we will need, but we will still have to modify it so that the Lambda can send messages to the queue. Click the <strong>+</strong> button to drop down more information on the role, click <strong>Copy</strong> to copy the execution role’s code, and then click <strong>Create policy</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CkwvhGZC8hsXZ6yzSKqSGA.png" /></figure><p>On the next screen, click <strong>JSON</strong> and then delete the existing code. Paste the code from the AWSLambdaSQSQueueExecutionRole and add “sqs:SendMessage”, under the Action section for the policy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L3X6Ycu6P_P3K0Khob9ERw.png" /></figure><p>Click <strong>Next: Tags</strong>, then we won’t be adding tags so click <strong>Next: Review</strong>. Give your policy a name, review the summary of permissions, and then click <strong>Create policy</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jHkmEbPanojOj1d6EJdUXQ.png" /></figure><p>Now, head back to <strong>Roles </strong>browser to continue with creating the new role, search for the policy that you just created, select your new policy, and then click <strong>Next</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cCTd8kw9b-VRuN-97ycM6A.png" /></figure><p>Give the role a name and then click <strong>Create role</strong>. We are now ready for Step 2!</p><h4>Step 2: Create a Lambda function in the console</h4><p>Now, let’s switch over to the Lambda console to create our function! Click the “Create function” button in the top right corner of the AWS console.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BEPew03qU4ilDmMQxzODKA.png" /></figure><p>Leave the default setting for “Author from scratch”, input the custom Lambda function name, choose Python 3.7 as your runtime, and leave the default setting of “x86_64” for your Lambda functions architecture.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/990/1*Hh9F8Qo0kSCfc1upOlooJA.png" /></figure><p>Now, we must click into “Change default execution role” and attach the role that we previously created for the Lambda function to be able to send messages to the SQS queue.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yniMc2dA-kIWch4mDMPyvQ.png" /></figure><p>As we can see above, the Lambda function was successfully created! Step 2 is complete!</p><h4>Step 3: Modify the Lambda to send a message to the SQS queue</h4><p>For this project, the message that our Lambda function will send to the SQS queue will contain the current date and time. To do this, we will need to import the json, boto3, time, and datetime libraries. You can also view the script in my <a href="https://github.com/destanyparria/stay-golden/blob/main/wk15lambda_sqs.py">GitHub Repository</a>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6f3e681ad3c85fba33f5554713bd9500/href">https://medium.com/media/6f3e681ad3c85fba33f5554713bd9500/href</a></iframe><p>After you have inserted the Lambda function’s code, hold down Command &amp; S to save your file and then click to <strong>Deploy</strong>. When prompted to create a trigger, create a custom trigger for the HTTP API. My test event trigger is called “api_trigger_test”. You will then see the green message at the top of the screen showing that it was successfully created.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*N4A5165saLTslNwLLb7HCA.png" /></figure><p>Now we are ready to test Lambda function’s code! Click the <strong>Test drop down arrow</strong> and <strong>Configure test event</strong>. Click <strong>Create new event</strong>, give the event a name, click the dropdown for the Template section and select <strong>SQS</strong>, and the click<strong> Save</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/814/1*jAteBWA_BJ-BppUXDTrjnw.png" /></figure><p>You should now get a response back showing a Status 200 and your message that says the current date and time, which means that the code ran successfully!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZzYAAiTsuITCuv39XqEIKQ.png" /></figure><p>Let’s check SQS just to verify that our message is there. Go to the SQS console, click <strong>Queues</strong>, click the queue that we created for this project, and then click <strong>Send and receive messages</strong>. Stroll down to the Recieve messages section and you should see that you have a message available. Click <strong>Poll for messages</strong> and then you will see the messages show up.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2rHnCVjubOB73Ltvs1LD2Q.png" /></figure><p>If you click into the message, you should be able to see your message with the date and time!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/821/1*1-D2GF8JtWDMAFWPA8xMdw.png" /></figure><p>Step 3 is complete!</p><h4>Step 4: Create an API Gateway HTTP API trigger</h4><p>Now, lets create an API Gateway HTTP API that will trigger our Lambda function to send the date and timestamp message to SQS. Head over to the API console and click <strong>Create API, </strong>then <strong>Build </strong>for the HTTP API option, then <strong>Add Integration</strong>. You can then choose your AWS region, choose your Lambda function’s ARN, name your API, and then click <strong>Next</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2vTtSmhCkWOAqXKDD510xw.png" /></figure><p>We will keep the Method and Integration target the same but we will change our Resource path to be “/” and then we will click <strong>Next</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PL5UQMIdEMuQm2for36Cqg.png" /></figure><p>Leave the Stage name as $default and click <strong>Next</strong>. Review the API information and the click <strong>Create</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qvOVhR3gsn2USDgVWYOy0Q.png" /></figure><p>You should now see the Invoke URL shown for your API. Save that URL code because we will be using that you test the tigger to our Lambda function.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uYstOLU4oiYrfifskHHf0w.png" /></figure><h4>Step 5: Test the API Gateway trigger</h4><p>Finally! It’s time to test our API Gateway HTTP trigger to our Lambda function message by pasting the Invoke URL into the web browser.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/531/1*dFs-Kfzux52xZlxuzkJPFA.png" /></figure><p>We can also check our SQS queue to make sure that Lambda successfully sent the message there as well. Our queue now shows that it has another message in there.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3LSMY34iTseV4b5AlhD7Ew.png" /></figure><p>We can click into the message and see that it will show the same date and time as our URL test.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/820/1*E8mZ6aiMXy3WaKUSt5EAPQ.png" /></figure><p>Congratulations! We have successfully created a Lambda function that is invoked by the API Gateway HTTP trigger and also sends a message to the SQS queue.</p><p>If you feel that this article is helpful, please leave some claps or a comment to let me know. Keep an eye out for future articles where I will be focusing on containerization!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gSLgf5sW6w9JZ5aWu02RmQ.png" /></figure><p>Follow me on LinkedIn at <a href="https://www.linkedin.com/in/destanyparria/?source=about_page-------------------------------------">https://www.linkedin.com/in/destanyparria/</a> to follow my journey in tech!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e94fcbcacc2e" width="1" height="1" alt=""><hr><p><a href="https://towardsaws.com/integrating-with-python-lambda-and-sqs-e94fcbcacc2e">Integrating with Python, Lambda, &amp; SQS</a> was originally published in <a href="https://towardsaws.com/">Towards AWS</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Another Day at The Office Using Python & Dynamo DB]]></title>
            <link>https://faun.pub/another-day-at-the-office-using-python-dynamo-db-f0c3b577c632?source=rss-b6a964ef08a6------2</link>
            <guid isPermaLink="false">https://medium.com/p/f0c3b577c632</guid>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[datatables]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[boto3]]></category>
            <category><![CDATA[dynamodb]]></category>
            <dc:creator><![CDATA[Destany Parria]]></dc:creator>
            <pubDate>Fri, 21 Apr 2023 20:17:13 GMT</pubDate>
            <atom:updated>2023-05-24T21:19:40.582Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*FMPRvVLuiLur7Ka0.jpg" /></figure><p>Hi everyone! Thanks for joining me while I dive deeper into Python! Today, we will be using Python and Boto3 to create a DynamoDB table, add items to the table, and then scan it. My table will be created to reflect my favorite 10 episodes of The Office. Feel free to drop a comment on the article to let me know what you think of the code or even which episodes from The Office are your favorite! Before we get started, lets go over some key terms that are important to know for this project.</p><p><strong>Python:</strong><em> </em>One of the most popular programming languages among developers that is used to build websites and software, automate tasks, and conduct data analysis. Python can be used with many other programs and its easy to learn syntax emphasizes readability, which makes the programming language very attractive to beginners. <em>(</em><a href="https://www.coursera.org/articles/what-is-python-used-for-a-beginners-guide-to-using-python"><em>Source</em></a><em>)</em></p><p><strong>DynamoDB: </strong>An AWS service that is a no SQL serverless database that creates tables that are populated with Sting, Number, or Binary attribute types of data. It is very flexible, offers high performance, and low latency that is in the milliseconds.</p><p><strong>Boto3:</strong> An AWS Software Development Kit for Python that allows you to use Python to create, configure, and manage several of your AWS services. You need at least Python 3.7 or later installed in order to use Boto3. You can install Boto3 by entering pip install boto3 into the command line. You can find out more about installing an using Boto3 by checking out the <a href="https://boto3.amazonaws.com/v1/documentation/api/latest/guide/quickstart.html"><em>AWS documentation</em></a>.</p><h4>Prerequisites:</h4><ul><li>A computer with internet</li><li>Python Version 3.7+</li><li>Basic knowledge of Python</li><li>An Integrated Development Environment (IDE)</li><li>An AWS account</li></ul><p>For this project, I will be using AWS Cloud9 for my IDE. You will likely need to run a few more configurations if you are using a different IDE service. Please remember to save each of the scripts below in your environment as a separate Python file. Execute each file by hitting the “Run” command in at the top of the Cloud9 IDE or by executing&lt;file_name&gt;.py in the command line. You will need to change the file name to match the name that you gave the current file that you are working on.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*7J07Q5WNlOLUazPfE1vF-Q.png" /><figcaption>This is the “Run” button that should be shown at the top of the Cloud9 IDE</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/744/0*Bzr-eLd-dDHrYM6I" /></figure><h4>Step 1: Create a DynamoDB table</h4><p>I have my source code shown below for how I will create the DynamoDB table. If you take a look at the comments within the code (the message after the # sign), you can see what action the code will perform!</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cd1c6f98a25cdb230c2e5feee3735a49/href">https://medium.com/media/cd1c6f98a25cdb230c2e5feee3735a49/href</a></iframe><p>This script imports Boto3, connects to DynamoDB, creates the table, gives the table a name, and prints the response from the script. I have created a numeric data type for “Season” and a string data type for “Episode”. We can see in the Key Schema section that “Season” has been assigned as the HASH key type, which means that it is our Partition Key. Also, we have “Episode” assigned as the RANGE key type, which means that is set as the sort key. We have a read and write maximum capacity of 1 and our table is named The_Office_Episodes.</p><p>Originally, I received the following error when I ran the script because I added an “S” at the end of the ProvisionedThroughput parameter. Luckily, Python was nice enough to inform me of the mistake by sending the error message below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RHHNjEjt59HyzA_LMItAlQ.png" /><figcaption>Python wasn’t happy about the unnecessary “S”!</figcaption></figure><p>After the quick revision, our script worked like a charm! If you take a look at the “Tables” section in your DynamoDB platform on the AWS console, you should see the table listed. You can see “The_Office_Episodes” table below showing as active.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1019/1*lQBtv1ZW92xwcz1IISkisg.png" /></figure><p>Now lets click into the table to confirm that our partition and sort keys are there.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/679/1*yR7XFwlI4ZSRQYL4juEzZA.png" /><figcaption>We can see above that “Season” is our partition key and “Episode” is our sort key.</figcaption></figure><p>That’s it! Our table is created and everything is looking great so far! Now that Step 1 is complete, you get to find out which 10 episodes of The Office are my favorites!</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Ftenor.com%2Fembed%2F3580217&amp;display_name=Tenor&amp;url=https%3A%2F%2Ftenor.com%2Fview%2Fyes-jim-the-office-gif-3580217&amp;image=https%3A%2F%2Fmedia.tenor.com%2FyX2yYrW-Cu4AAAAC%2Fyes-jim.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=tenor" width="600" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/813e971853234d510d19d81eaa7a6988/href">https://medium.com/media/813e971853234d510d19d81eaa7a6988/href</a></iframe><h4>Step 2: Add 10 items to the table</h4><p>I have the source code listed below that we will use to add 10 items to our list. In this case, we will be adding the information to list some of my favorite episodes on The Office! It’s going to be hard to only pick 10, but I’m going to give it a try!</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/78d05a7b5905158f9ef79904eb55bb23/href">https://medium.com/media/78d05a7b5905158f9ef79904eb55bb23/href</a></iframe><p>After several failed attempts and a bunch of research, I realized that I made the mistake of putting single quotations around my integers that for the “Season” of the episodes. It was giving me an error because I had that key designated as a number value type. I have a picture below to give an example.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/272/1*Y8YPB7yYlzdjLm4a12AqgA.png" /><figcaption>The single quotation is what was causing the error.</figcaption></figure><p>Once I removed those quotations for my numeric key type, I received the confirmation that the items were successfully added to the table. Now lets check our DynamoDB table on the AWS console just to confirm that the items were properly added! You can do this by clicking “Explore items” that is located to the left of the DynamoDB page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*K2N6Hf-hbI2fG-MVXo_zag.png" /></figure><p>As we can see above, we have successfully added 10 items to the DynamoDB table!</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Ftenor.com%2Fembed%2F5675769&amp;display_name=Tenor&amp;url=https%3A%2F%2Ftenor.com%2Fview%2Ftheoffice-dwight-yes-celebrate-fistpump-gif-5675769&amp;image=https%3A%2F%2Fmedia.tenor.com%2FmXeoKcLaY6EAAAAC%2Ftheoffice-dwight.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=tenor" width="600" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/96cdc2098191a263767f54d683834de8/href">https://medium.com/media/96cdc2098191a263767f54d683834de8/href</a></iframe><h4>Step 3: Scan the DynamoDB table</h4><p>I have the source code shown below for you to look over as we go through our last step of scanning the table!</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/31f986db9615fbcafd58d09cbc0e7475/href">https://medium.com/media/31f986db9615fbcafd58d09cbc0e7475/href</a></iframe><p>After running the script, we should get a response showing that the scan is complete.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/581/1*rI7qJFa470l8LbeGn1K_iA.png" /></figure><p>Congratulations! You have successfully used Python and Boto3 to create a DynamoDB table, add items to the table, and then scan it!</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Ftenor.com%2Fembed%2F26388528&amp;display_name=Tenor&amp;url=https%3A%2F%2Ftenor.com%2Fview%2Fthe-office-gif-26388528&amp;image=https%3A%2F%2Fmedia.tenor.com%2FX15e67QrANUAAAAC%2Fthe-office.gif&amp;key=d04bfffea46d4aeda930ec88cc64b87c&amp;type=text%2Fhtml&amp;schema=tenor" width="600" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/0d821bb086e80e8a9cf69fd8381c8ecd/href">https://medium.com/media/0d821bb086e80e8a9cf69fd8381c8ecd/href</a></iframe><p>If this article was helpful to you, please leave some claps or a comment! Feel free to leave a comment to let me know what you thought about the scripts or even to tell me about your favorite episodes from The Office. Keep an eye out for my next Python project coming soon!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*FiWXXMOKpb27EiJ8.png" /></figure><h4>👋 If you find this helpful, please click the clap 👏 button below a few times to show your support for the author 👇</h4><h4>🚀<a href="http://from.faun.to/r/8zxxd">Join FAUN Developer Community &amp; Get Similar Stories in your Inbox Each Week</a></h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f0c3b577c632" width="1" height="1" alt=""><hr><p><a href="https://faun.pub/another-day-at-the-office-using-python-dynamo-db-f0c3b577c632">Another Day at The Office Using Python &amp; Dynamo DB</a> was originally published in <a href="https://faun.pub/">FAUN.dev() 🐾</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using Python to Extract and Store Information]]></title>
            <link>https://python.plainenglish.io/using-python-to-extract-and-store-information-2c6a5ea19a56?source=rss-b6a964ef08a6------2</link>
            <guid isPermaLink="false">https://medium.com/p/2c6a5ea19a56</guid>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[python-dictionaries]]></category>
            <dc:creator><![CDATA[Destany Parria]]></dc:creator>
            <pubDate>Wed, 12 Apr 2023 09:28:19 GMT</pubDate>
            <atom:updated>2023-05-21T04:47:54.151Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Bp3v94de3rdkzR_qMZKHEQ.png" /></figure><p>Hi everyone! Thank you for joining me today where we will use Python to walk through a real world scenario in the DevOps field. When it comes to building scripts in Python, it’s important to remember that there is more than one way to skin a cat (or in this case, a snake). You will likely see the task accomplished various ways, but it’s all about using what works best for you! Lets take a look at the scenario!</p><p><strong><em>Scenario:</em></strong><em> Your company needs to learn about the files located on various machines. You have been asked to build a script that extracts information such as the name and size about the files in the current working directory and stores it in a list of dictionaries.</em></p><p>You may be wondering what is Python or even a script. Before we start, here are a few key terms that you will need to know!</p><p><strong>Python:</strong><em> </em>One of the most popular programming languages among developers that is used to build websites and software, automate tasks, and conduct data analysis. Python can be used with many other programs and its easy to learn syntax emphasizes readability, which makes the programming language very attractive to beginners. <em>(</em><a href="https://www.coursera.org/articles/what-is-python-used-for-a-beginners-guide-to-using-python"><em>Source</em></a><em>)</em></p><p><strong>Script:</strong> A file that contains multiple Python commands and is ran to perform a task or solve a problem.</p><p><strong>Dictionaries:</strong> This is Python’s implementation of a data structure. A dictionary consists of a collection of key-value pairs and each key-value pair maps the key to its associated value. (<a href="https://realpython.com/lessons/dictionary-python/#:~:text=Dictionaries%20in%20Python&amp;text=Dictionaries%20are%20Python&#39;s%20implementation%20of,key%20to%20its%20associated%20value."><em>Source</em></a>)</p><p><strong>Loops:</strong> A sequence of instructions continually repeated until a certain condition is reached.</p><p><strong>Integrated Development Environment (IDE):</strong> An application that increases developer productivity by combining capabilities such as software editing, building, testing, and packaging in an easy-to-use application.</p><p>Prerequisites:</p><ul><li>A computer with internet</li><li>Python Version 3.4+</li><li>Basic knowledge of Python</li><li>An IDE</li></ul><p>Let’s get started by opening a Python file to work in within our IDE. I will be working in AWS Cloud 9 but you can choose any IDE service that works best for you. Please be aware that your code may be slightly different if you are using a different IDE service that I am. I will also be working from the repository that I have created in GitHub. When you are in your main repository, you can check the files in that repository by running the <em>ls -lh </em>command in the Cloud 9 command line to see what files we should expect as our output.</p><p>I will explain each step but I have the source code shown below :</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5fc2ee21c1c8e0e3cc8e6625797b659d/href">https://medium.com/media/5fc2ee21c1c8e0e3cc8e6625797b659d/href</a></iframe><h4>Step 1: Create a list for the dictionary</h4><p>First, we will run the commands below:</p><pre>import os<br>cwd = os.getcwd </pre><p>We need to run <em>import os</em> so that we can interact with the Operating System (OS) and use its functions to perform the tasks that we are assigned to do. The <em>cwd = os.getcwd</em> code allows us to get our current working directory.</p><p>Next, we can create our empty list that we will be importing our dictionary list into. We can create our empty list named “dict_list” by running the code below.</p><pre>dict_list = []</pre><h4>Step 2: It’s forloop time!</h4><p>Now that we have our empty list, it’s time to bring in the forloop action to iterate through all the files and directories in the current working directory.</p><pre>for file_name in os.listdir(cwd):<br>    file_path = os.path.join(cwd, file_name)<br>    file_size = os.path.getsize(file_path)<br>    dict_file = {<br>        &#39;file_name&#39; : file_name,<br>        &#39;file_path&#39; : file_path,<br>        &#39;file_size&#39; : file_size<br>    }</pre><p>As you can see above, we created the dict_file, which is our dictionary file, and we assigned the file name, file path, and the file size to be included in that dictionary file.</p><h4>Step 3: Append the dictionary to the list</h4><p>You can enclose the dictionary file into the list by appending it there. You will just need to include the code below:</p><pre>dict_list.append(dict_file)</pre><p>Next, you will add the code below to print our the dictionary list after the Python code is ran.</p><pre>print(dict_list, sep=&quot;\n&quot;)</pre><p>Finally, hit “Run” at the top of the screen to run the script. I have it marked in a red box in the picture below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LkQ8wFTpCVwxnL4-gGAesQ.png" /></figure><p>Congratulations! You successfully created a Python script that extracts and stores information!</p><p><em>More content at </em><a href="https://plainenglish.io/"><strong><em>PlainEnglish.io</em></strong></a><em>.</em></p><p><em>Sign up for our </em><a href="http://newsletter.plainenglish.io/"><strong><em>free weekly newsletter</em></strong></a><em>. Follow us on </em><a href="https://twitter.com/inPlainEngHQ"><strong><em>Twitter</em></strong></a>, <a href="https://www.linkedin.com/company/inplainenglish/"><strong><em>LinkedIn</em></strong></a><em>, </em><a href="https://www.youtube.com/channel/UCtipWUghju290NWcn8jhyAw"><strong><em>YouTube</em></strong></a><em>, and </em><a href="https://discord.gg/GtDtUAvyhW"><strong><em>Discord</em></strong></a><strong><em>.</em></strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2c6a5ea19a56" width="1" height="1" alt=""><hr><p><a href="https://python.plainenglish.io/using-python-to-extract-and-store-information-2c6a5ea19a56">Using Python to Extract and Store Information</a> was originally published in <a href="https://python.plainenglish.io/">Python in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>