<?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 Sharon Johnson on Medium]]></title>
        <description><![CDATA[Stories by Sharon Johnson on Medium]]></description>
        <link>https://medium.com/@sharonrjohnson?source=rss-4606c122b421------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*OCc-1K8rCmcV-_bY</url>
            <title>Stories by Sharon Johnson on Medium</title>
            <link>https://medium.com/@sharonrjohnson?source=rss-4606c122b421------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 11:38:52 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sharonrjohnson/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[How to Build a Two Tier Architecure Using AWS and Terraform Cloud]]></title>
            <link>https://sharonrjohnson.medium.com/how-to-build-a-two-tier-architecure-using-aws-and-terraform-cloud-ce20932c31f3?source=rss-4606c122b421------2</link>
            <guid isPermaLink="false">https://medium.com/p/ce20932c31f3</guid>
            <dc:creator><![CDATA[Sharon Johnson]]></dc:creator>
            <pubDate>Sat, 24 Jun 2023 13:22:18 GMT</pubDate>
            <atom:updated>2023-06-24T13:22:18.691Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/300/0*4iIdgmNum7sLLrel" /></figure><p>Let’s get started with the “what is”</p><p><strong>What is Terraform? Terraform an infrastructure as code tool that lets you build, change, and version cloud and on-prem resources safely and efficiently.</strong></p><p><strong>What is Terraform Cloud?</strong> <em>Terraform Cloud is an application that helps teams use Terraform to provision infrastructure.</em></p><p><strong>What is a Two Tier Architecture using AWS EC2 and RDS? </strong><em>A two-tier architecture using AWS EC2 and RDS (Relational Database Service) typically consists of two layers: the web server tier and the database tier. The web server tier is responsible for serving the web application or website, while the database tier handles the storage and retrieval of data.</em></p><p>The project objective is to create a highly available two-tier AWS architecture containing the following:</p><ul><li>Custom VPC with 2 public subnets for the Web Server Tier, 2 private subnets for the RDS Tier, appropriate route tables.</li><li>Launch and EC2 instance with your choice of webserver in each web tier subnets, I will be using Apache.</li><li>One RDS MySQL Instance (micro) in the private RDS subnets</li><li>Security groups properly configured for needed resources</li><li>Deploy this using Terraform Cloud as a CI/CD tool to check the build</li></ul><p>First, we need to create a Terraform Cloud account at https://app.terraform.io.</p><p>Once you have created your account you will need to create a new workspace and set the required enviroment variables such as your ‘AWS_ACCESS_KEY_ID’, ‘AWS_SECRET_ACCESS_KEY’, ‘AWS _REGION’ in the Terraform Cloud workspace that was created.</p><p><em>“Use the </em><a href="https://registry.terraform.io/"><em>Terraform Registry</em></a><em> for guidance when building out your terraform script”</em></p><p>I will be using the AWS Console and Cloud9 to build out my terraform script:</p><pre>mkdir &lt;directory name&gt;</pre><p>Now create a file within your directory and name it main.tf and write out your script:</p><p><em>A </em><strong><em>resource block</em></strong><em> declares a resource of a given type (&quot;aws_instance&quot;) with a given local name (&quot;web&quot;). The name is used to refer to this resource from elsewhere in the same Terraform module, you will see in this script the resource block with will build out the infrastructure.</em></p><pre>terraform {<br>  required_providers {<br>    aws = {<br>      source  = &quot;hashicorp/aws&quot;<br>      version = &quot;5.0.1&quot;<br>    }<br>  }<br>}<br><br>provider &quot;aws&quot; {<br>  shared_credentials_files = [&quot;/users/sharon/.aws/credentials&quot;]<br>  region                   = &quot;us-east-1&quot;<br>}<br><br>resource &quot;tls_private_key&quot; &quot;twotier_keypair&quot; {<br>  algorithm = &quot;RSA&quot;<br>  rsa_bits  = 2048<br>}<br><br>resource &quot;aws_key_pair&quot; &quot;twotier_keypair&quot; {<br>  key_name   = &quot;twotier_keypair-keypair&quot;<br>  public_key = tls_private_key.twotier_keypair.public_key_openssh<br>}<br><br>terraform {<br>  required_version = &quot;&gt;= 1.4.6&quot;<br><br>  cloud {<br>    organization = &quot;Sharon-LUIT&quot;<br><br>    workspaces {<br>      name = &quot;TwoTierArchiProject&quot;<br>    }<br>  }<br>}<br><br>resource &quot;aws_vpc&quot; &quot;myvpc&quot; {<br>  cidr_block = &quot;10.0.0.0/16&quot;<br><br>  tags = {<br>    Name = &quot;myvpc&quot;<br>  }<br>}<br><br>resource &quot;aws_subnet&quot; &quot;public_subnet_1&quot; {<br>  cidr_block        = &quot;10.0.1.0/24&quot;<br>  vpc_id            = var.vpc_id<br>  availability_zone = &quot;us-east-1a&quot;<br><br>  tags = {<br>    Name = &quot;public-subnet-1&quot;<br>  }<br>}<br><br>resource &quot;aws_subnet&quot; &quot;public_subnet_2&quot; {<br>  cidr_block        = &quot;10.0.2.0/24&quot;<br>  vpc_id            = var.vpc_id<br>  availability_zone = &quot;us-east-1b&quot;<br><br>  tags = {<br>    Name = &quot;public-subnet-2&quot;<br>  }<br>}<br><br>resource &quot;aws_subnet&quot; &quot;private_subnet_1&quot; {<br>  cidr_block        = &quot;10.0.11.0/24&quot;<br>  vpc_id            = var.vpc_id<br>  availability_zone = &quot;us-east-1a&quot;<br><br>  tags = {<br>    Name = &quot;private-subnet-1&quot;<br>  }<br>}<br><br>resource &quot;aws_subnet&quot; &quot;private_subnet_2&quot; {<br>  cidr_block        = &quot;10.0.12.0/24&quot;<br>  vpc_id            = var.vpc_id<br>  availability_zone = &quot;us-east-1b&quot;<br><br>  tags = {<br>    Name = &quot;private-subnet-2&quot;<br>  }<br>}<br><br>resource &quot;aws_internet_gateway&quot; &quot;sharon_twotier_igw&quot; {<br>  vpc_id = var.vpc_id<br><br>  tags = {<br>    Name = &quot;my-vpc-igw&quot;<br>  }<br>}<br><br># Create the first route table<br>resource &quot;aws_route_table&quot; &quot;public_route_table1&quot; {<br>  vpc_id = var.vpc_id<br><br>  tags = {<br>    Name = &quot;public-route-table-1&quot;<br>  }<br><br>  route {<br>    cidr_block = &quot;0.0.0.0/0&quot;<br>    gateway_id = aws_internet_gateway.sharon_twotier_igw.id<br>  }<br>}<br><br># Create the second route table<br>resource &quot;aws_route_table&quot; &quot;public_route_table2&quot; {<br>  vpc_id = var.vpc_id<br><br>  tags = {<br>    Name = &quot;public-route-table-2&quot;<br>  }<br><br>  route {<br>    cidr_block = &quot;0.0.0.0/0&quot;<br>    gateway_id = aws_internet_gateway.sharon_twotier_igw.id<br>  }<br>}<br><br># First route table with the first public subnet association 1<br>resource &quot;aws_route_table_association&quot; &quot;public_subnet_association1&quot; {<br>  subnet_id      = aws_subnet.public_subnet_1.id<br>  route_table_id = aws_route_table.public_route_table1.id<br>}<br><br># Second route table with the second public subnet association 2<br>resource &quot;aws_route_table_association&quot; &quot;public_subnet_association2&quot; {<br>  subnet_id      = aws_subnet.public_subnet_2.id<br>  route_table_id = aws_route_table.public_route_table2.id<br>}<br><br>resource &quot;aws_security_group&quot; &quot;webserver_sg&quot; {<br>  name        = &quot;webserver_sg&quot;<br>  description = &quot;Security group for web servers&quot;<br>  vpc_id      = var.vpc_id<br><br>  ingress {<br>    from_port   = 22<br>    to_port     = 22<br>    protocol    = &quot;tcp&quot;<br>    cidr_blocks = [&quot;0.0.0.0/0&quot;]<br>  }<br><br>  ingress {<br>    description = &quot;http&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><br>  ingress {<br>    from_port   = 443<br>    to_port     = 443<br>    protocol    = &quot;tcp&quot;<br>    cidr_blocks = [&quot;0.0.0.0/0&quot;]<br>  }<br><br>  ingress {<br>    description = &quot;http&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>  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>  }<br><br>  tags = {<br>    Name = &quot;sharon_sg&quot;<br>  }<br>}<br><br># First EC2 instance<br>resource &quot;aws_instance&quot; &quot;web_server1&quot; {<br>  ami                         = &quot;ami-09988af04120b3591&quot;<br>  instance_type               = &quot;t2.micro&quot;<br>  subnet_id                   = aws_subnet.public_subnet_1.id<br>  vpc_security_group_ids      = [aws_security_group.webserver_sg.id]<br>  associate_public_ip_address = true<br>  key_name                    = aws_key_pair.twotier_keypair.key_name<br><br>  user_data = &lt;&lt;-EOF<br>#! /bin/bash<br>yum update -y<br>yum install httpd -y<br>systemctl start httpd<br>systemctl enable httpd<br>EOF<br><br>  tags = {<br>    Name = &quot;web-server-instance-1&quot;<br>  }<br>}<br><br># Second EC2 instance<br>resource &quot;aws_instance&quot; &quot;web_server2&quot; {<br>  ami                         = &quot;ami-09988af04120b3591&quot;<br>  instance_type               = &quot;t2.micro&quot;<br>  subnet_id                   = aws_subnet.public_subnet_2.id<br>  vpc_security_group_ids      = [aws_security_group.webserver_sg.id]<br>  associate_public_ip_address = true<br>  key_name                    = aws_key_pair.twotier_keypair.key_name<br><br>  user_data = &lt;&lt;-EOF<br>#! /bin/bash<br>yum update -y<br>yum install httpd -y<br>systemctl start httpd<br>systemctl enable httpd<br>EOF<br><br>  tags = {<br>    Name = &quot;web-server-instance-2&quot;<br>  }<br>}<br><br><br>resource &quot;aws_security_group&quot; &quot;rds_sg&quot; {<br>  name        = &quot;sjrds_sg&quot;<br>  description = &quot;Security group for RDS&quot;<br>  vpc_id      = var.vpc_id<br><br>  ingress {<br>    from_port   = 3306<br>    to_port     = 3306<br>    protocol    = &quot;tcp&quot;<br>    cidr_blocks = [&quot;0.0.0.0/0&quot;]<br>  }<br>  ingress {<br>    from_port   = 22<br>    to_port     = 22<br>    protocol    = &quot;tcp&quot;<br>    cidr_blocks = [&quot;0.0.0.0/0&quot;]<br>  }<br>  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>  }<br><br>  tags = {<br>    Name = &quot;rds-security-group&quot;<br>  }<br>}<br><br>resource &quot;aws_db_instance&quot; &quot;rds_instance&quot; {<br>  engine                    = &quot;mysql&quot;<br>  instance_class            = &quot;db.t2.micro&quot;<br>  allocated_storage         = 20<br>  storage_type              = &quot;gp2&quot;<br>  publicly_accessible       = false<br>  identifier                = &quot;sharon-rds-instance&quot;<br>  username                  = &quot;sharonrdsadmin&quot;<br>  password                  = &quot;sharonrdspassword123&quot;<br>  skip_final_snapshot       = false<br>  final_snapshot_identifier = &quot;my-snapshot&quot;<br>  tags = {<br>    Name = &quot;rds-instance&quot;<br>  }<br>}<br><br>resource &quot;aws_eip&quot; &quot;nat_eip&quot; {<br>  tags = {<br>    Name = &quot;nat-eip&quot;<br>  }<br>}<br><br>resource &quot;aws_nat_gateway&quot; &quot;nat_gateway&quot; {<br>  allocation_id = aws_eip.nat_eip.id<br>  subnet_id     = aws_subnet.public_subnet_1.id<br><br>  tags = {<br>    Name = &quot;nat-gateway&quot;<br>  }<br>}<br><br># Associate the NAT gateway with the private subnets<br>resource &quot;aws_route_table_association&quot; &quot;private_subnet_1&quot; {<br>  subnet_id      = aws_subnet.private_subnet_1.id<br>  route_table_id = aws_route_table.public_route_table1.id<br>}<br><br>resource &quot;aws_route_table_association&quot; &quot;private_subnet_2&quot; {<br>  subnet_id      = aws_subnet.private_subnet_2.id<br>  route_table_id = aws_route_table.public_route_table2.id<br>}<br><br># Private route tables to the NAT gateway<br>resource &quot;aws_route&quot; &quot;private_route1&quot; {<br>  route_table_id         = aws_route_table.public_route_table1.id<br>  destination_cidr_block = &quot;0.0.0.0/0&quot;<br>  nat_gateway_id         = aws_nat_gateway.nat_gateway.id<br>}<br><br>resource &quot;aws_route&quot; &quot;private_route2&quot; {<br>  route_table_id         = aws_route_table.public_route_table2.id<br>  destination_cidr_block = &quot;0.0.0.0/0&quot;<br>  nat_gateway_id         = aws_nat_gateway.nat_gateway.id<br>}<br><br>resource &quot;aws_lb&quot; &quot;web_lb&quot; {<br>  name               = &quot;myweb-lb&quot;<br>  load_balancer_type = &quot;application&quot;<br>  security_groups    = [aws_security_group.webserver_sg.id]<br>  subnets            = [aws_subnet.public_subnet_1.id, aws_subnet.public_subnet_2.id]<br><br>  tags = {<br>    Name = &quot;myweb-lb&quot;<br>  }<br>}<br><br># Add Listener to Load Balancer<br>resource &quot;aws_lb_listener&quot; &quot;web_lb_listener&quot; {<br>  load_balancer_arn = aws_lb.web_lb.arn<br>  port              = 8080<br>  protocol          = &quot;HTTP&quot;<br><br>  default_action {<br>    type             = &quot;forward&quot;<br>    target_group_arn = aws_lb_target_group.web_target_group.arn<br>  }<br>}<br><br>#Target Group for Load Balancer<br>resource &quot;aws_lb_target_group&quot; &quot;web_target_group&quot; {<br>  name        = 8080<br>  port        = 8080<br>  protocol    = &quot;HTTP&quot;<br>  target_type = &quot;instance&quot;<br>  vpc_id      = var.vpc_id<br><br>  health_check {<br>    healthy_threshold   = 2<br>    unhealthy_threshold = 2<br>    timeout             = 3<br>    interval            = 30<br>    path                = &quot;/&quot;<br>  }<br>}</pre><p>Now let run the script, first we will need to initializes a working directory containing Terraform configuration files.</p><pre>terraform init</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/542/1*xkz5SdjPeVkDcIh_y5-5EA.png" /></figure><pre>terraform fmt<br><br>terraform validate</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/438/1*Fx5YFsBxGD_7H5xk3NlqvQ.png" /></figure><p>The terraform login command can be used to automatically obtain and save an API token for Terraform Cloud</p><pre>terraform login</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/580/1*_rIp3-lL4khoC52tFl0sVQ.png" /></figure><pre>terraform plan<br><br>The plan lets you to preview the actions Terraform would take to modify <br>your infrastructure, or save a speculative plan which you can apply later. </pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/488/1*mnQ93D7J3Vt5wf6VQ9fH9w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/482/1*ff1fdcdhe0khAFuxURsCag.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/482/1*6nj6pbU7UADuTbh6As-KDg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/612/1*gAJzbquRB5a-9TDOPvX56Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/616/1*hz5wUQS_OiELfc5MTP0Hng.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/524/1*X_oyKkum99Cb5v2Wm1ydHQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/464/1*Aj76vRMaB8VWTZM2qW-1sw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/522/1*p2YR0mggsWWFrpjPvrZKTg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/470/1*P6nAp8mlRA1GsM7QMKdt_w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/514/1*maDqZhe7UFPU-bKWzpsfxQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/594/1*Bw9QQxmdIAv1Vl43L0J6Gg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/544/1*fqpQQbpO2fXxHAfFsThQ5g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/548/1*c7_7irL2pOyR3rKpXCqpwA.png" /></figure><p>Now let navigate to the Terraform Cloud workspace what you created, from here we will run</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6Msoh9xS-eNRJnogFSyAEA.png" /><figcaption>To the right of the page clic on Actions and Start New Run</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/648/1*_P0LPVfgvGN4GeNW-T2HpQ.png" /><figcaption>Choose a Reason for starting run and hit Start Run</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1bSNZaKXCQEHw5__ucn_yw.png" /><figcaption>Confirm and Apply</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/878/1*VTHGmCBANSd7fjhut30QeQ.png" /><figcaption>Confirm Plan</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hnsJJsk1U1vbpTdmmvWukQ.png" /><figcaption>Plan Finished and Apply Finished</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e_Eaij6Vv7Ay-6FDXJVWwQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oGapxvFMRXrcxq3fmlefdg.png" /></figure><p>Now let navigate back to the AWS Cloud9</p><pre>terraform apply -auto-approve<br><br>-performs a plan just like terraform plan does, but then actually carries out the planned changes to each resource using the <br>relevant infrastructure provider&#39;s API. <br>It asks for confirmation from the user before making any changes, unless it was explicitly told to skip approval.</pre><p>Now let verify that the 2 webservers, the RDS, the subnets and the VPC was created in the console.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tLHo57OC6N5InNEnGObE8g.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BMCSBjtS--1dltEfkh53Ig.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P4twq6UeMw8FaaCcfhGz0Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KVeKtW32oB7-koQrEznlEQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1008/1*8MtCBp0GaHoqOXANTTCy9w.png" /></figure><p>Everything has been created now lets verify that this worked!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1rZDvmEweovP0GvAJ1s6AQ.jpeg" /><figcaption>Webserver 1</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5rlOI2bG_9Ywu1UhDKKoLw.jpeg" /><figcaption>Webserver 2</figcaption></figure><p>Project complete!!</p><p><a href="https://github.com/SharonRJohnson/Sharon-Gold-LUIT/blob/main/Terraform%20Two%20Tier%20Architecture-Terraform%20Cloud">https://github.com/SharonRJohnson/Sharon-Gold-LUIT/blob/main/Terraform%20Two%20Tier%20Architecture-Terraform%20Cloud</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ce20932c31f3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Installing Jenkins Using Terraform and EC2]]></title>
            <link>https://sharonrjohnson.medium.com/installing-jenkins-using-terraform-and-ec2-361efa40c776?source=rss-4606c122b421------2</link>
            <guid isPermaLink="false">https://medium.com/p/361efa40c776</guid>
            <dc:creator><![CDATA[Sharon Johnson]]></dc:creator>
            <pubDate>Sat, 03 Jun 2023 15:54:06 GMT</pubDate>
            <atom:updated>2023-06-03T15:54:06.451Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*HizT6n-nCeYCQ0vW" /></figure><p>Let’s get started with the “what is”</p><p><strong>What is Terraform? </strong><em>Terraform an infrastructure as code tool that lets you build, change, and version cloud and on-prem resources safely and efficiently.</em></p><p><strong>What is Jenkins?</strong> <em>Jenkins an open source automation server which enables developers around the world to reliably build, test, and deploy their software.</em></p><p>With this project I will be using the AWS Console and spin up my Cloud9. Also we are going to use the Terraform Registry <a href="https://registry.terraform.io/">https://registry.terraform.io/</a>-</p><p><strong><em>The Terraform Registry </em></strong><em>is an interactive resource for discovering a wide selection of integrations (providers), configuration packages (modules), and security rules (policies) for use with Terraform. The Registry includes solutions developed by HashiCorp, third-party vendors, and our Terraform community.</em></p><p>Commands that will be used to execute this project:</p><p><strong>terraform init</strong> <em>command initializes a working directory containing Terraform configuration files. This is the first command that should be run after writing a new Terraform configuration or cloning an existing one from version control. It is safe to run this command multiple times.</em></p><p><strong>terraform fmt</strong> <em>command is used to rewrite Terraform configuration files to a canonical format and style. This command applies a subset of the </em><a href="https://developer.hashicorp.com/terraform/language/syntax/style"><em>Terraform language style conventions</em></a><em>, along with other minor adjustments for readability.</em></p><p><strong>terraform validate</strong> <em>command validates the configuration files in a directory, referring only to the configuration and not accessing any remote services such as remote state, provider APIs, etc.</em></p><p><em>Validate runs checks that verify whether a configuration is syntactically valid and internally consistent, regardless of any provided variables or existing state. It is thus primarily useful for general verification of reusable modules, including correctness of attribute names and value types.</em></p><p><strong>terraform plan</strong> <em>command creates an execution plan, which lets you preview the changes that Terraform plans to make to your infrastructure. By default, when Terraform creates a plan it:</em></p><ul><li><em>Reads the current state of any already-existing remote objects to make sure that the Terraform state is up-to-date.</em></li><li><em>Compares the current configuration to the prior state and noting any differences.</em></li><li><em>Proposes a set of change actions that should, if applied, make the remote objects match the configuration.</em></li></ul><p><strong>terraform apply</strong> <em>command executes the actions proposed in a Terraform plan.</em></p><p><strong>terraform destroy</strong> c<em>ommand is a convenient way to destroy all remote objects managed by a particular Terraform configuration.</em></p><p><em>While you will typically not want to destroy long-lived objects in a production environment, Terraform is sometimes used to manage ephemeral infrastructure for development purposes, in which case you can use </em><em>terraform destroy to conveniently clean up all of those temporary objects once you are finished with your work.</em></p><p>Objectives:</p><ol><li>Deploy 1 EC2 Instances in your Default VPC.</li><li>Bootstrap the EC2 instance with a script that will install and start Jenkins. Review the official Jenkins Documentation for more information: <a href="https://www.jenkins.io/doc/book/installing/linux/">https://www.jenkins.io/doc/book/installing/linux/</a></li><li>Create and assign a Security Group to the Jenkins Security Group that allows traffic on port 22 from your ip and allows traffic from port 8080.</li><li>Create a S3 bucket for your Jenkins Artifacts that is not open to the public.</li><li>Verify that you can reach your Jenkins install via port 8080 in your browser. Be sure to include a screenshot of the Jenkins login screen in your documentation.</li></ol><p>First we will need to create a new directory using the command line (I’m creating one call Jenkins) once you create your directory cd into it.</p><pre>mkdir &lt;your directory name&gt;</pre><p>Now we will create a <em>main.tf</em> file to build out my terraform code <em>(Code in the Terraform language is stored in plain text files with the . tf file extension. There is also a JSON-based variant of the language that is named with the . tf.)</em></p><p>We will need to add to our .tf file the AWS provider required providers information and region we are working in (this information can be found in the Terraform Registry)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/592/1*FPpblVoX_cJEPv4nJzC0ow.png" /></figure><p>Now we are going to add in the resource blocks to set up our EC2 instance, this will include the ami, instance type, security groups and the script to install Jenkins.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Zo9SGebFJfoSAxOGZNu0XA.png" /></figure><p>Next we will create a resource block to generate our private keys</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/532/1*QwaGAqC1D0NkDg1Q0JWLDg.png" /></figure><p>Next we will create our secruity groups to allow traffic inbound connections to ports 8080, 443 and 22 and allow outbound to all ip and ports.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/526/1*sgS2UG6nZzI44AgUtTZyww.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/458/1*DRqURh61b6b34gkMtcDN1A.png" /></figure><p>Now let create the S3 bucket for the Jenkins Artifacts that’s should not have public access.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/476/1*gUkGClCl0mq7Uon7W3GULw.png" /></figure><p>Now lets run our commands</p><pre>terraform init</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/550/1*DgpvgmjC1Sbsc8Ed75Of-w.png" /></figure><p>Run command terraform fmt- this will make sure your main.tf is formatted correctly.</p><pre>terraform fmt</pre><p>Next command:</p><pre>terraform validate<br></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/390/1*A_h6SCyr1npWwrSRvWWqRA.png" /></figure><pre>terraform plan</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/930/1*QuEHJ-rmuej4TvXJ2unnUQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/376/1*bn-h4DQ4pmb2v5NwB6HU4w.png" /></figure><p>There is alot of information but this is what you are looking for when running the terraform plan.</p><p>Now we are going to apply</p><pre>terraform apply</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/948/1*cuZ4W0cECR7ea41nBgQ_KQ.png" /></figure><p>Once you run the apply you will receive this message, here you can type in “yes” to perform the actions described above.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/390/1*3PFq8Xd07WRSlQmQwk9vtw.png" /></figure><p>All has been applied. When running the apply command, this will show you that all of your configuration was set up.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/426/1*6edf4uFhDu8MVNqaBU0XzQ.png" /></figure><p>Now we can verify everything was configured in the AWS Console.</p><p>EC2 created</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_DC3hkGX4fHMomTCkFuISg.png" /></figure><p>Security Groups created</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7lUhaB6m1rqN7Pf3hUWbvg.png" /></figure><p>S3 Bucket (jenkinsartiproject) was created with public block acesss.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-NXOBdCnF-W4IUySx2JFPg.png" /></figure><p>Now we can grab our EC2 instance public IP address to test this out</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/860/1*ZLEZDw7RgjL-irRzeMIvag.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jioNWSj2vSQi_zGr65CVgw.png" /></figure><p>Here we go a completed project!!!!</p><p>Now we can tear it down to avoid charges in AWS.</p><pre>terraform destroy</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/416/1*jnz7kGWSdELhzT53zlQ3BA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/528/1*DlYsM3jBPslY6Ep4Z5U7bg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/318/1*ZokljAYKIQhrUKG8yMMt8A.png" /></figure><p><a href="https://github.com/SharonRJohnson/Sharon-Gold-LUIT/blob/main/Deploying%20Jeknkins%20with%20Terraform">https://github.com/SharonRJohnson/Sharon-Gold-LUIT/blob/main/Deploying%20Jeknkins%20with%20Terraform</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=361efa40c776" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Spinning Up Two Kubernetes Deployments with Two Pods]]></title>
            <link>https://sharonrjohnson.medium.com/spinning-up-two-kubernetes-deployments-with-two-pods-5260c68e4e57?source=rss-4606c122b421------2</link>
            <guid isPermaLink="false">https://medium.com/p/5260c68e4e57</guid>
            <dc:creator><![CDATA[Sharon Johnson]]></dc:creator>
            <pubDate>Sun, 21 May 2023 16:57:34 GMT</pubDate>
            <atom:updated>2023-05-21T16:57:34.259Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*t-9MR9lSVH4OOkkP" /><figcaption>Photo by <a href="https://unsplash.com/@growtika?utm_source=medium&amp;utm_medium=referral">Growtika</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Lets get started with the “what is”</p><p><strong>What does Deployment mean in Kubernetes? </strong><em>A Kubernetes Deployment tells Kubernetes how to create or modify instances of the pods that hold a containerized application. Deployments can help to efficiently scale the number of replica pods, enable the rollout of updated code in a controlled manner, or roll back to an earlier deployment version if necessary.</em></p><p><strong>What does pods mean in Kubernetes?</strong> <em>A pod is the smallest execution unit in Kubernetes. A pod encapsulates one or more applications. Pods are ephemeral by nature, if a pod (or the node it executes on) fails, Kubernetes can automatically create a new replica of that pod to continue operations.</em></p><p><strong>What is a ConfigMap? </strong><em>ConfigMaps are ideal for most situations where you want to supply environment-specific configuration values to your pods. They store key-value pairs and make them available to pods as environment variables, command line arguments, or files in a mounted volume.</em></p><p><strong>FOUNDATIONAL</strong><br>Spin up two deployments. One deployment contains 2 pods running the nginx image. Include a ConfigMap that points to a custom index.html page that contains the line “This is Deployment One”. The other deployment contains 2 pods running the nginx image. Include a ConfigMap that points to a custom index.html page that contains the line “This is Deployment Two”.</p><p>Create a service that points to both deployments. You should be able to access both deployments using the same ip address and port number.</p><p>Use the curl command to validate that you eventual see the index.html pages from both Deployment 1 and Deployment 2.</p><p>Example: curl service_ip_address:service_port</p><p>I will be using AWS Cloud9, make sure that K8 and MiniKube is installed in your enviroment.</p><p>First lets create a local directory using the following command</p><pre>mkdir &lt;your file name&gt;<br>cd into your file      </pre><p>Create two deployments that contains two pods running the nginx image using yaml file (using vim command to create)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/920/1*1x7rbDvktO9JVwxrg1nO_Q.png" /><figcaption>First Deployment</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1020/1*jBN-p0fEq5aIGnjWEUUbBQ.png" /><figcaption>Second Deployment</figcaption></figure><p>Now we are going to create two yaml ConfigMaps for each Deployment using vim.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1010/1*5wilOHl0M3ylLkzNgn-36A.png" /><figcaption>First ConfigMap</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/992/1*fHKu_uO6Gqb70utekw4gng.png" /><figcaption>Second ConfigMap</figcaption></figure><p>The next we will create the service yml that will bring all these files together to get the end results (using the vim command)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/724/1*-Wr2u4YanvU5QlA-NN6NOw.png" /><figcaption>Service</figcaption></figure><p>So let put this all together, first we are going to apply both configmaps</p><p><strong>Kubectl apply -f </strong>(<em>to apply a configuration to a resource by filename or stdin)</em></p><pre>kubectl apply -f &lt;your first configmap file name&gt;<br>Kubeclt apply -f &lt;your second configmap file name&gt;</pre><p>You should get a return that your files have been created.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/440/1*z_soZbuPPP5eKzzx67gxsA.png" /><figcaption>Example</figcaption></figure><p>If you run the following command you will get a description of your configmap files:</p><p><strong>kubectl describe</strong>- <em>it describe pods command provides detailed information about each of the pods that provide Kubernetes infrastructure. If the output from a specific pod is desired, run the command kubectl describe pod pod_name — namespace kube-system .</em></p><pre>kubectl describe configmap</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/476/1*uaX8OAuNWC90-l14pHj-AA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5DGS_ovmuWDN2-9zoEewMA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/488/1*CiU7nc1wZi7hdtYxw6CmAQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/378/1*1JjLgxGOU-5BetFzPRwQdg.png" /></figure><p>Now let apply both deployment files</p><pre>kubectl apply -f &lt;first deployment file name&gt;<br>kubectl apply -f &lt;second deployment file name&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/526/1*RySqESJdQkDiyP0HtfArOw.png" /></figure><p>Notice that both deployments has been created. Let’s run the following command to see your available deployments.</p><p><strong>Kubectl get deployment</strong> -<em>tells Kubernetes how to create or modify instances of the pods that hold a containerized application. Deployments can help to efficiently scale the number of replica pods, enable the rollout of updated code in a controlled manner, or roll back to an earlier deployment version if necessary.</em></p><pre>kubectl get deployment</pre><p>If you run the following command you will see your pods running status</p><p><strong>kubectl get pods -o wide</strong> <em>command displays a list of all pods in the current namespace, along with other information. Any additional information will be published alongside the results in plain language. Pods hold the name of the node.</em></p><pre>kubectl get pods -o wide<br><br></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/882/1*ZMgVwCz4mGir1nwsSdawYA.png" /></figure><p>Last we are going to apply the service file</p><pre>kubectl apply -f &lt;your service file name&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/462/1*sl_tPhFK9x8l5MXdkQUKlQ.png" /></figure><p>Here you can see the service has been created. Run the following command to see your service detail.</p><p><strong>Kubectl get service</strong>-<em> it shows you a list of service information that you created.</em></p><pre>kubectl get service</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/588/1*hay1f0U6kkg8jKXHhhHpzA.png" /></figure><p>Let run the last command, using the kubectl get all command we can list down all the pods, services, statefulsets, etc. in a namespace but not all the resources are listed using this command.</p><p><strong>kubectl get all- </strong><em>list down all the pods, services, statefulsets, etc. in a namespace but not all the resources are listed using this command. Hence, if you want to see the pods, services, and statefulsets in a particular namespace then you can use this command.</em></p><pre>kubectl get all</pre><p>We are now going to curl to see what we will get:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/472/1*c_HbGrjj7XDbhrYYDCoRBQ.png" /></figure><p>Project complete!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5260c68e4e57" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Creating A Docker Swarm in AWS That Has Manager and Worker Nodes]]></title>
            <link>https://sharonrjohnson.medium.com/creating-a-docker-swarm-in-aws-that-has-manager-and-worker-nodes-eacd99c9985c?source=rss-4606c122b421------2</link>
            <guid isPermaLink="false">https://medium.com/p/eacd99c9985c</guid>
            <dc:creator><![CDATA[Sharon Johnson]]></dc:creator>
            <pubDate>Sun, 07 May 2023 12:15:34 GMT</pubDate>
            <atom:updated>2023-05-07T12:16:42.267Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/300/0*iWZw5Xe7IJcQU6c_" /></figure><p>Let’s get started with the what is:</p><p><strong>What is Docker Swarm? </strong><em>A group of either physical or virtual machines that are running the Docker application and that have been configured to join together in a cluster. The activities of the cluster are controlled by a swarm manager, and machines that have joined the cluster are referred to as nodes.</em></p><p>What are Nodes?</p><p><strong>Manager nodes</strong> <em>handle cluster management tasks:</em></p><ul><li><em>maintaining cluster state</em></li><li><em>scheduling services</em></li><li><em>serving swarm mode </em><a href="https://docs.docker.com/engine/api/"><em>HTTP API endpoints</em></a></li></ul><p><strong>Worker nodes </strong><em>are also instances of Docker Engine whose sole purpose is to execute containers. Worker nodes don’t participate in the Raft distributed state, make scheduling decisions, or serve the swarm mode HTTP API.</em></p><p><em>You can create a swarm of one manager node, but you cannot have a worker node without at least one manager node.</em></p><p><strong>Task:</strong></p><p>Using AWS, create a Docker Swarm that consists of one manager and three worker nodes.</p><p>Verify the cluster is working by deploying the following tiered architecture:</p><ul><li>a service based on the Redis docker image with 4 replicas</li><li>a service based on the Apache docker image with 10 replicas</li><li>a service based on the Postgres docker image with 1 replica</li></ul><p>Let’s get started!</p><p>Step 1: Create a Docker Swarm that consists of one manager and three worker nodes.</p><p>Open up your AWS console and navigate to the EC2 and lets launch 4 instances one for the manager and one for each worker nodes.</p><p>I will be creating the 4 instances using Amazon Linux 2(if you look to the right of the page under summary you and select to create all 4 instances at one time), select your instance type as t2 micro, your key pair you can select an existing or create a new one.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*73mYlzluAEOOF_ssNNOd2w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TRAg47UbSjmGJ8uHpteP8g.png" /></figure><p>In the Network setting we will need to make sure that your security groups are created with the proper settings. You can choose to click create security groups from here.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VOXe4SGcVm6VNcldI9OMFQ.png" /></figure><p>From here make sure your security group have the following settings, security groups acts as a virtual firewall for your EC2 instances to control incoming and outgoing traffic. Both inbound and outbound rules control the flow of traffic to and traffic from your instance. So from here click on create security group and edit the inbound rules</p><p>TCP port</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZDmx6cFJsXwjrIYXwUZKbw.png" /></figure><p>The following ports must be available. On some systems, these ports are open by default.</p><ul><li>Port 2377 TCP for communication with and between manager nodes</li><li>Port 7946 TCP/UDP for overlay network node discovery</li><li>Port 4789 UDP (configurable) for overlay network traffic.</li><li>Also make sure to add SSH with port 22.</li></ul><p>Next let proceed to the Advance detail and add in user data to install docker once we launch the instance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/556/1*gi4grb4KWDvRdlsWSqMGAg.png" /></figure><p>Let’s launch our instances.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/201/1*0WJrG5THn5jg-mLr7cFGMg.png" /></figure><p>All instance has been created so lets name each instance one we will name Manger Node and the other three are for the worker nodes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tsSshbnnWdDTwNFfpE-ujw.png" /></figure><p>Step 2: Setting up Manager and Worker Node to create our cluster.</p><p>So let configure the manager node first, click on the manager node and click on connect, I will SSH into the manger node instance through the AWS CLI (cloud shell) to setup the swarm mode.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oYms7l_Ade0ZDhxhYI8cDw.png" /></figure><p>Now that you are SSH into the manager node, let join swarm using the following command</p><pre>docker swarm init --advertise-addr &lt;ip&gt; (use the private IP address)</pre><p>You should get the following return with the manager token that can be attached to the three workers nodes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/904/1*vHAbP20qXuMFK0eKI3OwKA.png" /></figure><p>So from here you will need to go back to the instance for each worker and SSH into the three worker nodes to have them join into the manager node.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*C5V7JO61VWMp9gU7g7fyBQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wTsap9R60_k5nbFr4pPm4g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wTsap9R60_k5nbFr4pPm4g.png" /></figure><p>Let’s use the following command to get a list of nodes</p><pre>docker node ls</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/827/1*5TM9LyayrcTFxubYx3ZiHg.png" /></figure><p>Ok we have all 4 nodes, one is a leader(manager) and the others are the three workers.</p><p>Step 3: Adding a service based on the Redis docker image with 4 replicas</p><pre>docker service create --name redis --replicas 4 redis</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/577/1*yIzJzcT2NetB23SrB93buQ.png" /></figure><p>Step 4: Adding a service based on the Apache docker image with 10 replicas</p><pre>docker service create --name apache --replicas 10 httpd</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/586/1*WAFJh1jIOBh5W_Zlp1gcuA.png" /></figure><p>Step 5: Adding a service based on the Postgres docker image with 1 replica</p><pre>docker service create --name postgres --replicas 1 -e POSTGRES_PASSWORD=mypassword postgres</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/837/1*SvBsq3j-ktZgLUFJegm6mg.png" /></figure><p>Now that all of the services are added we can now run the following command to list</p><pre>docker service ls</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/523/1*OzZA_WuEA82KkdStgbEYEg.png" /></figure><p>Project has been completed.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eacd99c9985c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Creating Docker Containers Using Boto3/Python, GitHub Repos and Bind Mounting]]></title>
            <link>https://sharonrjohnson.medium.com/creating-docker-containers-using-boto3-python-github-repos-and-bind-mounting-ae2d56c505f?source=rss-4606c122b421------2</link>
            <guid isPermaLink="false">https://medium.com/p/ae2d56c505f</guid>
            <dc:creator><![CDATA[Sharon Johnson]]></dc:creator>
            <pubDate>Mon, 01 May 2023 19:38:49 GMT</pubDate>
            <atom:updated>2023-05-02T20:01:15.065Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*24zGVHjIqohIFDhC" /><figcaption>Photo by <a href="https://unsplash.com/@rubaitulazad?utm_source=medium&amp;utm_medium=referral">Rubaitul Azad</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Let’s get started with the “<strong>what is</strong>”!</p><p><strong>What is Docker Containers? </strong><em>A Docker container image is a lightweight, standalone, executable package of software that includes everything needed to run an application: code, runtime, system tools, system libraries and settings.</em></p><p><strong>What is Docker Hub? </strong><em>Docker Hub is a hosted repository service provided by Docker for finding and sharing container images with your team. Key features include: Private Repositories: Push and pull container images. Automated Builds: Automatically build container images from GitHub and Bitbucket and push them to Docker Hub.</em></p><p><strong>What is Boto3/Python? </strong><em>Python (Boto3) to create, configure, and manage AWS services, such as Amazon Elastic Compute Cloud (Amazon EC2) and Amazon Simple Storage Service (Amazon S3). The SDK provides an object-oriented API as well as low-level access to AWS services.</em></p><p><strong>What is GitHub? </strong><em>GitHub a is code hosting platform for version control and collaboration. It lets you and others work together on projects from anywhere.</em></p><p><strong>What is bind mount in dockers? </strong><em>A storage area (file/directory) on your local machine available inside your container.</em></p><p>The project for week 16 scenario:</p><p>A software development team is working on a Python-based application. The team needs to simplify their development environment setup and ensure consistent execution of their code across different machines.</p><p>The team can create a Dockerfile for Boto3/Python that utilizes either the Ubuntu or Python official images available on Dockerhub. The Dockerfile can be customized to include any necessary libraries or dependencies required by the team’s Python application.</p><p>The team can then download three repositories to their local host and create three Ubuntu containers using the customized Dockerfile. Each container can be configured with a bind mount to one of the repo directories, allowing the team to easily access the code and make changes as needed.</p><p>Finally, team members can log into each container and verify access to each repo directory, ensuring that the containers have been properly configured and that the team can effectively collaborate on their codebase. By utilizing Docker, the team can also ensure that their development environment is portable and can be easily replicated on different machines, streamlining their workflow and enabling efficient collaboration.</p><p>Foundational part of the project is to:</p><ul><li>Build docker file for Boto3 / Python</li><li>Use either the Ubuntu or Python official images on Docker Hub</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 to each repo directory</li></ul><p>Step 1: Build docker file for Boto3/Python</p><p>I will be using AWS Cloud9 for the IDE, we will need to create a directory using <strong>mkdir</strong> and whatever name you will like to use.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/401/1*vjDQAM5YRZ3tkovka676yQ.png" /></figure><p>Step 2: Use either the Ubuntu or Python official images on Docker Hub</p><p>I will create a dockerfile within the Cloud9, click on File, New From Template, then choose Python File, name your file and save it under your directory you created with no extension.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/415/1*Wzg5lZVd-f5ejha25DrLAA.png" /></figure><p>You can create a dockerfile using the <a href="https://hub.docker.com/_/python">https://hub.docker.com/_/python</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MktvxtjkaHXJ7gN3PfYotA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/522/1*2Zyn_HEDkgXQIBt9dt52Bg.png" /></figure><p>Step 3: Download any three repos to local host</p><p>From your GitHub account you can download any three report to your local host. Use the git clone command along with the GitHub URL you want to use.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/797/1*6pGSSiLCWwBg2kqxsRAngg.png" /></figure><p>Step 4: Create three Ubuntu containers</p><p>First I will build out the image for our containers using the following command</p><p>docker build -t (whatever name you want to use) . (don’t forget to add the . behind the command. As you can see below we have “successfully built” and it “successfully tagged”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/513/1*CcgSFrmVCpFEOW-kDesaqg.png" /></figure><p>Here you can run docker image to see that the image was created.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*9DxlcPk8sjiznCfTSHWc_g.png" /></figure><p>Now let’s create 3 Ubuntu containers using the docker command:</p><p>docker run -dt — — name (name your containers) -v “$(pwd)”/(path to your repos) ubuntu</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/865/1*oWO_rzWhgBpq3F3_2zcuVw.png" /><figcaption>example of my container using the docker run command</figcaption></figure><p>Now I’m going to run the docker container inspect (your container name) to see the bind mount. You will need to do this for each container you created.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/519/1*Tck11xfkCVhoYldMnzPCqg.png" /><figcaption>Example</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/869/1*JFsb9tz02tPqT2osfo5bbw.png" /><figcaption>Bind Mount for Sharon-Gold-LUIT</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/844/1*HATtGr-ycg1OxGBPz4P6FA.png" /><figcaption>Bind Mount for gold-member</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/816/1*J9O3HCuYPrm5p-z4VWb6Ew.png" /><figcaption>Bind Mount for Stephanie-Gold_LUIT</figcaption></figure><p>Step 6: Log into each container and verify access to each repo directory</p><p>Use the command docker container exec -it and (your container name to see if you can log into your containers</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/584/1*XvnpfzF3mAcmbtz4mpgDbQ.png" /><figcaption>This is an example of what you are looking for (my container name is incorrect in the snipit because I forgot to snip before cleaning up the containers)</figcaption></figure><p>If you can log into your containers you have successfully complete the project!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ae2d56c505f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using SQS, Python, Lambda & API Gateway Triggers To Send Messages]]></title>
            <link>https://sharonrjohnson.medium.com/using-sqs-python-lambda-api-gateway-triggers-to-send-messages-161b4cff866e?source=rss-4606c122b421------2</link>
            <guid isPermaLink="false">https://medium.com/p/161b4cff866e</guid>
            <dc:creator><![CDATA[Sharon Johnson]]></dc:creator>
            <pubDate>Sat, 22 Apr 2023 20:00:06 GMT</pubDate>
            <atom:updated>2023-04-22T20:00:06.331Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*R-ittPrLwg7bIVd7" /><figcaption>Photo by <a href="https://unsplash.com/@switch_dtp_fotografie?utm_source=medium&amp;utm_medium=referral">Lucas van Oort</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>So lets get started with the “What is”</p><p><strong>What is SQS? </strong><em>Amazon Simple Queue Service (SQS) lets you send, store, and receive messages between software components at any volume, without losing messages or requiring other services to be available.</em></p><p><strong>What is Python? </strong><em>Python is a computer programming language often used to build websites and software, automate tasks, and conduct data analysis. Python is a general-purpose language, meaning it can be used to create a variety of different programs and isn’t specialized for any specific problems.</em></p><p><strong>What is Lambda?</strong> <em>Lambda is a serverless compute service that runs your code in response to events and automatically manages the underlying compute resources for you.</em></p><p><strong>What is API Gateway &amp; Triggers?</strong> <em>API is use to create an HTTP endpoint that clients can interact with and your Lambda function can respond to, while trigger is a resource you configure to allow another AWS service to invoke your function when certain events or conditions occur.</em></p><p>Scenario:</p><p>A company wants to create a system that can track customer orders and send notifications when orders have been shipped. They want to use AWS services to build the system. They have decided to use SQS, Lambda, and Python for the project.</p><p><em>I will be using AWS Console and the Cloud9 (IDE) to perform the task.</em></p><p>Step 1: Create a Standard SQS Queue using Python.</p><p>In Cloud9 we will need to open a new file and name it(don’t forget to save it as a .py file) now we can open a new terminal so we can run the script. As you can see below it provided me a url after hitting run.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/784/1*5fHyqvoixtcO2HQ--90EaA.png" /></figure><p>Let navigate to the AWS Console and search for SQS to verify that it was created successfully.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6-5z8xBXGf5JJBRZr0Qkcg.png" /></figure><p>Step 2: Create a Lambda function in the console with a Python 3.7 or higher runtime.</p><p>Now lets search for “Lambda” and create a Lambda function, click on create function and follow the entries below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NGS70mm3d15AouQN62Jx7w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8oLK7np1ySoSZix8IBv9YA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZzgPr-lXSuGbuPYH7K0oiw.png" /></figure><p>Here you will need to add your permissions, click on Create Function</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A1tf8OiwmMj2-mISeZbMZw.png" /><figcaption>Permission Policies Attached</figcaption></figure><p>Successfully created the function</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kbSTAYi5MCyqxOy3pjsWuA.png" /></figure><p>Step 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.</p><p>In the Lambda function I created I entered in a Python script to create a message which will print out the date and time the message was sent.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/934/1*4_dgcNsSWO0SMe4ZClWfPw.png" /></figure><p>From here you will need to “Deploy” and “Test” the code to get the execution results, hopefully you received a successful result here.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2tZu0D2vG__a92srESxAhw.png" /></figure><p>Navigate back to SQS in the console, click on your SQS Queue, then hit the Send and Receive message in the right corner of the screen, poll for the message and click your message ID number (mine not shown below missed the screenshot)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YNSj2rHlTKsAAYQBjh19og.png" /></figure><p>After clicking on your ID you should this message</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/858/1*DV9w4gJXj5yeicZJqZI9Dw.png" /></figure><p>Step 4: Create an API gateway HTTP API type trigger.</p><p>Navigate back to your Lambda function and click on add trigger, select API Gateway, create a new API, use HTTP API and under security select open now add.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/848/1*6Uts14g0U6bu8ZCzb6t_jg.png" /></figure><p>Once you click “add” you will see the API Gateway, click on the API endpoint (https)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qLEdX1C1cehHIovJRZoOxA.png" /></figure><p>You should see the following results</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/776/1*636ReEGQJ6lyl-zHTGD65w.png" /></figure><p>Step 5: Test the trigger to verify the message was sent.</p><p>Navigate to the SQS to verify the message was sent. (this is what your verification should look like my time should not be the same as the above verification, I deleted the wrong screenshot but wanted to show you what to look for)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/852/1*01iCmE2w4jNbnKO6gbf7uw.png" /></figure><p>Project complete!</p><p><a href="https://github.com/SharonRJohnson/Sharon-Gold-LUIT/blob/main/Week15_CustomerOrder.py">Sharon-Gold-LUIT/Week15_CustomerOrder.py at main · SharonRJohnson/Sharon-Gold-LUIT</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=161b4cff866e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Create a DynamoDB Table Using Boto3 and Python!]]></title>
            <link>https://sharonrjohnson.medium.com/how-to-create-a-dynamodb-table-using-boto3-and-python-2b4f2b8c4a4c?source=rss-4606c122b421------2</link>
            <guid isPermaLink="false">https://medium.com/p/2b4f2b8c4a4c</guid>
            <dc:creator><![CDATA[Sharon Johnson]]></dc:creator>
            <pubDate>Sat, 15 Apr 2023 20:47:46 GMT</pubDate>
            <atom:updated>2023-04-15T20:47:46.151Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*t9uVunRDfREP-v_L" /><figcaption>Photo by <a href="https://unsplash.com/pt-br/@jstrippa?utm_source=medium&amp;utm_medium=referral">James Harrison</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Lets get started with the “what is”!</p><p><strong>What is DynamoDB?</strong> <em>Amazon DynamoDB is a fully managed, serverless, key-value NoSQL database designed </em><strong><em>to run high-performance applications at any scale</em></strong><em>. DynamoDB offers built-in security, continuous backups, automated multi-Region replication, in-memory caching, and data import and export tools.</em></p><p><strong>What is Boto3?</strong><em>(AWS) Software Development Kit (SDK) for Python, which allows Python developers to write software that makes use of services like Amazon S3 and Amazon EC2.</em></p><p><strong>What is Python? </strong><em>Python is an interpreted, object-oriented, high-level programming language with dynamic semantics developed by Guido van Rossum. It was originally released in 1991.</em></p><p>So with this project, I’m creating a DynamoDB table to list out my 10 favorite ice cream brands and flavors using boto3 and python.</p><p>A few things will be needed to achieve this, first you will need to create an <a href="https://docs.aws.amazon.com/cloud9/latest/user-guide/setup-express.html">AWS account</a>, then choose a IDE <em>(An integrated development environment (IDE) is a software application that helps programmers develop software code efficiently. It increases developer productivity by combining capabilities such as software editing, building, testing, and packaging in an easy-to-use application)</em>. I will be using <a href="https://docs.aws.amazon.com/cloud9/latest/user-guide/setup-express.html">AWS Cloud9. </a>(you can click onto the underline words and be directed to AWS site for instructions).</p><p>Once you have your account set up and your Cloud9 running, you will need to navigate to Cloud9, click on FILE, then Save As, name your file make sure you save it under the folder you created as a .py file.</p><p>Open up a new terminal and put in a map to your directory you will be using. You will need to add in the following script</p><p>pip3 install boto3</p><p>pip3 install awscli</p><p>aws configure</p><p>You will be prompt here to add in your credentials, enter in your region and your output format(json).</p><p>Ok now I can start writing my script to create the DynamoDB table for my “Favorite Ice Cream”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/462/1*Y45yYl-GTkRBsenezKxjIw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/468/1*KajnWAEnC-Fk4gv-jajDOA.png" /></figure><p>Once you click onto run you should get the following return Table Created!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/734/1*ddRJsiHDb0buY9F1w4I8Ig.png" /></figure><p>So lets navigate to the console and search DynamoDB and see if the table was actually created using this script</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JNDh_PvIRzyuD2qqTaTT0w.png" /><figcaption>The table was successfully created!</figcaption></figure><p>So from here I will create a script to list out my favorite ice cream brand and flavors. I did create another .py file to add to the table.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/626/1*XBFwUvmZtOTL0wxk2tZ2hQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*XcV-7o9ym7ET_Gj_RZ2reg.png" /></figure><p>As you can see this script gave me a return with my “Favorite Ice Cream” listing out my favorite brand and flavors!!!! Also this script allowed me to scan out my table.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8h0XAnFfDJdBd2LFWqygrA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jb3y57V_NUse3BH3iFHQGA.png" /><figcaption>Scanned table return using the above script!</figcaption></figure><p>Ok lets navigate back to the console and see if it actually listed out my “Favorite Ice Cream”, the brand and flavors</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dCz_fGsigCe9piHyzslaDA.png" /></figure><p>There you go!! The project is completed and now lets push it to GITHUB!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*69OEweYDN0Od05xzKCuUXg.png" /><figcaption>Photo by Rubaitul Azad on Unsplash</figcaption></figure><p><strong><em>By the way don’t forget to remove your access key and secret keys, I forgot and it costed me a lot of time getting it resolve.</em></strong></p><p><a href="https://github.com/SharonRJohnson/Sharon-Gold-LUIT">https://github.com/SharonRJohnson/Sharon-Gold-LUIT</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2b4f2b8c4a4c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Build A Script In Python That Extracts Information Such as File Names, Size and File Dictionaries]]></title>
            <link>https://sharonrjohnson.medium.com/build-a-script-in-python-that-extracts-information-such-as-file-names-size-and-its-dictionaries-298e16025ecb?source=rss-4606c122b421------2</link>
            <guid isPermaLink="false">https://medium.com/p/298e16025ecb</guid>
            <dc:creator><![CDATA[Sharon Johnson]]></dc:creator>
            <pubDate>Fri, 07 Apr 2023 21:30:23 GMT</pubDate>
            <atom:updated>2023-04-09T14:40:32.269Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*-wpAmY3a5bUBSwMH" /><figcaption>Photo by <a href="https://unsplash.com/@clemhlrdt?utm_source=medium&amp;utm_medium=referral">Clément Hélardot</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>First lets go over a few what is!</p><p><strong>What is Python? <em>Python is a computer programming language often used to build websites and software, automate tasks, and conduct data analysis</em></strong><em>.</em></p><p><strong>What is IDE? </strong><em>An integrated development environment (IDE) is a software application that helps programmers develop software code efficiently. Some examples of popular IDE are </em><strong><em>AWS Cloud 9</em></strong><em>, </em><strong><em>NetBeans, Microsoft Visual Studio, Adobe Flex Builder, and Eclipse.</em></strong></p><p><strong>What is Python Dictionaries?</strong> <em>Dictionaries are used to store data values in key:value pairs. A dictionary is a collection which is ordered*, changeable and do not allow duplicates.</em></p><p><strong>What is Current Directories in Python? </strong><em>CWD is for current working directory in python. This returns the path of the current python directory as a string in Python.</em></p><p><em>Objectives:</em></p><p>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.</p><p>I will be creating a script to that generates a list of dictionaries about files in the working directory. Then print the list. Push code to GitHub.</p><p>Ok, lets start with opening up your IDE, I will be using AWS Cloud9, (<em>please use the link below for instructions on how to set up AWS Cloud9. </em><a href="https://docs.aws.amazon.com/cloud9/latest/user-guide/setup-express.html"><strong>https://docs.aws.amazon.com/cloud9/latest/user-guide/setup-express.html</strong></a><strong>)</strong>, first you will need to name your file and save it, then open up command prompt so that you can run your script to see the output of your script. You will need to cd into your file to run the script.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/688/1*zC9bYH7QriUyWVq0nAHO9Q.png" /><figcaption>Script that will accomplish the completion of this project!</figcaption></figure><p>As you can see this script prints out the name of the files, the size of the files and it dictionaries.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zKsCbesEALKTXgsb-tBtiA.png" /><figcaption>Command prompt will show you your script output!</figcaption></figure><p>Once you get to this point you can push it to your GITHUB!</p><p><a href="https://github.com/SharonRJohnson/Sharon-Gold-LUIT/blob/main/Python-Week13-project.py">https://github.com/SharonRJohnson/Sharon-Gold-LUIT/blob/main/Python-Week13-project.py</a></p><p>Short and to the point!!!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Xwc0DzYmPfzUu4CX" /><figcaption>Photo by <a href="https://unsplash.com/@synkevych?utm_source=medium&amp;utm_medium=referral">Roman Synkevych 🇺🇦</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=298e16025ecb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Build a 3 Tier Architecture in AWS]]></title>
            <link>https://sharonrjohnson.medium.com/how-to-build-a-3-tier-architecture-in-aws-977dc778dd22?source=rss-4606c122b421------2</link>
            <guid isPermaLink="false">https://medium.com/p/977dc778dd22</guid>
            <dc:creator><![CDATA[Sharon Johnson]]></dc:creator>
            <pubDate>Sun, 12 Mar 2023 13:27:37 GMT</pubDate>
            <atom:updated>2023-03-17T20:37:13.152Z</atom:updated>
            <content:encoded><![CDATA[<p><strong><em>What is 3 Tier Architecture</em>- </strong><em>is the most popular implementation of a multi-tier architecture and consists of a single presentation tier, logic tier, and data tier.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/868/1*cIadcmlK9_VshgrHeV4AhQ.png" /></figure><p>Objective for this project:</p><p>You have been asked to design and create a highly available 3 Tier architecture for your company’s new web application.</p><p>Lets start building the Web Tier</p><p><strong>Web Tier</strong></p><ol><li>2 public subnets</li><li>Minimum of 2 EC2 instances with an OS of your choice (free tier) in an Auto Scaling Group.</li><li>EC2 Web Server Security Group allowing inbound permission from the internet.</li><li>Boot strap static web page or create a custom AMI that already includes the static web page.</li><li>Create a public route table and associate the 2 public subnets.</li></ol><p>Let’s start building the Web Tier</p><p>Step1: We will need to login to the AWS console, in the search click on “Create VPC”, in the setting click on VPC and more, name your VPC.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/535/1*zg4LEYNYHQPv-qdhIZt_MQ.png" /></figure><p>Number of Availability Zone will be 2, Number of Subnets will be 2 and the Number of Subnets will be 4.</p><p>Nat Gateway lets use In 1 AZ</p><p>VPC Endpoints use S3 Gateway</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/484/1*HqLEPdJZyo5Tgiw7sw5yJQ.png" /></figure><p>From here we are going to click on Create VPC</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/128/1*EudgIVJaOgwDiVgWym0wLw.png" /></figure><p>Ok, now you will see the Create VPC Workflow make sure you see the “Success” and now we can move on to view VPC</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/837/1*xI0iJDSWZ5gL99nFn095vA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/804/1*16Mn-5ivNqkXCUbvXlTJ1Q.png" /></figure><p>When viewing your VPC you will see that your Subnets, Internet Gateway and Nat Gateway and Routing Table has been created</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/349/1*z-pwG2En7N1FtyupTBsuWw.png" /><figcaption>Subnets was created</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3eOhGp9_6DqXjCP1SiZO9A.png" /><figcaption>Internet Gateway was created</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NUuR2PlCQXbRkWyUlBJ7wg.png" /><figcaption>Nat Gateway was created</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Pa3wHZyNSQqno_GgO4Clkw.png" /><figcaption>Resource Map that shows your Subnets, Route Table and Network Connections</figcaption></figure><p>Step 2: Now we are going to create our EC2 Instances Launch Template</p><p>Navigate to EC2, click on Launch Template</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/406/1*oSe442WdXc44neLsty0mMg.png" /></figure><p>Name your template, under the Auto Scaling guidance check the box to “provide guidance to help set up a template that you can use with EC2 Auto Scaling.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/820/1*deDhh0yb3C7CUiDYzSiZ1w.png" /></figure><p>Next we will need to choose and AMI (Amazon Machine Image), I’m using the Amazon Linux (Free Tier Eligible)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/785/1*b1i89UmZjegiCjA8Bl23Tw.png" /></figure><p>Key Pair you can create or use and existing</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/796/1*1NZPSX0fel20GVcl_rLVrA.png" /></figure><p>Under the Network Settings I created a security group, named it, in the description I typed in “Allow SSH and HTTP” and then click on the VPC that was created for this project. Under the “Advance Network Configurations here you will need to enable the Auto-assigned public IP.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/771/1*vBwYzbqxJL6ujcAdOvaWzA.png" /></figure><p>From here we will need to add in security group inbound rules for SSH and HTTP (follow the screen shot below)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/783/1*ilj0Eg0c0IXTVaKAivGf3w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/779/1*XbmZ_LxqpKJvbKMzoula3Q.png" /></figure><p>Under the Advance Detail, User Data add in this bash script to install Apache and now click on “Create Launch Template”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/777/1*DSaPtrpA7OM2D9FmX00Fdg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9OHxh4KhcEM6JdZizfJeFw.png" /></figure><p>Step 3: Creating a Auto Scaling Group</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yztueSEciYgfMHlHdHrzyQ.png" /></figure><p>Name your Auto Scaling group</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/837/1*bCwl0br2guwiDn4R58CQyA.png" /></figure><p>Under launch template, click on the drop down and select your template name and click next</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/798/1*LGxJSFS3LNcgd9ErR5SGCw.png" /></figure><p>Under Network select your VPC you created for this project, under the Availability Zone and subnets click on the two public subnets.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/788/1*xNhP3S8fPkUcCIYrE5OOjw.png" /></figure><p>Under the load balancing click on “Attach to a new load balancer” and the load balancer type should be Application Load Balancer, the load balance name is created here, load balancer scheme needs to be set at Internet Facing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/792/1*v22I4K9bKx1kJ8tX4Y1V2Q.png" /></figure><p>Go to the Listeners and routing, the Protocol should be listed as HTTP, Port 80, Default routing (forward to) click on the create a target group and this will create an instance target group with default setting.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/789/1*C4K2M5fwphfnG4MduqLj7Q.png" /></figure><p>Let configure the group size and scaling policies</p><p>Group size Desire Capacity 2</p><p>Minimum Capacity 2</p><p>Maximum Capacity 5</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/803/1*tUqS_ivWu9VD_6CNfd83Lg.png" /></figure><p>Scaling Policies click on “Target tracking scaling policy” and next.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/801/1*vS4bivb0d2qnuucCyOi-YQ.png" /></figure><p>After clicking on next, click on create auto scaling group. At this point lets navigate to the EC2 console and lets click on the two running instances and copy and paste the public IP address in a web browser to see if we have successfully completed this part of the project.</p><p>Successful!!!!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1kR7NHcwcs8N6Bpw4mCwWA.png" /></figure><p>Lets build the Application Tier</p><p><strong>Application Tier</strong></p><ol><li>2 private subnets</li><li>Minimum of 2 EC2 instances with an OS of your choice (free tier) in an Auto Scaling Group.</li><li>EC2 Application Server Security Group allowing inbound permission from the Web Server Security Group.</li><li>Associate with private route table.<br><em>Note: This is not a true application tier as we don’t have any provided code to run on the EC2 instances.</em></li></ol><p>Step 1: Create another launch template</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3b6RrdzdhlmAq3o2mDIdRg.png" /></figure><p>Name your new template, and lets make the description App Tier and check the box and lets get some guidance on auto scaling.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/835/1*2Nf9m72Cb-d0kQx_mHFQKg.png" /></figure><p>Here we need to select the AMI, I’m using Amazon Linux (free tier), instance type and key pair</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/811/1*Y65CRBNCeFZTzyNhOm2nTw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/782/1*dMxgfIN27yImP87f4JA78Q.png" /></figure><p>Under Network Settings let click on “Create security group”, name your security group name, you will need to add some text in the description and then select your project VPC</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/786/1*afJiukuDRBRY_TI6UlKtZA.png" /></figure><p>Here we will need to create inbound security rules see description below for rules that was created for this project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/778/1*qWAOhNAq21RWStQ92C6V8g.png" /></figure><p>Now we can create launch template</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/268/1*TpNCr1gZVao_udyH_ofnsw.png" /></figure><p>Step 2: Create a Auto Scale Group</p><p>Go to your EC2 and search for Auto Scale and click on create</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iANNGi6FbXDT5CT7zreJ3Q.png" /></figure><p>Under the choose instance launch option go to Network and choose the VPC you are using for your project, then select your Availability Zones and Subnets, make sure you are selecting your 2 private subnets.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/827/1*5IN9FGN1LfHFQRfn2W7asA.png" /></figure><p>Let head down to configure advance options and choose the load balancing click on the “Attach to a new load balancer”, under the attached a new load balancer load balancer type should be “Application Load Balancer”, name your load balancer, under the load balance scheme click Internet-facing</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/801/1*IKhlIVie02hD3ujcnEofmg.png" /></figure><p>Under the Network mapping, listeners and routing click on the create a target group and name the target group</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/802/1*ntTEqq1pPXdaAlkkdVWaCA.png" /></figure><p>From here you can just click on Next</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/831/1*X1Reia9P5U0I7RohlefyDA.png" /></figure><p>Now under the Group size</p><p>Desire Capacity 2, Minimum Capacity 2 and the Maximum Capacity 4</p><p>Scaling Policies click on “None” and then click on Next</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/811/1*0dqb9yLvJzZChDo1qiBjFA.png" /></figure><p>Click on Create Auto Scaling Group</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/238/1*i57-Z4w17UZ9eTqjNXazFg.png" /></figure><p>Auto Scaling Group is successfully created (verify that you see 2 groups)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DNXstk36H5TukSzyXpLFPA.png" /></figure><p>At this point we will need to verify that we have 4 instances running. You should be seeing 2 public and 2 private.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*siAuS5XzeANzlttZDDGXFA.png" /></figure><p>Application Tier has been completed, now lets build the Database Tier</p><p><strong>Database Tier</strong></p><ol><li>Use a free Tier MySQL RDS Database.</li><li>The Database Security Group should allow inbound traffic for MySQL from the Application Server Security Group.</li><li>2 private subnets.</li><li>Associate with private route table.<br><em>Note: No need to use Multi-AZ but be sure to document how you would add it</em></li><li>Remember that when diagraming this tier you are only creating one RDS instance in one subnet even though you are creating two subnets. If you use multi-AZ or a read replica then and only then should you have a second instance. Make sure to label accordingly.</li></ol><p>Step 1: Create a RDS</p><p>In the search type in RDS (Relational Database Service) in the center of the screen click on “Create database”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_jXhgoy6Bdkite_CS2czPw.png" /></figure><p>Under the Create Database creation method we will be clicking on Standard create, Engine option we will use the MYSQL</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/837/1*3wEhp6bUZSpBuJ8uFLQQrQ.png" /></figure><p>Under template click on “Free tier”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/786/1*hdCxLLqTTc7pZR6c-rUVrw.png" /></figure><p>Settings we need to name the DB instance identifier</p><p>Credential Setting, Master username you can keep it as “admin”, Master password</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/768/1*48zYsJpitBD4FxnIGOK9bg.png" /></figure><p>Instance configuration select “Burstable classes” and select the db.t2.micro</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/807/1*apxpFyOv-R5wcs0YYvDugA.png" /></figure><p>Under the connectivity Compute resource select “Don&#39;t connect to an EC2 compute resource, under the Network type select IPv4, the VPC select your project VPC, DB subnet group select Create new DB Subnet Group, Public access click on “No”, under the VPC security group (firewall) click on “Create new”, name your new VPC group, availability zone leave it “No preference and last Database port should be 3306</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/777/1*d95VetCS3KBo7uWsC3Id9A.png" /></figure><p>No click on Create database</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/173/1*j4UPQTXLRpUNmNiUN9623w.png" /></figure><p>Once you click on Create database you will have to wait a bit before the status reads “Available”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AmZjrkk7n7RrZX0HTchgSw.png" /></figure><p>Click on your DB identifier you created, now click on the tab “connectivity &amp; security, to the right you will see VPC security groups click on your security group name, this will open to allow us to edit the inbound rules</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TPWuNyOp32Tvv6saQ96LUw.png" /></figure><p>So from here put a check in the box, under action (tab) drop down and select “Edit inbound rules</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HIe-x8ogDN9Bu1JcRIl_rg.png" /></figure><p>In the Edit inbound rules click on Delete and Save Rules</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*chwscGkZDKv5_V0aSSUS5A.png" /></figure><p>Ok now we are going to test it, now go to your instances select one of your public instance and find the public IPv4 IP address copy and paste into a web browser and you should get this</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xXHEf-s_8DoPKiNqquoJsg.png" /></figure><p>Now we will test the private IP address by pinging it on the command prompt</p><p>SSH using your public instances, then ping a private IPV4 address on the command prompt, if you are getting this you have successfully completed this project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EXCZKOpAPdwGk-AcaLs1wg.png" /></figure><p>Complete!!!!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=977dc778dd22" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Creating a DynamoDB Table using IAM Roles and EC2]]></title>
            <link>https://sharonrjohnson.medium.com/creating-a-dynamodb-table-using-iam-roles-and-ec2-5e5a8b973daf?source=rss-4606c122b421------2</link>
            <guid isPermaLink="false">https://medium.com/p/5e5a8b973daf</guid>
            <dc:creator><![CDATA[Sharon Johnson]]></dc:creator>
            <pubDate>Thu, 02 Mar 2023 21:16:29 GMT</pubDate>
            <atom:updated>2023-03-02T21:16:29.038Z</atom:updated>
            <content:encoded><![CDATA[<p>Objectives:</p><p>Create a DynamoDB table for something of your choosing (e.g. movies, food, games)</p><ol><li>Add 10 or more items to the table</li><li>Create a t.2micro EC2 the principle of least privilege, grant the EC2 instance read access to DynamoDB.</li><li>Use the AWS CLI in the EC2 instance to scan the DynamoDB table</li><li>Use the AWS CLI in the EC2 instance to validate you cannot write an item to the DynamoDB table</li></ol><p>Lets go over what is:</p><p><strong>IAM Roles</strong> <em>is an IAM identity that you can create in your account that has specific permissions. An IAM role is similar to an IAM user, in that it is an AWS identity with permission policies that determine what the identity can and cannot do in AWS.</em></p><p><strong>DynamoDB </strong><em>is a fully managed proprietary NoSQL database service that supports key–value and document data structures and is offered by Amazon.com as part of the Amazon Web Services portfolio.</em></p><p><strong>EC2 Instance</strong>-<em>provides scalable computing capacity in the Amazon Web Services (AWS) Cloud. Using Amazon EC2 eliminates your need to invest in hardware up front, so you can develop and deploy applications faster.</em></p><p>Step 1:</p><p>I’m going to create a DynamoDB table using brands of Sunglasses (note all of these steps will be created and launched in the AWS Console). Lets search DynamoDB.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TdETPyCwTawVWyLXdMfyHA.png" /></figure><p>Lets starting creating the table, click on the create table</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/375/1*MxcIeTbiTT8O0HjowEKyNA.png" /></figure><p>As stated above I’m using brands of sunglasses for my project, so I’m going under the Table Details:</p><p>Table Name: I’m going make the Table Name “Sunglasses”</p><p>Partition Key: “Brand”</p><p>Sort Key is optional so I’m going to leave that blank</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/816/1*BpxCrAQRK-zT7vqMpxvSMQ.png" /></figure><p>Next is the Table settings I’m going to leave it set as Default settings</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/826/1*UyiPjUOJhJTDDXOoRYKUsQ.png" /></figure><p>No need to add new tags so at this point you can click on create table</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/835/1*PDUrtuUtnnRMRc1mmrNQzg.png" /></figure><p>As you can see the Sunglasses table has been created and active</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_b5Zj5WWFgElGHl6bUXJ_w.png" /></figure><p>Lets click on the table “Sunglasses” and lets choose the Explore table items</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Vq7Y2kPVcw4FpDRao9CmcA.png" /></figure><p>Now I’m going to add in the 10 brand name of sunglasses by clicking on create items</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Dw560IaQ5w4gC-rH2wL9cg.png" /></figure><p>Now that I have added in my 10 brands of sunglasses as you can see below we will now move to step 2</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3WreluR3whFKKw_u4sYojA.png" /></figure><p>Step 2:</p><p>Now we need to create an t2. micro EC2 Instance, so lets search EC2 in the console, from here you can launch a new EC2 instance</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/520/1*LLOCAclAUysX3XRjfnGExw.png" /></figure><p>So here name your instance, I will be naming mine DynamoDB Week 8. Now lets choose your preferred AMI, I will be using Amazon Linux.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/814/1*46fxOgQLwtbslcy5zBnAaA.png" /></figure><p>Next I will be selecting the Instance Type using t2.micro (free tier eligible)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/807/1*nOd_H3uxqMybif11UBlEZQ.png" /></figure><p>Under Key Pair you can create a new or use an existing</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/797/1*SWos2pcPUe23Y2z69pMEoQ.png" /></figure><p>Under the Network Settings, you can choose the create security group or use existing, make sure that the Allow SSH traffic from is check and the Allow HTTP traffic from the internet</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/797/1*dWAOaxHVZTco1QBgD4DyIA.png" /></figure><p>Let me to move down to the Advance Details from here we need to create new IAM profile</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/785/1*mUt3HRXOHbPhZxUXjuWHoQ.png" /></figure><p>Step 3:</p><p>Ok now this should have directed you to the Identity and Access Management (IAM) screen, from here we will need to lick create role</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HK3Za8KKCyl103tx82Nm3A.png" /></figure><p>Under the “Select trust entity, the trusted entity type keep set at AWS service and the Use case keep EC2 selected and click on Next.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eXvlcYaKzJhyqm75YmSg1Q.png" /></figure><p>From here lets create the permissions, in the filter search “dynamo” and it will give you a few items with the dynamo name, click on the one “AmazonDynamoDBReadOnlyAccess, click next</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JQb2MkrlXtx-Dt1olWRftA.png" /></figure><p>Now I’m going to Name, Review and Create, I named mine DynamoBD_project, you can leave the description as is,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RR2W4pQTA3DSjcBSKGMqrA.png" /></figure><p>Now click on Create Role</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QE0N4DZNkwvuzeK0pgwN_w.png" /></figure><p>Now lets Launch our EC2 instance, navigate back to the EC2 and find your project instance, click on your instance click on action, security and modify IAM role</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IY_jKq2-vIgXbU-BjAiJ0g.png" /></figure><p>From here drop down and select your IAM role name you created, tje click the Update IAM role</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*AEKsEwxHnP9oMMhGYvcr-g.png" /></figure><p>Step 4:</p><p>I will be using the AWS CLI in the EC2 instance to scan the DynamoDB table, but first you will need to ssh in to connect</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/965/1*ORLMsX4Yt3JdpLh_CjHUCg.png" /></figure><p>Once you are at the command line let scan our created DynamoDB table type in the following</p><p>aws dynamodb scan — table-name Sunglasses — region us-east-1</p><p>This will list out what was created in your DynamoDB table.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/835/1*DfW6O3o6nLYGglvwdQyT2g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fLGYU7soZw1xZC1M67TJQQ.png" /></figure><p>Step 5:</p><p>I will use the AWS CLI in the EC2 instance to validate that you can’t write and item to the DynamoDB table, you should not be using your IAM Access keys) this how you can verify the role is working properly.</p><p>Run this command:</p><p>aws dynamodb put-item — table-name Sunglasses — region us-east-1 — item ‘{“Brand”: {“S”: “Shoes”}}’</p><p>If you are seeing the AccessDeniedExpection error message you have successfully completed this project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VpcUA89qsaKxf8QLbuPvfw.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5e5a8b973daf" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>