<?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 Henry Ukaegbu on Medium]]></title>
        <description><![CDATA[Stories by Henry Ukaegbu on Medium]]></description>
        <link>https://medium.com/@chidexhenrytee?source=rss-7776e6eb71cc------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*VG6fKDoGwy_BEcZHWhUOVQ.jpeg</url>
            <title>Stories by Henry Ukaegbu on Medium</title>
            <link>https://medium.com/@chidexhenrytee?source=rss-7776e6eb71cc------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 23:13:27 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@chidexhenrytee/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[Host a Dynamic E-commerce Website on AWS]]></title>
            <link>https://medium.com/@chidexhenrytee/host-a-dynamic-e-commerce-website-on-aws-3a8793046097?source=rss-7776e6eb71cc------2</link>
            <guid isPermaLink="false">https://medium.com/p/3a8793046097</guid>
            <dc:creator><![CDATA[Henry Ukaegbu]]></dc:creator>
            <pubDate>Sun, 03 Mar 2024 05:06:50 GMT</pubDate>
            <atom:updated>2024-03-03T05:06:50.095Z</atom:updated>
            <content:encoded><![CDATA[<p>Using AWS Services to Host a Dynamic E-commerce Website on AWS</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*y_FmLG_cfGXgugMyPHIE1A.png" /></figure><h4>Requirements</h4><ol><li>AWS Certified Cloud Practitioner CLF-C01</li><li>AWS Certified Solutions Architect — Associate SAA-C03</li></ol><h4>Introduction</h4><p>In this project, I will walk you through developing and deploying a Dynamic E-commerce website on Amazon Web Services (AWS). Dynamic websites can display dynamic or personalized content i.e. it is a website that changes as users interact with it. Also, we will learn how to use reference architecture to host this website using various core AWS services and how they work together. The core AWS services we will use in this project are as follows:</p><ul><li>Custom VPC with public and private subnets</li><li>Security groups</li><li>EC2 instances</li><li>NAT gateways</li><li>RDS Instance</li><li>S3 Bucket</li><li>Application load balancer</li><li>Route 53</li><li>Certificate manager</li><li>AWS Auto-scaling group</li></ul><p>Before we proceed, let’s breakdown our objectives into the following steps:</p><ol><li>Create VPC with public and private subnets</li><li>Create NAT gateways in the public subnets</li><li>Create the security group</li><li>Create the RDS instance</li><li>Create S3 buckets</li><li>Create an IAM role with an S3 policy</li><li>Deploy eCommerce website</li><li>Import the dummy date for the website</li><li>Create an application load balancer</li><li>Register a new domain name in route 53</li><li>Create a record set in route 53</li><li>Register for an SSL certificate in the AWS certificate manager</li><li>Create an HTTPS listener</li><li>SSH into an EC2 instance in the private subnet</li><li>Update the ENV file</li><li>Create auto-scaling group</li><li>Clean up</li></ol><p>We will use the reference architecture below to host this website.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*3ZCC9aE7bxzt0KFg" /></figure><p>The resources deployed in the above architecture are explained as follows:</p><ol><li><strong>VPC</strong> with public and private subnets in 2 availability zones</li><li>An <strong>internet gateway</strong> is used to allow communication between instances in VPC and the internet</li><li>We are using 2 A<strong>vailability zones</strong> for high availability and fault tolerance</li><li>Resources such as NAT gateway, bastion host, and application load balancer use P<strong>ublic subnets</strong></li><li>We will put the webservers and database servers in the P<strong>rivate subnets</strong> to protect them</li><li>The <strong>NAT gateway</strong> allows the instances in the private app subnets and private data subnets to access the internet</li><li>We are using MySQL RDS database</li><li>We will use <strong>EC2 instances</strong> to host our website</li><li>An <strong>Application load balancer</strong> will be used to distribute web traffic across an auto-scaling group of EC2 instances in multiple AZs</li><li>Using Auto-Scaling Group to dynamically create our EC2 instances to make our website highly available, scalable, fault-tolerant, and elastic</li><li>We will use<strong> Route 53</strong> to register our domain name and create a record-set</li><li>We will use<strong> AWS S3</strong> to store our web files</li><li>We will use <strong>IAM Role</strong> to permit EC2 to download web files from AWS S3</li><li>Once we have installed our website on an EC2 instance, we will use the EC2 instance we installed our website on to create an <strong>AMI</strong></li></ol><p>Let’s start!</p><h4>Step 1: Create VPC with Public and Private Subnets</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*VU32m_YNrTTK4c38" /></figure><p>The figure above describes a three-tier VPC architecture, and it’s explained as follows:</p><p>Tier 1 — Our Public Subnet will be located here, and will host resources such as the NAT Gateway, Load Balancer, and Bastion host.</p><p>Tier 2 — This is our private subnet that will hold the webservers such as the Amazon EC2 Instances</p><p>Tier 3 — This is another private subnet that will hold our databases</p><p>The 3 — tiers described above will be placed in the us-east-1a availability zone. For high availability and fault tolerance, we will duplicate these subnets in the us-east-1a availability zone as described in the architecture above. Let’s dive into the project in detail!</p><p>Navigate to the Amazon management console, and select the region for your VPC. From the architecture, we see that the region is in the us-east-1. Next, type VPC in the search bar or select VPC from the console and click Create VPC.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*1grru7_9y1M--o7XIFSq_A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*Cu9MTAkOgzs1lak1.png" /></figure><p>Next, we will select VPC only and name our VPC “Dev VPC”. We leave it at the IPv4 CIDR block and based on our reference architecture we will enter <strong>10.0.0.0/16</strong> in the <strong>IPv4 CIDR block</strong>. Leave the <strong>IPv6 CIDR block </strong>and <strong>Tenancy </strong>to default, scroll down, and click <strong>Create VPC </strong>at the bottom right.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*nPBCMW_--CEtSIu52CSDiw.png" /></figure><p>If your VPC is successfully created, you should see a message on your console that looks like the one below</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*ZtPpz_dY5KgttG7L.png" /></figure><p>For you to see the VPC we created, click the drop-down arrow on the <strong>Select a VPC search box </strong>(click <strong>refresh</strong> if you don’t see the VPC we created). The VPC information is displayed as shown below. We will choose the VPC we just created “Dev VPC”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*zFqqJOXKNkyKcQ3Y.png" /></figure><p>Next, Let’s enable the DNS hostname in our VPC by selecting <strong>Actions </strong>and <strong>Edit VPC settings.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*RnweE5wo8x2V3qnd.png" /></figure><p>Under <strong>Edit</strong> <strong>VPC settings </strong>make sure that <strong>Enable DNS hostnames </strong>is checked then click <strong>Save. </strong>You will see a message that says “You have successfully modified the settings for …”</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*N2Al6_4C0Xq_WP1hMb6SeA.png" /></figure><h4>Internet Gateway</h4><p>We will create an Internet gateway for our VPC. At the left side menu of <strong>Your VPC </strong>in the management console, click Internet Gateway and then select <strong>Create internet gateway </strong>as shown below</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*rVD3C_-XG8MRYC5t.png" /></figure><p>Let’s give our internet gateway a name — <strong>Dev Internet Gateway </strong>and click <strong>Create Internet Gateway</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*WNNIW_qhhMZocKzq.png" /></figure><p>The diagram shown below shows that we have successfully our Internet Gateway and in order to allow the VPC we created earlier to connect and communicate with the Internet, we will attach it to the Internet Gateway. To do that, click; <strong>Attach to the VPC</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*tCkfcLnNrkvbvO__.png" /></figure><p>Select the Dev VPC that we created and click <strong>Attach Internet gateway.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*Ctlb-0Aw4fv0xMim.png" /></figure><p>We have successfully attached the internet gateway to our VPC. The Details below show the <strong>State </strong>and the <strong>VPC ID</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*ckkxWcjaIaf2TQXO.png" /></figure><p>The Internet gateway is successfully attached. Let’s create our public subnets in the 1st and 2nd AZs.</p><h4>Public Subnets</h4><p>Once we have our VPC setup, next, we create our <strong>public subnets</strong> in the first and second availability zones. Ensure that you have your VPC filtered to the Dev VPC and then at the right corner of your console, click <strong>subnets. </strong>Once you are on the subnet page, click <strong>Create Subnet</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*GVro3M8ga9JgEreb_Mimow.png" /></figure><p>Select the VPC where you want our public subnet to be — Dev VPC</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*auQGF-PSPJ1vg8vOdrpKlQ.png" /></figure><p>With reference to our architecture, we will call our subnet — <strong>Public Subnet AZ1 and </strong>put this subnet in the<strong> us-east-1a-availability zone. The CIDR block </strong>should be<strong> 10.0.0.0/24. Click Create subnet</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*EK_r9DpmQr6dMHSyTQoQQg.png" /></figure><p>The figure below shows that we have successfully created our first public subnet in the us-east-1a Availability Zone.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*r5LarVM0Q7K9fJ2TQ_CnuA.png" /></figure><p>Next, we will create our second public subnet in the us-east-1b Availability Zone — <strong>Public Subnet AZ2</strong>. Same process as the public subnet AZ1 except that we have to choose the us-east-1b instead of us-east-1a. Don’t forget to filter our VPC to the Dev VPC. With reference to our architecture, we will call our subnet — <strong>Public Subnet AZ2 and </strong>put this subnet in the<strong> us-east-1b-availability zone. The CIDR block </strong>should be<strong> 10.0.1.0/24 (Note the changes in the CIDR block). Click Create subnet.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*F5FTKbxX3JHZ2-b7xLJb4A.png" /></figure><p>The figure shows that we have successfully created our second public subnet in the us-east-1b Availability Zone (this depends on your region)</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*Zj0lHSCVJIhwNuBaMBV0mA.png" /></figure><p>If you select <strong>Clear filters and filter to our Dev VPC, </strong>it shows the 2 subnets that we created in these regions. The figure below shows the public subnets we have created so far. Ensure that the two public subnets are in different Availability Zones (AZ1), <strong>us-east-1a and us-east-1b respectively</strong>. Good job!!</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*UVjEyVOONweUI1Y7kKtlkg.png" /></figure><p>Anytime EC2 Instances are launched in these public subnets, a public IPv4 address will be assigned to these instances, hence, the need to enable<strong> Auto assign IP settings</strong> for these two public subnets. With reference to the fig. above, check public subnet AZ1 and <strong>click Actions</strong>. From the drop-down menu, click <strong>Edit subnet settings</strong>. Under <strong>Edit subnet settings and Auto-assign IP settings </strong>check the <strong>Enable auto-assign public IPv4 address </strong>and click save (bottom right when you scroll down). See fig. below</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*qQVPN7XXV6fWE8blmYC9DQ.png" /></figure><p><strong>Public subnet AZ2 (Check the subnet and follow the same steps)</strong>. Great job! We have successfully enabled the <strong>auto-assign public IPv4 address </strong>for the two public subnets. So far we have created the Internet Gateway and two public subnets for our VPC. Let’s keep going!!</p><p>Recall from our reference architecture, the next is to create a <strong>Public Route Table. </strong>The Route Table will route traffic to the internet(see the<strong> </strong>reference architecture below to refresh our memory)</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*rNug8ydGxhREUai-sWZ2Fw.png" /></figure><p>From the VPC setup page, locate and click <strong>Route tables</strong> from the left side of the page (still filtered by the Dev VPC). The Route table shown below is the default table also referred to as the main table and it’s private by default. <strong>Click Create route table.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*TYXzLXcfnVkUMdJGBu2CZA.png" /></figure><p>Under Name, Type,<strong> Public Route Table</strong>, and ensure that you select <strong>Dev VPC</strong> under VPC and under <strong>Key </strong>and <strong>Value</strong> type in <strong>Name</strong> and <strong>Public Route table. </strong>Click<strong> Create route table.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*qB6xkx1TwqttLKT3lMuW_w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*4892i9YwKQ8mYwFWoJtq7w.png" /></figure><p>Good job! We have successfully created our Public Route Table as shown below</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*PtmKWossCrmCyqSA4LY9Ig.png" /></figure><p>To allow the Public Route Table to route traffic to the internet, we will have to add a route to the Public Route Table. As shown below, click on the <strong>Routes tab </strong>and then<strong> Edit routes</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*bVwZfcJs1qEoYv5ZAK7FXA.png" /></figure><p>On the <strong>Edit Routes</strong> page, click on<strong> Add Route. </strong>Under<strong> Destination, type inside the box 0.0.0.0/0 </strong>to replace<strong> 10.0.0.0/16. </strong>Also, under<strong> Target, </strong>click inside the box and choose<strong> Internet Gateway igw- the # (Dev Internet Gateway). </strong>Click<strong> Save changes</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*uYUe-JENl6-yalhAm-9n5w.png" /></figure><p>We successfully added a route to our public route table. We can view it under the <strong>Routes tab. </strong>Next, we will associate the two public subnets, AZ1 and AZ2, with this route table. Ensure that we are still under the <strong>Public Route Table page. </strong>Locate and click on<strong> the subnet association tab, then </strong>click on<strong> Edit subnet associations. </strong>On the<strong> Edit subnet associations page, </strong>we see that<strong> </strong>the two public subnets are listed. Check both public subnets and click <strong>Save associations.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*sgYMdZX6LPGagkz5_uw1-A.png" /></figure><p>Good job! We have associated the two public subnets that we created with the Public Route Table. To confirm, we can see the subnets under the <strong>Subnet associations</strong> tab as shown below</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*0cxagxFEiTGP0DwSt0TZ7A.png" /></figure><h4>Private Subnets</h4><p>With reference to our architecture, we will need to create 4 private subnets in order to finish setting up our Dev VPC. Still, on the VPC page, ensure you filter by Dev VPC and click Create subnet. On the Create subnet page, under VPC ID choose Dev VPC and Our CIDR block should be <strong>10.0.2.0/24. </strong>Click<strong> Create subnet</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*auQGF-PSPJ1vg8vOdrpKlQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*G7qu_WGB_tVMLjpk.png" /></figure><p>Great! We have successfully created our 1st private subnet, <strong>Private App Subnet AZ1</strong>, in the us-east-1a Availability Zone. Using the same processes above, let’s create the remaining 3 private subnets using the settings below and referring to our reference architecture:</p><p><strong>2nd Subnet</strong></p><p>VPC ID: Dev VPC</p><p>Subnet name: Private App Subnet AZ2</p><p>Availability Zone: us-east-1b</p><p>IPv4 CIDR block: 10.0.3.0/24</p><p><strong>3rd Subnet</strong></p><p>VPC ID: Dev VPC</p><p>Subnet name: Private Data Subnet AZ1</p><p>Availability Zone: us-east-1a</p><p>IPv4 CIDR block: 10.0.4.0/24</p><p><strong>4th Subnet</strong></p><p>VPC ID: Dev VPC</p><p>Subnet name: Private Data Subnet AZ2</p><p>Availability Zone: us-east-1b</p><p>IPv4 CIDR block: 10.0.5.0/24</p><p>Great job! We have successfully created all 4 Private Subnets, making 6 subnets in total including the 2 public subnets. To see the list, click <strong>Clear Filters </strong>and filter it by <strong>Dev VPC. </strong>As shown below, review and ensure that each subnet is placed in the right<strong> AZs and AZ ID </strong>(compare with the list of the subnets)</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*jF7ZsLZ3T8pMLzQaNTgNXg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*5OniW-ADm2rYhok3ZV6pQg.png" /></figure><p>Let’s quickly dive into the basic <strong>difference between public and private subnets</strong>. A public subnet is associated with a route table that can route traffic to the internet. In other words, when we create a route table and add a route to the route table to route traffic to the internet, any subnet associated with the route table is a public subnet.</p><p>On the other hand, when we have a route table that does not have a route to the internet, any subnet associated with the route table is a private subnet. By default, any subnets associated with the <strong>main route table are private</strong></p><h4>Step 2: Create NAT (Network Address Translation) Gateways</h4><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*409UlSO-PN9LP0KBeIzbjQ.jpeg" /><figcaption><strong>NAT Gateway Reference Architecture</strong></figcaption></figure><p>With reference to our architecture, the NAT Gateways will allow instances in the private subnets; <strong>Private App, and Private Data Subnets</strong> to access the internet. As shown in the architecture Fig above, we will create a NAT gateway in the first and second availability zones. Check to see if you are still in the same region where we created our Dev VPC (N. Virginia us-east-1). NAT Gateway is located on the VPC Page. In the search box, type and click VPC</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*vFOhpJ8yaBLpX5uD.png" /></figure><p>As shown below, at the left corner of the VPC page, select NAT gateways and click Create NAT gateway;</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*HAfg8_z8asWUM9Rk.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*E9VqzgCW1QJFst9L.png" /></figure><p>Under Name, type <strong>NAT gateway AZ1</strong> click on the drop-down arrow under <strong>Subnet,</strong> and select <strong>Public Subnet AZ1</strong>. Leave the C<strong>onnectivity type</strong> on <strong>Public</strong> and click <strong>Allocate Elastic IP.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*n58f542sVGMB790yNNAc4Q.png" /></figure><p>Review and click<strong> Create NAT gateway. </strong>You should see a successful page as shown below</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*M8LC5ypeqgzDSUQgVBWBZA.png" /></figure><p>Next, we create a route table and name it <strong>Private Route Table AZ1</strong>. Still, on the VPC page, locate the <strong>Route tables at the left side of your screen </strong>and click on it. Make sure to select Dev VPC and under Tags, fill in the boxes as shown below and click <strong>Create route table</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*52ZTX_EbulZ3QdN8.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*0XDlB35wYotIK-g4N5S46w.png" /></figure><p>You should see a successful page as shown below</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*jR1xdhXfyPGD47lo.png" /></figure><p>Next is to add a route to the <strong>Private Route Table AZ1</strong> that we just created, to route traffic to the internet through the <strong>NAT Gateway</strong> in the <strong>Public Subnet AZ1. </strong>Scroll down and locate<strong> the Routes tab </strong>and on the right corner click<strong> Edit routes then Add route as shown below</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*qJxBq-hKHZcZMoQJ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*4e4s-mV8DyEx98-x.png" /></figure><p>Under <strong>Destination</strong>, replace 10.0.0.0/16 with the Internet traffic of 0.0.0.0/0. Under <strong>Target, </strong>click inside the box and replace<strong> local </strong>with<strong> NAT gateway AZ1. Locate NAT Gateway </strong>(ensure that you don’t select Internet Gateway) and click on it<strong>, NAT gateway AZ1 </strong>should appear, and then click<strong> save changes.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*wKMdRuFHreL7gRmelL4vNw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*MPFcSgKCcCtfQrjnX551lg.png" /></figure><p>We have successfully added a route to our private route table. To view it, scroll down, we will see the added route displayed under the <strong>Routes</strong> as shown below</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*bYiU0a4iA4aSkLAQE6Vb4w.png" /></figure><p>Next, we will associate <strong>Private Route Table AZ1</strong> with <strong>Private App Subnet AZ1</strong> and <strong>Private Data Subnet AZ1. To do that, locate and select the Subnet associations</strong> tab, and at the right corner click <strong>Edit subnet associations.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*ur8OqNHZxGbGVsAqo6IanQ.png" /></figure><p>On the <strong>Edit subnet associations page, </strong>we will see the available subnets list that needed to be selected. Check the <strong>Private App Subnet AZ1</strong> and <strong>Private Data Subnet AZ1 boxes, </strong>then click <strong>Save associations as shown below</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*cUtDCfwflGo7NfZcntpfcQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*1B2sZlDqcge6tU1Mqwac4Q.png" /></figure><p>Great job! We have successfully associated <strong>Private App Subnet AZ1</strong> and <strong>Private Data Subnet AZ1 </strong>to the <strong>Private Route Table AZ1</strong> as shown under <strong>Explicit subnet associations</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*wkvAFJdI5zXDn4v5pSLPdQ.png" /></figure><p>We are making progress! we have succeeded in creating our first<strong> NAT Gateway</strong> in the <strong>Public Subnet AZ1</strong>. Let’s proceed to create our second <strong>NAT Gateways</strong> in the <strong>Public Subnet AZ2</strong>. We will follow the same procedures as how we created the first NAT Gateway.</p><p>follow the same procedures as <strong>NAT Gateways AZ1</strong>. When you get to the <strong>NAT gateway settings</strong>, fill in the boxes as shown below (endure that you click <strong>Allocate Elastic IP</strong>)</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*mkeIJDvgWIMyXDnZtlsZQQ.png" /></figure><p>After you have successfully created the <strong>NAT Gateway AZ2</strong>, you should see a similar Fig below</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*uS78izAUwDo9i99aBy2hog.png" /></figure><p>Same as NAT Gateway AZ1, we create our Private Route Table and associate this table to the <strong>Private</strong> <strong>App Subnet AZ2 </strong>and <strong>Private Data Subnet AZ2. </strong>Again, we will follow the same as we did in<strong> </strong>Private Route Table AZ. Name this second table — <strong>Private Route Table AZ2. </strong>When you get to the<strong> Create route table </strong>page, fill in the boxes as shown below and click<strong> Create route table</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*s14_rMvajnHR1gqkjKFFGw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*UjR2SSxE4EDac6QOYyJPbQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*UbyqRguqXeUNcjQ8KIQAeg.png" /></figure><p>Also, add a route to the <strong>Private Route Table AZ2</strong>, to route traffic to the internet through the <strong>NAT Gateway</strong> in the <strong>Public Subnet AZ2. </strong>Scroll down and locate<strong> the Routes tab </strong>and on the right corner click<strong> Edit routes then Add route </strong>as shown below.<strong> Under Destination, </strong>type<strong> 0.0.0.0/0, </strong>and under<strong> Target </strong>choose,<strong> NAT Gateway AZ2 </strong>and click <strong>Save changes.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*VcCG30OK-8vOH7Ns3ilIMQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*kSfMJbqiPF7FAlmPG8RpPQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*tTGZ-gUVPbgnm3MuqQER8g.png" /></figure><p>As we did before, we will associate <strong>Private Route Table AZ2</strong> with <strong>Private App Subnet AZ2</strong> and <strong>Private Data Subnet AZ2. </strong>To do that<strong>, </strong>locate and select the<strong> Subnet associations</strong> tab, and at the right corner click <strong>Edit subnet associations.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*ur8OqNHZxGbGVsAqo6IanQ.png" /></figure><p>Check the <strong>Private App Subnet AZ2</strong> and <strong>Private Data Subnet AZ2 boxes, </strong>then click <strong>Save associations as shown below</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*yGhHRGKqzijJVXkA7tuYHA.png" /></figure><p>We have successfully updated the subnet associations for <strong>Private Route Table AZ2 </strong>as shown under <strong>Explicit subnet associations</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*PxRuWAMh7ue9b94cuQq0Hg.png" /></figure><p>Good job! We have completed this step — create <strong>NAT gateways</strong>. Through the NAT gateways, our resources in the private subnets will have access to the internet.</p><h4>STEP 3: Create Security Groups</h4><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*sn8GF-7SAZBqQ__aFEyCJg.jpeg" /></figure><p>The reference architecture above describes in parts the security groups we will create for this project. On the right side of the architecture is the breakdown of the security group parts we will need for this project. The parts are explained as follows:</p><p><strong><em>ALB(Application load balancer) Security Group</em></strong></p><ul><li>This is the security group that we will add to the application load balancer</li><li>Port: 80 and 443 with Source: 0.0.0/0</li></ul><p><strong><em>SSH Security Group</em></strong></p><ul><li>This is the security group that we will use to SSH into our EC2 instance and should always be limited to the IP address</li><li>Port: 22 with Source: Your IP Address</li></ul><p><strong><em>Webserver Security Group</em></strong></p><ul><li>This is the security group that we will add to the web servers in the private app subnets</li><li>Port: 80 and 443 with Source: ALB Security Group</li><li>Port: 22 with Source: SSH Security Group</li></ul><p><strong>Database Security Group</strong></p><ul><li>This is the security group that we will add to the RDS instance in the private data subnet</li><li>Port: 3306 with Source: Webserver Security Group</li></ul><p>Let’s start with the first part; <strong>ALB Security groups</strong>! The security group can be found on the VPC page. So, type VPC in the management console home and click it. On the left-hand side of the page locate and click <strong>Security Groups</strong> under the <strong>Security</strong> drop-down arrow. Then Filter it by <strong>Dev-VPC</strong> — the VPC we created previously <strong>&gt; Security groups &gt; Create security group</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*sy2UZPtAq6h-tCtT" /></figure><p>Enter the following information settings:</p><p><strong>Basic details</strong></p><ul><li>Security group name: ALB Security Group</li><li>Description: ALB Security Group</li><li>VPC: Dev VPC</li></ul><p><strong>Inbound rules</strong></p><p><strong>1st rule</strong></p><ul><li>Type: HTTP</li><li>Protocol: TCP</li><li>Port range: 80</li><li>Source: 0.0.0.0/0</li></ul><p><strong>2nd rule</strong></p><ul><li>Type: HTTPS</li><li>Protocol: TCP</li><li>Port range: 443</li><li>Source: 0.0.0.0/0</li></ul><p>Once you entered the information, click <strong>Create security group</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*9lg420NaAzBwhkb-TLiXAA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*Gnweu5iLs78D6U9KQU_qQQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*zVIXPHv3CrAnUlG6mzLilw.png" /></figure><p>Below Figure shows that you have successfully created the ALB security group</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*tpRp1F5SxUfzH3-V4wFv9Q.png" /></figure><p>For<strong> SSH Security Group; </strong>click <strong>Security Groups </strong>to go back one directory and click Create <strong>Security Groups</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*1dhWpiyFBFi1fJasovQtTw.png" /></figure><p>Enter the following settings and click <strong>Create security group</strong> as shown in the Fig below:</p><p><strong>Basic details</strong></p><ul><li>Security group name: SSH Security Group</li><li>Description: SSH Security Group</li><li>VPC: Dev VPC</li></ul><p><strong>Inbound rules</strong></p><ul><li>Type: SSH</li><li>Protocol: TCP</li><li>Port range: 22</li><li>Source: My IP</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*g-IrajxYjEB5Tn-MPDJoJA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*1fH5K5Buc38Wwoku3C3FGA.png" /></figure><p>Next is the <strong>Webserver Security Group</strong>. Follow the same procedures as above enter the following settings and click <strong>Create security group</strong>:</p><p><strong>Basic details</strong></p><ul><li>Security group name: Webserver Security Group</li><li>Description: Webserver Security Group</li><li>VPC: Dev VPC</li></ul><p><strong>Inbound rules</strong></p><p><strong>1st rule</strong></p><ul><li>Type: HTTP</li><li>Protocol: TCP</li><li>Port range: 80</li><li>Source: ALB Security Group</li></ul><p><strong>2nd rule</strong></p><ul><li>Type: HTTPS</li><li>Protocol: TCP</li><li>Port range: 443</li><li>Source: ALB Security Group</li></ul><p><strong>3rd rule</strong></p><ul><li>Type: SSH</li><li>Protocol: TCP</li><li>Port range: 22</li><li>Source: SSH Security Group</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*7EX5gUOU9USD069OkQavMA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*mx3jYf6QNF0H1EWI6UJcUQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*MgvLzfwo1iBdkr1nid9-YQ.png" /></figure><p>Next is the<strong> database security group</strong>. Enter the following information below then click <strong>Create security groups. </strong>See fig. below</p><p><strong>Basic details</strong></p><ul><li>Security group name: Database Security Group</li><li>Description: Database Security Group</li><li>VPC: Dev VPC</li></ul><p><strong>Inbound rules</strong></p><ul><li>Type: MYSQL/Aurora</li><li>Protocol: TCP</li><li>Port range: 3306</li><li>Source: Webserver Security Group</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*8nhUNw3Nx9j0tCO0uqJ-lA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*SRpZh2Q6ZciKI910D67YwA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*aUW7Q8HDTGkch3ONbinqLw.png" /></figure><h4>Step 4: Create the RDS (Relational Database Service) Instance</h4><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*gjs_2bjIxVa_MinmkcDzIw.jpeg" /></figure><p>With reference to our architecture above, the RDS Instance will be created in the private data subnets. But before we create our RDS, we will first create subnet groups — this allows us to specify the subnets that will be used to create the AWS RDS database. Let’s start!</p><p>On the management console page, type <strong>RDS</strong> in the search box, locate, and select <strong>RDS</strong>. At the bottom left corner of the <strong>RDS</strong> page, locate, and click <strong>Subnet groups</strong>. Then, click <strong>Create DB subnet group. </strong>See the figures below</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*JEUPwK5M2QsLS3WjLFroIA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*F5t7ArL8ADVT6WtL.png" /></figure><p>Enter the information settings below and click <strong>Create:</strong></p><p><strong>Subnet group details</strong></p><p>Name: <em>Database subnets</em></p><p>Description: <em>Database subnets</em></p><p>VPC: <em>Dev VPC</em></p><p><strong>Add subnets</strong></p><p>Availability Zones: choose <em>us-east-1a and us-east-1b</em> availability zones</p><p>Subnets: select subnet with <em>CIDR block 10.0.5.0/24</em> and subnet with <em>CIDR</em> <em>block 10.0.4.0/24</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*zXh3Iz7aF0994vSmhR_D_g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*_rFo5QRWoh670OWN.png" /></figure><p>Now that we have created our subnet groups, Let’s create the database. Select <strong>Database </strong>and click <strong>Create database</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*enalghMpUxcOwqqk.png" /></figure><p>Engine options: <em>MySQL</em></p><p>Engine Version: <em>MySQL 5.7.37 or the latest</em></p><p>Templates: <em>Dev/Test</em></p><p>Availability and durability: <em>Single DB instance</em></p><p><strong>Settings</strong></p><p>DB instance identifier: <em>Type a name for your DB instance</em></p><p>Credentials Settings: <em>Provide your master username, and password, and confirm the password. make sure you take note of your username and password so you don’t forget</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*Qt_zQTT9Llk6fpg8.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*_to4pBYLVkpdtOw7.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*zJzGzGpti90IB0bY.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*A5IPklTuRsnz36mHXlYu2A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*25haywYBPivSmXOfzg5nVw.png" /></figure><p><strong>Instance configuration</strong></p><p>DB instance class: <em>Burstable classes (includes t classes)</em></p><ul><li><em>select db.t2.micro</em></li></ul><p>Include previous generation classes: enabled</p><p><strong>Storage: </strong><em>Leave this as the default</em></p><p><strong>Connectivity</strong></p><p>Compute resources: Select Don’t connect to an EC2 compute resource</p><p>Network type: IPv4</p><p>Virtual private cloud (VPC): Dev VPC</p><p>DB subnet group: Ensure that the 2 subnet groups we created earlier are selected</p><p>VPC security group (firewall): Choose existing</p><p>Existing VPC security groups: Database Security Group</p><p>Availability Zone: us-east-1b — This is where you choose the AZ you want to create the master database in</p><p>Database authentication: Select password authentication</p><p><strong>Additional configuration</strong></p><p>Database options: Specify your <strong>Initial database name </strong>and leave other boxes as default. Make sure you specify the initial database name the database creation will not complete</p><p>See the figures below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*ZmIBE057pEEEZEq_m-kRzQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*MhvTxu9OeDjsM7dwA1alqw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*dJHBHLyAs6MS5Tpp.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*LS_F_loiWmQy63f0.png" /></figure><p>Ensure that the <strong>Password authentication</strong> under <strong>Database authentication</strong> is selected</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*w_aIfEtax48FC-KcDak3iQ.png" /></figure><p>Leave other settings as default, review, scroll down, and click <strong>Create database</strong>. This will take a while to complete. Click <strong>View credential details</strong> and take note of your credentials because once we create the RDS instance, we won’t have access to the credentials.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*Ss7hexxKHHS5224J.png" /></figure><p>The figure below shows the completion of the database. The <strong>Status</strong> should say <strong>available</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*MLSm8Jw8hqLL2Exr.png" /></figure><p>Great job! We have successfully created an RDS instance with the MYSQL engine</p><h4>Step 4: Create S3 Buckets</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_VvhUvXkZogPjjOKfWDL8A.png" /></figure><p>Next, we will create S3 bucket and upload the web files into the S3 bucket. On the management console page, type S3 in the search box, and click S3 under services. In the left navigation pane, choose <strong>Buckets</strong>. Click <strong>create bucket </strong>as shown below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/711/0*vUMkO0mB8Dg7ablu.png" /></figure><p>For the <strong>Bucket name</strong>, enter a unique name for your bucket. We will upload the web files into this bucket. For <strong>Region</strong>, choose the AWS Region where you want the bucket to reside (us-east-1). We will leave the rest of the settings as default, then click <strong>Create bucket</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*UFp_ym5b9piXbCDf" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*loMcCtdTyLNTM-dC1qws5Q.png" /></figure><p>We have successfully created our bucket! Next, we will click on the bucket name we created so we can upload the web files into the bucket. Click on the bucket name (<strong>chidex1-dynamic-web-files</strong>) and then select <strong>Upload</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Utyizn-dxM6S5_Tc" /></figure><p>Locate and open the folder where you stored the web files and drag or upload are into the bucket. Click upload</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*jb73RNTTlQxfTFdT" /></figure><p>The web files are uploaded successfully into our bucket as shown in the <strong>Status </strong>above. You should see the web files in the S3 bucket once you click close. Next, we will create another bucket and upload the second file, dummy.zip into the bucket. To create the 2nd bucket, click on <strong>Amazon S3 </strong>to go back to one directory, then click <strong>create bucket</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*Utyizn-dxM6S5_Tc" /></figure><p>Give your bucket a unique name and like we name the web file bucket, ensure that the name ends with dummy data, this is how we will be able to identify the content of this bucket. Also, ensure that you are in the right region. For instance, I will name my bucket “<strong>chidex-fleetcat-dummy-data” </strong>as shown below. Similar to how we create the first bucket, we will leave the rest of the settings to default, and then click<strong> Create bucket</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*loMcCtdTyLNTM-dC1qws5Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*8uXN2iofHEGXqotf" /></figure><p>Once we have successfully created the bucket, click on the bucket to open it and then select <strong>upload </strong>to add the dummy file. We can either <strong>Add files or drag the file</strong> into our bucket <strong>&gt; Upload</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*OeH_SRH235m5FQFp" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*yvT3iqCcmb6CGcW2" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*W7IsvDBypiOr3ayL" /></figure><p>We have successfully created the second bucket for our dummy file. Below is the summary of the two separate buckets we created for our files, web and dummy files.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/989/1*D_ClK7wnUOUdHrE3hUu58Q.png" /></figure><p>Great job so far! Let’s proceed to the next step.</p><h4>Step 5: Create an IAM Role with S3 Policy</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qQqbT_JfCUyKroCOAaGiTw.png" /></figure><p>We will create an IAM Role with the S3FullAccess policy. This role will allow the EC2 instance to download the web files from the S3 bucket we created. <br>From the AWS Console, go to <strong>Identity &amp; Access Management</strong> select <strong>Roles</strong> from the Details sidebar, and Click <strong>Create Role</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*vZB68sPUSTKiL66h.png" /></figure><p>under <strong>Trusted entity type</strong> Choose <strong>AWS service &gt; </strong>under<strong> Use case </strong>select<strong> EC2 &gt; Next</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*91Wth56Iih58MrCP.png" /></figure><p>Under<strong> Permissions policies</strong>, we will attach the S3 policy to this IAM role. Type <strong>AmazonS3FullAccess</strong> <strong>&gt; </strong>press<strong> Enter</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_3kh6uCkqNoizFKq.png" /></figure><p>As shown above, check the <strong>AmazonS3FullAccess </strong>and click<strong> Next.</strong> Under<strong> Role details, </strong>give the role a name<strong>, </strong>scroll down, and<strong> </strong>click<strong> Create role</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Ow4E3BT9yH1CpqfY" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*nUODZ86iyffTuS9b.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*M2duOGKFXTnxuBnQ.png" /></figure><p>Good job! We have successfully created the IAM role and attached a permissions policy as shown above.</p><h4>Step 6: Deploy E-commerce Website</h4><p>Here, we will install our website on an EC2 instance. To install our website, we will launch our EC2 instance in the public subnet and install the necessary commands that our website needs to function properly. Also, we will download our web files from the S3 bucket, and connect the EC2 instance to the RDS database we created earlier.<br><strong>NB: Ensure that you’re still in the same region (N.Virginia)</strong></p><p>In other to launch the EC2 Instance, let’s head over to the management console. Type EC2 in the search bar and either you click <strong>Launch instance</strong> or on the left side click <strong>Instances</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/711/0*F8Gpcv7HwdFil2BI.png" /></figure><p>Carefully enter the following information and see the figures below:</p><p><strong>Launch an instance</strong></p><ul><li>Name and tags: <strong>Key</strong> — type Name, <strong>Value </strong>— Setup Server</li></ul><p><strong>Application and OS Images (AMI)</strong></p><ul><li>Select the <strong>Quick Start</strong> tab and select <strong>Amazon Linux 2 AMI Free tier</strong></li></ul><p><strong>Instance type: </strong>Instance type — select t2.micro (Free tier eligible)</p><p><strong>Key pair (login): key pair name — </strong>select your key pair (myec2key). If you have not created your security key pair, please follow this project link <a href="https://medium.com/@chidexhenrytee/how-to-create-amazon-ec2-key-pairs-bde2f02dcfd8">https://medium.com/@chidexhenrytee/how-to-create-amazon-ec2-key-pairs-bde2f02dcfd8</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*hur4-0SrQQ9oXCvUrZ1x4A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*4QpVzgbWWl4w8VT4s8jHYw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*DEmANvHtHseiSkdj3X_8Bg.png" /></figure><p><strong>Network settings</strong></p><ul><li>click <strong>Edit</strong></li><li>VPC: select Dev VPC</li><li>Subnet: Public Subnet AZ1</li><li>Auto-assign public IP: Enable</li></ul><p><strong>Firewall (security groups)</strong></p><ul><li>Select <strong>existing security group</strong></li><li>Click on the drop-down and select these security groups: <strong>SSH, ALB, and Webserver Security Group </strong>(Recall that we created these security groups earlier). Review them by expanding + icon</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*CpYhILky7pkeIUBD2D4Ovg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*GiTN4JvpIkyOssMIMu5m7w.png" /></figure><p>Leave<strong> Configure storage </strong>as the default. For<strong> Advance details</strong>, under <strong>IAM instance profile</strong>, we will select the IAM role we created; <strong>S3Role. </strong>before you launch the instance, you can have a quick review of the summary of the EC2 instance on the right side as shown below. After the review, click <strong>Launch instance</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/711/0*d0DVUYMWS3EuL3C9.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*lvL_W3dBylVwaGTF.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/711/0*Dyaaz_LCeP6wngFd.png" /></figure><p>We’ve successfully launched the EC2 instance. Wait until the <strong>Instance state</strong> is <strong>Running</strong> and the <strong>Status check</strong> shows <strong>Passed</strong> as shown above.</p><p>Next, we will SSH into the EC2 instance to install our website. This link here contains a project on how to SSH into a Public EC2 instance. The Figure below shows that we have successfully SSH into the Public EC2 instance</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*iIoutMkIWndw9iUX" /></figure><p>Once you are able to SSH into your EC2 instance, we will run the following commands to install our website on the EC2 instance. The commands (with their respective meanings) below will install our website</p><p>NB: After you paste each command, ensure that you wait for the shell prompt to appear before proceeding to the next command.</p><pre>#1. A command to change to root user and update ec2 instance<br>sudo su<br>sudo yum update -y<br><br><br>#2. This command will install the apache web server<br>sudo yum install -y httpd httpd-tools mod_ssl<br>sudo systemctl enable httpd <br>sudo systemctl start httpd<br><br><br>#3. This command will install php version 7.4. <br>sudo amazon-linux-extras enable php7.4<br>sudo yum clean metadata<br>sudo yum install php php-common php-pear -y<br>sudo yum install php-{cgi,curl,mbstring,gd,mysqlnd,gettext,json,xml,fpm,intl,zip} -y<br><br><br>#4. This command will install mysql 5.7<br>sudo rpm -Uvh https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm<br>sudo rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022<br>sudo yum install mysql-community-server -y<br>sudo systemctl enable mysqld<br>sudo systemctl start mysqld<br><br><br>#5. set permissions. The next command will set some permissions on the files on our EC2 instance<br>sudo usermod -a -G apache ec2-user<br>sudo chown -R ec2-user:apache /var/www<br>sudo chmod 2775 /var/www &amp;&amp; find /var/www -type d -exec sudo chmod 2775 {} \;<br>sudo find /var/www -type f -exec sudo chmod 0664 {} \;<br><br><br>#6. download the FleetCart zip from s3 to the html derectory on the ec2 instance<br>sudo aws s3 sync s3://chidex1-dynamic-web-files /var/www/html<br><br><br>#7. change to the html directory and unzip the FleetCart zip folder<br>cd /var/www/html<br>sudo unzip FleetCart.zip<br><br><br>#8. move all the files and folder from the FleetCart directory to the html directory<br>sudo mv FleetCart/* /var/www/html<br><br><br>#9. move all the hidden files from the FleetCart diretory to the html directory<br>sudo mv FleetCart/.DS_Store /var/www/html<br>sudo mv FleetCart/.editorconfig /var/www/html<br>sudo mv FleetCart/.env /var/www/html<br>sudo mv FleetCart/.env.example /var/www/html<br>sudo mv FleetCart/.eslintignore /var/www/html<br>sudo mv FleetCart/.eslintrc /var/www/html<br>sudo mv FleetCart/.gitignore /var/www/html<br>sudo mv FleetCart/.htaccess /var/www/html<br>sudo mv FleetCart/.npmrc /var/www/html<br>sudo mv FleetCart/.php_cs /var/www/html<br>sudo mv FleetCart/.rtlcssrc /var/www/html<br><br><br>#10. delete the FleetCart and FleetCart.zip folder<br>sudo rm -rf FleetCart FleetCart.zip<br><br><br>#11. enable mod_rewrite on ec2 linux, add apache to group, and restart server<br>sudo sed -i &#39;/&lt;Directory &quot;\/var\/www\/html&quot;&gt;/,/&lt;\/Directory&gt;/ s/AllowOverride None/AllowOverride All/&#39; /etc/httpd/conf/httpd.conf<br>chown apache:apache -R /var/www/html <br>sudo service httpd restart<br></pre><p>Once we have successfully run all our commands and restarted our web server, we can access the website. To access the website, head over to the EC2 instance console — click on Setup Server, and copy the <strong>Public IPv4 address.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*v_wtXF8plMle89LceThgAA.png" /></figure><p>Open a new web browser and paste the<strong> Public IPv4 address.</strong> if you entered all your information correctly you should see the figure below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*XIYLyrUaRg0NV3oy" /></figure><p>We can now access our website. Next, we finish the installation of our website. Scroll down and click continue as shown below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/711/0*sHBF5J4DYvSDAPWT.png" /></figure><p>On the next page, we will connect the EC2 instance to the RDS database. Fill the page below with your RDS database information.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/711/0*ElNfAILxPSWP_OtH.png" /></figure><p>Head over to the RDS management console page (recall we created RDS in step 4). Click <strong>Database &gt; RDS DB Identifier </strong>to get to the page below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*HGbEHeCgb0SmHt7U" /></figure><p>Host: This will be your Endpoint. C<strong>opy your Endpoint and paste it into the Host field<br></strong>You can get all other information under the<strong> configuration tab as shown below.</strong> Copy and paste your<strong> DB name</strong> into the<strong> Database </strong>field and your <strong>Master name</strong> into the <strong>DB username.</strong> Enter your<strong> Database password (</strong>wherever you save it<strong>)</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*0HvmoJjCbAwIqSbG" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*YfAEp1EcIXtVSI_g" /></figure><p>Next, we enter the administration information about the website as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*h15hAlZ6LJXO2xUV" /></figure><p>Next, we enter our store information as shown below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Cv4OiJrOj7TgwS0o" /></figure><p>After you have entered all the information as illustrated above, click<strong> Install. </strong>Give it some time to install. The figure shows we have successfully installed our website</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*mZuBdSKCwr8y6sLy" /></figure><p>Next, click <strong>Go to Your Shop</strong> to view the e-commerce store.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*dJqKdqEQjsugviV4" /></figure><p>We have successfully installed our fleetcart store. At the moment, the site is empty because the web developer has given us a blank template to customize our website the way we want it. In the next step, we will upload the dummy data to this website to make it presentable. Great Job!!</p><h4>Step 6: Import the Dummy Data for the Website</h4><p>We will import our dummy data into the website we just launched to make it presentable. The first thing we will do is to download MySQL Workbench. Open a new tab and search “MySQL Workbench”. Choose your OS from the dropdown and follow the instructions. Ensure that you download the latest version</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SErePO4QDMx96GZRmUN9dg.png" /></figure><p>Once you have successfully installed it, you should see the figures below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/976/0*4Dz2fzMjsUvSH9CW.png" /></figure><p>Once the <strong>installation completes</strong> click <strong>Next </strong>and then<strong> Finish</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*oYJrxsZ5pBzqwtFu.png" /></figure><p>Next, we will create a <strong>Pem file</strong> in the management console. Head to the <strong>EC2 dashboard</strong> and on the left side, locate <strong>Key Pairs</strong> and click on it</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*mYSQItRymDuokIgI.png" /></figure><p>Under <strong>Key Pair</strong>, enter the following information:<br>Name: give your key pair a name; <strong>Dummy-Key </strong><br><strong>Key pair type</strong>: select <strong>RSA</strong><br><strong>Private key file format</strong>: <strong>.pem</strong></p><p>Click <strong>Create key pair. </strong>We have successfully created the key pair. Next, we will and EC2 intsance in the public subnet. Navigate to the EC2 instance page click <strong>Launch instance </strong>and enter the information below:</p><ul><li><strong>Name and tags</strong>: Dummy Server</li></ul><p><strong>Application and OS Images (AMI)</strong></p><ul><li>Select the <strong>Quick Start</strong> tab and select <strong>Amazon Linux 2 AMI Free tier</strong></li></ul><p><strong>Instance type: </strong>Instance type — select t2.micro (Free tier eligible)</p><p><strong>Key pair (login): key pair name — </strong>select the key pair we created; Dummy-key</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*IWp2MR2oKhUF18RE.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/971/0*ws1pgMhwLn2jd_vW.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/974/0*buOnTEWD298u5Smg.png" /></figure><p><strong>Network settings</strong></p><ul><li>click <strong>Edit</strong></li><li>VPC: Dev VPC</li><li>Subnet: Public Subnet AZ1</li><li>Auto-assign public IP: Enable</li></ul><p><strong>Firewall (security groups)</strong></p><ul><li>Select <strong>existing security group. </strong>Click on the drop-down and select <strong>SSH</strong> <strong>Security Group</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ZjZuzPUIA_RcJ-PH" /></figure><p>Leave the rest to their <strong>default settings &gt; Review the settings &gt; Launch instance. </strong>Good job! We have successfully launched the EC2 Instance, called <strong>Dummy Server</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5D9qlNTXBfchgrzEoGqA1A.png" /></figure><p>Next, we will create a security group that will be added to the RDS instance to allow us to connect to it from the dummy server. To create the security group, on the <strong>EC2 dashboard &gt; Security Groups &gt; Create security group</strong></p><p>Enter the following information:</p><p><strong>Basic details</strong></p><ul><li>Security group name: Dummy Security Group</li><li>Description: Dummy Security Group</li><li>VPC: Dev VPC</li></ul><p><strong>Inbound rules</strong></p><ul><li>Type: Custom TCP</li><li>Protocol: TCP</li><li>Port range: 3306</li><li>Source: Custom. The source will be the Private IP of the Dummy Server we created. To get the <strong>Source of your Inbound rule</strong>, go to your <strong>Dummy Server under Instances running and copy the Private IPv4 address. </strong>Scroll down and click<strong> Create security group</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*H6gWzW0dmc4GXMFN" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*bG9_pix6YQH6Efsq" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*vU25oYhsnGhep6Gz" /></figure><p>We have successfully created the dummy security group. Next, we will add this security group to our RDS database to allow our EC2 instance to connect to it.</p><p>Head over to the management console, enter RDS in the search box and press enter. On the RDS dashboard, click DB instances</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*o0QWpBSTaiRVZTDS.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*D2w_u8jgz1pkO_x_.png" /></figure><p>As shown above, select your <strong>RDS instance (dev-rds-db)</strong> and click <strong>Modify. </strong>On this page, scroll down to the security group section, select<strong> Database Security Group </strong>and the<strong> Dummy Security Group, and </strong>then click<strong> Continue</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/950/0*ihLdexXF77yMLkml.png" /></figure><p>On the next page, select <strong>Apply immediately</strong> and click <strong>Modify DB instance. </strong>We have successfully modified our database instance and added the Dummy security group to it. If you select your database instance again, under VPC security groups, the Dummy security group is added to the RDS instance. See figures below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*NQOrrxB490uFnJTY.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*IP5EbAuR4NiwAX9o" /></figure><p>Next, we will import the SQL file for our website into the RDS database. To the SQL file, open MYSQL Workbench</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3E7tJcyJUMI4uMH6Cqz-Lg.png" /></figure><p>Click <strong>Database</strong>, then select <strong>Connect to Database</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/499/0*jv-euGhB5V6W0xwY.png" /></figure><p>Under Connection Method, click the dropdown arrow, Select <strong>Standard TCP/IP over SSH</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/848/0*wBtC2eo_u-y3tp7H.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xGnn86Dggzco0MM8_adgTg.png" /></figure><p>Under Parameters, enter the following information<br><strong>SSH Hostname</strong>: This would be the<strong> DNS name of our Dummy EC2 instance. </strong>Go back to your <strong>EC2 instance &gt; Dummy Server &gt; Copy the Public IPv4 DNS &gt; Paste it in the SSH Hostname </strong>box</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_qI5KrhEKsQKt-rt" /></figure><p><strong>SSH Username</strong>: enter ec2-user<br><strong>SSH Key File</strong>: click on the 3 dots to locate, copy, and paste in this box the path where you saved the <strong>Dummy-Key.pem </strong>file that we created earlier <br><strong>MySQL Hostname</strong>: This is the endpoint of your RDS database. Navigate to your RDS dashboard in the management console. click <strong>Databases &gt; dev-rds-db &gt; Connectivity &amp; security</strong>. under <strong>Connectivity &amp; security,</strong> copy and paste the <strong>Endpoint</strong> into the MySQL Hostname box.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/762/0*zRHp2kL9Edj5Z4Yb.png" /></figure><p><strong>MySQL Server Port:</strong> 3306<br><strong>Username</strong>: enter your RDS username (Master username under Configuration)<br>Next, Click <strong>Store in Vault</strong> under <strong>Password </strong>and enter your <strong>RDS password &gt; Click OK </strong>again</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/440/0*Dzkj0OimpmHS9_ZX.png" /></figure><p>If you see the warning message above, hit Ok. We have successfully connected to the RDS database as shown below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*y3TvKmyYUZ5vniCT" /></figure><p>Now that we have connected to the RDS database, the next is to import our SQL file into the database</p><p>SQL File: Download the SQL file: <a href="https://drive.google.com/file/d/1e1tK0phHUK4Tnb4hpgBtOY0zkSGLO0lh/view?usp=sharing">https://drive.google.com/file/d/1e1tK0phHUK4Tnb4hpgBtOY0zkSGLO0lh/view?usp=sharing</a></p><p>To import the SQL file, select<strong> Object Info (or Administration) </strong>tab &gt; click <strong>Data Import/Restore.</strong> Under <strong>Data Import</strong> selec<strong>t Import from Self-Contained File. </strong>Next, browse to where you saved your SQL file and upload it as shown below</p><p>Under <strong>Default Target Schema</strong>, select applicationdb (database name). Click <strong>Start Import</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*J7YWBXn2HJGomdGG" /></figure><p>Give it some time to finish importing the file. The diagram below shows that the SQL file was successfully imported into the RDS database. Good job!!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*nbqX9byKi0JVE-l_" /></figure><p>We can close MySQL Workbench afterward. Let’s clean up the extra resources used to import our data into the RDS database. Terminate our <strong>Dummy EC2 instance </strong>by going back to your <strong>EC2 dashboard &gt; Instance running &gt; Dummy Server &gt; Actions &gt; Terminate instance &gt; Terminate</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*G8L8IWLvgOgFG55-" /></figure><p>Next, we will remove the dummy security group we added to the RDS instance. Head to the <strong>RDS management console &gt; Dashboard &gt;</strong> <strong>DB Instances &gt; select your RDS instance &gt; Modify</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/861/0*65wy-hWXtqiOsZ4D.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/907/0*HdOGbFSVIV1VCAt3.png" /></figure><p>On the Modify DB instance: dev-rds-db page, scroll down to the<strong> security group section &gt; Remove the Dummy Security Group &gt; Continue</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/707/0*RRp0yTG-m7MmTKJ7.png" /></figure><p>Under Schedule modifications &gt; select <strong>Apply immediately &gt; Modify DB instance</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/953/0*sK0HrmkDF71Fi0tT.png" /></figure><p>We successfully removed the dummy security group from the RDS database. As we can see from the DB instance page, under<strong> Security, </strong>we no longer have the<strong> Dummy Security Group</strong></p><p>Also, we will need to remove the Dummy Security Group and Dummy Key Pair we created earlier. On the <strong>EC2 dashboard &gt; select Dummy Security Group &gt; Actions &gt; Delete security groups</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*VDpwa5LdXVPuVOT3" /></figure><p>Next, go to <strong>Key Pairs &gt; Dummy key &gt; Actions &gt; Delete.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*O5XuFsomcGPtZ6dC" /></figure><p>We have successfully cleaned up the extra resources we used to import our data into the RDS database.</p><p>To complete our installation, we will SSH into our Setup Server to run these commands (Mac User).</p><pre>sudo su<br>sudo aws s3 sync s3://chidex-fleetcat-dummy-data /home/ec2-user<br>sudo unzip dummy.zip<br>sudo mv dummy/* /var/www/html/public<br>sudo mv -f dummy/.DS_Store /var/www/html/public<br>sudo rm -rf /var/www/html/storage/framework/cache/data/cache<br>sudo rm -rf dummy dummy.zip<br>chown apache:apache -R /var/www/html <br>sudo service httpd restart</pre><p>Let’s over to the EC2 instance management console page, select your <strong>Setup Server &gt;</strong>Copy the <strong>Public IPv4 address of our Setup Server </strong>as shown below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*WLYoOxzDT-Dk00fe" /></figure><p>Open your terminal. Your terminal will always open to your home directory as shown below (My home is the “User”). Make sure you move your keypair file (downloaded) into the home folder. Type “ls” and press enter to confirm that the keypair file is in your home directory (“User”).</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*b_UcXuwsCDyzJsKc9mt6zA.png" /></figure><p>Change the permission on the keypair to allow us to ssh into the EC2 instance. To change the permission, type, and press enter the command below. As we know, the name of the keypair is “myec2key.pem”. You are free to enter any keypair name you have created (in case you have one)</p><pre>chmod 400 {myec2key.pem}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*MtbnjCn8nNf3-nef7zDK3A.png" /></figure><p>Enter the command below to SSH into the Setup Server</p><pre>ssh -i myec2key.pem ec2-user@3.92.42.158</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*EE3XKynjKpUQp2Oe" /></figure><p>Once we have SSH into the Setup Server, we will run the commands to install our dummy data. Copy and paste the commands line by line.</p><pre># this will change to the root user <br>sudo su<br><br># this will download the dummy file from the s3 bucket. ensure you update <br># your bucket name. copy and update your s3 bucket name <br>sudo aws s3 sync s3://chidex-fleetcat-dummy-data /home/ec2-user<br><br># unzip the dummy file <br>sudo unzip dummy.zip<br><br>#This command will copy all the files out of the unzipped version of the dummy <br>#file and copy it to this public directory<br>sudo mv dummy/* /var/www/html/public<br><br>#This command will move this hidden file from the unzipped dummy folder <br>#into the public directory<br>sudo mv -f dummy/.DS_Store /var/www/html/public<br><br>#This command will delete this cache directory from our EC2 instance.<br>sudo rm -rf /var/www/html/storage/framework/cache/data/cache<br><br>#this will these folders from the EC2 instance since we have moved our files <br>sudo rm -rf dummy dummy.zip<br><br>#This command will give the apache the access to our HTML directory and the <br>#last command is going to restart the apache server.<br>chown apache:apache -R /var/www/html <br>sudo service httpd restart</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*D96E-OKM8q_H2c_W" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*t3Eh8rsJBYM06LMx" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*cHEg1ERBNIokYP8L" /></figure><p>These are all the commands we need to run to move our dummy data to our website. Let’s head to our website to see if all the images and the dummy data have been imported to our website. Let’s head over to the EC2 management console and copy the Public IPv4 address of the <strong>Setup Server. </strong>Open a new tap and paste the Public IPv4 address and press enter</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*KRyuYzljYQdwiPSf" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*rsFljbxpKVa3KQlU" /></figure><p>Good Job! As shown above, we have successfully imported all our images and dummy data for the website.</p><h4>Part 7: Create an Amazon Machine Image (AMI)</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ytap1y1NKGRd6kHkvcwWBA.png" /></figure><p><em>An Amazon Machine Image (AMI) is a fully managed image provided by AWS that provides the information required to launch an instance. After you create and register an AMI, you can use it to launch new instances.</em></p><p>Once we have installed and configured our website, we will use the EC2 instance we installed our website on to create an AMI. Then we can use the AMI to launch new EC2 instances with our website already configured on them. Let’s head over to the <strong>EC2 Instance Dashboard</strong>, then click <strong>Instances (running)</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*zZcW5yN43Hr9mOCc.png" /></figure><p><strong>check the Setup Server &gt; Actions &gt; Image and templates &gt; Create image</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*mja2y57eC4AGDmb_" /></figure><p>On the Create image page, enter the following information as shown in the diagram below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*6Kegj0a8OBxiRqGs" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*WCo8afwyEneHsdgI" /></figure><p>Click <strong>Create Image. </strong>We have successfully created our AMI from the Setup Server</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*fSBT95QFSnZclNYW" /></figure><p>When we create an AMI a snapshot is also created. Wait until the status is completed/available. This AMI can now be used to launch new EC2 instances with our website already installed on it. This is how we use an EC2 instance to create an AMI.</p><p>Good job!! Let’s keep going</p><h4>Part 8: Create an Application Load Balancer</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zLiCurD6ambZgJxFXCvcIA.png" /></figure><p>In this project, the ALB will be used to distribute or route web traffic across the EC2 instances in two Availability zones as displayed in the reference architecture above. Therefore, before we create our ALB, we will first launch EC2 instances in each of the <strong>Private App Subnets.</strong></p><p>Similar to how we launched our Setup Server, we will follow the same process in launching our web servers in the private app subnets. Navigate to the EC2 instance page click <strong>Launch instance </strong>and enter the information below:</p><p><strong>Launch an instance</strong></p><ul><li>Name and tags: <strong>Key</strong> — type Name, <strong>Value </strong>— Webserver AZ1</li></ul><p><strong>Application and OS Images (AMI)</strong></p><ul><li>Select the <strong>My AMIs</strong> tab &gt; select <strong>Owned by me </strong>&gt; under <strong>Amazon Machine Image (AMI)</strong>, choose the <strong>FleetCart AMI</strong> we created</li></ul><p><strong>Instance type: </strong>Instance type — select t2.micro (Free tier eligible)</p><p><strong>Key pair (login): key pair name — </strong>select the key pair we created in step 6 (myec2key) or your key</p><p><strong>Network settings</strong></p><ul><li>click <strong>Edit</strong></li><li>VPC: Dev VPC</li><li>Subnet: Private App Subnet AZ1</li><li>Auto-assign public IP: Enable</li></ul><p><strong>Firewall (security groups)</strong></p><ul><li>Select <strong>existing security group</strong></li><li>Click on the drop-down and select <strong>Webserver Security Group</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*n8p4zkWcLLXD5FBz" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*INn0-Q9wXsKw3NUX" /></figure><p>Leave the storage to <strong>default </strong>and<strong> </strong>click<strong> Launch instance</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ext04d4bQVucsQub.png" /></figure><p>We have successfully launched the first EC2 instance in the private app subnet AZ1. Next, we will launch the second EC2 instance in the private app subnet AZ2. Follow the steps and launch the <strong>“Webserver AZ2”</strong></p><p><strong>NB: private app subnet AZ1 and webserver AZ1 will change when creating your Webserver AZ2</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*DNc7_LQUPVdzrAPO" /></figure><p>We have successfully launched our EC2 instances in the private app subnet AZ1 and private app subnet AZ2.</p><p>Next, before we launch our ALB, we will first create a target group, which is used in routing. The load balancer checks the health of targets in this target group using the health check settings defined for the target group. We will put these instances in the target group to allow the ALB to route traffic to them.</p><p>Let’s head over to the EC2 page, in the navigation pane, under <strong>Load Balancing</strong>, choose <strong>Target Groups</strong>. Then click on <strong>Create target group.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*EVOEELH9L9P9gVG-fb5pEA.png" /></figure><ul><li>Under <strong>Basic configuration</strong>, keep the Target type as <strong>Instances</strong></li><li>For the <strong>Target group name</strong>, enter <strong>Dev-TG</strong> or any name for the new target group</li><li>Keep the <strong>Protocol (HTTP)</strong> and <strong>port (80)</strong> as the default</li><li>Next, we will select our <strong>Dev VPC</strong> or the VPC containing your instances. Keep the <strong>Protocol version as HTTP1</strong></li><li>Under <strong>Health checks</strong>, keep the settings as default</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*udJK9n4eE0IuQ464cm7qXw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*kA4H_KVU5y8zyyElM2sX8A.png" /></figure><p>Under <strong>Advance health check settings</strong>, keep all boxes as default except <strong>Success codes box: enter 200,301,302. Click Next</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UtX0UXxodZ8dUtGlmPkd8Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p3xGF4QMUUTZwFwsTJE8aw.png" /></figure><p>On the <strong>Rgister targets page</strong>, we will select the instances we want the ALB to route traffic to. For Available instances, select <strong>Webserver AZ1</strong> and <strong>Webserver AZ2</strong>. Keep the default <strong>port 80</strong>, and choose<strong> Include as pending below, </strong>then click<strong> Create target group</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*wqAeNY_A4of472oZ7fSsBg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*moWzJBlw2JickflA8HlNlw.png" /></figure><p>We have successfully created our target groups. Next, is to create our application load balancer (ALB).</p><p>To create an ALB, in the navigation pane, under<strong> Load Balancing</strong>, select <strong>Load Balancers</strong>. Click <strong>Create load balancer</strong>. Under <strong>Load balancer types</strong>, for <strong>Application Load Balancer</strong> type, click <strong>Create.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*IVCfWpL1FHc2vLn1GYpoZg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*37t7Jmg2cx8FAlYIIrB8Fg.png" /></figure><p>Next is to provide our basic configuration information for our load balancer. such as a name, scheme, and IP address type. Then, we will provide information about our network and one or more listeners. A listener is a process that checks for connection requests. It is configured with a protocol and a port for connections from clients to the load balancer. Enter the following information below:</p><p><strong>Basic configuration</strong></p><ul><li>Load balancer name: <strong>Dev-ALB</strong> or any name you desire</li><li>For<strong> Scheme</strong> and <strong>IP address type</strong>, we will keep the default values</li><li>Network mapping: Select <strong>Dev-VPC</strong>, and for Mappings we will select two availability zones and one subnet per zone. Therefore, we will choose <strong>us-east-1a</strong> and select <strong>Public Subnet AZ1</strong>. For the second AZ, choose <strong>us-east-1b</strong> and select <strong>Public Subnet AZ2.</strong></li><li>For Security groups: remove the default and select the <strong>ALB Security Group.</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*mb9GWOhueQDyShvqzKmofA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*4ULy1A9TXhm8PifBqbw_NQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*gvv0GXGz7KcWI86cWd4gZQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*3yI35jRVU5RA_HcnbezThQ.png" /></figure><p>For <strong>Listeners and Routing</strong>, we will keep the default <strong>Protocol (HTTP)</strong> and <strong>Port (80)</strong>. This will configure a listener that accepts HTTP traffic on port 80 and forwards traffic to the selected target group by default. Under <strong>Default action</strong>, select the target group created earlier, <strong>Dev-TG</strong>. Let’s review our configuration and choose <strong>Create load balancer</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*yAokPEl49EblfslaiDJcZg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*DAjc7_20Y3Qno9rF3EK6CA.png" /></figure><p>We have successfully created our load balancer! Click View load balancer to see the<strong> Dev-ALB</strong> we created as shown below. We will wait for its <strong>State</strong> to be <strong>Active</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*j85RppvcUOHtw6lz" /></figure><p>We will use the DNS name of the load balancer to access our website. Open a new tab, copy and paste the <strong>DNS name</strong> of the load balancer into the address field of the tab, and hit enter</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Z5sk2RSjQf6YdEYs" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*9fvgLWjVyGGg5_1i" /></figure><p>We can now access our website using the DNS name of the application load balancer.</p><p>We need to terminate our Setup Server. <strong>Head over to your running instances &gt; Setup Server &gt; Instance state &gt; Terminate instance</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*OHDA_bsHNAW5F6_Z.png" /></figure><p><em>Note: To enable installation of the necessary software, we set up the server in the public subnet, giving it internet access. Afterward, we used it to create an Amazon Machine Image (AMI), which we will use for future server launches. The setup server was only utilized for application installation and configuration.</em></p><h4>Step 9: Register a New Domain Name in Route 53</h4><p>Registering a new domain name in Route 53 will allow our end users to access our website using the domain name we registered instead of the DNS name of our application load balancer. Follow this link <a href="https://aws.amazon.com/getting-started/hands-on/get-a-domain/">https://aws.amazon.com/getting-started/hands-on/get-a-domain/</a> to register your domain name (feel free to use any video if you prefer a video). Once this part is completed, we will proceed to create a record in Route 53 with the domain name.</p><h4>Step 10: Create a Record Set in Route 53</h4><p>We will create a record set in Route 53 where we will use the domain name we created to access the website. To create a record set, enter <em>Route 53</em> in the search bar and select Route 53 to open the service console</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*_tPSvkUe-w_co2Wk.png" /></figure><p>The page displayed below shows that I have two registered domain names. Note that if it is your first time registering a new domain name, one hosted zone will show up under DNS management. Choose Hosted Zones and click on the name of the name of the hosted zone that you want to create records in.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*vDafp1r-UYGImRW9" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*EEVwFeIYJpSEj9eA" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*Jt9Zxtn8sOhQsvVL" /></figure><p>We can now create DNS records for our domain. In this guide, we will create a simple A record type. Choose the <strong>Create record</strong> button to get started.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*2piK563N5-sHUad2" /></figure><p>Enter the following information:</p><p>To allow users to connect to your ALB using IPv4, enter your A record information and ensure <strong>A </strong>is selected in the <strong>Record type</strong> field. For this project, we will enter <strong>www</strong> for <strong>Record</strong> <strong>name</strong>.</p><p>Toggle the<strong> Alias</strong> on</p><p><strong>Under Route traffic to:</strong></p><ul><li>Select <strong>Alias to Application and Classic Load Balancer</strong> in the Choose an Endpoint dropdown menu.</li><li>In the <strong>Choose Region</strong> dropdown menu, select the Region in which your ALB is located.; US East (N. Virginia) [us-east-1]</li><li>In the <strong>Choose load balancer </strong>dropdown menu, select the existing ALB that you want to receive traffic from this domain.</li><li>Choose the <strong>Create records</strong> button once you have finished.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*G11DV8k7orYvEDM8" /></figure><p>As shown below, we have successfully created our record set and we can now access the website using the DNS name</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*uGstOqncC43iGVff" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*xnPvIITysWwE_iyh.png" /></figure><p>To access the website as shown above, check the record that we created, copy the record name, open a new tab, paste the name in the address bar, and press enter. We can now access our website from our domain name. In the next part of our project, once we have set up our SSL listener to secure our website, we will SSH into our EC2 instance and update the domain name of our website.</p><h4>Step 11: Register for an SSL Certificate in AWS Certificate Manager</h4><p>AWS Certificate Manager is a service that lets you easily provision, manage, and deploy public and private Secure Sockets Layer/Transport Layer Security (SSL/TLS) certificates for use with AWS services and your internal connected resources. In other words, we will use the SSL Certificate to encrypt the communication between the web browser and web servers.</p><p>If you noticed, our website displayed above is not secured, hence we will register a free SSL Certificate and use it to secure our website. Let’s head over to the management console, type certificate manager in the search bar, and hit enter.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*RXCIA6TShET6_Trmsn4oxA.png" /></figure><p>Click <strong>Request a certificate,</strong> select <strong>Request a public certificate</strong> under <strong>Certificate type,</strong> and<strong> click Next</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*OY9ifN7Ki8BbSDkTcU5z3Q.png" /></figure><p>Under <strong>Domain names</strong>, enter your domain name, and <strong>click Add another name to this certificate </strong>to add a wildcard to the domain name (it will allow us to have “www” in front of the domain name). Type *. followed by the domain name. Leave the rest as default, scroll down, and click <strong>Request. </strong>See below diagrams</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*umTCoNcyvUZ4Ui3F26Uhuw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*8J1fpBxXfxidOr4ctUom3g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*l-1ko5wQ72LyAU4GUJkjvg.png" /></figure><p>Click view certificate to view the certificate</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*En6gHBYzQb2FN0_euS4MSQ.png" /></figure><p>The status says Pending validation because we still need to create a record set in Route 53 to validate the domain name we registered. Click <strong>Create records in Route 53</strong> and<strong> </strong>select the domain name and wildcard. Then click <strong>Create record</strong> as shown below</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*jN-P5yiv5uW6JcilxdIDWg.png" /></figure><p>We have successfully created a DNS record in Route 53. Refresh the page and ensure the <strong>Status</strong> changes to<strong> issued and </strong>the domain names are showing<strong> Success</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*6Z2EBQBeQCSGtrIBS6GU8g.png" /></figure><h4>Step 12: Create an HTTPS Listener for the Application Load Balancer</h4><p>In this step, we will create an HTTPS listener for our ALB to secure our website. Recall that in step 8, we had earlier created an ALB. Let’s head over to the EC2 dashboard, in the navigation pane, under<strong> Load Balancing</strong>, select <strong>Load Balancers</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*h9kokG9c4QoGLW-dVEnryQ.png" /></figure><p>Select your load balancer name then click the <strong>Listeners</strong> tab then Click <strong>Add listener. </strong>As shown below, select<strong> HTTPS</strong> under <strong>Protocol</strong>, and this will always be on <strong>Port 443 </strong>as shown below</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*3hoQ_-KoCAhn-0-_.png" /></figure><p>Under <strong>Action types</strong> select<strong> Forward to target groups.</strong> In the Select a target group, choose Dev-TG (or your target group name) in the drop box</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*PBQ4k3d2WbP80AZt" /></figure><p>Under <strong>Default SSL/TLS certificate From ACM,</strong> select the certificate you created earlier and <strong>Add</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*yYLyvLvoBpkmFi7W" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*wxV1bS5t1ibAqL8A" /></figure><p>We have successfully added the HTTPS listener. Next, we need to edit the HTTP listener to redirect HTTP traffic to HTTPS. To edit the HTTP listener, check box HTTP, select the Manager listener drop-down, and select Edit listener as shown below</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*3CjBpzTk-Mc0MmSk" /></figure><p>Under <strong>Default actions</strong>, choose <strong>Redirect to URL. </strong>Under<strong> Protocol </strong>and<strong> Port, </strong>select<strong> HTTPS </strong>and type <strong>443. </strong>Scroll down and click <strong>Save changes</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*eV2qYumNRTrc_v9D" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*614ywTE_rtOXsrBP" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*truF50TNxecsQWO-" /></figure><p>We have successfully edited our HTTP listener to redirect traffic to HTTPS. Let’s check our website to ensure that it is secure. As shown below, retype your domain name in the address bar of your browser starting with https then press enter. We have successfully used the SSL certificate to secure the communications to our website, thus it has the lock icon. It is expected that your website is not loading well. In the next part, we will update the settings of our domain name in the website’s configuration file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*tLbSKMRchV2S_TAZ" /></figure><h4>Step 12: Launch Bastion Host</h4><p>To SSH into the private instances in the private subnets, we will first launch an EC2 instance in the public subnet called bastion host or jump box. Next, we will ssh into the instance we launched in the public subnet, and lastly from the instance in the public subnet, we can ssh into any in the private subnets. Let’s proceed. Similar to how we launch the webservers, click<strong> Launch instance</strong> from the<strong> EC2 Dashboard</strong> and enter the information below. Review the <strong>Summary</strong> and click <strong>Launch instance.</strong></p><p>Name: Bastion Host</p><p>AMI: Amazon Linux 2</p><p>Instance type: t2.micro</p><p>Key pair: Select your key pair</p><p>VPC: Dev VPC</p><p>Subnet: Public Subnet AZ1</p><p>Security Group: SSH Security Group</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*-4cJ5YkygFG7G-kel2pXeA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*PHHD5tNPUPKSPK33c3G_Jw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*gEi2HYgzusQk1Y4ZF7sZMw.png" /></figure><p>Good Job! We have successfully launched our Bastion Host instance. Wait until the <strong>Instance state</strong> says Running and <strong>Status check</strong> 2/2 passed.</p><h4>Step 13: Launch Bastion HostSSH into an EC2 Instance in the Private Subnet (Mac Users)</h4><p>Now that we have launched our Bastion host in the public subnet, we can use it to ssh into any of our EC2 instances in the private subnets. To ssh into an instance in the private subnet using a Mac computer, ensure that you run the following commands from the directory you saved your private key pair. Please note that the following commands assume you are using an Amazon Linux instance.</p><p><strong>Command 1</strong>: This command will add our private key to the App keychain. It will allow us to ssh from the bastion host to any instance in the private subnets</p><p>ssh-add — apple-use-keychain &lt;the-name-of-your-private-key.pem&gt; or</p><p>ssh-add -K &lt;the-name-of-your-private-key.pem&gt;</p><p><strong>Example</strong>: ssh-add — apple-use-keychain myec2key.pem or</p><p>ssh-add -K myec2key.pem</p><p><strong>Command 2</strong>: This will allow us to ssh into the Bastion host in the public subnet</p><p>ssh -A ec2-user@&lt;the-public-ipv4-ip-of-your-bastion-host from the management console&gt;</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*4v6oUHb9UeOkiSTF2e48uQ.png" /></figure><p><strong>Example</strong>: ssh -A ec2-user@44.213.116.158</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*2GGT4n-XPM7tFVhp" /></figure><p><strong>Command 3</strong>: We can now ssh from the Bastion host into any of the instances in the private subnets:<strong> Webserver AZ1</strong> in this case</p><p>ssh ec2-user@&lt;the-private-ipv4-ip-of-the-instance-in-the-private-subnet&gt;</p><p>Example: ssh ec2-user@10.0.2.209</p><p><strong>Ensure that you copied the Private IPv4 address of the Webserver AZ1. </strong>If everything works well, we should get the diagram below. We have successfully ssh into our instance (Webserver AZ1) in the private subnet</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*YcgG-dKh5IIihys5RB-R7A.png" /></figure><p>Good job! We have successfully SSH into the EC2 instance in the private subnet.</p><h4>Step 14: Update the ENV File</h4><p>As we can see in step 12, the website did not load the images properly. In this step, we will update the domain name settings for the website to load properly. Before the updates, we will terminate one of the EC2 instances. In this case, let’s terminate Webserver AZ2. Head over to the EC2 instance dashboard and terminate the server.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*rnc3iOWiC04pKiKu.png" /></figure><p>Next, we will SSH into the Webserver AZ1. Follow the instructions in step 12 to SSH into Webserver AZ1</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*YcgG-dKh5IIihys5RB-R7A.png" /></figure><p>Once we have SSH into the private EC2 Instance (Webserver AZ1) as shown above, we will follow the following steps:</p><ul><li>Change to root user with this command <strong>sudo su</strong></li><li>Change your directory to the HTML directory by typing this command <strong>cd /var/www/html</strong></li><li>The file we are editing is in the HTML directory, type <strong>nano .env</strong> and press enter</li><li>In the <strong>Nano text editor</strong>, we need to <strong>update the APP URL to the URL of our website. </strong>Move the down arrow up to the row where we have <strong>APP URL</strong>, update the <strong>APP URL</strong> as shown below and press <strong>Ctrl X, Y and press Enter</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/945/1*w-FJaAnmRapSEqb-1frxYw.png" /></figure><p>We have successfully updated the app url in the env file of our website. Whenever we update any settings in your configurations file, it’s a good practice to restart your webserver. Hence type <strong>service https restart.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*mHz9ImdnI-0g-O47" /></figure><p>Since we have updated the APP URl Let’s head over to the website to see if the images are loading properly. You should the below diagram if your website loaded properly</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*lTAfxZqOGU6F1hDp" /></figure><h4>Step 15: Create the AMI of the Updated EC2 instance (Wbserver AZ1)</h4><p>Since we updated the configuration file in the previous step, we will need to create a new AMI of our website. Also, we will need to delete the old AMI that was previously created so we can avoid using it accidentally.</p><p>Head over to the EC2 Instance dashboard. Select <strong>Webserver AZ1 &gt; Actions &gt; Images and templates &gt; Create image</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Jl3AVhLT9DajcGpi" /></figure><p>As shown below, enter the information under <strong>Create image</strong> and click Create image</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*l9JHu8lsPeac8Q58" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*OdamE8jn4tp8oeLj" /></figure><p>We have successfully created our <strong>FleetCart AMI Version 2. </strong>Wait until the <strong>Status is Available</strong> then you can delete the old AMI (FleetCart AMI). <strong>Select the old AMI and select Deregister AMI — </strong>this will delete the old AMI from your EC2 console.</p><p>Select <strong>FleetCart AMI&gt; Actions &gt; Click Deregister AMI&gt; Deregister AMI. </strong>See diagrams below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*RfKxQpass9nfidkw" /></figure><p>We will also delete the snapshot of the FleetCart AMI. Under the <strong>Elastic Block Store</strong>, select <strong>Snapshots</strong> &gt; select FleetCart AMI &gt; Actions &gt; Click <strong>Delete snapshot, then Delete</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*SY_XJVAN0J23cOgJ" /></figure><p>We have successfully created the AMI and deleted the old AMI.</p><h4>Step 15: Create the Auto Scaling Group</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*l6uviEHItLwjWjk8" /></figure><p>In this step, we will create an auto-scaling group to dynamically create and scale the web servers in the private app subnet. Before we create an auto-scaling group, we will first terminate the EC2 instances we manually created. Head over to the <strong>Instance running</strong> under <strong>EC2 Dashboard. </strong>Select both <strong>Webserver AZ1</strong> and <strong>Webserver AZ2</strong>, click <strong>Instance state,</strong> and <strong>Terminate</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*Z5WC488NwGC0DFf_" /></figure><p>After terminating the EC2 instances, the next step before creating an auto-scaling group is to create a <strong>Launch Templates. </strong>Before we can create an Auto Scaling group using a launch template, we must create a launch template with the parameters required to launch an EC2 instance. These parameters include the ID of the Amazon Machine Image (AMI) and an instance type.<br>This launch template contains the configuration of the EC2 instances that the auto-scaling group will use to launch the new EC2 instances. In other words, A launch template provides full functionality for Amazon EC2 Auto Scaling. To create a Launch Template, let’s head over to the EC2 Instance service page, on the navigation pane, under <strong>Instances</strong>, choose <strong>Launch Templates</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*PPJy4AmCRiJSXsX-.png" /></figure><p>Click <strong>Create launch template</strong>. Enter a name and describe the initial version of the launch template, and Under <strong>Auto Scaling guidance</strong>, select the check box to have Amazon EC2 provide guidance to help create a template to use with Amazon EC2 Auto Scaling. See figure below</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*dReFVQC744UmSlLr" /></figure><p>Next, follow the information below and fill out each required field and any optional fields as needed.</p><p><strong>Application and OS Images (Amazon Machine Image)</strong>: Under<strong> </strong>the<strong> My AMIs </strong>tab, choose <strong>Owned by me, </strong>then select<strong> FleetCart AMI Version 2</strong></p><p>For<strong> Instance type</strong>: t2.micro (free tier)</p><p><strong>Key pair (login)</strong>: For the <strong>Key pair name</strong>, choose an existing key pair (the one you created)</p><p>Under<strong> Network Settings:</strong></p><ul><li><strong>Subnet Info</strong>: leave as default</li><li>For <strong>Firewall (security groups): </strong>choose <strong>Select existing security group</strong></li><li>Security groups: Select the <strong>Webserver Security Group</strong> we created</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_dNc8dN-Jo8oFEjk" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*DEzXF1gXtK9xmutG" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*QJWo5PfYx-EPw15n" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ENmEOPCMdTjUya7r" /></figure><p>Leave the rest of the settings as default and <strong>Create launch template</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*DdKUNM_7Jrq0SWFO" /></figure><p>Here we go! We have successfully created our <strong>launch template.</strong></p><p>We will go ahead and create our auto-scaling group. Ensure you choose the same AWS Region that you used when you created the launch template. Choose <strong>Create Auto Scaling group</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*HSrLB9vGXrPigZ5b.png" /></figure><p>On the <strong>Choose launch template or configuration</strong> page, let’s enter the following information:</p><ul><li>For <strong>Auto Scaling group name: </strong>enter a name for your Auto Scaling group. Dev-ASG</li><li>For the <strong>Launch template</strong>, choose the existing launch template we created</li><li>On the <strong>Choose instance launch options</strong> page, under <strong>Network</strong>, for <strong>VPC</strong>, choose Dev VPC we created. Note that the Auto Scaling group must be created in the same VPC as the security group you specified in your launch template.</li><li>For <strong>Availability Zones and subnets, </strong>we will select<strong> Private App Subnet AZ1</strong> and<strong> Private App Subnet AZ2 </strong>(check and ensure you select the correct subnets)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/711/0*YiPMhc13iO_R_3LI.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*7RUWUEbgFetveDeo" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*0v6l7joPsndutWbL" /></figure><p>Click next. Under <strong>Load balancing</strong>, we will attach our auto-scaling group with the ALB we created previously. Under <strong>Load balancing</strong>, select the following options:</p><ul><li>Attach to an existing load balancer</li><li>Choose from your load balancer target groups</li><li><strong>Existing load balancer target groups</strong>: select your target group</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*YaIFfAB-1YTZKyQqtVjkIA.png" /></figure><p>Under <strong>Health checks</strong>, and Monitoring, ensure to check “<strong>Turn on Elastic Load Balancing health checks</strong> and <strong>Enable group metrics collection within CloudWatch” </strong>then click <strong>Next</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*V29A2_ulPxXLHtD0YNDg7A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*zIYAGA1gosD98TkX1D3Yjw.png" /></figure><p>Under <strong>Group size, </strong>we will specify<strong> </strong>our <strong>Desired capacity</strong> to 2, <strong>Minimum capacity</strong> to 1, and <strong>Maximum capacity</strong> to 4. This means that the auto-scaling group will maintain 2 instances and scale down to a minimum of 1 instance and a maximum capacity of 4 instances. Leave everything else as default and click <strong>Next</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*kN3rBuHGKkk9fFspM2T9qQ.png" /></figure><p>On the <strong>Add notifications</strong> page, under SNS Topic, select the Cloudwatch topic we created earlier. If you don’t have one, click <strong>Create a topic </strong>to set up a Cloudwatch notification<strong>. Check </strong>all <strong>Event types</strong> and click <strong>Next</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*Kx5S7zMuEjs1zxz4Jcnp6w.png" /></figure><p>On the <strong>Add tags</strong> page, provide a tag key and value for each tag, and then choose <strong>Next</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*hnjOSWV7gYFRjwqSDpsBiA.png" /></figure><p>On the <strong>Review</strong> page, review your settings and choose <strong>Create Auto Scaling group</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*KRVUqulYUGjKd20OwSAYuQ.png" /></figure><p>Good job! We successfully created our auto-scaling group with the desired capacity of 2 instances. If we check our instances (from the EC2 dashboard), we should have 2 instances running as shown below (ensure that the instances pass the status check). These are instances created by the auto-scaling groups with tag names “ASG-Webserver”</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*eV9AR4rdZ8Fg6MU5" /></figure><p>Also, let’s make sure that the <strong>Health status</strong> of the <strong>Registered targets</strong> is healthy. We do this by going to <strong>Target Groups</strong> under <strong>Load Balancing </strong>on the EC2 Instance page. As shown below, we can see that the Registered targets are healthy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*lPG2hXqr50VmhckC" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*eWIV70gW6uIktRox" /></figure><p>After confirming that the instances have passed the status and our Registered targets are healthy, we can access our website. Open a new type and enter your domain name.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*SpuT2Lu_ygj0HwTB" /></figure><p>This is how we can create an auto-scaling group to dynamically create and scale the EC2 instances in the private app subnet.</p><h4>Clean up</h4><p>We will clean up our AWS services so they won’t incur costs. Ensure to clean up the services/resources as numbered below</p><ol><li>Auto-scaling group</li><li>Launch template</li><li>Application load balancer</li><li>Target group</li><li>RDS instance (You can create a final snapshot of this RDS. We will use it for a Terraform project. Watch out for the project soon!!)</li><li>Bastion host</li><li>Security groups</li><li>NAT gateway</li><li>VPC</li><li>Elastic IP</li><li>Record Set</li></ol><p>Create a snapshot of the RDS as shown below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/751/0*g2CtBu__5hKwOggh.png" /></figure><p>Congratulations on completing this project with me! I am so glad you made it. Let me know if you have any questions and I look forward to seeing you on my next project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Mj6pQFFP_hDmjRgI" /><figcaption>Photo by <a href="https://unsplash.com/@eilisgarvey?utm_source=medium&amp;utm_medium=referral">Eilis Garvey</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>follow me on Linkedin: <a href="https://www.linkedin.com/in/chidexhenry/">https://www.linkedin.com/in/chidexhenry/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3a8793046097" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deploy a WordPress Website on AWS]]></title>
            <link>https://medium.com/@chidexhenrytee/deploy-a-wordpress-website-on-aws-c7fb75ee1f1d?source=rss-7776e6eb71cc------2</link>
            <guid isPermaLink="false">https://medium.com/p/c7fb75ee1f1d</guid>
            <dc:creator><![CDATA[Henry Ukaegbu]]></dc:creator>
            <pubDate>Wed, 24 Jan 2024 05:20:19 GMT</pubDate>
            <atom:updated>2024-01-24T05:20:19.429Z</atom:updated>
            <content:encoded><![CDATA[<p>Using AWS services to deploy a WordPress Website in the management console.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qFpLMm-rpgT47tN5k1nsGA.png" /></figure><h4>Requirements</h4><ol><li>AWS Certified Cloud Practitioner CLF-C01</li><li>AWS Certified Solutions Architect — Associate SAA-C03<strong>Introduction</strong></li></ol><p>Welcome to our project on how to deploy a dynamic website on AWS. We will use reference architecture to host this website using various AWS services and how they work together. The AWS services we will use include the following:</p><ul><li>VPC with public and private subnets</li><li>Security groups</li><li>EC2 instances</li><li>NAT gateways</li><li>RDS</li><li>Application load balancer</li><li>Route 53</li><li>Auto Scaling Group</li><li>Certificate manager</li><li>Amazon Elastic File System and more</li></ul><h4><strong>We will divide the objectives into the following steps:</strong></h4><ol><li>Build a three-tier AWS network VPC from scratch</li><li>Create NAT gateways</li><li>Create the security groups</li><li>Create the RDS instance</li><li>Create the elastic file system (EFS)</li><li>How to create a key pair</li><li>Launch the Setup Server</li><li>SSH into an EC2 instance in the public subnet</li><li>Create an application load balancer</li><li>Create a record set in route 53</li><li>Register for an SSL certificate in the AWS certificate manager</li><li>Launch bastion host</li><li>SSH into an instance in the Private Subnet</li><li>Create an HTTPS listener for the application load balancer</li><li>Create an Auto Scaling Group</li><li>Install WordPress Theme and Template</li><li>Clean up</li></ol><p>I will make sure each step is simplified. By the end of this project, you should be able to successfully deploy your dynamic website on AWS. Let’s get started!</p><h4><strong>Step 1: Build a three-tier AWS network VPC from scratch</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MLxXfS6Ch4b_4-n4apaz3g.jpeg" /><figcaption>VPC Reference Architecture (Fig 1)</figcaption></figure><p>Figure 1 above describes a three-tier VPC architecture, and it’s explained as follows:</p><p>Tier 1 — Our Public Subnet will be located here, and will host resources such as the NAT Gateway, Load Balancer, and Bastion host.</p><p>Tier 2 — This is our private subnet that will hold the webservers such as the Amazon EC2 Instances</p><p>Tier 3 — This is another private subnet that will hold our databases</p><p>The 3 — tiers described above will be placed in the us-east-1a availability zone. For high availability and fault tolerance, we will duplicate these subnets in the us-east-1a availability zone as described in the architecture above. Let’s dive into the project in detail!</p><p>Navigate to the Amazon management console, and select the region for your VPC. From the architecture, we see that the region is in the us-east-1. Next, type VPC in the search bar or select VPC from the console and click Create VPC.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1grru7_9y1M--o7XIFSq_A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/0*Cu9MTAkOgzs1lak1.png" /></figure><p>Next, we will select VPC only and name our VPC “Dev VPC”. We leave it at the IPv4 CIDR block and based on our reference architecture we will enter <strong>10.0.0.0/16</strong> in the <strong>IPv4 CIDR block</strong>. Leave the <strong>IPv6 CIDR block </strong>and <strong>Tenancy </strong>to default, scroll down, and click <strong>Create VPC </strong>at the bottom right.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nPBCMW_--CEtSIu52CSDiw.png" /></figure><p>If your VPC is successfully created, you should see a message on your console that looks like the one below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/0*ZtPpz_dY5KgttG7L.png" /></figure><p>For you to see the VPC we created, click the drop-down arrow on the <strong>Select a VPC search box </strong>(click <strong>refresh</strong> if you don’t see the VPC we created). The VPC information is displayed as shown below. We will choose the VPC we just created “Dev VPC”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/0*zFqqJOXKNkyKcQ3Y.png" /></figure><p>Next, Let’s enable the DNS hostname in our VPC by selecting <strong>Actions </strong>and <strong>Edit VPC settings.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/827/0*RnweE5wo8x2V3qnd.png" /></figure><p>Under Edit <strong>VPC settings </strong>make sure that <strong>Enable DNS hostnames </strong>is checked then click <strong>Save. </strong>You will see a message that says “You have successfully modified the settings for …”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*N2Al6_4C0Xq_WP1hMb6SeA.png" /></figure><h4><strong>Internet Gateway</strong></h4><p>We will create an Internet gateway for our VPC. At the left side menu of <strong>Your VPC </strong>in the management console, click Internet Gateway and then select <strong>Create internet gateway </strong>as shown below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/0*rVD3C_-XG8MRYC5t.png" /></figure><p>Let’s give our internet gateway a name — <strong>Dev Internet Gateway </strong>and click <strong>Create Internet Gateway</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/0*WNNIW_qhhMZocKzq.png" /></figure><p>The diagram shown below shows that we have successfully our Internet Gateway and to allow the VPC we created earlier to connect and communicate with the Internet, we will attach it to the Internet Gateway. To do that, click; <strong>Attach to the VPC</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/0*tCkfcLnNrkvbvO__.png" /></figure><p>Select the Dev VPC that we created and click <strong>Attach Internet gateway.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/0*Ctlb-0Aw4fv0xMim.png" /></figure><p>We have successfully attached the internet gateway to our VPC. The Details below show the <strong>State </strong>and the <strong>VPC ID</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/865/0*ckkxWcjaIaf2TQXO.png" /></figure><h4><strong>Public Subnets</strong></h4><p>Once we have our VPC setup, next, we create our <strong>public subnets</strong> in the first and second availability zones. Ensure that you have your VPC filtered to the Dev VPC and then at the right corner of your console, click <strong>subnets. </strong>Once you are on the subnet page, click <strong>Create Subnet</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GVro3M8ga9JgEreb_Mimow.png" /></figure><p>Select the VPC where you want our public subnet to be — Dev VPC</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*auQGF-PSPJ1vg8vOdrpKlQ.png" /></figure><p>Regarding our architecture, we will call our subnet — <strong>Public Subnet AZ1 and </strong>put this subnet in the<strong> us-east-1a-availability zone. The CIDR block </strong>should be<strong> 10.0.0.0/24. Click Create subnet</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EK_r9DpmQr6dMHSyTQoQQg.png" /></figure><p>The figure below shows that we have successfully created our first public subnet in the us-east-1a Availability Zone.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*r5LarVM0Q7K9fJ2TQ_CnuA.png" /></figure><p>Next, we will create our second public subnet in the us-east-1b Availability Zone — <strong>Public Subnet AZ2</strong>. It is the same process as the public subnet AZ1 except that we have to choose the us-east-1b instead of us-east-1a. Don’t forget to filter our VPC to the Dev VPC. Regarding our architecture, we will call our subnet — <strong>Public Subnet AZ2 and </strong>put this subnet in the<strong> us-east-1b-availability zone. The CIDR block </strong>should be<strong> 10.0.1.0/24 (Note the changes in the CIDR block). Click Create subnet.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*F5FTKbxX3JHZ2-b7xLJb4A.png" /></figure><p>The figure shows that we have successfully created our second public subnet in the us-east-1b Availability Zone (this depends on your region)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Zj0lHSCVJIhwNuBaMBV0mA.png" /></figure><p>If you select <strong>Clear filters and filter to our Dev VPC, </strong>it shows the 2 subnets that we created in these regions. The figure below shows the public subnets we have created so far. Ensure that the two public subnets are in different Availability Zones (AZ1), <strong>us-east-1a and us-east-1b respectively</strong>. Good job!!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UVjEyVOONweUI1Y7kKtlkg.png" /></figure><p>Anytime EC2 Instances are launched in these public subnets, a public IPv4 address will be assigned to these instances, hence, the need to enable<strong> Auto assign IP settings</strong> for these two public subnets. With reference to the fig. above, check public subnet AZ1 and <strong>click Actions</strong>. From the drop-down menu, click <strong>Edit subnet settings</strong>. Under <strong>Edit subnet settings and Auto-assign IP settings </strong>check the <strong>Enable auto-assign public IPv4 address </strong>and click save (bottom right when you scroll down). See fig. below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qQVPN7XXV6fWE8blmYC9DQ.png" /></figure><p><strong>Public subnet AZ2 (Check the subnet and follow the same steps)</strong>. Great job! We have successfully enabled the <strong>auto-assign public IPv4 address </strong>for the two public subnets. So far we have created the Internet Gateway and two public subnets for our VPC. Let’s keep going!!</p><p>Recall from our reference architecture, the next is to create a <strong>Public Route Table. </strong>The Route Table will route traffic to the internet(see the<strong> </strong>reference architecture below to refresh our memory)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rNug8ydGxhREUai-sWZ2Fw.png" /></figure><p>From the VPC setup page, locate and click <strong>Route tables</strong> from the left side of the page (still filtered by the Dev VPC). The Route table shown below is the default table also referred to as the main table and it’s private by default. <strong>Click Create route table.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*TYXzLXcfnVkUMdJGBu2CZA.png" /></figure><p>Under Name, Type,<strong> Public Route Table</strong>, and ensure that you select <strong>Dev VPC</strong> under VPC and <strong>Key </strong>and <strong>Value</strong> type in <strong>Name</strong> and <strong>Public Route table. </strong>Click<strong> Create route table.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*qB6xkx1TwqttLKT3lMuW_w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/679/1*4892i9YwKQ8mYwFWoJtq7w.png" /></figure><p>Good job! We have successfully created our Public Route Table as shown below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*PtmKWossCrmCyqSA4LY9Ig.png" /></figure><p>To allow the Public Route Table to route traffic to the internet, we will have to add a route to the Public Route Table. As shown below, click on the <strong>Routes tab </strong>and then<strong> Edit routes</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*bVwZfcJs1qEoYv5ZAK7FXA.png" /></figure><p>On the <strong>Edit Routes</strong> page, click on<strong> Add Route. </strong>Under<strong> Destination, type inside the box 0.0.0.0/0 </strong>to replace<strong> 10.0.0.0/16. </strong>Also, under<strong> Target, </strong>click inside the box and choose<strong> Internet Gateway igw- the # (Dev Internet Gateway). </strong>Click<strong> Save changes</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*uYUe-JENl6-yalhAm-9n5w.png" /></figure><p>We successfully added a route to our public route table. We can view it under the <strong>Routes tab. </strong>Next, we will associate the two public subnets, AZ1 and AZ2, with this route table. Ensure that we are still under the <strong>Public Route Table page. </strong>Locate and click on<strong> the subnet association tab, then </strong>click on<strong> Edit subnet associations. </strong>On the<strong> Edit subnet associations page, </strong>we see that<strong> </strong>the two public subnets are listed. Check both public subnets and click <strong>Save associations.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*sgYMdZX6LPGagkz5_uw1-A.png" /></figure><p>Good job! We have associated the two public subnets that we created with the Public Route Table. To confirm, we can see the subnets under the <strong>Subnet associations</strong> tab as shown below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*0cxagxFEiTGP0DwSt0TZ7A.png" /></figure><h4><strong>Private Subnets</strong></h4><p>With reference to our architecture, we will need to create 4 private subnets to finish setting up our Dev VPC. Still, on the VPC page, ensure you filter by Dev VPC and click Create subnet. On the Create subnet page, under VPC ID choose Dev VPC and Our CIDR block should be <strong>10.0.2.0/24. </strong>Click<strong> Create subnet</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*auQGF-PSPJ1vg8vOdrpKlQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*G7qu_WGB_tVMLjpk.png" /></figure><p>Great! We have successfully created our 1st private subnet, <strong>Private App Subnet AZ1</strong>, in the us-east-1a Availability Zone. Using the same processes above, let’s create the remaining 3 private subnets using the settings below and referring to our reference architecture:</p><p><strong>2nd Subnet</strong></p><p>VPC ID: Dev VPC</p><p>Subnet name: Private App Subnet AZ2</p><p>Availability Zone: us-east-1b</p><p>IPv4 CIDR block: 10.0.3.0/24</p><p><strong>3rd Subnet</strong></p><p>VPC ID: Dev VPC</p><p>Subnet name: Private Data Subnet AZ1</p><p>Availability Zone: us-east-1a</p><p>IPv4 CIDR block: 10.0.4.0/24</p><p><strong>4th Subnet</strong></p><p>VPC ID: Dev VPC</p><p>Subnet name: Private Data Subnet AZ2</p><p>Availability Zone: us-east-1b</p><p>IPv4 CIDR block: 10.0.5.0/24</p><p>Great job! We have successfully created all 4 Private Subnets, making 6 subnets in total including the 2 public subnets. To see the list, click <strong>Clear Filters </strong>and filter it by <strong>Dev VPC. </strong>As shown below, review and ensure that each subnet is placed in the right<strong> AZs and AZ ID </strong>(compare with the list of the subnets)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*jF7ZsLZ3T8pMLzQaNTgNXg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/768/1*5OniW-ADm2rYhok3ZV6pQg.png" /></figure><p>Let’s quickly dive into the basic <strong>difference between public and private subnets</strong>. A public subnet is associated with a route table that can route traffic to the internet. In other words, when we create a route table and add a route to the route table to route traffic to the internet, any subnet associated with the route table is a public subnet.</p><p>On the other hand, when we have a route table that does not have a route to the internet, any subnet associated with the route table is a private subnet. By default, any subnets associated with the <strong>main route table are private</strong></p><h4>Step 2: Create NAT (Network Address Translation) Gateways</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*409UlSO-PN9LP0KBeIzbjQ.jpeg" /><figcaption><strong>NAT Gateway Reference Architecture</strong></figcaption></figure><p>With reference to our architecture, the NAT Gateways will allow instances in the private subnets; <strong>Private App, and Private Data Subnets</strong> to access the internet. As shown in the architecture Fig above, we will create a NAT gateway in the first and second availability zones. Check to see if you are still in the same region where we created our Dev VPC (N. Virginia us-east-1). NAT Gateway is located on the VPC Page. In the search box, type and click VPC</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*vFOhpJ8yaBLpX5uD.png" /></figure><p>As shown below, at the left corner of the VPC page, select NAT gateways and click Create NAT gateway;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*HAfg8_z8asWUM9Rk.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*E9VqzgCW1QJFst9L.png" /></figure><p>Under Name, type <strong>NAT gateway AZ1</strong> click on the drop-down arrow under <strong>Subnet,</strong> and select <strong>Public Subnet AZ1</strong>. Leave the C<strong>onnectivity type</strong> on <strong>Public</strong> and click <strong>Allocate Elastic IP.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*n58f542sVGMB790yNNAc4Q.png" /></figure><p>Review and click<strong> Create NAT gateway. </strong>You should see a successful page as shown below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*M8LC5ypeqgzDSUQgVBWBZA.png" /></figure><p>Next, we create a route table and name it <strong>Private Route Table AZ1</strong>. Still, on the VPC page, locate the <strong>Route tables at the left side of your screen </strong>and click on it. Make sure to select Dev VPC and under Tags, fill in the boxes as shown below and click <strong>Create route table</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*52ZTX_EbulZ3QdN8.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*0XDlB35wYotIK-g4N5S46w.png" /></figure><p>You should see a successful page as shown below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*jR1xdhXfyPGD47lo.png" /></figure><p>Next is to add a route to the <strong>Private Route Table AZ1</strong> that we just created, to route traffic to the internet through the <strong>NAT Gateway</strong> in the <strong>Public Subnet AZ1. </strong>Scroll down and locate<strong> the Routes tab </strong>and on the right corner click<strong> Edit routes then Add route as shown below;</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*qJxBq-hKHZcZMoQJ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*4e4s-mV8DyEx98-x.png" /></figure><p>Under <strong>Destination</strong>, replace 10.0.0.0/16 with the Internet traffic of 0.0.0.0/0. Under <strong>Target, </strong>click inside the box and replace<strong> local </strong>with<strong> NAT gateway AZ1. Locate NAT Gateway </strong>(ensure that you don’t select Internet Gateway) and click on it<strong>, NAT gateway AZ1 </strong>should appear, and then click<strong> save changes.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*wKMdRuFHreL7gRmelL4vNw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*MPFcSgKCcCtfQrjnX551lg.png" /></figure><p>We have successfully added a route to our private route table. To view it, scroll down, we will see the added route displayed under the <strong>Routes</strong> as shown below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*bYiU0a4iA4aSkLAQE6Vb4w.png" /></figure><p>Next, we will associate <strong>Private Route Table AZ1</strong> with <strong>Private App Subnet AZ1</strong> and <strong>Private Data Subnet AZ1. To do that, locate and select the Subnet associations</strong> tab, and at the right corner click <strong>Edit subnet associations.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*ur8OqNHZxGbGVsAqo6IanQ.png" /></figure><p>On the <strong>Edit subnet associations page, </strong>we will see the available subnets list that needed to be selected. Check the <strong>Private App Subnet AZ1</strong> and <strong>Private Data Subnet AZ1 boxes, </strong>then click <strong>Save associations as shown below</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*cUtDCfwflGo7NfZcntpfcQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*1B2sZlDqcge6tU1Mqwac4Q.png" /></figure><p>Great job! We have successfully associated <strong>Private App Subnet AZ1</strong> and <strong>Private Data Subnet AZ1 </strong>to the <strong>Private Route Table AZ1</strong> as shown under <strong>Explicit subnet associations</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*wkvAFJdI5zXDn4v5pSLPdQ.png" /></figure><p>We are making progress! we have succeeded in creating our first<strong> NAT Gateway</strong> in the <strong>Public Subnet AZ1</strong>. Let’s proceed to create our second <strong>NAT Gateways</strong> in the <strong>Public Subnet AZ2</strong>. We will follow the same procedures as how we created the first NAT Gateway.</p><p>follow the same procedures as <strong>NAT Gateways AZ1</strong>. When you get to the <strong>NAT gateway settings</strong>, fill in the boxes as shown below (ensure that you click <strong>Allocate Elastic IP</strong>)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*mkeIJDvgWIMyXDnZtlsZQQ.png" /></figure><p>After you have successfully created the <strong>NAT Gateway AZ2</strong>, you should see a similar Fig below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*uS78izAUwDo9i99aBy2hog.png" /></figure><p>Same as NAT Gateway AZ1, we create our Private Route Table and associate this table to the <strong>Private</strong> <strong>App Subnet AZ2 </strong>and <strong>Private Data Subnet AZ2. </strong>Again, we will follow the same as we did in<strong> </strong>Private Route Table AZ. Name this second table — <strong>Private Route Table AZ2. </strong>When you get to the<strong> Create route table </strong>page, fill in the boxes as shown below and click<strong> Create route table</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/691/1*s14_rMvajnHR1gqkjKFFGw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*UjR2SSxE4EDac6QOYyJPbQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UbyqRguqXeUNcjQ8KIQAeg.png" /></figure><p>Also, add a route to the <strong>Private Route Table AZ2</strong>, to route traffic to the internet through the <strong>NAT Gateway</strong> in the <strong>Public Subnet AZ2. </strong>Scroll down and locate<strong> the Routes tab </strong>and on the right corner click<strong> Edit routes then Add route </strong>as shown below.<strong> Under Destination, </strong>type<strong> 0.0.0.0/0, </strong>and under<strong> Target </strong>choose,<strong> NAT Gateway AZ2 </strong>and click <strong>Save changes.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*VcCG30OK-8vOH7Ns3ilIMQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*kSfMJbqiPF7FAlmPG8RpPQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*tTGZ-gUVPbgnm3MuqQER8g.png" /></figure><p>As we did before, we will associate <strong>Private Route Table AZ2</strong> with <strong>Private App Subnet AZ2</strong> and <strong>Private Data Subnet AZ2. </strong>To do that<strong>, </strong>locate and select the<strong> Subnet associations</strong> tab, and at the right corner click <strong>Edit subnet associations.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*ur8OqNHZxGbGVsAqo6IanQ.png" /></figure><p>Check the <strong>Private App Subnet AZ2</strong> and <strong>Private Data Subnet AZ2 boxes, </strong>then click <strong>Save associations as shown below</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*yGhHRGKqzijJVXkA7tuYHA.png" /></figure><p>We have successfully updated the subnet associations for <strong>Private Route Table AZ2 </strong>as shown under <strong>Explicit subnet associations</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*PxRuWAMh7ue9b94cuQq0Hg.png" /></figure><p>Good job! We have completed this step — create <strong>NAT gateways</strong>. Through the NAT gateways, our resources in the private subnets will have access to the internet.</p><h4>STEP 3: Create Security Groups</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sn8GF-7SAZBqQ__aFEyCJg.jpeg" /><figcaption>WordPress Security Group Reference Architecture</figcaption></figure><p>The reference architecture above describes in parts the security groups we will create for this project. On the right side of the architecture is the breakdown of the security group parts. The parts are as follows:</p><ul><li><strong><em>ALB(Application load balancer) Security Group</em> — </strong>Port: 80 and 443 with Source: 0.0.0.0/0</li><li><strong><em>SSH Security Group</em> — </strong>Port: 22 with Source: Your IP Address</li><li><strong><em>Webserver Security Group</em> — </strong>Port: 80 and 443 with Source: ALB Security Group, Port: 22 with Source: SSH Security Group</li><li><strong><em>Database Security Group </em>— </strong>Port: 3306 Source: Webserver Security Group</li><li><strong><em>EFS Security Group</em> — </strong>Port: 2049 Source: Webserver Security Group, EFS Security Group, Port: 22 Source: SSH Security Group</li></ul><p>Let’s start with the first part; <strong>ALB Security groups</strong>! The security group can be found on the VPC page. So, type VPC in the management console home and click it. On the left-hand side of the page locate and click <strong>Security Groups</strong> under the <strong>Security</strong> drop-down arrow. Then click <strong>Create security group.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*KDK7tDtRbjdJqoNp.png" /></figure><p>Enter the following information settings:</p><p><strong>Basic details</strong></p><ul><li>Security group name: ALB Security Group</li><li>Description: ALB Security Group</li><li>VPC: Dev VPC</li></ul><p><strong>Inbound rules</strong></p><p><strong>1st rule</strong></p><ul><li>Type: HTTP</li><li>Protocol: TCP</li><li>Port range: 80</li><li>Source: 0.0.0.0/0</li></ul><p><strong>2nd rule</strong></p><ul><li>Type: HTTPS</li><li>Protocol: TCP</li><li>Port range: 443</li><li>Source: 0.0.0.0/0</li></ul><p>Once you entered the information, click <strong>Create security group</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*9lg420NaAzBwhkb-TLiXAA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*Gnweu5iLs78D6U9KQU_qQQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*zVIXPHv3CrAnUlG6mzLilw.png" /></figure><p>Below Fig shows that you have successfully created the ALB security group</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*tpRp1F5SxUfzH3-V4wFv9Q.png" /></figure><p>For<strong> SSH Security Group; </strong>click <strong>Security Groups </strong>to go back one directory and click Create <strong>Security Groups</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1dhWpiyFBFi1fJasovQtTw.png" /></figure><p>Enter the following settings and click <strong>Create security group</strong> as shown in the Fig below:</p><p><strong>Basic details</strong></p><ul><li>Security group name: SSH Security Group</li><li>Description: SSH Security Group</li><li>VPC: Dev VPC</li></ul><p><strong>Inbound rules</strong></p><ul><li>Type: SSH</li><li>Protocol: TCP</li><li>Port range: 22</li><li>Source: My IP</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*g-IrajxYjEB5Tn-MPDJoJA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*1fH5K5Buc38Wwoku3C3FGA.png" /></figure><p>Next is <strong>Webserver Security Group</strong>. Follow the same procedures as above, enter the following settings, and click <strong>Create security group</strong>:</p><p><strong>Basic details</strong></p><ul><li>Security group name: Webserver Security Group</li><li>Description: Webserver Security Group</li><li>VPC: Dev VPC</li></ul><p><strong>Inbound rules</strong></p><p><strong>1st rule</strong></p><ul><li>Type: HTTP</li><li>Protocol: TCP</li><li>Port range: 80</li><li>Source: ALB Security Group</li></ul><p><strong>2nd rule</strong></p><ul><li>Type: HTTPS</li><li>Protocol: TCP</li><li>Port range: 443</li><li>Source: ALB Security Group</li></ul><p><strong>3rd rule</strong></p><ul><li>Type: SSH</li><li>Protocol: TCP</li><li>Port range: 22</li><li>Source: SSH Security Group</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*7EX5gUOU9USD069OkQavMA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*mx3jYf6QNF0H1EWI6UJcUQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*MgvLzfwo1iBdkr1nid9-YQ.png" /></figure><p>Next is the <strong>database security group</strong>. Enter the following information below then click <strong>Create security groups. </strong>See fig. below</p><p><strong>Basic details</strong></p><ul><li>Security group name: Database Security Group</li><li>Description: Database Security Group</li><li>VPC: Dev VPC</li></ul><p><strong>Inbound rules</strong></p><ul><li>Type: MYSQL/Aurora</li><li>Protocol: TCP</li><li>Port range: 3306</li><li>Source: Webserver Security Group</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*8nhUNw3Nx9j0tCO0uqJ-lA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*SRpZh2Q6ZciKI910D67YwA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*aUW7Q8HDTGkch3ONbinqLw.png" /></figure><p>The last security group we will create for this is the EFS security group. Also, enter the following information below then click <strong>Create security group</strong></p><p><strong>Basic details</strong></p><ul><li>Security group name: EFS Security Group</li><li>Description: EFS Security Group</li><li>VPC: Dev VPC</li></ul><p><strong>Inbound rules</strong></p><p><strong>1st rule</strong></p><ul><li>Type: NFS</li><li>Protocol: TCP</li><li>Port range: 2049</li><li>Source: Webserver Security Group</li></ul><p><strong>2nd rule</strong></p><ul><li>Type: SSH</li><li>Protocol: TCP</li><li>Port range: 22</li><li>Source: Webserver Security Group</li></ul><p><strong>3rd rule</strong></p><ul><li>Type: NFS</li><li>Protocol: TCP</li><li>Port range: 2049</li><li>Source: EFS Security Group</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EJ226odE5yPpt1qIVSEHqQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qW2Vrjc9BXSs9GASxd54_A.png" /></figure><p>Review all the security groups we created on the security group page, and filter them to the Dev VPC. Your list of all security groups should look like the Fig below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*o6OtqmNzdsVgidnJ.png" /></figure><h4>Step 4: Create the RDS (Relational Database Service) Instance</h4><p><strong>What is an AWS RDS?</strong></p><p><strong>Amazon Relational Database Service (Amazon RDS) is a web service that makes it easier to set up, operate, and scale a relational database in the cloud</strong>. It provides cost-efficient, resizable capacity for an industry-standard relational database and manages common database administration tasks, freeing up developers to focus on what makes their applications and businesses unique. <strong>Amazon RDS gives you access to the capabilities of MySQL, MariaDB, PostgreSQL, Microsoft SQL Server, Oracle, or Amazon Aurora database server.</strong> Amazon RDS automatically backs up your database and maintains the database software that powers your DB instance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gjs_2bjIxVa_MinmkcDzIw.jpeg" /><figcaption>WordPress RDS Reference Architecture</figcaption></figure><p>With reference to our architecture above, the RDS Instance will be created in the private data subnets. But before we create our RDS, we will first create subnet groups — this allows us to specify which subnets we want to create our RDS database in. Let’s start!</p><p>On the management console page, type <strong>RDS</strong> in the search box, locate, and select <strong>RDS</strong>. At the bottom left corner of the <strong>RDS</strong> page, locate, and click <strong>Subnet groups</strong>. Then, click <strong>Create DB subnet group. </strong>See the figures below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JEUPwK5M2QsLS3WjLFroIA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*F5t7ArL8ADVT6WtL.png" /></figure><p>Enter the information settings below and click <strong>Create:</strong></p><p><strong>Subnet group details</strong></p><p>Name: <em>Database subnets</em></p><p>Description: <em>Database subnets</em></p><p>VPC: <em>Dev VPC</em></p><p><strong>Add subnets</strong></p><p>Availability Zones: choose <em>us-east-1a and us-east-1b</em> availability zones</p><p>Subnets: select subnet with <em>CIDR block 10.0.5.0/24</em> and subnet with <em>CIDR</em> <em>block 10.0.4.0/24</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*zXh3Iz7aF0994vSmhR_D_g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*_rFo5QRWoh670OWN.png" /></figure><p>Now that we have created our subnet groups, Let’s create the database. Select <strong>Database </strong>and click <strong>Create database</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*enalghMpUxcOwqqk.png" /></figure><p>Select the information below:</p><p>Choose a database creation method: <em>Standard create</em></p><p>Engine options: <em>MySQL</em></p><p>Engine Version: <em>MySQL 5.7.37 or the latest</em></p><p>Templates: <em>Dev/Test</em></p><p>Availability and durability: <em>Single DB instance</em></p><p><strong>Settings</strong></p><p>DB instance identifier: <em>Type a name for your DB instance</em></p><p>Credentials Settings: <em>Provide your master username, and password, and confirm the password. make sure you take note of your username and password so you don’t forget</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*Qt_zQTT9Llk6fpg8.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*_to4pBYLVkpdtOw7.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*zJzGzGpti90IB0bY.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*A5IPklTuRsnz36mHXlYu2A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*25haywYBPivSmXOfzg5nVw.png" /></figure><p><strong>Instance configuration</strong></p><p>DB instance class: <em>Burstable classes (includes t classes)</em></p><ul><li><em>select db.t2.micro</em></li></ul><p>Include previous generation classes: enabled</p><p><strong>Storage: </strong><em>Leave this as the default</em></p><p><strong>Connectivity</strong></p><p>Compute resources: Select Don’t connect to an EC2 compute resource</p><p>Network type: IPv4</p><p>Virtual private cloud (VPC): Dev VPC</p><p>DB subnet group: Ensure that the 2 subnet groups we created earlier are selected</p><p>VPC security group (firewall): Choose existing</p><p>Existing VPC security groups: Database Security Group</p><p>Availability Zone: us-east-1b — This is where you choose the AZ you want to create the master database in</p><p>Database authentication: Select password authentication</p><p><strong>Additional configuration</strong></p><p>Database options: Specify your <strong>Initial database name </strong>and leave other boxes as default. Make sure you specify the initial database name the database creation will not complete</p><p>See the figures below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*ZmIBE057pEEEZEq_m-kRzQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MhvTxu9OeDjsM7dwA1alqw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*dJHBHLyAs6MS5Tpp.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*LS_F_loiWmQy63f0.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*w_aIfEtax48FC-KcDak3iQ.png" /></figure><p>Leave other settings as default, review, scroll down, and click <strong>Create database</strong>. This will take a while to complete. Click <strong>View credential details</strong> and take note of your credentials because <strong>once we create the RDS instance, we won’t have access to the credentials</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*Ss7hexxKHHS5224J.png" /></figure><p>The figure below shows the completion of the database. The <strong>Status</strong> should say <strong>available</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*MLSm8Jw8hqLL2Exr.png" /></figure><p>Great job! We have successfully created an RDS instance with the MYSQL engine</p><h4>Step 5: Create the Elastic File System (EFS)</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*A7CxvTeyQb_HUoBGXBClfQ.png" /><figcaption>Elastic File System (EFS) Reference Architecture</figcaption></figure><h4>Elastic File System (EFS) Reference Architecture</h4><p><strong>What is AWS EFS?</strong></p><p><strong>Amazon Elastic File System (Amazon EFS) provides serverless, fully elastic file storage so that you can share file data without provisioning or managing storage capacity and performance.</strong></p><p>Amazon EFS is used so that the webservers can have access to shared files and the webservers will use the mount targets in each availability zones in the VPC, to connect to the EFS. The mount targets will be created in the private data subnets in each AZ. Therefore, the EFS will allow the webservers in the private app subnets to pull the application code and configuration files from the same location.</p><p>Let’s start! Head over to the management console, type EFS in the search box, and click EFS. On the EFS page, click <strong>Create file system. </strong>See figures below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vgxjG6Wr9RuCXia2ZV1Vtg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*N0jDHd_fW2HlgPpFUqW2NQ.png" /></figure><p>Select <strong>Customize</strong> on the <strong>Create file system page.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kd6O2bYwZdxNbqFlB90NyQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*y51ojL5GtYqoJk-hzIsYSA.png" /></figure><p>Under File system settings, give any name to your file system and uncheck <strong>Enable encryption of data at rest</strong> so we don’t get charged. For the rest of the boxes, leave them as default. Scroll down to the <strong>Tags</strong> and enter the following information:</p><p><strong>Tags</strong></p><p>Tag key: Name</p><p>Tag value: Enter the same name as the EFS file system name</p><p><strong>Network access</strong></p><p>VPC: Dev VPC</p><p><strong>Mount targets</strong></p><p>Availability zone: choose <strong>us-east-1a and us-east-1b</strong></p><p>Subnet ID: Select <strong>private data AZ1 and private data AZ2</strong></p><p>IP address: Leave it as default — Automatic</p><p>Security groups: Choose <strong>EFS Security Group </strong>and click<strong> next</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*r12Dh7HCzvI1Sar0_by6Bg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Y6nJDKC4D75cJLUatOp5Cw.png" /></figure><p>Leave the <strong>File system policy page </strong>as default and click <strong>Next. </strong>Review the settings and click<strong> Create</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*u6kQcFT-KXf2647c.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*NESb71csmnY9nrgl.png" /></figure><p>Great job! We must view the detailed information on the mount targets. From the figure above, click on the <strong>File system ID</strong>. Then click <strong>attach</strong>. We can find information to mount the file system on the displayed page below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FVvrLFNVY7ISCg2G3HTUgg.png" /></figure><p>Well done! We are done creating the Elastic File System (EFS)</p><h4>Step 6: Create a Key Pair to SSH into EC2 Instances</h4><p>It is important to create a key pair to connect to our Amazon EC2 instances. I completed a project on how to create a key pair. The link below will take you to the project.</p><p><a href="https://medium.com/@chidexhenrytee/how-to-create-amazon-ec2-key-pairs-bde2f02dcfd8">How to Create Amazon EC2 Key Pairs</a></p><p>After completing and creating the key pair, you can come back to this project and continue from step 7.</p><h4>Step 7: Launch the Setup Server (EC2 Instance)</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_DPw4KEkrb76brKHs-FU0A.png" /></figure><p>In this part of the project, an EC2 instance (Setup Server) will be launched to allow us to install WordPress in the public subnet AZ1. In other to launch the EC2 Instance, let’s head over to the management console. Type EC2 in the search bar and either you click <strong>Launch instance</strong> or on the left side click <strong>Instances</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zwMG5l50YYGrQqkuW68QFA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ow8WA-oepiyQA7lQPLFSpA.png" /></figure><p>Carefully enter the following information and see the figures below:</p><p><strong>Launch an instance</strong></p><ul><li>Name and tags: <strong>Key</strong> — type Name, <strong>Value </strong>— Setup Server</li></ul><p><strong>Application and OS Images (AMI)</strong></p><ul><li>Select the <strong>Quick Start</strong> tab and select <strong>Amazon Linux 2 AMI Free tier</strong></li></ul><p><strong>Instance type: </strong>Instance type — select t2.micro (Free tier eligible)</p><p><strong>Key pair (login): key pair name — </strong>select the key pair we created in step 6 (myec2key)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*hur4-0SrQQ9oXCvUrZ1x4A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*4QpVzgbWWl4w8VT4s8jHYw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*DEmANvHtHseiSkdj3X_8Bg.png" /></figure><p><strong>Network settings</strong></p><ul><li>click <strong>Edit</strong></li><li>VPC: select Dev VPC</li><li>Subnet: Public Subnet AZ1</li><li>Auto-assign public IP: Enable</li></ul><p><strong>Firewall (security groups)</strong></p><ul><li>Select <strong>existing security group</strong></li><li>Click on the drop-down and select these security groups: <strong>SSH, ALB, and Webserver Security Group </strong>(Recall that we created these security groups earlier). Review them by expanding + icon</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*CpYhILky7pkeIUBD2D4Ovg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*GiTN4JvpIkyOssMIMu5m7w.png" /></figure><p>Under <strong>Advanced details</strong> page, leave all the boxes as default. before you launch the instance, you can have a quick review of the summary of the EC2 instance on the right side as shown below. After the review, click <strong>Launch instance</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/469/0*lvL_W3dBylVwaGTF.png" /><figcaption>Summary of the Setup Server</figcaption></figure><p>Click the instance ID to view the instance. The instance becomes ready when the <strong>Instance state</strong> and <strong>Status check</strong> status say <strong>Running</strong> and <strong>checks passed. </strong>We have successfully launched the EC2 instance (Setup Server). Great job!</p><h4>Step 8: SSH Into an EC2 Instance in the Public Subnet</h4><p>After you launch an instance, it can take a few minutes for the instance to be ready so that you can connect to it. Check that your instance has passed its status checks. You can view this information in the <strong>Status check</strong> column on the <strong>Instances</strong> page. To SSH into an EC2 Instance in the Public Subnet, follow the link below. After completing the project, come back to this project and move to the next step</p><p><a href="https://medium.com/@chidexhenrytee/how-to-ssh-into-your-public-ec2-instance-for-linux-mac-os-windows-powershell-e8ad627d213d">How to SSH into your Public EC2 Instance for Linux/Mac OS/Windows PowerShell</a></p><h4>Step 9: Install WordPress</h4><p>Once you have SSH into your setup server, we will run some commands to install our WordPress site and move the file to the EFS. Before we run these commands, we will have to update the mount information of our EFS. Let’s head over to the management console. Type EFS in the search box and select EFS. On the EFS page, select your <strong>EFS ID </strong>and<strong> </strong>click<strong> attach </strong>as shown below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*tFIOEQKnYq2WD_El.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*H9iIeEnW7vhNWpI-.png" /></figure><p>From your <strong>attached</strong> page, copy from <strong>“fs to .com”</strong> and replace it with the first command as displayed below. Then copy the whole first command and paste it into your bash terminal.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FVvrLFNVY7ISCg2G3HTUgg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m4L9t7ZDjJ9R28bQ58TsEQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*1jdDwUhQWd_WFi8H" /></figure><p>After pasting the first command, we need to check if our EFS was mounted correctly. Type “df -h”(with a space)into your shell prompt and press enter. You should have the same information as the one above. This means that our EFS was mounted properly. Now, we are ready to proceed to the rest of the commands. We will copy and paste the commands from #2 to #7 (with their respective meanings). After you paste each command, ensure that you wait for the shell prompt to appear before proceeding to the next command.</p><p>Note: <strong>Copy commands, one after the other. Do not copy and paste all commands at once</strong></p><pre>#2. install apache <br>sudo yum install -y httpd httpd-tools mod_ssl<br>sudo systemctl enable httpd <br>sudo systemctl start httpd<br><br><br>#3. install php 7.4<br>sudo amazon-linux-extras enable php7.4<br>sudo yum clean metadata<br>sudo yum install php php-common php-pear -y<br>sudo yum install php-{cgi,curl,mbstring,gd,mysqlnd,gettext,json,xml,fpm,intl,zip} -y<br><br><br>#4. install mysql5.7<br>sudo rpm -Uvh https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm<br>sudo rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022<br>sudo yum install mysql-community-server -y<br>sudo systemctl enable mysqld<br>sudo systemctl start mysqld<br><br><br>#5. set permissions<br>sudo usermod -a -G apache ec2-user<br>sudo chown -R ec2-user:apache /var/www<br>sudo chmod 2775 /var/www &amp;&amp; find /var/www -type d -exec sudo chmod 2775 {} \;<br>sudo find /var/www -type f -exec sudo chmod 0664 {} \;<br>chown apache:apache -R /var/www/html <br><br><br>#6. download wordpress files and move the files to the html directory <br>wget https://wordpress.org/latest.tar.gz<br>tar -xzf latest.tar.gz<br>cp -r wordpress/* /var/www/html/<br><br><br>#7. create the wp-config.php file<br>cp /var/www/html/wp-config-sample.php /var/www/html/wp-config.php<br></pre><p>You made it this far, good job! Once we create the wp-config.php file, we will edit it to enter the information of our RDS instance. The next command (# 8 command) will open the nano text editor on our EC2 instance and we will edit our RDS information in the text editor. Once you paste the command and press enter, it will open the nano editor as displayed below. Recall that we created the RDS instance in step 4 and asked to take note of our credential details.</p><pre>#8. edit the wp-config.php file<br>nano /var/www/html/wp-config.php </pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/910/1*Cj94sc7YFzLsn4QeHpRfhg.png" /><figcaption>Nano Editor</figcaption></figure><p>Press the down arrow on your mouse key or keyboard till you get to the line below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/431/0*KrG7pVr_66BwLY13.png" /></figure><p>The right arrow should take us to where we will need to enter our RDS instance information. Let’s head over to the RDS instance page in the management console, and fill in the necessary information. select your RDS instance under the <strong>DB identifier</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*JEUPwK5M2QsLS3WjLFroIA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*MLSm8Jw8hqLL2Exr.png" /></figure><p>On the RDS instance page, under the <strong>configuration tab</strong>, we will need our <strong>“DB name (DB_NAME) — Applicationdb”</strong> and “<strong>Master username (DB_USER) — chidex”</strong>, to fill them in the nano editor. Also, under the <strong>Database password</strong>, enter your password (you should have this in the credential details you saved). For our <strong>Database hostname</strong>, select the <strong>connectivity &amp; security tab</strong>, and copy and paste the RDS <strong>Endpoint </strong>URL in the <strong>“DB_HOST” </strong>section. Leave other sections —<strong> “DB_CHARSET”</strong> and <strong>“DB_COLLATE”</strong> as default. Please, see the editor&#39;s figures below and compare them with your figures</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*jkRv8H5KNWw3RjwDFMnA2w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*olo0Z7F9VrUKK4VtWf43gQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UPqQSczHKGooyjzmk1IPiA.png" /></figure><p>Good job! We have successfully entered all the information needed for our EC2 instance to connect to the RDS instance. <strong>Hit Ctrl + X then press Y and Enter</strong>. It should take you back to your shell prompt. lastly, we copy and paste our #9 command. The command will restart our web server.</p><pre>#9. restart the webserver<br>service httpd restart</pre><p>Once you restart your web server, head over to the EC2 instance console — click on Setup Server, and copy the <strong>Public IPv4 address.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*v_wtXF8plMle89LceThgAA.png" /></figure><p>Open a new web browser and paste the<strong> Public IPv4 address.</strong> if you entered all your information correctly you should see the figure below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/510/1*y1H801oL7VFgrHVRwDz_7Q.png" /></figure><p>Here you go! We have successfully configured our WordPress site and on this, we will finish the installation. Enter your preferred information below and click <strong>Install WordPress</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*I5HXHiH46rXwwAAeBpbdrw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PumATrFhw5zy3Eg9H1oGiw.png" /></figure><p>Good job! WordPress has been installed successfully!! It will take you to the <strong>“Success!”</strong> page, click <strong>log In</strong> and enter your credentials as shown below. click Log In and it should take you to the “Welcome to WordPress” Page as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5a-fmB-Ch6On25JMByMQdg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1iIA2mdbZGV4-DYMAUAslQ.png" /></figure><p>We have successfully installed our WordPress website and moved the files to the EFS! Do not terminate the setup server, we will need it to create an application load balancer to route traffic to the EC2 instance in the private subnet.</p><h4>Step 10: Create an Application Load Balancer</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/467/1*hLytPG6GGRYmweAtpcbJtA.png" /><figcaption>Reference Architecture</figcaption></figure><p>Application Load Balancer operated at the level (layer 7), routing traffic to targets (EC2 instances, containers, IP addresses, and Lambda functions) based on the content of the request. In this project, the ALB will be used to distribute or route web traffic across the EC2 instances in two Availability zones as displayed in the reference architecture above. Therefore, before we create our ALB, we will first launch EC2 instances in each of the <strong>Private App Subnets.</strong></p><p>Similar to how we launched our Setup Server in step 8, we will follow the same process in launching our web servers in the private app subnets. Navigate to the EC2 instance page click <strong>Launch instance </strong>and enter the information below:</p><p><strong>Launch an instance</strong></p><ul><li>Name and tags: <strong>Key</strong> — type Name, <strong>Value </strong>— Webserver AZ1</li></ul><p><strong>Application and OS Images (AMI)</strong></p><ul><li>Select the <strong>Quick Start</strong> tab and select <strong>Amazon Linux 2 AMI Free tier</strong></li></ul><p><strong>Instance type: </strong>Instance type — select t2.micro (Free tier eligible)</p><p><strong>Key pair (login): key pair name — </strong>select the key pair we created in step 6 (myec2key) or your key</p><p><strong>Network settings</strong></p><ul><li>click <strong>Edit</strong></li><li>VPC: Dev VPC</li><li>Subnet: Private App Subnet AZ1</li><li>Auto-assign public IP: Enable</li></ul><p><strong>Firewall (security groups)</strong></p><ul><li>Select <strong>existing security group</strong></li><li>Click on the drop-down and select <strong>Webserver Security Group</strong></li></ul><p>Under the <strong>Advanced details</strong> page, leave all the boxes as default and scroll to the <strong>User data</strong> section, copy and paste the commands below in the box. You will recall that these commands were run on the setup server in which we installed Apache, PHP version 7.4, and MySQL. Hence, when we launch the webservers EC2 instances, they will run these commands for us.</p><p>Hold on! Before you copy and paste, let’s ensure that our EFS information command line is updated.</p><pre>#!/bin/bash<br>yum update -y<br>sudo yum install -y httpd httpd-tools mod_ssl<br>sudo systemctl enable httpd <br>sudo systemctl start httpd<br>sudo amazon-linux-extras enable php7.4<br>sudo yum clean metadata<br>sudo yum install php php-common php-pear -y<br>sudo yum install php-{cgi,curl,mbstring,gd,mysqlnd,gettext,json,xml,fpm,intl,zip} -y<br>sudo rpm -Uvh https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm<br>sudo rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022<br>sudo yum install mysql-community-server -y<br>sudo systemctl enable mysqld<br>sudo systemctl start mysqld<br>echo &quot;fs-0bf07bb23863103b4.efs.us-east-1.amazonaws.com:/ /var/www/html nfs4 nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2 0 0&quot; &gt;&gt; /etc/fstab<br>mount -a<br>chown apache:apache -R /var/www/html<br>sudo service httpd restart</pre><p>On the EFS page, select your <strong>EFS ID </strong>and<strong> </strong>click<strong> attach </strong>as shown below</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*H9iIeEnW7vhNWpI-.png" /></figure><p>From your <strong>attach</strong> page, copy from <strong>“fs to .com”</strong> and update the EFS information in the commands</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*FVvrLFNVY7ISCg2G3HTUgg.png" /></figure><pre>echo &quot;fs-0bf07bb23863103b4.efs.us-east-1.amazonaws.com:/ /var/www/html nfs4 nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2 0 0&quot; &gt;&gt; /etc/fstab<br>mount -a</pre><p>Next, we will copy and paste the updated commands into the User data box</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/608/1*IC7mUbKHC9rrr5-yu8a5xQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*C_egpNt0rCuLY0CzJhmA6w.png" /></figure><p>Review the <strong>Summary</strong> of our instance and click <strong>Launch instance</strong></p><p>Let’s launch the second EC2 instance in the private app subnet AZ2. Follow the same process as above and enter the following information below</p><p><strong>Launch an instance</strong></p><ul><li>Name and tags: <strong>Key</strong> — type Name, <strong>Value </strong>— Webserver AZ2</li></ul><p><strong>Application and OS Images (AMI)</strong></p><ul><li>Select the <strong>Quick Start</strong> tab and select <strong>Amazon Linux 2 AMI Free tier</strong></li></ul><p><strong>Instance type: </strong>Instance type — select t2.micro (Free tier eligible)</p><p><strong>Key pair (login): key pair name — </strong>select the key pair we created in step 6 (myec2key) or your key</p><p><strong>Network settings</strong></p><ul><li>click <strong>Edit</strong></li><li>VPC: Dev VPC</li><li>Subnet: Private App Subnet AZ2</li><li>Auto-assign public IP: Enable</li></ul><p><strong>Firewall (security groups)</strong></p><ul><li>Select <strong>existing security group</strong></li><li>Click on the drop-down and select <strong>Webserver Security Group</strong></li></ul><p>Under <strong>User data,</strong> copy and paste the commands below (same as the commands in Webserver AZ1)</p><pre>#!/bin/bash<br>yum update -y<br>sudo yum install -y httpd httpd-tools mod_ssl<br>sudo systemctl enable httpd <br>sudo systemctl start httpd<br>sudo amazon-linux-extras enable php7.4<br>sudo yum clean metadata<br>sudo yum install php php-common php-pear -y<br>sudo yum install php-{cgi,curl,mbstring,gd,mysqlnd,gettext,json,xml,fpm,intl,zip} -y<br>sudo rpm -Uvh https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm<br>sudo rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022<br>sudo yum install mysql-community-server -y<br>sudo systemctl enable mysqld<br>sudo systemctl start mysqld<br>echo &quot;fs-0bf07bb23863103b4.efs.us-east-1.amazonaws.com:/ /var/www/html nfs4 nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2 0 0&quot; &gt;&gt; /etc/fstab<br>mount -a<br>chown apache:apache -R /var/www/html<br>sudo service httpd restart</pre><p>Also, review the <strong>Summary</strong> of our instance and click <strong>Launch instance</strong></p><p>Good job! We have successfully launched our two instances in the private app subnet AZ1 and private app subnet AZ2. Let’s view our instances.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*PtsbqKl0VpMkcf27BDQFwA.png" /></figure><p>Before we launch our ALB, we will first create a target group, which is used in routing. The load balancer checks the health of targets in this target group using the health check settings defined for the target group. We will put these instances in the target group to allow the ALB to route traffic to them.</p><p>Let’s head over to the EC2 page, in the navigation pane, under <strong>Load Balancing</strong>, choose <strong>Target Groups</strong>. Then click on <strong>Create target group.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EVOEELH9L9P9gVG-fb5pEA.png" /></figure><ul><li>Under <strong>Basic configuration</strong>, keep the Target type as <strong>Instances</strong></li><li>For the <strong>Target group name</strong>, enter <strong>Dev-TG</strong> or any name for the new target group</li><li>Keep the <strong>Protocol (HTTP)</strong> and <strong>port (80)</strong> as the default</li><li>Next, we will select our <strong>Dev VPC</strong> or the VPC containing your instances. Keep the <strong>Protocol version as HTTP1</strong></li><li>Under <strong>Health checks</strong>, keep the settings as default</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*udJK9n4eE0IuQ464cm7qXw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kA4H_KVU5y8zyyElM2sX8A.png" /></figure><p>Under <strong>Advance health check settings</strong>, keep all boxes as default except <strong>Success codes box: enter 200,301,302. Click Next</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UtX0UXxodZ8dUtGlmPkd8Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p3xGF4QMUUTZwFwsTJE8aw.png" /></figure><p>On the <strong>Rgister targets page</strong>, we will select the instances we want the ALB to route traffic to. For Available instances, select <strong>Webserver AZ1</strong> and <strong>Webserver AZ2</strong>. Keep the default <strong>port 80</strong>, and choose<strong> Include as pending below, </strong>then click<strong> Create target group</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wqAeNY_A4of472oZ7fSsBg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*moWzJBlw2JickflA8HlNlw.png" /></figure><p>We have successfully created our target groups. Next, is to create our application load balancer (ALB).</p><p>To create an ALB, in the navigation pane, under<strong> Load Balancing</strong>, select <strong>Load Balancers</strong>. Click <strong>Create load balancer</strong>. Under <strong>Load balancer types</strong>, for <strong>Application Load Balancer</strong> type, click <strong>Create.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IVCfWpL1FHc2vLn1GYpoZg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*37t7Jmg2cx8FAlYIIrB8Fg.png" /></figure><p>Next is to provide our basic configuration information for our load balancer. such as a name, scheme, and IP address type. Then, we will provide information about our network and one or more listeners. A listener is a process that checks for connection requests. It is configured with a protocol and a port for client connections to the load balancer. Enter the following information below:</p><p><strong>Basic configuration</strong></p><ul><li>Load balancer name: <strong>Dev-ALB</strong> or any name you desire</li><li>For<strong> Scheme</strong> and <strong>IP address type</strong>, we will keep the default values</li><li>Network mapping: Select <strong>Dev-VPC</strong>, and for Mappings we will select two availability zones and one subnet per zone. Therefore, we will choose <strong>us-east-1a</strong> and select <strong>Public Subnet AZ1</strong>. For the second AZ, choose <strong>us-east-1b</strong> and select <strong>Public Subnet AZ2.</strong></li><li>For Security groups: remove the default and select the <strong>ALB Security Group.</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mb9GWOhueQDyShvqzKmofA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4ULy1A9TXhm8PifBqbw_NQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gvv0GXGz7KcWI86cWd4gZQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3yI35jRVU5RA_HcnbezThQ.png" /></figure><p>For <strong>Listeners and Routing</strong>, we will keep the default <strong>Protocol (HTTP)</strong> and <strong>Port (80)</strong>. This will configure a listener that accepts HTTP traffic on port 80 and forwards traffic to the selected target group by default. Under <strong>Default action</strong>, select the target group created earlier, <strong>Dev-TG</strong>. Let’s review our configuration and choose <strong>Create load balancer</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yAokPEl49EblfslaiDJcZg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*DAjc7_20Y3Qno9rF3EK6CA.png" /></figure><p>We have successfully created our load balancer! Click View load balancer to see the<strong> Dev-ALB</strong> we created as shown below. We will wait for its <strong>State</strong> to be <strong>Active</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*DGLLZM-w0aoGbxBM" /></figure><p>We will use the DNS name of the load balancer to access our website. Open a new tab, copy and paste the DNS name of the load balancer into the address field of the tab, and hit enter</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*DKuyE_xAMYC2Qfcb" /></figure><p>If everything is working, we should get the below website address</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*1QpGw-IyStMo0jX6" /></figure><p>Our website can now be accessed using the DNS name of our application load balancer. To set up our website, we will need to go to the WordPress settings and change and update our domain name address. To change the domain name settings in our WordPress configuration file, add “/wp-admin” in front of the load balancer DNS name in the address bar and press enter.</p><p>NB: <strong>First copy the DNS name url before adding the /wp-admin</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*sfHWpv6aWg2HovKf" /></figure><p>When we hit enter, we will see the page below. Log into the website and it will bring us to the WordPress website as shown below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Ky-aspHe-RpQ_ycE" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*-8E_C6VsEbfBbGqo" /></figure><p>Once you get to the website page, go to <strong>Settings</strong> and click <strong>General</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*HImNKAhGjzbT4nH7" /></figure><p>Under general settings, we will update the <strong>WordPress Address(URL)</strong> and <strong>Site Address (URL). </strong>Paste the load balancer DNS name URL in the WordPress and Site Address bar. Ensure that you remove the / at the end of the URL. After the update, scroll down and click <strong>Save Changes</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*dJHNLM06S0zpoWil" /></figure><p>After you hit save changes, log back in, and the WordPress Website has been updated to the new load balancer URL.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*Ky-aspHe-RpQ_ycE" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*HTwb8RvGBy_5WzTZ" /></figure><p>Great job! Let’s go ahead and terminate our <strong>Setup Server</strong> since we have launched the 2 EC2 instances in the private app subnets and we can access our website using the load balancer DNS name. We have successfully created an ALB to route traffic to the EC2 instances in the private subnets.</p><h4>Step 12: Register a New Domain Name in Route 53</h4><p>Registering a new domain name in Route 53 will allow our end users to access our website using the domain name we registered instead of the DNS name of our application load balancer. Follow this link here (<a href="https://www.youtube.com/watch?v=yxfexNnBHu0">https://www.youtube.com/watch?v=yxfexNnBHu0</a>) to register your domain name (feel free to use any video if you prefer a video). Once this part is completed, we will proceed to create a record in Route 53 with the domain name.</p><h4><strong>Step 13: Create a Record Set in Route 53</strong></h4><p>We will create a record set in Route 53 where we will use the domain name we created to access the website. To create a record set, head over to the management console type Route 53 in the search box, and hit enter.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_tPSvkUe-w_co2Wk.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*vDafp1r-UYGImRW9" /></figure><p>The page displayed above shows that I have two registered domain names. Note that if it is your first time registering a new domain name, one hosted zone will show up under DNS management. Choose Hosted Zone(s) and click on the name of the name of the hosted zone that you want to create records in.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*EEVwFeIYJpSEj9eA" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Jt9Zxtn8sOhQsvVL" /></figure><p>We can now create DNS records for our domain. In this guide, we will create a simple A record type. Choose the <strong>Create record</strong> button to get started.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*2piK563N5-sHUad2" /></figure><p>Enter the following information:</p><p>To allow users to connect to your ALB using IPv4, enter your A record information and ensure <strong>A </strong>is selected in the <strong>Record type</strong> field. For this project, we will enter <strong>www</strong> for <strong>Record</strong> <strong>name</strong>.</p><p>Toggle the<strong> Alias</strong> on</p><p><strong>Under Route traffic to:</strong></p><ul><li>Select <strong>Alias to Application and Classic Load Balancer</strong> in the Choose an Endpoint dropdown menu.</li><li>In the <strong>Choose Region</strong> dropdown menu, select the Region in which your ALB is located.; US East (N. Virginia) [us-east-1]</li><li>In the <strong>Choose load balancer </strong>dropdown menu, select the existing ALB that you want to receive traffic from this domain.</li><li>Choose the <strong>Create records</strong> button once you have finished.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*G11DV8k7orYvEDM8" /></figure><p>As shown below, we have successfully created our record set and we can now access the website using the DNS name</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*uGstOqncC43iGVff" /></figure><p>To access the website as shown above, check the record that we created, copy the record name, open a new tab, paste the name in the address bar and press enter.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*rctf7--XOrQpCzqA" /></figure><p>Great Job! We can now access our website using the domain name. Recall that every time the domain name is changed, we will have to go to the WordPress settings and change the domain name. To change the settings, first, copy your domain name in the address bar, then add “/wp-admin” and press enter as shown below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*36YRwhuQnA_P3LyI" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Cp8P0EcKXLuu4Jkq" /></figure><p>Log in to the WordPress site. As shown below, notice that the website is still pointing to the ALB DNS name, so we will point it to the registered domain name. Go to <strong>Settings</strong> and then click<strong> General.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*TeQ01cY2HyfHiNbB" /></figure><p>Update the<strong> WordPress Address (URL) and Site Address (URL)</strong> by pasting the domain name URL. Ensure the forward slash is removed, scroll down, and click <strong>Save Changes.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*9ZU_sP9231h_TURJ" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*r546ZbxnAwdJNnqV" /></figure><p>You will notice that after we logged in, the WordPress website is now pointing to the domain name as shown above. Well done!</p><h4>Step 14: Register for an SSL Certificate in AWS Certificate Manager</h4><p>AWS Certificate Manager is a service that lets you easily provision, manage, and deploy public and private Secure Sockets Layer/Transport Layer Security (SSL/TLS) certificates for use with AWS services and your internal connected resources. In other words, we will use the SSL Certificate to encrypt the communication between the web browser and web servers.</p><p>If you noticed, our website displayed above is not secured, hence we will register a free SSL Certificate and use it to secure our website. Let’s head over to the management console, type certificate manager in the search bar, and hit enter.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RXCIA6TShET6_Trmsn4oxA.png" /></figure><p>Click <strong>Request a certificate,</strong> select <strong>Request a public certificate</strong> under <strong>Certificate type,</strong> and<strong> click Next</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*OY9ifN7Ki8BbSDkTcU5z3Q.png" /></figure><p>Under <strong>Domain names</strong>, enter your domain name, and <strong>click Add another name to this certificate </strong>to add a wildcard to the domain name (it will allow us to have “www” in front of the domain name). Type *. followed by the domain name. Leave the rest as default, scroll down, and click <strong>Request. </strong>See below diagrams</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*umTCoNcyvUZ4Ui3F26Uhuw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*8J1fpBxXfxidOr4ctUom3g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*l-1ko5wQ72LyAU4GUJkjvg.png" /></figure><p>Click view certificate to view the certificate</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*En6gHBYzQb2FN0_euS4MSQ.png" /></figure><p>The status says Pending validation because we still need to create a record set in Route 53 to validate the domain name we registered. Click <strong>Create records in Route 53</strong> and<strong> </strong>select the domain name and wildcard. Then click <strong>Create record</strong> as shown below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*jN-P5yiv5uW6JcilxdIDWg.png" /></figure><p>We have successfully created a DNS record in Route 53. Refresh the page and ensure the <strong>Status</strong> changes to<strong> issued and </strong>the domain names are showing<strong> Success</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/770/1*6Z2EBQBeQCSGtrIBS6GU8g.png" /></figure><h4>Step 15: Launch Bastion Host</h4><p>To SSH into the private instances in the private subnets, we will first launch an EC2 instance in the public subnet called bastion host or jump box. Next, we will ssh into the instance we launched in the public subnet, and lastly from the instance in the public subnet, we can ssh into any in the private subnets</p><p><strong>Note</strong>: AWS recently introduced the EC2 Instance Connect Endpoint (EIC Endpoint), a groundbreaking solution that allows you to securely connect to your instances and other Virtual Private Cloud (VPC) resources directly from the Internet. With the EIC Endpoint, you no longer require an Internet Gateway (IGW) in your VPC, a public IP address on your resource, a bastion host, or any additional agent to establish a secure connection. This innovative feature combines identity-based and network-based access controls, providing the necessary isolation, control, and logging capabilities to meet your organization’s strict security requirements.</p><p>For this project, we will ssh into the private subnets via Bastion Host. Let’s proceed. Similar to how we launch the webservers, click<strong> Launch instance</strong> from the<strong> EC2 Dashboard</strong> and enter the information below. Review the <strong>Summary</strong> and click <strong>Launch instance</strong></p><p>Name: Bastion Host</p><p>AMI: Amazon Linux 2</p><p>Instance type: t2.micro</p><p>Key pair: Select your key pair</p><p>VPC: Dev VPC</p><p>Subnet: Public Subnet AZ1</p><p>Security Group: SSH Security Group</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*-4cJ5YkygFG7G-kel2pXeA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*PHHD5tNPUPKSPK33c3G_Jw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*gEi2HYgzusQk1Y4ZF7sZMw.png" /></figure><p>Good Job! We have successfully launched our Bastion Host instance. Wait until the <strong>Instance state</strong> says Running and <strong>Status check</strong> 2/2 passed.</p><h4>Step 16: SSH into an EC2 Instance in the Private Subnet (Mac Users)</h4><p>Now that we have launched our Bastion host in the public subnet, we can use it to ssh into any of our EC2 instances in the private subnets. To ssh into an instance in the private subnet using a Mac computer, ensure that you run the following commands from the directory you saved your private key pair. Please note that the following commands assume you are using an Amazon Linux instance.</p><p>For Windows users, follow this video link: <a href="https://www.youtube.com/watch?v=TZbFwkLoFPM">https://www.youtube.com/watch?v=TZbFwkLoFPM</a></p><p><strong>Command 1</strong>: This command will add our private key to the App keychain. It will allow us to ssh from the bastion host to any instance in the private subnets</p><p>ssh-add — apple-use-keychain &lt;the-name-of-your-private-key.pem&gt; or</p><p>ssh-add -K &lt;the-name-of-your-private-key.pem&gt;</p><p><strong>Example</strong>: ssh-add — apple-use-keychain myec2key.pem or</p><p>ssh-add -K myec2key.pem</p><p><strong>Command 2</strong>: This will allow us to ssh into the Bastion host in the public subnet</p><p>ssh -A ec2-user@&lt;the-public-ipv4-ip-of-your-bastion-host from the management console&gt;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*4v6oUHb9UeOkiSTF2e48uQ.png" /></figure><p><strong>Example</strong>: ssh -A ec2-user@44.213.116.158</p><p><strong>Command 3</strong>: We can now ssh from the Bastion host into any of the instances in the private subnets:<strong> Webserver AZ1</strong> in this case</p><p>ssh ec2-user@&lt;the-private-ipv4-ip-of-the-instance-in-the-private-subnet&gt;</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*gEi2HYgzusQk1Y4ZF7sZMw.png" /></figure><p>Example: ssh ec2-user@10.0.2.209</p><p><strong>Ensure that you copied the Private IPv4 address of the Webserver AZ1. </strong>If everything works well, we should get the diagram below. We have successfully ssh into our instance (Webserver AZ1) in the private subnet</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/944/1*YcgG-dKh5IIihys5RB-R7A.png" /></figure><p>Good Job! Let’s continue</p><h4>Step 17: Create an HTTPS Listener for the Application Load Balancer</h4><p>An HTTPS listener for an AWS Application Load Balancer is a component that accepts secure connections using the HTTPS protocol. In this step, we will create an HTTPS listener for our ALB to secure our website. Recall that in step 11, we had earlier created an ALB. Let’s head over to the EC2 dashboard, in the navigation pane, under<strong> Load Balancing</strong>, select <strong>Load Balancers</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*h9kokG9c4QoGLW-dVEnryQ.png" /></figure><p>Select your load balancer name then click the <strong>Listeners</strong> tab then Click <strong>Add listener. </strong>As shown below, select<strong> HTTPS</strong> under <strong>Protocol</strong>, and this will always be on <strong>Port 443 </strong>as shown below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/840/0*3hoQ_-KoCAhn-0-_.png" /></figure><p>Under <strong>Action types</strong> select<strong> Forward to target groups.</strong> In the Select a target group, choose Dev-TG (or your target group name) in the drop box</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*PBQ4k3d2WbP80AZt" /></figure><p>Under <strong>Default SSL/TLS certificate From ACM,</strong> select the certificate you created earlier and <strong>Add</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*yYLyvLvoBpkmFi7W" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*wxV1bS5t1ibAqL8A" /></figure><p>We have successfully added the HTTPS listener. Next, we need to edit the HTTP listener to redirect HTTP traffic to HTTPS. To edit the HTTP listener, check box HTTP, select the Manager listener drop-down, and select Edit listener as shown below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*3CjBpzTk-Mc0MmSk" /></figure><p>Under <strong>Default actions</strong>, choose <strong>Redirect to URL. </strong>Under<strong> Protocol </strong>and<strong> Port, </strong>select<strong> HTTPS </strong>and type <strong>443. </strong>Scroll down and click <strong>Save changes</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*eV2qYumNRTrc_v9D" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*614ywTE_rtOXsrBP" /></figure><p>We have successfully edited our HTTP listener to redirect traffic to HTTPS. To make sure our website is secured, we will SSH into our webservers in the private app subnets, modify the wp-config file, and upload the code below in the file</p><pre>/* SSL Settings */<br>define(&#39;FORCE_SSL_ADMIN&#39;, true);<br><br>// Get true SSL status from AWS load balancer<br>if(isset($_SERVER[&#39;HTTP_X_FORWARDED_PROTO&#39;]) &amp;&amp; $_SERVER[&#39;HTTP_X_FORWARDED_PROTO&#39;] === &#39;https&#39;) {<br>  $_SERVER[&#39;HTTPS&#39;] = &#39;1&#39;;<br>}</pre><p>Recall from the previous step, SSH into the Webserver AZ1 as shown below</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*YcgG-dKh5IIihys5RB-R7A.png" /></figure><p>Once you ssh into the Webserver AZ1 in the private subnet, enter the following commands:</p><p>type<strong> sudo su</strong> to change to the root user, next is to go to the nano text editor, type, <strong>nano /var/www/html/wp-config.php, </strong>and press enter</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/1*wa-zEGZihbhkWPgYogYTgw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*yYDspacNhD_YXR4p" /></figure><p>Move the down arrow up to the row as shown and press enter twice</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/218/0*3YXlDyMfU3uQHosn.png" /></figure><p>Once you press enter twice, copy and paste the command below</p><pre>/* SSL Settings */<br>define(&#39;FORCE_SSL_ADMIN&#39;, true);<br><br>// Get true SSL status from AWS load balancer<br>if(isset($_SERVER[&#39;HTTP_X_FORWARDED_PROTO&#39;]) &amp;&amp; $_SERVER[&#39;HTTP_X_FORWARDED_PROTO&#39;] === &#39;https&#39;) {<br>  $_SERVER[&#39;HTTPS&#39;] = &#39;1&#39;;<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Hp8FWCjNITi_kVaX" /></figure><p>See the figure above and compare.<strong> Enter Ctrl + X, Y, and press enter.</strong> Once we edited the wp-config file and added the code, let’s go to our website to see if our website is secure. Type your domain name with https://</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*tBpoBx7T4TizmKTR" /></figure><p>Good job! We can access our website and the connection to our website is secure. Let’s update the URL settings for our WordPress site. Copy the <strong>domain name</strong> in the address bar, type <strong>/wp-admin </strong>and press enter</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/314/1*MLYFStAl0DUC29skZfUe1Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*vvYGABdggRBoUgYQ" /></figure><p>Login into the WordPress website as shown below. Go to <strong>settings &gt; General. </strong>Update the<strong> WordPress Address (URL) and Site Address (URL)</strong> by pasting the new domain name URL. The URL has changed from HTTP <strong>to HTTPS. </strong>Ensure you remove the forward slash at the end, scroll down, and click <strong>Save Changes</strong>. See the figures below and compare</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*7So4nIHGDHBI3l3g" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*8VSV9DsHDR8yYZvR" /></figure><p>To make sure everything works properly, log in again</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ObX4WiULj2_wVT8E" /></figure><p>Good job! The figure below shows that our website is secured and working properly. This is how we create an HTTPS listener for our website</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*9frpCnPO9VDgulPS" /></figure><h4>Step 18: Create an Auto Scaling Group</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h064J40eKJ2gM0hbmtiqpA.png" /></figure><p>What is Auto Scaling Group?</p><p>An <em>Auto Scaling group</em> contains a collection of EC2 instances that are treated as a logical grouping for automatic scaling and management. An Auto Scaling group also lets you use Amazon EC2 Auto Scaling features such as health check replacements and scaling policies. Both maintaining the number of instances in an Auto Scaling group and automatic scaling are the core functionality of the Amazon EC2 Auto Scaling service. The size of an Auto Scaling group depends on the number of instances that you set as the desired capacity. You can adjust its size to meet demand, either manually or by using automatic scaling.</p><p>In this step, we will create an auto-scaling group to dynamically create and scale the web servers in the private app subnet. Before we create an auto-scaling group, we will first terminate the EC2 instances we manually created. Head over to the <strong>Instance running</strong> under <strong>EC2 Dashboard. </strong>Select both <strong>Webserver AZ1</strong> and <strong>Webserver AZ2</strong>, click <strong>Instance state,</strong> and <strong>Terminate</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Z5WC488NwGC0DFf_" /></figure><p>After terminating the EC2 instances, the next step before creating an auto-scaling group is to create a <strong>Launch Templates. </strong>Before we can create an Auto Scaling group using a launch template, we must create a launch template with the parameters required to launch an EC2 instance. These parameters include the ID of the Amazon Machine Image (AMI) and an instance type.<br><strong>This launch template contains the configuration of the EC2 instances that the auto-scaling group will use to launch the new EC2 instances.</strong> In other words, A launch template provides full functionality for Amazon EC2 Auto Scaling. To create a Launch Template, let’s head over to the EC2 Instance service page, on the navigation pane, under <strong>Instances</strong>, choose <strong>Launch Templates</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/711/0*PPJy4AmCRiJSXsX-.png" /></figure><p>Click <strong>Create launch template</strong>. Enter a name and describe the initial version of the launch template, and Under <strong>Auto Scaling guidance</strong>, select the check box to have Amazon EC2 provide guidance to help create a template to use with Amazon EC2 Auto Scaling. See figure below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*dReFVQC744UmSlLr" /></figure><p>Next, follow the information below and fill out each required field and any optional fields as needed.</p><p><strong>Application and OS Images (Amazon Machine Image)</strong>: Under<strong> </strong>the<strong> Quick Start</strong> tab, choose Amazon Linux 2 AMI</p><p>For<strong> Instance type</strong>: t2.micro (free tier)</p><p><strong>Key pair (login)</strong>: For the <strong>Key pair name</strong>, choose an existing key pair (the one you created)</p><p>Under<strong> Network Settings:</strong></p><ul><li><strong>Subnet Info</strong>: leave as default</li><li>For <strong>Firewall (security groups): </strong>choose <strong>Select existing security group</strong></li><li>Security groups: Select the <strong>Webserver Security Group</strong> we created</li></ul><p>Under<strong> User data,</strong> copy and paste the commands below. Same commands in step 11 and ensure you have updated the EFS file. Click <strong>Create launch template</strong></p><pre>#!/bin/bash<br>yum update -y<br>sudo yum install -y httpd httpd-tools mod_ssl<br>sudo systemctl enable httpd <br>sudo systemctl start httpd<br>sudo amazon-linux-extras enable php7.4<br>sudo yum clean metadata<br>sudo yum install php php-common php-pear -y<br>sudo yum install php-{cgi,curl,mbstring,gd,mysqlnd,gettext,json,xml,fpm,intl,zip} -y<br>sudo rpm -Uvh https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm<br>sudo rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022<br>sudo yum install mysql-community-server -y<br>sudo systemctl enable mysqld<br>sudo systemctl start mysqld<br>echo &quot;fs-0bf07bb23863103b4.efs.us-east-1.amazonaws.com:/ /var/www/html nfs4 nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2 0 0&quot; &gt;&gt; /etc/fstab<br>mount -a<br>chown apache:apache -R /var/www/html<br>sudo service httpd restart</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*8n6Oj9j92QP4POI7.png" /></figure><p>Click <strong>View launch templates</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*VxYTgui-UGnNKWrH6rriMw.png" /></figure><p>Here we go! We have successfully created our <strong>launch template.</strong></p><p>We will go ahead and create our auto-scaling group. Ensure you choose the same AWS Region that you used when you created the launch template. Choose <strong>Create Auto Scaling group</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/711/0*HSrLB9vGXrPigZ5b.png" /></figure><p>On the <strong>Choose launch template or configuration</strong> page, let’s enter the following information:</p><ul><li>For <strong>Auto Scaling group name:</strong> enter a name for your Auto Scaling group. Dev-ASG</li><li>For the <strong>Launch template</strong>, choose the existing launch template we created</li><li>On the <strong>Choose instance launch options</strong> page, under <strong>Network</strong>, for <strong>VPC</strong>, choose Dev VPC we created. Note that the Auto Scaling group must be created in the same VPC as the security group you specified in your launch template.</li><li>For <strong>Availability Zones and subnets, </strong>we will select<strong> Private App Subnet AZ1</strong> and<strong> Private App Subnet AZ2 </strong>(check and ensure you select the correct subnets)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/711/0*YiPMhc13iO_R_3LI.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*7RUWUEbgFetveDeo" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*0v6l7joPsndutWbL" /></figure><p>Click next. Under <strong>Load balancing</strong>, we will attach our auto-scaling group with the ALB we created previously. Under <strong>Load balancing</strong>, select the following options:</p><ul><li>Attach to an existing load balancer</li><li>Choose from your load balancer target groups</li><li><strong>Existing load balancer target groups</strong>: select your target group</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*YaIFfAB-1YTZKyQqtVjkIA.png" /></figure><p>Under Health checks, and Monitoring, ensure to check “<strong>Turn on Elastic Load Balancing health checks</strong> and <strong>Enable group metrics collection within CloudWatch” </strong>then click <strong>Next</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*V29A2_ulPxXLHtD0YNDg7A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*zIYAGA1gosD98TkX1D3Yjw.png" /></figure><p>Under <strong>Group size, </strong>we will specify<strong> </strong>our <strong>Desired capacity</strong> to 2, <strong>Minimum capacity</strong> to 1, and <strong>Maximum capacity</strong> to 4. This means that the auto-scaling group will maintain 2 instances and scale down to a minimum of 1 instance and a maximum capacity of 4 instances. Leave everything else as default and click <strong>Next</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*kN3rBuHGKkk9fFspM2T9qQ.png" /></figure><p>On the <strong>Add notifications</strong> page, under SNS Topic, select the Cloudwatch topic we created earlier. If you don’t have one, click <strong>Create a topic </strong>to set up a Cloudwatch notification<strong>. Check </strong>all <strong>Event types</strong> and click <strong>Next</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*Kx5S7zMuEjs1zxz4Jcnp6w.png" /></figure><p>On the Add tags page, provide a tag key and value for each tag, and then choose <strong>Next</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*hnjOSWV7gYFRjwqSDpsBiA.png" /></figure><p>On the <strong>Review</strong> page, review your settings and choose <strong>Create Auto Scaling group</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*KRVUqulYUGjKd20OwSAYuQ.png" /></figure><p>Good job! We successfully created our auto-scaling group with the desired capacity of 2 instances. If we check our instances (from the EC2 dashboard), we should have 2 instances running as shown below (ensure that the instances pass the status check). These are instances created by the auto-scaling groups with tag names “ASG-Webserver”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*eV9AR4rdZ8Fg6MU5" /></figure><p>Also, let’s make sure that the <strong>Health status</strong> of the <strong>Registered targets</strong> is healthy. We do this by going to <strong>Target Groups</strong> under <strong>Load Balancing </strong>on the EC2 Instance page. As shown below, we can see that the Registered targets are healthy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*lPG2hXqr50VmhckC" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*eWIV70gW6uIktRox" /></figure><p>After confirming that the instances have passed the status and our Registered targets are healthy, we can access our website. Open a new type and enter your domain name.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ohqR8Rbwk7LTk1KR" /></figure><p>This is how we can create an auto-scaling group to dynamically create and scale the EC2 instances in the private app subnet.</p><h4><strong>Part 19: Install WordPress Theme and Template</strong></h4><p>Next, we will install themes and templates for our website to make it look presentable. To create themes and themes for our website, let’s log into our website. Type; address name/wp-admin and press enter</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Vxvw9Id9HPvwN4oK" /></figure><p>On the website, select <strong>Appearance</strong> and then click on <strong>Themes</strong> as shown above. On the Themes page, click on <strong>Add New</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*kBbiezDq0Audpq7Y" /></figure><p>On the Add Themes page, we will Install the <strong>Astra theme </strong>and then click <strong>Activate</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*IoCUdzsC-pSXR6VT" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/503/0*AfYZ0nncaAY2Ie-n.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/502/0*kMRSwnXwsFEaH4co.png" /></figure><p>Next, we will click on<strong> Get Started</strong> to install the templates</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*lVyuSWgPitqHrDad" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/711/0*1MochbTOJN4bJJ37.png" /></figure><p>On the page below, click on <strong>Build Your Website Now </strong>and then select <strong>Elementor</strong> as shown below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/711/0*0sch7xzC8d1qCajI.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*scsYEw_tqcR5RIzf" /></figure><p>On the next page, we can search for any templates for your website. In my case, under<strong> Local Business,</strong> I chose<strong> Car Garage</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*R2qCzEyucNPSE5V7" /></figure><p>Next, as shown in the pages below, select <strong>We Rent Limousines</strong> and then click <strong>Skip &amp; Continue</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*b5WL7_9tsj4DMcyY" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*wF7lD8W4vLq8x2eh" /></figure><p>On this page, enter your information and click <strong>Submit &amp; Build My Website</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*-eWDSEWTEdUNj5HZ" /></figure><p>The website page will start to build up as displayed below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*mvG9N_AzLvdk7Qa0" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ujc8Pcgniq_rtfEU" /></figure><p>It has successfully built our website. Click <strong>View Your Website</strong> to see our website. Give it time to load the website. Congratulations, we have successfully built our website</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*7kvtugWdwC3TJL9A" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*x7yciVcyckm1ft5H" /></figure><p>Log out of the website as the admin and we will access our website the same way end users would access it. Go ahead and type your domain name in the address bar and press enter.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*7kvtugWdwC3TJL9A" /></figure><h4>Clean up</h4><p>We will clean up our AWS services so they won’t incur costs. Ensure to clean up the services/resources as numbered below</p><ol><li>Auto-scaling group</li><li>Launch template</li><li>Application load balancer</li><li>Target group</li><li>RDS instance</li><li>Bastion host</li><li>EFS</li><li>Security groups</li><li>NAT gateway</li><li>VPC</li><li>Elastic IP</li><li>Record Set</li></ol><p>Congratulations on completing this project with me! I am so glad you made it. Let me know if you have any questions and I look forward to seeing you on my next project. Build real-world projects with me <a href="https://www.aosnote.com/a/2147524876/WLBooyWz">here</a>! and showcase your projects</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*rGGhKW1UIk25h5PI" /><figcaption>Photo by <a href="https://unsplash.com/@brettgarwood?utm_source=medium&amp;utm_medium=referral">Brett Garwood</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>follow me on Linkedin: <a href="https://www.linkedin.com/in/chidexhenry/">https://www.linkedin.com/in/chidexhenry/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c7fb75ee1f1d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to SSH into your Public EC2 Instance for Linux/Mac OS/Windows PowerShell]]></title>
            <link>https://medium.com/@chidexhenrytee/how-to-ssh-into-your-public-ec2-instance-for-linux-mac-os-windows-powershell-e8ad627d213d?source=rss-7776e6eb71cc------2</link>
            <guid isPermaLink="false">https://medium.com/p/e8ad627d213d</guid>
            <dc:creator><![CDATA[Henry Ukaegbu]]></dc:creator>
            <pubDate>Tue, 23 Jan 2024 05:14:41 GMT</pubDate>
            <atom:updated>2024-01-23T05:14:41.458Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/699/0*g4NPeyY5y2xVyKep" /></figure><p>SSH is one of the important functions. It allows you to control machines, for example, Amazon EC2 Instance, all using the command line. In this project, we will learn how to SSH into your EC2 Instance using Linux/Mac</p><p>A very important prerequisite is to first and foremost create and launch an Amazon or Linux EC2 Instance to connect to, and key pair (check here to know how to create a key pair). Therefore, the first thing we will do is walk you through how to create and launch an EC2 Instance.</p><p><strong>For Windows users, please follow the video below. The video showed how to use Windows Powershell to SSH into the AWS Instance</strong></p><p><a href="https://www.youtube.com/watch?v=sJ3SJ-66-F8">https://www.youtube.com/watch?v=sJ3SJ-66-F8</a></p><p>Let’s start! In the Amazon Management Console, type EC2 in the search bar, and click EC2 under services. This will take you to the EC2 home page. Either you click <strong>Launch instance</strong> or In the navigation pane, under <strong>Instances,</strong> choose <strong>Instances.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zwMG5l50YYGrQqkuW68QFA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ow8WA-oepiyQA7lQPLFSpA.png" /></figure><p>Carefully enter the following information and see the figures below:</p><p><strong>Launch an instance</strong></p><ul><li>Name: Setup Server</li></ul><p><strong>Application and OS Images (AMI)</strong></p><ul><li>Select the <strong>Quick Start</strong> tab and select <strong>Amazon Linux 2 AMI Free tier. </strong>Leave the A<strong>rchitecture</strong> box as the default</li></ul><p><strong>Instance type: </strong>Instance type — select t2.micro (Free tier eligible)</p><p><strong>Key pair (login): key pair name — </strong>select the key pair we created here (myec2key). If you do not know how to create one, I suggest you visit the project link below and create one before you continue. It is required!!</p><p><a href="https://medium.com/@chidexhenrytee/how-to-create-amazon-ec2-key-pairs-bde2f02dcfd8">How to Create Amazon EC2 Key Pairs</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JxstJ0Fbn0-K8qMlOdEVKA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CeeSKYgjlV0qVnqkNa00Yw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*shh8lW3OWCIhEtd2cyLelA.png" /></figure><p><strong>Network settings</strong></p><ul><li>click <strong>Edit</strong></li><li>VPC: choose the VPC you created for your current project or leave it as default if do not have one</li><li>Subnet: choose the one you created with reference to the project architecture or choose any default subnets as shown below</li><li>Auto-assign public IP: Enable</li></ul><p><strong>Firewall (security groups)</strong></p><ul><li>Select <strong>Create</strong> <strong>security group </strong>if you do not have any<strong> existing security group</strong></li><li>Security group name: SSH Security Group</li><li>Description: Allow access on port 22</li><li>Inbound Security Group Rules: under<strong> Type</strong>; choose SSH on port 22 (this will allow us to SSH into the EC2 instance) and under the <strong>Source type</strong>; choose My IP.</li></ul><p>Note: Anytime we want to ssh into an EC2 instance, always limit it to My IP. This means that only the computer connected to my IP address will be able to ssh into your EC2 instance.</p><ul><li>Under <strong>Advanced details</strong> page, leave all the boxes as default. before you launch the instance, you can have a quick review of the summary of the EC2 instance on the right side as shown below. After the review, click <strong>Launch instance</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h_HesgUL1HHZiPC1Ercl5w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ie_O4VAn9tnts0fN-kG1Gw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4B5NtYOrkkuMcEje4cRaMg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kaiMtQSXf9HiSKiu0MGl6g.png" /></figure><p>After you launch an instance, it can take a few minutes for the instance to be ready so that you can connect to it. Check that your instance has passed its <strong>status checks</strong>. You can view this information in the <strong>Status check</strong> column on the <strong>Instances</strong> page<strong>. </strong>We have successfully launched the EC2 instance (Setup Server). Great job!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8MXAGzLBXxKF4ofac_rEeQ.png" /></figure><p>Next, let’s SSH into our instance!! To ssh into our EC2 instance, <strong>step 1,</strong> open your terminal. Your terminal will always open to your home directory as shown below (My home is the “User”).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/575/1*b_UcXuwsCDyzJsKc9mt6zA.png" /></figure><p>Step 2: Make sure you move your keypair (downloaded) into the home folder. Type “ls” and press enter. This should give you the list of what is in your home folder including the keypair. If you do not see your keypair in the list, it means you have yet to move it to the folder.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/489/1*rYl-7fE1eefEAADX4J4UCg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/131/1*PJxpvXJXHHa2Pics3P9dzA.png" /></figure><p>Step 3: Change the permission on the keypair to allow us to ssh into the EC2 instance. To change the permission, type, and press enter the command below. As we know, the name of the keypair is “myec2key.pem”. You are free to enter any keypair name you have created (in case you have one)</p><pre>chmod 400 {myec2key.pem} </pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/583/1*MtbnjCn8nNf3-nef7zDK3A.png" /></figure><p>Now, we can ssh into our EC2 instance.</p><p>Step 4: Go to your EC2 launch page, check your EC2 instance, copy the Public IPv4 address of your instance, and paste it after the “@” symbol. The command below is the full command to ssh into our EC2 instance. Press the enter key.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*v_wtXF8plMle89LceThgAA.png" /></figure><pre>ssh -i myec2key.pem ec2-user@44.192.4.217</pre><p>It will ask you if you want to continue the connection, enter “yes” and press the enter key. The figure on the right shows you have successfully ssh into your EC2. You can enter ^C to log out, and it will take you back to the home directory.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/581/1*hMUR_9JV0pA8KFirJ7kxEg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/570/1*u0U2MEpkhlvGiizJMz49dQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/575/1*a6PDuwKLtB2I0A75c03DVQ.png" /></figure><p>Good job! You have completed this project. Thank you for completing this project with me, and I look forward to seeing you on my next project!!</p><p>Follow me on <a href="https://www.linkedin.com/in/chidexhenry/">https://www.linkedin.com/in/chidexhenry/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e8ad627d213d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deploy a Static Website on AWS]]></title>
            <link>https://medium.com/@chidexhenrytee/deploy-a-static-website-on-aws-f364688dc920?source=rss-7776e6eb71cc------2</link>
            <guid isPermaLink="false">https://medium.com/p/f364688dc920</guid>
            <dc:creator><![CDATA[Henry Ukaegbu]]></dc:creator>
            <pubDate>Tue, 09 Jan 2024 04:40:29 GMT</pubDate>
            <atom:updated>2024-01-24T04:33:09.909Z</atom:updated>
            <content:encoded><![CDATA[<p>Using AWS Services to Deploy Static on AWS</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YgjrbtMFasBukjRbGEkKtA.png" /></figure><h4>Requirements</h4><ol><li>AWS Certified Cloud Practitioner CLF-C01</li><li>AWS Certified Solutions Architect — Associate SAA-C03</li></ol><h4>Introduction</h4><p>In this project, I will walk you through developing and deploying static websites on Amazon Web Services (AWS). A static website delivers content in the same format in which it is stored. No server-side code execution is required. For example, if a static website consists of HTML documents displaying images, it delivers the HTML and images as-is to the browser, without altering the contents of the files. They consist of a mix of HTML documents, images, videos, CSS stylesheets, and JavaScript files.</p><p>We will also learn how to use reference architecture to host this website using various core AWS services and how they work together. The core AWS services we will use in this project are as follows:</p><ul><li>Custom VPC with public and private subnets</li><li>Security groups</li><li>EC2 instances</li><li>NAT gateways</li><li>Application load balancer</li><li>Route 53</li><li>Certificate manager</li><li>AWS Auto-scaling group</li></ul><h4>We will divide the objectives into the following steps:</h4><ol><li>Build a three-tier AWS network VPC from scratch</li><li>Create NAT Gateways</li><li>Create security groups</li><li>Create a Key Pair to SSH into the EC2 Instance</li><li>Create an application load balancer</li><li>Register a new domain name in route 53</li><li>Create a record set in Route 53</li><li>Register for an SSL certificate in the AWS certificate manager</li><li>Create an HTTPS (SSL) listener for an application load balancer</li><li>Create an auto-scaling group</li><li>Clean up</li></ol><p>By the end of this project, you should be able to successfully deploy your dynamic website on AWS. Let’s get started!</p><h4>Step 1: Build a three-tier AWS network VPC from scratch</h4><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*MLxXfS6Ch4b_4-n4apaz3g.jpeg" /><figcaption>VPC Reference Architecture (Fig 1)</figcaption></figure><p>Figure 1 above describes a three-tier VPC architecture, and it’s explained as follows:</p><p>Tier 1 — Our Public Subnet will be located here, and will host resources such as the NAT Gateway, Load Balancer, and Bastion host.</p><p>Tier 2 — This is our private subnet that will hold the webservers such as the Amazon EC2 Instances</p><p>Tier 3 — This is another private subnet that will hold our databases</p><p>The 3 — tiers described above will be placed in the us-east-1a availability zone. For high availability and fault tolerance, we will duplicate these subnets in the us-east-1a availability zone as described in the architecture above. Let’s dive into the project in detail!</p><p>Navigate to the Amazon management console, and select the region for your VPC. From the architecture, we see that the region is in the us-east-1. Next, type VPC in the search bar or select VPC from the console and click Create VPC.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*1grru7_9y1M--o7XIFSq_A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*Cu9MTAkOgzs1lak1.png" /></figure><p>Next, we will select VPC only and name our VPC “Dev VPC”. We leave it at the IPv4 CIDR block and based on our reference architecture we will enter <strong>10.0.0.0/16</strong> in the <strong>IPv4 CIDR block</strong>. Leave the <strong>IPv6 CIDR block </strong>and <strong>Tenancy </strong>to default, scroll down, and click <strong>Create VPC </strong>at the bottom right.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*nPBCMW_--CEtSIu52CSDiw.png" /></figure><p>If your VPC is successfully created, you should see a message on your console that looks like the one below</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*ZtPpz_dY5KgttG7L.png" /></figure><p>For you to see the VPC we created, click the drop-down arrow on the <strong>Select a VPC search box </strong>(click <strong>refresh</strong> if you don’t see the VPC we created). The VPC information is displayed as shown below. We will choose the VPC we just created “Dev VPC”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*zFqqJOXKNkyKcQ3Y.png" /></figure><p>Next, Let’s enable the DNS hostname in our VPC by selecting <strong>Actions </strong>and <strong>Edit VPC settings.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*RnweE5wo8x2V3qnd.png" /></figure><p>Under <strong>Edit</strong> <strong>VPC settings </strong>make sure that <strong>Enable DNS hostnames </strong>is checked then click <strong>Save. </strong>You will see a message that says “You have successfully modified the settings for …”</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*N2Al6_4C0Xq_WP1hMb6SeA.png" /></figure><h4>Internet Gateway</h4><p>We will create an Internet gateway for our VPC. At the left side menu of <strong>Your VPC </strong>in the management console, click Internet Gateway and then select <strong>Create internet gateway </strong>as shown below</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*rVD3C_-XG8MRYC5t.png" /></figure><p>Let’s give our internet gateway a name — <strong>Dev Internet Gateway </strong>and click <strong>Create Internet Gateway</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*WNNIW_qhhMZocKzq.png" /></figure><p>The diagram shown below shows that we have successfully our Internet Gateway and to allow the VPC we created earlier to connect and communicate with the Internet, we will attach it to the Internet Gateway. To do that, click; <strong>Attach to the VPC</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*tCkfcLnNrkvbvO__.png" /></figure><p>Select the Dev VPC that we created and click <strong>Attach Internet gateway.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*Ctlb-0Aw4fv0xMim.png" /></figure><p>We have successfully attached the internet gateway to our VPC. The Details below show the <strong>State </strong>and the <strong>VPC ID</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*ckkxWcjaIaf2TQXO.png" /></figure><h4>Public Subnets</h4><p>Once we have our VPC setup, we create our <strong>public subnets</strong> in the first and second availability zones. Ensure that you have your VPC filtered to the Dev VPC and then at the right corner of your console, click <strong>subnets. </strong>Once you are on the subnet page, click <strong>Create Subnet</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*GVro3M8ga9JgEreb_Mimow.png" /></figure><p>Select the VPC where you want our public subnet to be — Dev VPC</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*auQGF-PSPJ1vg8vOdrpKlQ.png" /></figure><p>With reference to our architecture, we will call our subnet — <strong>Public Subnet AZ1 and </strong>put this subnet in the<strong> us-east-1a-availability zone. The CIDR block </strong>should be<strong> 10.0.0.0/24. Click Create subnet</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*EK_r9DpmQr6dMHSyTQoQQg.png" /></figure><p>The figure below shows that we have successfully created our first public subnet in the US-east-1a Availability Zone.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*r5LarVM0Q7K9fJ2TQ_CnuA.png" /></figure><p>Next, we will create our second public subnet in the us-east-1b Availability Zone — <strong>Public Subnet AZ2</strong>. Same process as the public subnet AZ1 except that we have to choose the us-east-1b instead of us-east-1a. Don’t forget to filter our VPC to the Dev VPC. With reference to our architecture, we will call our subnet — <strong>Public Subnet AZ2 and </strong>put this subnet in the<strong> us-east-1b-availability zone. The CIDR block </strong>should be<strong> 10.0.1.0/24 (Note the changes in the CIDR block). Click Create subnet.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*F5FTKbxX3JHZ2-b7xLJb4A.png" /></figure><p>The figure shows that we have successfully created our second public subnet in the us-east-1b Availability Zone (this depends on your region)</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*Zj0lHSCVJIhwNuBaMBV0mA.png" /></figure><p>If you select <strong>Clear filters and filter to our Dev VPC, </strong>it shows the 2 subnets that we created in these regions. The figure below shows the public subnets we have created so far. Ensure that the two public subnets are in different Availability Zones (AZ1), <strong>us-east-1a and us-east-1b respectively</strong>. Good job!!</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*UVjEyVOONweUI1Y7kKtlkg.png" /></figure><p>Anytime EC2 Instances are launched in these public subnets, a public IPv4 address will be assigned to these instances, hence, the need to enable<strong> Auto assign IP settings</strong> for these two public subnets. With reference to the fig. above, check public subnet AZ1 and <strong>click Actions</strong>. From the drop-down menu, click <strong>Edit subnet settings</strong>. Under <strong>Edit subnet settings and Auto-assign IP settings </strong>check the <strong>Enable auto-assign public IPv4 address </strong>and click save (bottom right when you scroll down). See fig. below</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*qQVPN7XXV6fWE8blmYC9DQ.png" /></figure><p><strong>Public subnet AZ2 (Check the subnet and follow the same steps)</strong>. Great job! We have successfully enabled the <strong>auto-assign public IPv4 address </strong>for the two public subnets. So far we have created the Internet Gateway and two public subnets for our VPC. Let’s keep going!!</p><p>Recall from our reference architecture, the next is to create a <strong>Public Route Table. </strong>The Route Table will route traffic to the internet(see the<strong> </strong>reference architecture below to refresh our memory)</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*rNug8ydGxhREUai-sWZ2Fw.png" /></figure><p>From the VPC setup page, locate and click <strong>Route tables</strong> from the left side of the page (still filtered by the Dev VPC). The Route table shown below is the default table also referred to as the main table and it’s private by default. <strong>Click Create route table.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*TYXzLXcfnVkUMdJGBu2CZA.png" /></figure><p>Under Name, Type,<strong> Public Route Table</strong>, and ensure that you select <strong>Dev VPC</strong> under VPC and <strong>Key </strong>and <strong>Value</strong> type in <strong>Name</strong> and <strong>Public Route table. </strong>Click<strong> Create route table.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*qB6xkx1TwqttLKT3lMuW_w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*4892i9YwKQ8mYwFWoJtq7w.png" /></figure><p>Good job! We have successfully created our Public Route Table as shown below</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*PtmKWossCrmCyqSA4LY9Ig.png" /></figure><p>To allow the Public Route Table to route traffic to the internet, we will have to add a route to the Public Route Table. As shown below, click on the <strong>Routes tab </strong>and then<strong> Edit routes</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*bVwZfcJs1qEoYv5ZAK7FXA.png" /></figure><p>On the <strong>Edit Routes</strong> page, click on<strong> Add Route. </strong>Under<strong> Destination, type inside the box 0.0.0.0/0 </strong>to replace<strong> 10.0.0.0/16. </strong>Also, under<strong> Target, </strong>click inside the box and choose<strong> Internet Gateway igw- the # (Dev Internet Gateway). </strong>Click<strong> Save changes</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*uYUe-JENl6-yalhAm-9n5w.png" /></figure><p>We successfully added a route to our public route table. We can view it under the <strong>Routes tab. </strong>Next, we will associate the two public subnets, AZ1 and AZ2, with this route table. Ensure that we are still under the <strong>Public Route Table page. </strong>Locate and click on<strong> the subnet association tab, then </strong>click on<strong> Edit subnet associations. </strong>On the<strong> Edit subnet associations page, </strong>we see that<strong> </strong>the two public subnets are listed. Check both public subnets and click <strong>Save associations.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*sgYMdZX6LPGagkz5_uw1-A.png" /></figure><p>Good job! We have associated the two public subnets that we created with the Public Route Table. To confirm, we can see the subnets under the <strong>Subnet associations</strong> tab as shown below</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*0cxagxFEiTGP0DwSt0TZ7A.png" /></figure><h4>Private Subnets</h4><p>With reference to our architecture, we will need to create 4 private subnets to finish setting up our Dev VPC. Still, on the VPC page, ensure you filter by Dev VPC and click Create subnet. On the Create subnet page, under VPC ID choose Dev VPC and Our CIDR block should be <strong>10.0.2.0/24. </strong>Click<strong> Create subnet</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*auQGF-PSPJ1vg8vOdrpKlQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*G7qu_WGB_tVMLjpk.png" /></figure><p>Great! We have successfully created our 1st private subnet, <strong>Private App Subnet AZ1</strong>, in the us-east-1a Availability Zone. Using the same processes above, let’s create the remaining 3 private subnets using the settings below and referring to our reference architecture:</p><p><strong>2nd Subnet</strong></p><p>VPC ID: Dev VPC</p><p>Subnet name: Private App Subnet AZ2</p><p>Availability Zone: us-east-1b</p><p>IPv4 CIDR block: 10.0.3.0/24</p><p><strong>3rd Subnet</strong></p><p>VPC ID: Dev VPC</p><p>Subnet name: Private Data Subnet AZ1</p><p>Availability Zone: us-east-1a</p><p>IPv4 CIDR block: 10.0.4.0/24</p><p><strong>4th Subnet</strong></p><p>VPC ID: Dev VPC</p><p>Subnet name: Private Data Subnet AZ2</p><p>Availability Zone: us-east-1b</p><p>IPv4 CIDR block: 10.0.5.0/24</p><p>Great job! We have successfully created all 4 Private Subnets, making 6 subnets in total including the 2 public subnets. To see the list, click <strong>Clear Filters </strong>and filter it by <strong>Dev VPC. </strong>As shown below, review and ensure that each subnet is placed in the right<strong> AZs and AZ ID </strong>(compare with the list of the subnets)</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*jF7ZsLZ3T8pMLzQaNTgNXg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*5OniW-ADm2rYhok3ZV6pQg.png" /></figure><p>Let’s quickly dive into the basic <strong>difference between public and private subnets</strong>. A public subnet is associated with a route table that can route traffic to the internet. In other words, when we create a route table and add a route to the route table to route traffic to the internet, any subnet associated with the route table is a public subnet.</p><p>On the other hand, when we have a route table that does not have a route to the internet, any subnet associated with the route table is a private subnet. By default, any subnets associated with the <strong>main route table are private</strong></p><h4>Step 2: Create NAT (Network Address Translation) Gateways</h4><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*409UlSO-PN9LP0KBeIzbjQ.jpeg" /><figcaption><strong>NAT Gateway Reference Architecture</strong></figcaption></figure><p>With reference to our architecture, the NAT Gateways will allow instances in the private subnets; <strong>Private App, and Private Data Subnets</strong> to access the internet. As shown in the architecture Fig above, we will create a NAT gateway in the first and second availability zones. Check to see if you are still in the same region where we created our Dev VPC (N. Virginia us-east-1). NAT Gateway is located on the VPC Page. In the search box, type and click VPC</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*vFOhpJ8yaBLpX5uD.png" /></figure><p>As shown below, at the left corner of the VPC page, select NAT gateways and click Create NAT gateway;</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*HAfg8_z8asWUM9Rk.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*E9VqzgCW1QJFst9L.png" /></figure><p>Under Name, type <strong>NAT gateway AZ1</strong> click on the drop-down arrow under <strong>Subnet,</strong> and select <strong>Public Subnet AZ1</strong>. Leave the C<strong>onnectivity type</strong> on <strong>Public</strong> and click <strong>Allocate Elastic IP.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*n58f542sVGMB790yNNAc4Q.png" /></figure><p>Review and click<strong> Create NAT gateway. </strong>You should see a successful page as shown below</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*M8LC5ypeqgzDSUQgVBWBZA.png" /></figure><p>Next, we create a route table and name it <strong>Private Route Table AZ1</strong>. Still, on the VPC page, locate the <strong>Route tables at the left side of your screen </strong>and click on it. Make sure to select Dev VPC and under Tags, fill in the boxes as shown below and click <strong>Create route table</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*52ZTX_EbulZ3QdN8.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*0XDlB35wYotIK-g4N5S46w.png" /></figure><p>You should see a successful page as shown below</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*jR1xdhXfyPGD47lo.png" /></figure><p>Next is to add a route to the <strong>Private Route Table AZ1</strong> that we just created, to route traffic to the internet through the <strong>NAT Gateway</strong> in the <strong>Public Subnet AZ1. </strong>Scroll down and locate<strong> the Routes tab </strong>and on the right corner click<strong> Edit routes then Add route as shown below</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*qJxBq-hKHZcZMoQJ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*4e4s-mV8DyEx98-x.png" /></figure><p>Under <strong>Destination</strong>, replace 10.0.0.0/16 with the Internet traffic of 0.0.0.0/0. Under <strong>Target, </strong>click inside the box and replace<strong> local </strong>with<strong> NAT gateway AZ1. Locate NAT Gateway </strong>(ensure that you don’t select Internet Gateway) and click on it<strong>, NAT gateway AZ1 </strong>should appear, and then click<strong> save changes.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*wKMdRuFHreL7gRmelL4vNw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*MPFcSgKCcCtfQrjnX551lg.png" /></figure><p>We have successfully added a route to our private route table. To view it, scroll down, we will see the added route displayed under the <strong>Routes</strong> as shown below</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*bYiU0a4iA4aSkLAQE6Vb4w.png" /></figure><p>Next, we will associate <strong>Private Route Table AZ1</strong> with <strong>Private App Subnet AZ1</strong> and <strong>Private Data Subnet AZ1. To do that, locate and select the Subnet associations</strong> tab, and at the right corner click <strong>Edit subnet associations.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*ur8OqNHZxGbGVsAqo6IanQ.png" /></figure><p>On the <strong>Edit subnet associations page, </strong>we will see the available subnets list that needed to be selected. Check the <strong>Private App Subnet AZ1</strong> and <strong>Private Data Subnet AZ1 boxes, </strong>then click <strong>Save associations as shown below</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*cUtDCfwflGo7NfZcntpfcQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*1B2sZlDqcge6tU1Mqwac4Q.png" /></figure><p>Great job! We have successfully associated <strong>Private App Subnet AZ1</strong> and <strong>Private Data Subnet AZ1 </strong>to the <strong>Private Route Table AZ1</strong> as shown under <strong>Explicit subnet associations</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*wkvAFJdI5zXDn4v5pSLPdQ.png" /></figure><p>We are making progress! we have created our first<strong> NAT Gateway</strong> in the <strong>Public Subnet AZ1</strong>. Let’s proceed to create our second <strong>NAT Gateways</strong> in the <strong>Public Subnet AZ2</strong>. We will follow the same procedures as how we created the first NAT Gateway.</p><p>follow the same procedures as <strong>NAT Gateways AZ1</strong>. When you get to the <strong>NAT gateway settings</strong>, fill in the boxes as shown below (endure that you click <strong>Allocate Elastic IP</strong>)</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*mkeIJDvgWIMyXDnZtlsZQQ.png" /></figure><p>After you have successfully created the <strong>NAT Gateway AZ2</strong>, you should see a similar Fig below</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*uS78izAUwDo9i99aBy2hog.png" /></figure><p>Same as NAT Gateway AZ1, we create our Private Route Table and associate this table to the <strong>Private</strong> <strong>App Subnet AZ2 </strong>and <strong>Private Data Subnet AZ2. </strong>Again, we will follow the same as we did in<strong> </strong>Private Route Table AZ. Name this second table — <strong>Private Route Table AZ2. </strong>When you get to the<strong> Create route table </strong>page, fill in the boxes as shown below and click<strong> Create route table</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*s14_rMvajnHR1gqkjKFFGw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*UjR2SSxE4EDac6QOYyJPbQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*UbyqRguqXeUNcjQ8KIQAeg.png" /></figure><p>Also, add a route to the <strong>Private Route Table AZ2</strong>, to route traffic to the internet through the <strong>NAT Gateway</strong> in the <strong>Public Subnet AZ2. </strong>Scroll down and locate<strong> the Routes tab </strong>and on the right corner click<strong> Edit routes then Add route </strong>as shown below.<strong> Under Destination, </strong>type<strong> 0.0.0.0/0, </strong>and under<strong> Target </strong>choose,<strong> NAT Gateway AZ2 </strong>and click <strong>Save changes.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*VcCG30OK-8vOH7Ns3ilIMQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*kSfMJbqiPF7FAlmPG8RpPQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*tTGZ-gUVPbgnm3MuqQER8g.png" /></figure><p>As we did before, we will associate <strong>Private Route Table AZ2</strong> with <strong>Private App Subnet AZ2</strong> and <strong>Private Data Subnet AZ2. </strong>To do that<strong>, </strong>locate and select the<strong> Subnet associations</strong> tab, and at the right corner click <strong>Edit subnet associations.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*ur8OqNHZxGbGVsAqo6IanQ.png" /></figure><p>Check the <strong>Private App Subnet AZ2</strong> and <strong>Private Data Subnet AZ2 boxes, </strong>then click <strong>Save associations as shown below</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*yGhHRGKqzijJVXkA7tuYHA.png" /></figure><p>We have successfully updated the subnet associations for <strong>Private Route Table AZ2 </strong>as shown under <strong>Explicit subnet associations</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*PxRuWAMh7ue9b94cuQq0Hg.png" /></figure><p>Good job! We have completed this step — create <strong>NAT gateways</strong>. Through the NAT gateways, our resources in the private subnets will have access to the internet.</p><h4>STEP 3: Create Security Groups</h4><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*sn8GF-7SAZBqQ__aFEyCJg.jpeg" /><figcaption>WordPress Security Group Reference Architecture</figcaption></figure><p>The reference architecture above describes the security groups we will create for this project in parts. On the right side of the architecture is the breakdown of the security group parts we will need for this project. The parts are explained as follows:</p><ul><li><strong><em>ALB(Application load balancer) Security Group</em> — </strong>Port: 80 and 443 with Source: 0.0.0/0</li><li><strong><em>SSH Security Group</em> — </strong>Port: 22 with Source: Your IP Address</li><li><strong><em>Webserver Security Group</em> — </strong>Port: 80 and 443 with Source: ALB Security Group, Port: 22 with Source: SSH Security Group</li><li><strong><em>Database Security Group </em>— </strong>Port: 3306 Source: Webserver Security Group</li><li><strong><em>EFS Security Group</em> — </strong>Port: 2049 Source: Webserver Security Group, EFS Security Group, Port: 22 Source: SSH Security Group</li></ul><p>Let’s start with the first part; <strong>ALB Security groups</strong>! The security group can be found on the VPC page. So, type VPC in the management console home and click it. On the left-hand side of the page locate and click <strong>Security Groups</strong> under the <strong>Security</strong> drop-down arrow. Then click <strong>Create security group.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*KDK7tDtRbjdJqoNp.png" /></figure><p>Enter the following information settings:</p><p><strong>Basic details</strong></p><ul><li>Security group name: ALB Security Group</li><li>Description: ALB Security Group</li><li>VPC: Dev VPC</li></ul><p><strong>Inbound rules</strong></p><p><strong>1st rule</strong></p><ul><li>Type: HTTP</li><li>Protocol: TCP</li><li>Port range: 80</li><li>Source: 0.0.0.0/0</li></ul><p><strong>2nd rule</strong></p><ul><li>Type: HTTPS</li><li>Protocol: TCP</li><li>Port range: 443</li><li>Source: 0.0.0.0/0</li></ul><p>Once you entered the information, click <strong>Create security group</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*9lg420NaAzBwhkb-TLiXAA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*Gnweu5iLs78D6U9KQU_qQQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*zVIXPHv3CrAnUlG6mzLilw.png" /></figure><p>Below Fig shows that you have successfully created the ALB security group</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*tpRp1F5SxUfzH3-V4wFv9Q.png" /></figure><p>For<strong> SSH Security Group; </strong>click <strong>Security Groups </strong>to go back one directory and click Create <strong>Security Groups</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*1dhWpiyFBFi1fJasovQtTw.png" /></figure><p>Enter the following settings and click <strong>Create security group</strong> as shown in the Fig below:</p><p><strong>Basic details</strong></p><ul><li>Security group name: SSH Security Group</li><li>Description: SSH Security Group</li><li>VPC: Dev VPC</li></ul><p><strong>Inbound rules</strong></p><ul><li>Type: SSH</li><li>Protocol: TCP</li><li>Port range: 22</li><li>Source: My IP</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*g-IrajxYjEB5Tn-MPDJoJA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*1fH5K5Buc38Wwoku3C3FGA.png" /></figure><p>Next is the <strong>Webserver Security Group</strong>. Follow the same procedures as above enter the following settings and click <strong>Create security group</strong>:</p><p><strong>Basic details</strong></p><ul><li>Security group name: Webserver Security Group</li><li>Description: Webserver Security Group</li><li>VPC: Dev VPC</li></ul><p><strong>Inbound rules</strong></p><p><strong>1st rule</strong></p><ul><li>Type: HTTP</li><li>Protocol: TCP</li><li>Port range: 80</li><li>Source: ALB Security Group</li></ul><p><strong>2nd rule</strong></p><ul><li>Type: HTTPS</li><li>Protocol: TCP</li><li>Port range: 443</li><li>Source: ALB Security Group</li></ul><p><strong>3rd rule</strong></p><ul><li>Type: SSH</li><li>Protocol: TCP</li><li>Port range: 22</li><li>Source: SSH Security Group</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*7EX5gUOU9USD069OkQavMA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*mx3jYf6QNF0H1EWI6UJcUQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*MgvLzfwo1iBdkr1nid9-YQ.png" /></figure><p>Next is the<strong> database security group</strong>. Enter the following information below then click <strong>Create security groups. </strong>See fig. below</p><p><strong>Basic details</strong></p><ul><li>Security group name: Database Security Group</li><li>Description: Database Security Group</li><li>VPC: Dev VPC</li></ul><p><strong>Inbound rules</strong></p><ul><li>Type: MYSQL/Aurora</li><li>Protocol: TCP</li><li>Port range: 3306</li><li>Source: Webserver Security Group</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*8nhUNw3Nx9j0tCO0uqJ-lA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*SRpZh2Q6ZciKI910D67YwA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*aUW7Q8HDTGkch3ONbinqLw.png" /></figure><p>The last security group we will create for this is the EFS security group. Also, enter the following information below then click <strong>Create security group</strong></p><p><strong>Basic details</strong></p><ul><li>Security group name: EFS Security Group</li><li>Description: EFS Security Group</li><li>VPC: Dev VPC</li></ul><p><strong>Inbound rules</strong></p><p><strong>1st rule</strong></p><ul><li>Type: NFS</li><li>Protocol: TCP</li><li>Port range: 2049</li><li>Source: Webserver Security Group</li></ul><p><strong>2nd rule</strong></p><ul><li>Type: SSH</li><li>Protocol: TCP</li><li>Port range: 22</li><li>Source: Webserver Security Group</li></ul><p><strong>3rd rule</strong></p><ul><li>Type: NFS</li><li>Protocol: TCP</li><li>Port range: 2049</li><li>Source: EFS Security Group</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*EJ226odE5yPpt1qIVSEHqQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*qW2Vrjc9BXSs9GASxd54_A.png" /></figure><p>Review all the security groups we created on the security group page, and filter it to the Dev VPC. Your list of all security groups should look like the Fig below</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*o6OtqmNzdsVgidnJ.png" /></figure><h4>Step 4: Create a Key Pair to SSH into EC2 Instances</h4><p>It is important to create a key pair in other to connect to our Amazon EC2 instances. I completed a project on how to create a key pair. This link will take you to the project.</p><p><a href="https://medium.com/@chidexhenrytee/how-to-create-amazon-ec2-key-pairs-bde2f02dcfd8">How to Create Amazon EC2 Key Pairs</a></p><p>After completing and creating the key pair, you can come back to this project and continue from step 5</p><h4>Step 5: Create an Application Load Balancer</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hScipDZUjgOLDZrV2kfBRw.png" /></figure><p>Application Load Balancer operated at the level (layer 7), routing traffic to targets (EC2 instances, containers, IP addresses, and Lambda functions) based on the content of the request. In this project, the ALB will be used to distribute or route web traffic across the EC2 instances in two Availability zones as displayed in the reference architecture above. Therefore, before we create our ALB, we will first launch EC2 instances in each of the <strong>Private App Subnets.<br></strong>Navigate to the EC2 instance page click <strong>Launch instance </strong>and enter the information below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*zwMG5l50YYGrQqkuW68QFA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*ow8WA-oepiyQA7lQPLFSpA.png" /></figure><p><strong>Launch an instance</strong></p><ul><li>Name and tags: <strong>Key</strong> — type Name, <strong>Value </strong>— Webserver AZ1</li></ul><p><strong>Application and OS Images (AMI)</strong></p><ul><li>Select the <strong>Quick Start</strong> tab and select <strong>Amazon Linux 2 AMI Free tier</strong></li></ul><p><strong>Instance type: </strong>Instance type — select t2.micro (Free tier eligible)</p><p><strong>Key pair (login): key pair name — </strong>select the key pair we created in step 6 (myec2key) or your key</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/696/1*KYLxoWj-bUXs-VBNAr0NdQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*tLt4a3fB46V9X2AECjm7bA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*DEmANvHtHseiSkdj3X_8Bg.png" /></figure><p><strong>Network settings</strong></p><ul><li>click <strong>Edit</strong></li><li>VPC: Dev VPC</li><li>Subnet: Private App Subnet AZ1</li><li>Auto-assign public IP: Enable</li></ul><p><strong>Firewall (security groups)</strong></p><ul><li>Select <strong>existing security group</strong></li><li>Click on the drop-down and select <strong>Webserver Security Group</strong></li></ul><p>Under the <strong>Advanced details</strong> page, leave all the boxes as default and scroll to the <strong>User data</strong> section, copy and paste the commands below in the box. When we launch the webservers EC2 instances, they will run these commands for us. See Figures below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*evbKKLyfktRU826PI0KeEw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/678/1*SYvYG9y8ePhZvtUhiW6Fvw.png" /></figure><p>Copy these commands in the use data box</p><pre>#!/bin/bash<br>#change to root user <br>sudo su<br><br>#Update ec2 instance <br>yum update -y<br><br>#Install Apache webserver in the ec2 instance <br>yum install -y httpd<br><br>#change to the html directory <br>cd /var/www/html<br><br># use wget to download the webfile from gitub repo into the html directory <br>wget https://github.com/azeezsalu/jupiter/archive/refs/heads/main.zip<br><br>#unzip the webfile<br>unzip main.zip<br><br>#copy all the unzip webfiles into the html directory <br>cp -r jupiter-main/* /var/www/html/<br><br>#remove the unzip folder since we don&#39;t need them again <br>rm -rf jupiter-main main.zip<br><br>#enables Apache server in the start state <br>systemctl enable httpd <br><br>#this will start the Apache server <br>systemctl start httpd</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/650/1*vWLBrSMD2QfEjsaiEGyMjw.png" /></figure><p>Review the <strong>Summary</strong> of our instance and click <strong>Launch instance. </strong>You will see the image below if the EC2 Instance is launched successfully</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*4kTKqS-aYGuPWp2Yg2K2YA.png" /></figure><p>Let’s launch the second EC2 instance in the private app subnet AZ2. Follow the same process as above and enter the following information below</p><p><strong>Launch an instance</strong></p><ul><li>Name and tags: <strong>Key</strong> — type Name, <strong>Value </strong>— Webserver AZ2</li></ul><p><strong>Application and OS Images (AMI)</strong></p><ul><li>Select the <strong>Quick Start</strong> tab and select <strong>Amazon Linux 2 AMI Free tier</strong></li></ul><p><strong>Instance type: </strong>Instance type — select t2.micro (Free tier eligible)</p><p><strong>Key pair (login): key pair name — </strong>select the key pair we created in step 6 (myec2key) or your key</p><p><strong>Network settings</strong></p><ul><li>click <strong>Edit</strong></li><li>VPC: Dev VPC</li><li>Subnet: Private App Subnet AZ2</li><li>Auto-assign public IP: Enable</li></ul><p><strong>Firewall (security groups)</strong></p><ul><li>Select <strong>existing security group</strong></li><li>Click on the drop-down and select <strong>Webserver Security Group</strong></li></ul><p>Under <strong>User data,</strong> copy and paste the commands below (same as the commands in Webserver AZ1)</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*vWLBrSMD2QfEjsaiEGyMjw.png" /></figure><p>Also, review the <strong>Summary</strong> of our instance and click <strong>Launch instance</strong></p><p>Congratulations! We have successfully launched our two instances in the private app subnet AZ1 and private app subnet AZ2. Let’s view our instances.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*qEYnafr9Rsics8U7sP6WYw.png" /></figure><p>Now that we have successfully launched our EC2 instances in the private app AZ1 and the private app AZ2, we are ready to create the Application Load Balancer to route internet traffic to those EC2 instances.</p><p>Let’s head over to the EC2 page, in the navigation pane, under <strong>Load Balancing</strong>, choose <strong>Target Groups</strong>. Then click on <strong>Create target group.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*EVOEELH9L9P9gVG-fb5pEA.png" /></figure><ul><li>Under <strong>Basic configuration</strong>, keep the Target type as <strong>Instances</strong></li><li>For the <strong>Target group name</strong>, enter <strong>Dev-TG</strong> or any name for the new target group</li><li>Keep the <strong>Protocol (HTTP)</strong> and <strong>port (80)</strong> as the default</li><li>Next, we will select our <strong>Dev VPC</strong> or the VPC containing your instances. Keep the <strong>Protocol version as HTTP1</strong></li><li>Under <strong>Health checks</strong>, keep the settings as default</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*udJK9n4eE0IuQ464cm7qXw.png" /></figure><p>On the <strong>Rgister targets page</strong>, we will select the instances we want the ALB to route traffic to. For Available instances, select <strong>Webserver AZ1</strong> and <strong>Webserver AZ2</strong>. Keep the default <strong>port 80</strong>, and choose<strong> Include as pending below, </strong>then click<strong> Create target group</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/796/1*misVSpbgEeLqID7Nmlb6Fg.png" /></figure><p>Click <strong>Create target group</strong> under <strong>Review targets</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/762/1*tGhvReRi2HQIEi2deeVZ6w.png" /></figure><p>We have successfully created our target groups. Next, is to create our application load balancer (ALB).</p><p>To create an ALB, in the navigation pane, under<strong> Load Balancing</strong>, select <strong>Load Balancers</strong>. Click <strong>Create load balancer</strong>. Under <strong>Load balancer types</strong>, choose <strong>Application Load Balancer</strong> type, and click <strong>Create.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*IVCfWpL1FHc2vLn1GYpoZg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*37t7Jmg2cx8FAlYIIrB8Fg.png" /></figure><p>Next is to provide our basic configuration information for our load balancer. such as a name, scheme, and IP address type. Then, we will provide information about our network and one or more listeners.</p><p><strong>Basic configuration</strong></p><ul><li>Load balancer name: <strong>Dev-ALB</strong> or any name you desire</li><li>For<strong> Scheme</strong> and <strong>IP address type</strong>, we will keep the default values</li><li>Network mapping: Select <strong>Dev-VPC</strong>, and for Mappings we will select two availability zones and one subnet per zone. Therefore, we will choose <strong>us-east-1a</strong> and select <strong>Public Subnet AZ1</strong>. For the second AZ, choose <strong>us-east-1b</strong> and select <strong>Public Subnet AZ2.</strong></li><li>For Security groups: remove the default and select the <strong>ALB Security Group.</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*mb9GWOhueQDyShvqzKmofA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*4ULy1A9TXhm8PifBqbw_NQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*gvv0GXGz7KcWI86cWd4gZQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*3yI35jRVU5RA_HcnbezThQ.png" /></figure><p>For <strong>Listeners and Routing</strong>, we will keep the default <strong>Protocol (HTTP)</strong> and <strong>Port (80)</strong>. This will configure a listener that accepts HTTP traffic on port 80 and forwards traffic to the selected target group by default. Under <strong>Default action</strong>, select the target group created earlier, <strong>Dev-TG</strong>. Let’s review our configuration and choose <strong>Create load balancer</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*yAokPEl49EblfslaiDJcZg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*DAjc7_20Y3Qno9rF3EK6CA.png" /></figure><p>Good job! We have successfully created our load balancer! Click View load balancer to see the<strong> Dev-ALB</strong> we created as shown below. We will wait for its <strong>State</strong> to be <strong>Active</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*DGLLZM-w0aoGbxBM" /></figure><p>Next, we will use the DNS name of the load balancer to access our website. As shown above, check the <strong>Dev-ALB</strong>, open a new tab, copy and paste the DNS name of the load balancer into the address field of the tab, and hit enter</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*DKuyE_xAMYC2Qfcb" /></figure><p>After we have opened a new tab and pasted the DNS name that we copied it should bring us to this page</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*9bz-Y1gqZQcsOIxW_QW-GA.png" /></figure><p>Congratulations! The application load balancer is routing internet traffic to the EC2 instances in the private subnets and we can access the website using the DNS name of our application load balancer.</p><h4>Step 6: Register a New Domain Name in Route 53</h4><p>Registering a new domain name in Route 53 will allow our end users to access our website using the domain name we registered instead of the DNS name of our application load balancer. Follow this link</p><p><a href="https://aws.amazon.com/getting-started/hands-on/get-a-domain/">How to Register a Domain Name with Route 53</a></p><p>to register your domain name (feel free to use any video if you prefer a video). Once this part is completed, we will proceed to create a record in Route 53 with the domain name.</p><h4>Part 7: Create a Record Set in Route 53 or Configure DNS</h4><p>We will create a record set in Route 53 where we will use the domain name we created to access the website. To create a record set, enter <em>Route 53</em> in the search bar and select Route 53 to open the service console.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*HpUD0ljwv2OHkJNm.png" /></figure><p>The page displayed below shows that I have two registered domain names. Note that if it is your first time registering a new domain name, one hosted zone will show up under DNS management. Choose Hosted Zones and click on the name of the name of the hosted zone that you want to create records in.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*vDafp1r-UYGImRW9" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*EEVwFeIYJpSEj9eA" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*Jt9Zxtn8sOhQsvVL" /></figure><p>We can now create DNS records for our domain. In this guide, we will create a simple A record type. Choose the <strong>Create record</strong> button to get started.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*2piK563N5-sHUad2" /></figure><p>Enter the following information:</p><p>To allow users to connect to your ALB using IPv4, enter your A record information and ensure <strong>A </strong>is selected in the <strong>Record type</strong> field. For this project, we will enter <strong>www</strong> for <strong>Record</strong> <strong>name</strong>.</p><p>Toggle the<strong> Alias</strong> on</p><p><strong>Under Route traffic to:</strong></p><ul><li>Select <strong>Alias to Application and Classic Load Balancer</strong> in the Choose an Endpoint dropdown menu.</li><li>In the <strong>Choose Region</strong> dropdown menu, select the Region in which your ALB is located.; US East (N. Virginia) [us-east-1]</li><li>In the <strong>Choose load balancer </strong>dropdown menu, select the existing ALB that you want to receive traffic from this domain.</li><li>Choose the <strong>Create records</strong> button once you have finished.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*G11DV8k7orYvEDM8" /></figure><p>As shown below, we have successfully created our record set and we can now access the website using the DNS name</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*uGstOqncC43iGVff" /></figure><p>To access the website as shown above, check the record that we created, copy the record name, open a new tab, paste the name in the address bar and press enter. See Fig. below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/660/1*K8wlNYmHdkSPzaUAwp1FTg.png" /></figure><p>Congratulations! We can now access our website using our registered domain name.</p><h4>Step 8: Register for an SSL Certificate in AWS Certificate Manager</h4><p>We will use the SSL Certificate to encrypt the communication between the web browser and web servers, and the most common application of this service is a secure public website with significant traffic requirements.</p><p>If you noticed, our website displayed above is not secured, hence we will register a free SSL Certificate and use it to secure our website. Let’s head over to the management console, type certificate manager in the search bar, and hit enter.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*RXCIA6TShET6_Trmsn4oxA.png" /></figure><p>Click <strong>Request a certificate,</strong> select <strong>Request a public certificate</strong> under <strong>Certificate type,</strong> and<strong> click Next</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*OY9ifN7Ki8BbSDkTcU5z3Q.png" /></figure><p>Under <strong>Domain names</strong>, enter your domain name, and <strong>click Add another name to this certificate </strong>to add a wildcard to the domain name (it will allow us to have <strong>“www”</strong> in front of the domain name). Type *. followed by the domain name. Leave the rest as default, scroll down, and click <strong>Request. </strong>See below diagrams</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*umTCoNcyvUZ4Ui3F26Uhuw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*8J1fpBxXfxidOr4ctUom3g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*l-1ko5wQ72LyAU4GUJkjvg.png" /></figure><p>Click view certificate to view the certificate</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*En6gHBYzQb2FN0_euS4MSQ.png" /></figure><p>The status says Pending validation because we still need to create a record set in Route 53 to validate the domain name we registered. Click <strong>Create records in Route 53</strong> and<strong> </strong>select the domain name and wildcard. Then click <strong>Create record</strong> as shown below</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*jN-P5yiv5uW6JcilxdIDWg.png" /></figure><p>Great job! we have successfully created a DNS record in Route 53. Refresh the page and ensure the <strong>Status</strong> changes to<strong> issued and </strong>the domain names are showing<strong> Success</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/770/1*6Z2EBQBeQCSGtrIBS6GU8g.png" /></figure><h4>Step 9: Create an HTTPS Listener for the Application Load Balancer</h4><p>A listener checks for connection requests. You define a listener when you create your load balancer, and you can add listeners to your load balancer at any time.<br>In this step, we will create an HTTPS listener for our ALB to secure our website. Recall that in step 5, we had earlier created an ALB. Let’s head over to the EC2 dashboard, in the navigation pane, under<strong> Load Balancing</strong>, select <strong>Load Balancers</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*h9kokG9c4QoGLW-dVEnryQ.png" /></figure><p>Select your load balancer name then click the <strong>Listeners</strong> tab then Click <strong>Add listener. </strong>As shown below, select<strong> HTTPS</strong> under <strong>Protocol</strong>, and this will always be on <strong>Port 443 </strong>as shown below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/682/1*QFFjaSPoTSg7IaLIOdjiRg.png" /></figure><p>Under <strong>Action types</strong> select<strong> Forward to target groups.</strong> In the Select a target group, choose Dev-TG (or your target group name) in the drop box</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*PBQ4k3d2WbP80AZt" /></figure><p>Under <strong>Default SSL/TLS certificate From ACM,</strong> select the certificate you created earlier and <strong>Add</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*yYLyvLvoBpkmFi7W" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*wxV1bS5t1ibAqL8A" /></figure><p>Good job! We have successfully added the HTTPS listener. Next, we need to edit the HTTP listener to redirect HTTP traffic to HTTPS. To edit the HTTP listener, check box HTTP, select the Manager listener drop-down, and select Edit listener as shown below</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*3CjBpzTk-Mc0MmSk" /></figure><p>Under <strong>Default actions</strong>, choose <strong>Redirect to URL. </strong>Under<strong> Protocol </strong>and<strong> Port, </strong>select<strong> HTTPS </strong>and type <strong>443. </strong>Scroll down and click <strong>Save changes</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*eV2qYumNRTrc_v9D" /></figure><p>The Fig shows that we have successfully edited our HTTP listener to redirect traffic to HTTPS.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*614ywTE_rtOXsrBP" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/956/0*zzkimGJMrMqfse0-.png" /></figure><p>Now, we will let’s check if our website is secure. Open a new browser type https:// followed by your domain name then press enter</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/748/1*muijZGxB6_uZmhx7_YNtZQ.png" /></figure><p>Congratulations! Communications to the website is now secured, you can also see the <strong>Lock</strong> icon which wasn’t there earlier. <br>This is how we can use the SSL certificate to secure communications to our website.</p><h4>Step 10: Create an Auto Scaling Group</h4><p>In this step, we will create an auto-scaling group to dynamically create and scale the web servers in the private app subnet. Amazon EC2 Auto Scaling helps ensure that we have the correct number of Amazon EC2 instances available to handle the load for our application.<br>Before we create an auto-scaling group, we will first terminate the EC2 instances we manually created. Head over to the <strong>Instance running</strong> under <strong>EC2 Dashboard. </strong>Select both <strong>Webserver AZ1</strong> and <strong>Webserver AZ2</strong>, click <strong>Instance state,</strong> and <strong>Terminate.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*Z5WC488NwGC0DFf_" /></figure><p>Before we can create an Auto Scaling group using a launch template, we must create a <strong>launch template</strong> with the parameters required to launch an EC2 instance. These parameters include the ID of the Amazon Machine Image (AMI) and an instance type. <br>This launch template contains the configuration of the EC2 instances that the auto-scaling group will use to launch the new EC2 instances. In other words, A launch template provides full functionality for Amazon EC2 Auto Scaling. To create a Launch Template, let’s head over to the EC2 Instance service page, on the navigation pane, under <strong>Instances</strong>, choose <strong>Launch Templates</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*PPJy4AmCRiJSXsX-.png" /></figure><p>Click <strong>Create launch template</strong>. Enter a name and describe the initial version of the launch template, and Under <strong>Auto Scaling guidance</strong>, select the check box to have Amazon EC2 provide guidance to help create a template to use with Amazon EC2 Auto Scaling. See figure below</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*dReFVQC744UmSlLr" /></figure><p>Next, follow the information below and fill out each required field and any optional fields as needed.</p><p><strong>Application and OS Images (Amazon Machine Image)</strong>: Under<strong> </strong>the<strong> Quick Start</strong> tab, choose Amazon Linux 2 AMI</p><p>For<strong> Instance type</strong>: t2.micro (free tier)</p><p><strong>Key pair (login)</strong>: For the <strong>Key pair name</strong>, choose an existing key pair (the one you created)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/554/1*EPbokLTn1IUq6FSh5RprTQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/997/0*eXwHVpaX7owpfFLx.png" /></figure><p>under<strong> Network Settings:</strong></p><ul><li><strong>Subnet Info</strong>: leave as default</li><li>For <strong>Firewall (security groups): </strong>choose <strong>Select existing security group</strong></li><li>Security groups: Select the <strong>Webserver Security Group</strong> we created</li></ul><p>Under<strong> User data,</strong> copy and paste the commands below, and Click <strong>Create launch template</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/588/1*NiUd9GJv4c7J6M2lOV6X0g.png" /></figure><pre>#!/bin/bash<br>sudo su<br>yum update -y<br>yum install -y httpd<br>cd /var/www/html<br>wget https://github.com/azeezsalu/jupiter/archive/refs/heads/main.zip<br>unzip main.zip<br>cp -r jupiter-main/* /var/www/html/<br>rm -rf jupiter-main main.zip<br>systemctl enable httpd <br>systemctl start httpd</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/594/1*4rVJ6VoWr-4KYodOIo5mKg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*8n6Oj9j92QP4POI7.png" /></figure><p>Click <strong>View launch templates</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*VxYTgui-UGnNKWrH6rriMw.png" /></figure><p>Here we go! We have successfully created our <strong>launch template.</strong></p><p>We will go ahead and create our auto-scaling group. Ensure you choose the same AWS Region that you used when you created the launch template. Choose <strong>Create Auto Scaling group</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*HSrLB9vGXrPigZ5b.png" /></figure><p>On the <strong>Choose launch template or configuration</strong> page, let’s enter the following information:</p><ul><li>For <strong>Auto Scaling group name: </strong>enter a name for your Auto Scaling group. Dev-ASG</li><li>For the <strong>Launch template</strong>, choose the existing launch template we created</li><li>On the <strong>Choose instance launch options</strong> page, under <strong>Network</strong>, for <strong>VPC</strong>, choose Dev VPC we created. Note that the Auto Scaling group must be created in the same VPC as the security group you specified in your launch template.</li><li>For <strong>Availability Zones and subnets, </strong>we will select<strong> Private App Subnet AZ1</strong> and<strong> Private App Subnet AZ2 </strong>(check and ensure you select the correct subnets)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*YiPMhc13iO_R_3LI.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*7RUWUEbgFetveDeo" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*0v6l7joPsndutWbL" /></figure><p>Click next. Under <strong>Load balancing</strong>, we will attach our auto-scaling group with the ALB we created previously. Under <strong>Load balancing</strong>, select the following options:</p><ul><li>Attach to an existing load balancer</li><li>Choose from your load balancer target groups</li><li><strong>Existing load balancer target groups</strong>: select your target group</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*YaIFfAB-1YTZKyQqtVjkIA.png" /></figure><p>Under Health checks, and Monitoring, ensure to check “<strong>Turn on Elastic Load Balancing health checks</strong> and <strong>Enable group metrics collection within CloudWatch” </strong>then click <strong>Next</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*V29A2_ulPxXLHtD0YNDg7A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*zIYAGA1gosD98TkX1D3Yjw.png" /></figure><p>Under <strong>Group size, </strong>we will specify<strong> </strong>our <strong>Desired capacity</strong> to 2, <strong>Minimum capacity</strong> to 1, and <strong>Maximum capacity</strong> to 4. This means that the auto-scaling group will maintain 2 instances and scale down to a minimum of 1 instance and a maximum capacity of 4 instances. Leave everything else as default and click <strong>Next</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*kN3rBuHGKkk9fFspM2T9qQ.png" /></figure><p>On the <strong>Add notifications</strong> page, under SNS Topic, select the Cloudwatch topic we created earlier. If you don’t have one, click <strong>Create a topic </strong>to set up a Cloudwatch notification<strong>. Check </strong>all <strong>Event types</strong> and click <strong>Next</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*Kx5S7zMuEjs1zxz4Jcnp6w.png" /></figure><p>On the Add tags page, provide a tag key and value for each tag, and then choose <strong>Next</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*hnjOSWV7gYFRjwqSDpsBiA.png" /></figure><p>On the <strong>Review</strong> page, review your settings and choose <strong>Create Auto Scaling group</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*KRVUqulYUGjKd20OwSAYuQ.png" /></figure><p>Congratulations! We successfully created our auto-scaling group with the desired capacity of 2 instances. If we check our instances (from the EC2 dashboard), we should have 2 instances running as shown below (ensure that the instances pass the status check). These are instances created by the auto-scaling groups with tag names “ASG-Webserver”</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*eV9AR4rdZ8Fg6MU5" /></figure><p>Also, let’s make sure that the <strong>Health status</strong> of the <strong>Registered targets</strong> is healthy. We do this by going to <strong>Target Groups</strong> under <strong>Load Balancing </strong>on the EC2 Instance page. As shown below, we can see that the Registered targets are healthy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*lPG2hXqr50VmhckC" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*eWIV70gW6uIktRox" /></figure><p>After confirming that the instances have passed the status and our Registered targets are healthy, we can access our website. Open a new type and enter your domain name.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/748/1*muijZGxB6_uZmhx7_YNtZQ.png" /></figure><p>This is how we can create an auto-scaling group to dynamically create and scale the EC2 instances in the private app subnet.</p><h4>Clean up</h4><p>We will clean up our AWS services so they won’t incur costs. Ensure to clean up the services/resources as numbered below i.e according to how the services were numbered</p><ol><li>Auto-scaling group</li><li>Launch template</li><li>Application load balancer</li><li>Target group</li><li>Security groups</li><li>NAT gateway</li><li>VPC</li><li>Elastic IP</li><li>Record Set</li></ol><p>Congratulations on completing this project with me! I am so glad you made it to the end of this project. Kindly let me know if you have any questions and I look forward to seeing you on my next project. Follow the link below for more AWS projects</p><p><a href="https://medium.com/@chidexhenrytee">Henry Ukaegbu - Medium</a></p><p>follow me on Linkedin: <a href="https://www.linkedin.com/in/chidexhenry/">https://www.linkedin.com/in/chidexhenry/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f364688dc920" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Create Amazon EC2 Key Pairs]]></title>
            <link>https://medium.com/@chidexhenrytee/how-to-create-amazon-ec2-key-pairs-bde2f02dcfd8?source=rss-7776e6eb71cc------2</link>
            <guid isPermaLink="false">https://medium.com/p/bde2f02dcfd8</guid>
            <dc:creator><![CDATA[Henry Ukaegbu]]></dc:creator>
            <pubDate>Tue, 09 Jan 2024 04:08:10 GMT</pubDate>
            <atom:updated>2024-01-09T04:08:10.713Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/481/1*SJgKLvO0qaQNF9TKbRDi9w.png" /></figure><h4><strong>Introduction</strong></h4><p>A key pair (consisting of a public and a private key)is a set of security credentials that you use to prove your identity when connecting to an Amazon EC2 instance. Amazon EC2 stores the public key on your instance, and you store the private key. In other words, A key pair is a combination of a public key that is used to encrypt data and a private key that is used to decrypt data. For Linux instances, the private key allows you to securely SSH into your instance.</p><p>It is important to know that anyone who possesses your private key can connect to your instances, so you must store your private key in a secure place. You can use Amazon EC2 to create a key pair using one of the following methods: <strong>Console, AWS CLI, and PowerShell. </strong>For this article, we will use the Console method.</p><p>Let’s start! Head over to the Amazon management console, type EC2 in the search bar, and click EC2. This will take you to the EC2 home page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*zwMG5l50YYGrQqkuW68QFA.png" /></figure><p>In the navigation pane, under <strong>Network &amp; Security</strong>, choose <strong>Key Pairs and then click Create key pair </strong>at the top right corner.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/215/0*L5CLKrVQTBFp2GCa.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/423/0*g0PysI1uRIHs4dHT.png" /></figure><p>For <strong>Name</strong>, enter a descriptive name for the key pair, and for <strong>Key pair type</strong>, choose <strong>RSA.</strong></p><p>For <strong>Private key file format</strong>, choose the format in which to save the private key. To save the private key in a format that can be used with OpenSSH, choose <strong>pem</strong>. To save the private key in a format that can be used with PuTTY, choose <strong>ppk. Since we are using this key pair to SSH into our EC2 instance from a Mac (choose .ppk for Windows), we will select .pem. </strong>Click<strong> Create key pair</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bXAiGZeYAf-K0YPcKBhFsA.png" /></figure><p>You should see a similar figure below after clicking on the <strong>Create key pair</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZQQgwr0JGCZZzviIzUFDPA.png" /></figure><p>The private key file is automatically downloaded by your browser. The base file name is the name that you specified as the name of your key pair, and the file name extension is determined by the file format that you chose. Save the private key file in a safe place. If you plan to use an SSH client on a macOS or Linux computer to connect to your Linux instance, use the following command to set the permissions of your private key file so that only you can read it:</p><pre>chmod 400 key-pair-name.pem</pre><p>Note that if you do not set these permissions, then you cannot connect to your instance using this key pair.</p><p>Good job! You have completed how a key pair can be created. Thank you for completing this project with me and I look forward to seeing you on my next project!!</p><p>Follow me on <a href="https://www.linkedin.com/in/chidexhenry/">https://www.linkedin.com/in/chidexhenry/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bde2f02dcfd8" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>