<?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 Mohammed Firdous on Medium]]></title>
        <description><![CDATA[Stories by Mohammed Firdous on Medium]]></description>
        <link>https://medium.com/@mohammedfirdousaraoye?source=rss-19706121782c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*ZVNVHRaT8iAMmT7URIWBxQ.jpeg</url>
            <title>Stories by Mohammed Firdous on Medium</title>
            <link>https://medium.com/@mohammedfirdousaraoye?source=rss-19706121782c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 08:31:05 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mohammedfirdousaraoye/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[MCPs and APIs]]></title>
            <link>https://medium.com/@mohammedfirdousaraoye/mcps-and-apis-6d4d3559da63?source=rss-19706121782c------2</link>
            <guid isPermaLink="false">https://medium.com/p/6d4d3559da63</guid>
            <category><![CDATA[mcps]]></category>
            <category><![CDATA[mcp-server]]></category>
            <category><![CDATA[api]]></category>
            <category><![CDATA[integration]]></category>
            <category><![CDATA[mcp-protocol]]></category>
            <dc:creator><![CDATA[Mohammed Firdous]]></dc:creator>
            <pubDate>Mon, 12 May 2025 09:14:53 GMT</pubDate>
            <atom:updated>2025-05-12T09:16:22.369Z</atom:updated>
            <content:encoded><![CDATA[<h3>Overview</h3><p>You’ve probably seen lots of articles about MCPs, but this one’s different. I’m talking about both Model Context Protocols (MCPs) and Application Programming Interfaces (APIs). MCPs are like a USB-C port for AI, they make it easy for different AI systems to connect.</p><p>APIs, on the other hand, are the basic tools that let apps talk to each other. Knowing how both work is important for modern technology.</p><h3><strong>Model Context Protocol (MCP)</strong></h3><p>MCP, created by Anthropic in late 2024, is a standard way for AI models to connect with outside data, tools, and environments.</p><p>It works like this: AI apps (clients) ask for information from data sources or tools (servers) using JSON-RPC. MCP allows easy tool discovery, keeps track of context, and controls access securely. It aims to make AI connections as simple as USB-C for devices or HTTP for the web. The key idea is “<strong>context</strong>” helping AI understand the data and tools it uses.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/762/1*xVuzwqxIY7U-Jw5ru0Gc9g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/431/1*gv3ln4M2nX0di3Fe_LODDQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/442/1*T_V7kieWYGeG5Nk22kWQEw.png" /><figcaption><strong>Before MCPs and After MCPs</strong></figcaption></figure><h3><strong>Application Programming Interfaces (APIs)</strong></h3><p>An API is a tool that lets two software applications talk to each other, sharing data and actions. Like a messenger, it uses a client-server setup with requests and responses. There are different types of APIs, like REST, SOAP, and GraphQL. APIs make development easier, connect different systems, and help build new ideas using existing features. They have been important in software development for many years.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/625/1*Ceptf67tsI7ZkG7OlVgckA.png" /></figure><h3><strong>Use Cases</strong></h3><p>MCP helps AI code better, get data quickly, power chatbots with live data, and automate complex tasks. It also speeds up making AI apps.</p><p>APIs are used for things like connecting to social media, making secure payments, using maps, automating tasks, and building small, connected services. APIs handle many types of connections, but MCP is made just for helping AI use external tools and data.</p><h3><strong>Similarities</strong></h3><p>MCP and APIs both help software systems talk to each other using a client-server setup. They make it easier to connect systems, hide complex details, and keep things secure. Both also need clear instructions (documentation) for use.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QwB1mlH2viSHnnfFFk9h8w.png" /><figcaption><strong>Client-server architecture using MCP</strong></figcaption></figure><h3><strong>Differences</strong></h3><p>MCP is designed for AI agents to talk to software systems, while APIs connect any software. MCP uses one standard way to communicate, while APIs can use many. MCP lets AI find and use tools automatically, while APIs don’t. MCP is aware of the situation (context), but APIs usually aren’t. MCP can wrap around APIs and allows live, two-way chatting, while APIs usually just send and receive requests.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aClIVYz3awso0K6uIf7X5Q.png" /><figcaption><strong>Differences between MCPs and APIs</strong></figcaption></figure><p>APIs are still important for connecting digital services. MCP is becoming more important for helping AI reach its full potential by offering a standardized way for AI models to interact with the world. This development shows that AI needs special methods for integration.</p><h3><strong>Conclusion</strong></h3><p>MCP standardizes how AI connects to data and tools, using a simple client-server setup with JSON-RPC. APIs allow different software to communicate in various ways. While both help with communication, MCP is made for AI, offering a single protocol, automatic discovery, and context awareness. APIs are key for software integration. Understanding both is important for building connected systems.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*E1VjfbH00ISV7P4a.gif" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6d4d3559da63" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why a Serverless Mindset Matters]]></title>
            <link>https://medium.com/@mohammedfirdousaraoye/why-a-serverless-mindset-matters-a0103642631a?source=rss-19706121782c------2</link>
            <guid isPermaLink="false">https://medium.com/p/a0103642631a</guid>
            <category><![CDATA[serverless]]></category>
            <category><![CDATA[cloud-native]]></category>
            <category><![CDATA[serverless-architecture]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <dc:creator><![CDATA[Mohammed Firdous]]></dc:creator>
            <pubDate>Mon, 16 Sep 2024 14:24:29 GMT</pubDate>
            <atom:updated>2024-09-16T14:24:29.282Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lGy5sH3DLQfnpivkBF33jA.png" /><figcaption><strong>Serverless</strong></figcaption></figure><p>Serverless computing is a cloud-native approach that lets developers build and run applications without managing servers. Instead of handling server infrastructure, developers deploy code as functions that execute in response to events and automatically scale with demand.</p><p>Adopting serverless is not just a technology shift but a new mindset. It eliminates the need for server management, allowing teams to focus on creating event-driven, scalable applications. This approach streamlines development and helps businesses concentrate on their core goals, leading to faster and more efficient project delivery.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/984/1*PAuIbX5Ubsu-_qi8plHDSw.png" /><figcaption><strong>Serverless Architecture with AWS</strong></figcaption></figure><h3><strong>Serverless vs. Traditional Computing</strong></h3><p>Traditional computing requires managing server infrastructure, including provisioning, scaling, and maintenance. In contrast, serverless computing abstracts these concerns away. Functions are deployed and managed by the cloud provider, focusing on the code rather than the infrastructure.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*C4c-oEENpiMfIvNoBfPF3A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xhjimvwkSpaaunwJX0BQsA.png" /><figcaption><strong>Traditional-Based vs Serverless</strong></figcaption></figure><h3>Traditional Server-Based Computing</h3><p><strong>Advantages</strong>:</p><ol><li><strong>Full Control</strong>: Allows for tailored system management.</li><li><strong>Predictable Performance</strong>: Consistent and reliable performance.</li><li><strong>Flexibility in Deployment</strong>: Can be customized to fit specific needs.</li></ol><p><strong>Disadvantages</strong>:</p><ol><li><strong>Manual Scaling</strong>: Requires additional effort to adjust resources.</li><li><strong>Higher Costs</strong>: More expensive due to idle server costs.</li><li><strong>Server Management Overhead</strong>: Involves ongoing maintenance and management.</li></ol><h3>Serverless Computing</h3><p><strong>Advantages</strong>:</p><ol><li><strong>Scalability</strong>: Automatically adjusts to handle high workloads.</li><li><strong>Cost-Efficiency</strong>: Users only pay for the resources they consume.</li><li><strong>No Server Management</strong>: The provider manages servers, reducing maintenance tasks.</li></ol><p><strong>Disadvantages</strong>:</p><ol><li><strong>Event-Driven</strong>: May not suit applications requiring continuous processing.</li><li><strong>Cold Start Latency</strong>: Can cause delays when initiating new instances.</li><li><strong>Vendor Lock-In</strong>: Switching providers can be difficult due to proprietary services.</li></ol><h3>Build for Events</h3><p>Serverless computing excels with event-driven systems, where applications react to specific triggers like API calls or data changes. This approach encourages breaking down your application into small, manageable functions that handle individual events. The event-driven workflow involves an event trigger that initiates function execution, which processes the event and sends a response — without the need for manual server management. This makes your application easier to build and maintain.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/255/1*HJCI5Q4ZU_CHvUhKUnD4fQ.png" /><figcaption><strong>Event-driven workflow</strong></figcaption></figure><h3>Automatic Scaling</h3><p>A key advantage of serverless computing is automatic scaling. Functions dynamically adjust resources based on demand, allocating more during high traffic and scaling down when traffic decreases. This means you don’t need to estimate resource needs — the system adjusts automatically, ensuring efficient handling of varying loads.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A1xUXbehkw5L59GFg4ld2Q.png" /><figcaption><strong>Auto-Scaling System for Serverless Functions</strong></figcaption></figure><h3>Pay for What You Use</h3><p>One of the key benefits of serverless is that you only pay for the services you use. You don’t have to pay for idle servers, which means lower costs. The serverless mindset is about being efficient and saving money by paying for actual usage.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DmsyIz3KzhhV_lMthW8ocw.png" /><figcaption><strong>Pay for what you use</strong></figcaption></figure><h3>Benefits of Serverless Computing</h3><p>Serverless computing provides cost efficiency, scalability, and reduced operational overhead. By removing the need for server management, businesses can focus on developing their core applications. This approach streamlines development, allowing teams to concentrate on solving business problems while the cloud provider handles scaling and infrastructure.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0XKJPGkL0weY1YVd5DTfjA.png" /><figcaption><strong>Benefits of Serverless Computing</strong></figcaption></figure><h3>Conclusion</h3><p>Adopting a serverless mindset means focusing on building what matters, letting the system scale automatically, paying only for what you use, and designing your application around events. It’s a simpler, more efficient way to develop modern applications.</p><p><strong>Explore Serverless, Improve with Serverless, Grow with Serverless.</strong></p><p>Enjoy your reading, and I look forward to our next interaction! :)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*adXb1m7Cx-8_1LLk4lQ6tg.gif" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a0103642631a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding Docker]]></title>
            <link>https://medium.com/@mohammedfirdousaraoye/understanding-docker-fdfc1edf3bbd?source=rss-19706121782c------2</link>
            <guid isPermaLink="false">https://medium.com/p/fdfc1edf3bbd</guid>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[containerization]]></category>
            <dc:creator><![CDATA[Mohammed Firdous]]></dc:creator>
            <pubDate>Sat, 09 Dec 2023 08:35:49 GMT</pubDate>
            <atom:updated>2023-12-15T11:02:14.942Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dEgEQ0JBlwn323Q_i0spsg.png" /></figure><p>Greetings, fellow Cloud Explorers! I’m excited to be writing once more, and this time, I will be talking about <strong>Docker</strong>.</p><p>To understand <strong>Docker</strong>, you need to understand the meaning of <strong>containerization</strong>.</p><p>As software development changes constantly, efficiency and scalability are super important. Now let us talk about <strong>containerization</strong>. It puts applications and their needs into separate containers, making it easy to deploy them on different systems.</p><p>Containerization offers several key benefits that make it an attractive choice for software development projects.</p><p>Firstly, containers provide a lightweight and portable solution for packaging applications. By putting an application and its dependencies into a single container, developers can ensure consistent and reliable deployments across different systems.</p><p>Secondly, containerization allows for higher scalability and usage of resources. Containers can be easily scaled up or down depending on the demand, allowing applications to handle increased traffic without the need for significant infrastructure changes.</p><h3>Docker</h3><p>Now, let us talk about Docker, I am sure you have been waiting for this :)</p><p><strong>Docker</strong>, an open-source platform, has changed the way software is developed and deployed. Docker makes containerization easier for developers of all levels by providing user-friendly tools and APIs. Docker architecture follows a client-server model, where the client interacts with the Docker daemon to build, run, and manage containers. Containers are built on Docker image, which are easily shared and reusable across various environments.</p><p>By using Docker’s command-line or user-friendly graphical tools, developers can easily create, deploy, and manage containers using Docker. Docker offers an extensive range of official and community images, removing the need for manual setup of dependencies, which saves time and reduces configuration mistakes.<strong> Docker Hub</strong>, the main image repository, makes it easier to share and find containerized applications.</p><h3>Docker Architecture</h3><p>To enable containerization, management, and deployment of applications, Docker consists of several components that work together.</p><ol><li><strong>Docker Engine</strong>: This is the core of Docker, and it is responsible for creating and managing containers. Within the Docker Engine, it consists of;</li></ol><ul><li><strong>Docker Daemon (dockerd)</strong>: This runs in the background, managing Docker API requests and handling Docker objects like images, containers, networks, and volumes.</li><li><strong>Docker Client (docker)</strong>: A command-line tool allowing users to interact with the Docker daemon, executing commands to build, run, and manage containers.</li></ul><p>2. <strong>Images:</strong> These are templates containing applications and their necessary dependencies for running in isolation. Also, they are built using a <strong>Dockerfile</strong>, which specifies instructions for creating the image.</p><p>3. <strong>Containers:</strong> These are instances of Docker images that run applications in isolated environments. Each container has its own filesystem, processes, and networking, ensuring isolation while sharing the host OS kernel.</p><p>4. <strong>Registries: </strong>It is used to<strong> s</strong>tore Docker images. Docker Hub is the default public registry for finding, sharing, and downloading Docker images. Private registries like Amazon ECR, Azure Container Registry, or Google Container Registry store and distribute custom Docker images within organizations.</p><p>5. <strong>Docker Compose</strong>: This is a tool for defining and managing multi-container Docker applications. It also uses YAML files to configure multiple services.</p><p>6. <strong>Docker Swarm / Kubernetes: </strong>These are orchestration tools used for managing and scaling containers in a clustered environment.</p><p>For Docker Swarm, this is Docker’s native clustering and orchestration tool for users to manage multiple Docker nodes and deploy services across them.</p><p>Also, Kubernetes is an open-source container orchestration system used for automating deployment, scaling, and management of containerized applications.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/605/1*NuAuoKqmvUtcmXQ0C2a8iQ.png" /><figcaption><strong>Docker Architecture</strong></figcaption></figure><h3><strong>Containers vs Virtual Machines: A Comparison</strong></h3><p>To truly appreciate the power of containerization, it is essential to understand the differences between Docker containers and traditional virtual machines (VMs).</p><p>While both technologies enable isolation and resource allocation, they do it in distinct ways. Virtual machines emulate an entire operating system and run multiple instances of these emulated environments on a physical host, because each VM has its own kernel, memory, and resources, they are naturally large and demanding in terms of resources.</p><p>On the other hand, Docker containers share resources and the kernel of the host system. This approach leads to a notably smaller footprint and quicker startup durations compared to virtual machines.</p><p>A hypervisor is required to control the virtualization process in VMs, whereas Docker containers use the host operating system’s kernel and the Docker daemon. Containers are lighter, more efficient, more portable than virtual machines due to this difference. In terms of performance, Docker containers outshine VMs due to their minimal overhead. Containers can be launched and stopped within seconds, making them ideal for applications that require rapid scaling or frequent deployments.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/1*umnuGOVDw1-XRWvf5K4nAQ.png" /><figcaption><strong>VMs vs Containers</strong></figcaption></figure><h3><strong>Getting Started with Docker: Installation and Setup</strong></h3><p>The first step is to install Docker on your development machine or server. Docker provides installation packages for various operating systems, including <strong>Windows, macOS, and popular Linux distributions</strong>. After installing Docker, you’ll need to specify some basic settings and confirm that Docker is working properly. Here is a guide on how to install<strong> </strong><a href="https://docs.docker.com/engine/install/"><strong>Docker</strong></a> on your local machine.</p><p>For Linux, the process includes adding your user to the <strong>Docker group</strong> and initiating the Docker daemon. On other platforms (<strong>Windows and Mac</strong>), Docker should automatically start after installation. After the initial setup, you can verify your Docker installation by running a simple command, such as <strong>docker run hello-world</strong> on a terminal or command prompt. This command pulls a lightweight Docker image and runs a container based on it. If everything is configured correctly, you should see a friendly greeting from Docker, confirming that your installation is working as expected.</p><figure><img alt="Working as expected" src="https://cdn-images-1.medium.com/max/673/1*p3cGGc21bJ1O0Q8epaCmbw.png" /></figure><p>PS: <strong>I am using a Windows Machine :)</strong></p><h3>Container vs Image</h3><p>A container is a runtime instance of an image. It’s a lightweight, executable software package that includes an application and all its dependencies (libraries, binaries, and configuration files) needed to run it.</p><p>An image is a static, read-only template used to create containers. It’s a snapshot of a filesystem with an application’s code, libraries, and dependencies, along with metadata describing how to run the application.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/356/1*qnKd_b7DuoMhWPDdnNOhwQ.png" /></figure><h3>Building and Running Containers with Docker</h3><p>Now that Docker is up and running, it’s time to understand the process of building and running containers. Docker provides a simple workflow for creating and managing containers, making it accessible to accessible to developers of all skill levels.</p><p>But first, let me talk about running an instance of an image on Docker. To run an image, you can visit <a href="https://hub.docker.com/"><strong>Docker Hub</strong></a> and pull your desired image.</p><p>If you do not have the desired image on your local machine, run docker run &lt;image_name&gt; without pulling the image first will prompt Docker to try and download the image automatically from the default registry (usually <strong>Docker Hub</strong>)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/845/1*JpiiG0poCLDKhzcG427Kew.png" /><figcaption><strong>docker run.</strong></figcaption></figure><p>I chose a specific tag to launch the Python image because python is considerably a large file, So I opted for the <strong>Alpine variant</strong>. <strong>Alpine</strong> is a lightweight distribution.</p><h3><strong>Common Docker Commands</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R9hTN1EP8SMIGTcnOsb2pg.png" /><figcaption><strong>Common docker commands.</strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eEnwtTkgErHcMGchHwLzOQ.png" /><figcaption><strong>Docker commands in action</strong></figcaption></figure><h3>DockerFile</h3><p>A Dockerfile is a text file containing instructions for creating an image. These steps involve specifying the base image, adding dependencies, copying files into the image, and describing the commands that will be executed when the container starts. You can also specify additional options, such as port mapping, environment variables, and volume mounts, to customize the container’s behavior.</p><p>Once the Dockerfile is ready, you can build the image using the <strong>docker build</strong> command.</p><pre># Use an official Node.js runtime as the base image<br>FROM node:14<br><br># Set the working directory inside the container<br>WORKDIR /usr/src/app<br><br># Copy package.json and package-lock.json to the container<br>COPY package*.json ./<br><br># Install the application dependencies<br>RUN npm install<br><br># Copy the application code into the container<br>COPY . .<br><br># Expose a port (replace 3000 with your app&#39;s port if needed)<br>EXPOSE 3000<br><br># Define the command to run your application<br>CMD [&quot;npm&quot;, &quot;start&quot;]</pre><p>For more information on <strong>DockerFile</strong>, visit the official <a href="https://docs.docker.com/engine/reference/builder/">Docker Documentation</a></p><h3>Docker Compose</h3><p>To run multiple containers, we use <strong>Docker Compose</strong>. This helps to deal with complexity, as your application grows. Docker Compose allows you to describe your application’s services, networks, and volumes. By defining the relationships between services and specifying their configurations, you can easily spin up an entire application stack with a single command.</p><pre>version: &#39;3.8&#39;<br><br>services:<br>  web:<br>    image: nginx:latest<br>    ports:<br>      - &quot;8080:80&quot;<br>    volumes:<br>      - ./html:/usr/share/nginx/html<br>    networks:<br>      - mynetwork<br><br>networks:<br>  mynetwork:<br>    driver: bridge</pre><ul><li>version: &#39;3.8&#39;: Specifies the version of the Docker Compose file format being used.</li><li>services: Defines the services or containers to be orchestrated.</li><li>web: Service name for the container.</li><li>image: nginx:latest: Specifies the Docker image (nginx:latest) to use for this service. It pulls the latest Nginx image from <strong>Docker Hub.</strong></li><li>ports: Maps the container&#39;s port to the host machine.</li><li>&quot;8080:80&quot;: Binds port <strong>8080 </strong>on the host to port <strong>80</strong> on the container.</li><li>volumes: Mounts a directory from the host into the container.</li></ul><p>./html:/usr/share/nginx/html: Mounts the local html directory to the container&#39;s /usr/share/nginx/html directory, this will allow changes in the host directory to reflect in the container.</p><ul><li>networks: Specifies the networks this service is connected to.</li><li>networks: Defines the networks to be used by the services.</li><li>mynetwork: Configures a custom bridge network named mynetwork for service communication.</li></ul><p>For more information about<strong> Docker Compose</strong>, you can visit the<a href="https://docs.docker.com/compose/"> Official Docker Documentation.</a></p><p>When I was learning more about <strong>Docker Compose</strong>, I found a super-helpful article by <a href="https://www.linkedin.com/in/jh-walker/">James Walke</a>r on Spacelift’s website. He really knows his stuff about <a href="https://spacelift.io/blog/docker-compose">Docker Compose</a> and explains it really well. If you’re curious to learn more about it, I totally recommend checking out his guide.</p><h3><strong>Docker Networking and Storage</strong></h3><p>Why do we need<strong> Docker Volumes</strong>?</p><p><strong>Docker volumes</strong> are used to store and manage data generated and used by Docker containers. They allow data to be isolated from the container, making operations like data backup, migration, and overall administration of persistent data inside the Docker ecosystem easier.</p><p>For example, storing MySQL data within the container’s filesystem binds it to the container. If the container is removed or replaced, the data is lost. This is when Docker Volumes comes into play. You can map a volume to store MySQL data outside the container. As a result, even if the container is removed or changed, the data is retained in the volume.</p><p>In Docker, they are three types of volumes.</p><ul><li><strong>Host Volumes</strong>: Host volumes transfer a directory from the host computer to the container directly. Changes made in the container are reflected on the host, and vice versa.</li></ul><pre># Creating a container with a host volume<br>docker run -d -v /path/on/host:/container/path my_image</pre><ul><li><strong>Anonymous Volumes</strong>: Docker manages anonymous volumes, which have no unique name or reference. When a container is started without providing a volume, they are built automatically.</li></ul><pre># Creating a container with an anonymous volume<br>docker run -d -v /container/path my_image</pre><ul><li><strong>Named Volumes</strong>: Named volumes are stored on the host machine’s filesystem. However, you can provide a custom name. They are easier to manage, and Docker handles their lifecycle.</li></ul><pre># Creating a container with a named volume<br>docker run -d -v my_volume:/container/path my_image</pre><p>For more information on <strong>Docker Volumes</strong>, <a href="https://docs.docker.com/storage/volumes/">Volumes | Docker Docs</a></p><p>As for Docker Networking, this enables containers to communicate with each other and with external systems. By default, Docker creates a virtual network for each project, allowing containers to interact with one another using their allocated names. Docker also provides features like port mapping, network aliases, and DNS resolution, making it easy to expose containerized services to the outside world.</p><p>There are several network drivers available in Docker. Some of them include,</p><ul><li><strong>bridge</strong>: The default network created by Docker when no specific network is specified. It also provides network connectivity between containers on the same Docker daemon host.</li><li><strong>host</strong>: This allows containers to use the host’s networking directly, bypassing the container-level network isolation. It is useful for applications requiring high performance or those that need access to the host’s networking stack.</li><li><strong>none</strong>: This driver in Docker is a network isolation mode where a container has no network connectivity. When a container is attached to the “<strong>none”</strong> network, it means it operates in complete isolation from the network, having no access to external networks or other containers.</li></ul><h3><strong>Container Orchestration</strong></h3><p>Understanding container orchestration is essential because there are times when applications get more complicated and require scalability over numerous containers or even multiple hosts.</p><p><strong>Docker Swarm</strong> is a container orchestration tool provided by Docker that enables the management and deployment of containerized applications across multiple hosts. It is now easier to manage a cluster of Docker hosts and allows for easy scaling, high availability, and load balancing of containers.</p><p>In Docker swarm, we can designate <strong>Manager Nodes</strong> and <strong>Worker Nodes</strong></p><p>For the<strong> Manager Nodes</strong>, they oversee the Swarm cluster, as well as the scheduling of services and the orchestration of container deployment. Manager nodes manage the cluster’s state, task allocations, and high availability.</p><p><strong>Worker Nodes</strong>, on the other hand, perform tasks and operate containers deployed by manager nodes. Worker nodes are not involved in cluster administration, but instead run containers and applications.</p><p>PS: <strong>Docker Swarm is well-suited for production environments.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/906/1*pTBZt1pVK-hESGTYr9Q01Q.png" /></figure><h3>Key Features of Docker Swarm:</h3><ol><li><strong>Cluster Management</strong>: With Docker Swarm, you can construct a cluster of Docker hosts (nodes) and manage them as a single entity.</li><li><strong>Service Deployment</strong>: It simplifies the deployment of services as collections of containers throughout the Swarm cluster, allowing applications to be quickly dispersed and scaled.</li><li><strong>Load Balancing</strong>: Swarm manages load balancing for services between nodes, ensuring that traffic is distributed efficiently among containers.</li><li><strong>High Availability</strong>: Provides fault tolerance and high availability by automatically restarting containers on healthy nodes if they fail.</li></ol><h3>Basic Workflow with Docker Swarm</h3><p><strong>Initialize a Swarm</strong></p><pre>docker swarm init - advertise-addr &lt;MANAGER-IP&gt;</pre><p><strong>Join Nodes to the Swarm</strong></p><pre>docker swarm join - token &lt;TOKEN&gt; &lt;MANAGER-IP&gt;:&lt;PORT&gt;</pre><p><strong>Deploy Services</strong></p><pre>docker service create - replicas &lt;number of replicas&gt;- name my_service my_image</pre><p>For more information on Docker swarm, you can visit the official <a href="https://docs.docker.com/engine/swarm/">Docker Swarm documentation</a>.</p><p>Thanks for reading this guide on<strong> Docker</strong>! To learn more, visit the<a href="https://docs.docker.com/"> official Docker documentation</a>. I hope this guide was useful for you.</p><p>Enjoy your reading, and I look forward to our next interaction! :)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*adXb1m7Cx-8_1LLk4lQ6tg.gif" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fdfc1edf3bbd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[3 Tier Architecture using AWS CloudFormation]]></title>
            <link>https://medium.com/@mohammedfirdousaraoye/3-tier-architecture-using-aws-cloudformation-419044db9587?source=rss-19706121782c------2</link>
            <guid isPermaLink="false">https://medium.com/p/419044db9587</guid>
            <category><![CDATA[cloudformation]]></category>
            <category><![CDATA[vpc]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[ec2-instance]]></category>
            <category><![CDATA[rds]]></category>
            <dc:creator><![CDATA[Mohammed Firdous]]></dc:creator>
            <pubDate>Fri, 03 Nov 2023 19:42:15 GMT</pubDate>
            <atom:updated>2024-03-19T15:24:38.014Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="Architectural Diagram" src="https://cdn-images-1.medium.com/max/673/1*IAJFMFIZT5RI2UAYV5QXFA.png" /></figure><p>Hello and welcome to my article about this project, I had so much fun working on this, and I would be happy to guide you through.</p><p>AWS 3-tier architecture has been a very popular project these days, I have seen lots of people talking about it, building, writing blogs on it. Inspired by this trend, I decided to jump on board and explore it myself, with a unique approach — leveraging the capabilities of <strong>AWS CloudFormation</strong> for implementation.</p><p>In a three-tier computing architecture, we have distinct layers, each with its specific role:</p><ol><li><strong>Presentation Tier (Web Tier)</strong>: This is the user-facing interface, like a website or mobile app, where users interact directly. It’s the only tier accessible from the internet and focuses on presenting data and enabling user interactions.</li><li><strong>Application Tier (Logic Tier): </strong>Positioned in the middle, it bridges the presentation and data tiers, processing and manipulating data from both. Most of the application’s logic and code execution occur here. It’s not directly accessible to end-users, serving as a crucial layer for business logic and data processing.</li><li><strong>Data Tier:</strong> The third and final tier stores and manages databases, containing essential data for the application. Access to this tier is restricted and can only be reached through the presentation and application tiers. This isolation enhances security and data integrity.</li></ol><p>I plan to utilize AWS CloudFormation for the deployment of a <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-lamp-amazon-linux-2.html"><strong>LAMP (Linux, Apache, MySQL, and PHP) application on Amazon Linux</strong></a> within the AWS environment.</p><p>What is <strong>AWS CloudFormation</strong>? <strong>AWS CloudFormation</strong> is an AWS service that allows you to define and provision your infrastructure using templates. It simplifies infrastructure management by automating the creation, update, and deletion of AWS resources based on your specifications in the templates. This approach is known as <strong>Infrastructure as Code (IaC).</strong></p><p>Personally, I prefer minimizing my usage of the AWS UI when working on project implementation.</p><p>For this project, you do need the following prerequisites:</p><ul><li>AWS Account</li><li>AWS Credentials, specifically, your access and secret keys configured, alongside the default region.</li><li>Basic Knowledge of AWS and AWS CloudFormation.</li><li><a href="https://aws.amazon.com/cli/">AWS CLI</a> installed and configured with your AWS credentials.</li></ul><h3>VPC-STACK</h3><pre>AWSTemplateFormatVersion: 2010-09-09<br><br>Description: |<br>  This template deploys a multi-tier Virtual Private Cloud (VPC)<br>  infrastructure with public and private subnets, routing, and associated resources.<br>  The template creates a VPC, public and private subnets in different Availability Zones,<br>  and sets up necessary routing for internet access and network isolation.<br><br>Parameters:<br>  VpcCidrBlock:<br>    Type: String<br>    Default: 10.0.0.0/16  # Default CIDR block for the VPC<br>  Az1:<br>    Type: AWS::EC2::AvailabilityZone::Name<br>    Default: us-east-2a  # Default Availability Zone<br>  SubnetCidrBlocks:<br>    Description: &quot;A list of CIDR blocks for subnets&quot;<br>    Type: CommaDelimitedList<br>    Default: &quot;10.0.0.0/24,10.0.4.0/24,10.0.8.0/24,10.0.12.0/24,10.0.16.0/24,10.0.20.0/24,10.0.24.0/24,10.0.28.0/24,10.0.32.0/24&quot;<br>  Az2:<br>    Description: &quot;Availability Zones for subnets&quot;<br>    Type: AWS::EC2::AvailabilityZone::Name<br>    Default: &quot;us-east-2b&quot;<br>  Az3:<br>    Description: &quot;Additional Availability Zones for subnets&quot;<br>    Type: AWS::EC2::AvailabilityZone::Name<br>    Default: &quot;us-east-2c&quot;<br><br># Creating the VPC resource using the specified parameters.<br>Resources:<br>  MyVPC:<br>    Type: AWS::EC2::VPC<br>    Properties:<br>      CidrBlock: !Ref VpcCidrBlock  # Using the VpcCidrBlock parameter value<br>      Tags:<br>        - Key: Name<br>          Value: MyVPC<br><br>  # Adding Internet Gateway, Elastic IP, and NAT Gateway for Public Access to the Internet<br>  IGW:<br>    Type: AWS::EC2::InternetGateway<br>    Properties:<br>      Tags:<br>        - Key: Name<br>          Value: MyIGW<br><br>  AttachIGW:<br>    Type: AWS::EC2::VPCGatewayAttachment<br>    Properties:<br>      VpcId: !Ref MyVPC<br>      InternetGatewayId: !Ref IGW<br><br>  NatGatewayEIP:<br>    Type: AWS::EC2::EIP<br>    DependsOn: AttachIGW<br>    Properties:<br>      Domain: vpc<br><br>  NATGW:<br>    Type: AWS::EC2::NatGateway<br>    Properties:<br>      AllocationId: !GetAtt NatGatewayEIP.AllocationId<br>      SubnetId: !Ref PublicSubnet1<br>      Tags:<br>        - Key: Name<br>          Value: NATGateWay<br><br>  RouteToIGW:<br>    Type: AWS::EC2::Route<br>    Properties:<br>      RouteTableId: !Ref PublicRouteTable<br>      GatewayId: !Ref IGW<br>      DestinationCidrBlock: 0.0.0.0/0<br><br>  # Routes to NAT Gateway for Private Subnets<br>  RoutetoNATGW1:<br>    Type: AWS::EC2::Route<br>    Properties:<br>      RouteTableId: !Ref PrivateRouteTable<br>      NatGatewayId: !Ref NATGW<br>      DestinationCidrBlock: 0.0.0.0/0<br><br>  RoutetoNATGW2:<br>    Type: AWS::EC2::Route<br>    Properties:<br>      RouteTableId: !Ref DBRouteTable<br>      NatGatewayId: !Ref NATGW<br>      DestinationCidrBlock: 0.0.0.0/0<br><br># Subnets                <br>  PublicSubnet1:<br>   Type: AWS::EC2::Subnet<br>   Properties:<br>      AvailabilityZone: !Ref Az1<br>      CidrBlock: !Select [0, !Ref SubnetCidrBlocks] # Use the first CIDR block from SubnetCidrBlocks<br>      VpcId: !Ref MyVPC<br>      Tags:<br>        - Key: Name<br>          Value: PublicSubnet1  # Name tag <br>  PublicSubnet2:<br>    Type: AWS::EC2::Subnet<br>    Properties:<br>      AvailabilityZone: !Ref Az2<br>      CidrBlock: !Select [1, !Ref SubnetCidrBlocks] # Use the second CIDR block from SubnetCidrBlocks<br>      VpcId: !Ref MyVPC<br>      Tags:<br>        - Key: Name<br>          Value: PublicSubnet2  # Name tag <br>  PublicSubnet3:<br>    Type: AWS::EC2::Subnet<br>    Properties:<br>      AvailabilityZone: !Ref Az3<br>      CidrBlock: !Select [2, !Ref SubnetCidrBlocks] # Use the third CIDR block from SubnetCidrBlocks<br>      VpcId: !Ref MyVPC<br>      Tags:<br>        - Key: Name<br>          Value: PublicSubnet3  # Name tag <br>  PrivateSubnet1:<br>    Type: AWS::EC2::Subnet<br>    Properties:<br>      AvailabilityZone: !Ref Az1<br>      CidrBlock: !Select [3, !Ref SubnetCidrBlocks]  # Use the fourth CIDR block from SubnetCidrBlocks<br>      VpcId: !Ref MyVPC<br>      Tags:<br>        - Key: Name<br>          Value: PrivateSubnet1  # Name tag     <br>  PrivateSubnet2:<br>    Type: AWS::EC2::Subnet<br>    Properties:<br>      AvailabilityZone: !Ref Az2<br>      CidrBlock: !Select [4, !Ref SubnetCidrBlocks]  # Use the fifth CIDR block from SubnetCidrBlocks<br>      VpcId: !Ref MyVPC<br>      Tags:<br>        - Key: Name<br>          Value: PrivateSubnet2  # Name tag         <br>  PrivateSubnet3:<br>    Type: AWS::EC2::Subnet<br>    Properties:<br>      AvailabilityZone: !Ref Az3<br>      CidrBlock: !Select [5, !Ref SubnetCidrBlocks]  # Use the sixth CIDR block from SubnetCidrBlocks<br>      VpcId: !Ref MyVPC<br>      Tags:<br>        - Key: Name<br>          Value: PrivateSubnet3  # Name tag        <br>  PrivateDBSubnet1:<br>    Type: AWS::EC2::Subnet<br>    Properties:<br>      AvailabilityZone: !Ref Az1<br>      CidrBlock: !Select [6, !Ref SubnetCidrBlocks]  # Use the seventh CIDR block from SubnetCidrBlocks<br>      VpcId: !Ref MyVPC<br>      Tags:<br>        - Key: Name<br>          Value: PrivateDBSubnet1  # Name tag <br>  PrivateDBSubnet2:<br>    Type: AWS::EC2::Subnet<br>    Properties:<br>      AvailabilityZone: !Ref Az2<br>      CidrBlock: !Select [7, !Ref SubnetCidrBlocks]  # Use the eighth CIDR block from SubnetCidrBlocks<br>      VpcId: !Ref MyVPC<br>      Tags:<br>        - Key: Name<br>          Value: PrivateDBSubnet2  # Name tag <br>  PrivateDBSubnet3:<br>    Type: AWS::EC2::Subnet<br>    Properties:<br>      AvailabilityZone: !Ref Az3<br>      CidrBlock: !Select [8, !Ref SubnetCidrBlocks]  # Use the nineth CIDR block from SubnetCidrBlocks<br>      VpcId: !Ref MyVPC<br>      Tags:<br>        - Key: Name<br>          Value: PrivateDBSubnet3  # Name tag <br><br># Adding Route Tables<br>  PublicRouteTable:<br>    Type: AWS::EC2::RouteTable<br>    Properties:<br>      VpcId: !Ref MyVPC # Associates the route table with the MyVPC <br>      Tags:<br>        - Key: Name<br>          Value: PublicRouteTable  # Name tag <br>  PrivateRouteTable:<br>    Type: AWS::EC2::RouteTable<br>    Properties:<br>      VpcId: !Ref MyVPC # Associates the route table with the MyVPC <br>      Tags:<br>        - Key: Name<br>          Value: PrivateRouteTable  # Name tag <br>  DBRouteTable:<br>    Type: AWS::EC2::RouteTable<br>    Properties:<br>      VpcId: !Ref MyVPC   # Associates the route table with the MyVPC   <br>      Tags:<br>        - Key: Name<br>          Value: DBRouteTable  # Name tag<br><br># Associating the route tables with their various subnets<br>  PublicSubnet1RouteAssociation:<br>    Type: AWS::EC2::SubnetRouteTableAssociation<br>    Properties:<br>      RouteTableId: !Ref PublicRouteTable  <br>      SubnetId: !Ref PublicSubnet1<br>  PublicSubnet2RouteAssociation:<br>    Type: AWS::EC2::SubnetRouteTableAssociation<br>    Properties:<br>      RouteTableId: !Ref PublicRouteTable  <br>      SubnetId: !Ref PublicSubnet2<br>  PublicSubnet3RouteAssociation:<br>    Type: AWS::EC2::SubnetRouteTableAssociation<br>    Properties:<br>      RouteTableId: !Ref PublicRouteTable  <br>      SubnetId: !Ref PublicSubnet3<br>  PrivateSubnet1RouteAssociation:<br>    Type: AWS::EC2::SubnetRouteTableAssociation<br>    Properties:<br>      RouteTableId: !Ref PrivateRouteTable  <br>      SubnetId: !Ref PrivateSubnet1  <br>  PrivateSubnet2RouteAssociation:<br>    Type: AWS::EC2::SubnetRouteTableAssociation<br>    Properties:<br>      RouteTableId: !Ref PrivateRouteTable  <br>      SubnetId: !Ref PrivateSubnet2<br>  PrivateSubnet3RouteAssociation:<br>    Type: AWS::EC2::SubnetRouteTableAssociation<br>    Properties:<br>      RouteTableId: !Ref PrivateRouteTable  <br>      SubnetId: !Ref PrivateSubnet3<br>  PrivateDBSubnet1RouteAssociation:<br>    Type: AWS::EC2::SubnetRouteTableAssociation<br>    Properties:<br>      RouteTableId: !Ref DBRouteTable <br>      SubnetId: !Ref PrivateDBSubnet1 <br>  PrivateDBSubnet2RouteAssociation:<br>    Type: AWS::EC2::SubnetRouteTableAssociation<br>    Properties:<br>      RouteTableId: !Ref DBRouteTable <br>      SubnetId: !Ref PrivateDBSubnet2<br>  PrivateDBSubnet3RouteAssociation:<br>    Type: AWS::EC2::SubnetRouteTableAssociation<br>    Properties:<br>      RouteTableId: !Ref DBRouteTable <br>      SubnetId: !Ref PrivateDBSubnet3<br><br>Outputs:<br>  VPC:<br>    Description: The ID of the VPC<br>    Value: !Ref MyVPC<br>    Export:<br>      Name: 3tier-VPC<br><br>  InternetGateway:<br>    Description: A reference to the internet gateway<br>    Value: !Ref IGW<br>    Export:<br>      Name: 3tier-IGW<br><br>  PublicSubnet1:<br>    Description: The ID of Public Subnet 1<br>    Value: !Ref PublicSubnet1<br>    Export:<br>      Name: 3tier-PublicSubnet1<br><br>  PublicSubnet2:<br>    Description: The ID of Public Subnet 2<br>    Value: !Ref PublicSubnet2<br>    Export:<br>      Name: 3tier-PublicSubnet2<br><br>  PublicSubnet3:<br>    Description: The ID of Public Subnet 3<br>    Value: !Ref PublicSubnet3<br>    Export:<br>      Name: 3tier-PublicSubnet3<br><br>  PrivateSubnet1:<br>    Description: The ID of Private Subnet 1<br>    Value: !Ref PrivateSubnet1<br>    Export:<br>      Name: 3tier-PrivateSubnet1<br><br>  PrivateSubnet2:<br>    Description: The ID of Private Subnet 2<br>    Value: !Ref PrivateSubnet2<br>    Export:<br>      Name: 3tier-PrivateSubnet2<br><br>  PrivateSubnet3:<br>    Description: The ID of Private Subnet 3<br>    Value: !Ref PrivateSubnet3<br>    Export:<br>      Name: 3tier-PrivateSubnet3<br><br>  PrivateDBSubnet1:<br>    Description: The ID of Private DB Subnet 1<br>    Value: !Ref PrivateDBSubnet1<br>    Export:<br>      Name: 3tier-PrivateDBSubnet1<br><br>  PrivateDBSubnet2:<br>    Description: The ID of Private DB Subnet 2<br>    Value: !Ref PrivateDBSubnet2<br>    Export:<br>      Name: 3tier-PrivateDBSubnet2<br><br>  PrivateDBSubnet3:<br>    Description: The ID of Private DB Subnet 3<br>    Value: !Ref PrivateDBSubnet3<br>    Export:<br>      Name: 3tier-PrivateDBSubnet3</pre><p>In this template, it is all about setting up a robust multi-tier Virtual Private Cloud (VPC) infrastructure. This template takes care of creating public and private subnets, routing, and other essential resources. So, let me break it down step by step:</p><p><strong>AWSTemplateFormatVersion</strong>: I started off by defining the template format version. It’s like setting the stage for the template.</p><p><strong>Description</strong>: In essence, it’s like saying, “This is what you’re getting into”. I clearly stated that this template will create a VPC with public and private subnets, set up routing, and make sure everything is well-connected. It sets the mood and the expectations, making the template more than just lines of code.</p><p><strong>Parameters: </strong>Here, I laid out the parameters that I can tweak when deploying this template.</p><ul><li>VpcCidrBlock: This parameter defines the IP address range for the VPC.</li><li>Az1, Az2, Az3: These parameters allow us to choose the Availability Zones.</li><li>SubnetCidrBlocks: It&#39;s a list of CIDR blocks for our subnets.</li></ul><p><strong>Resources</strong>: This is where the real magic happens. I was creating all the AWS resources that I need for the VPC infrastructure:</p><ul><li>MyVPC: The VPC itself.</li><li>IGW and AttachIGW: An Internet Gateway and its attachment to the VPC.</li><li>NatGatewayEIP and NATGW: A Network Address Translation (NAT) Gateway.</li><li>RouteToIGW: Setting up a route to the Internet Gateway.</li><li>RoutetoNATGW1 and RoutetoNATGW2: These are routes to our NAT Gateway.</li><li>A bunch of PublicSubnet and PrivateSubnet resources: Creating public and private subnets in different Availability Zones.</li><li>PublicRouteTable, PrivateRouteTable, and DBRouteTable: These are route tables for the created subnets.</li><li>Various RouteAssociation resources: Then connecting the route tables to their respective subnets.</li></ul><p><strong>Outputs</strong>: Finally, we have some valuable exports. These allow other AWS resources to access and use the outputs from our stack.</p><ul><li>VPC, InternetGateway, and various Subnet IDs are exported for use in other parts of our AWS environment.</li></ul><p>This template is definitely the biggest section of the 3tier- architecture because it involved a lot of resources. Throughout the template you will see the function <strong>!Ref </strong>a lot and !<strong>GetAtt.</strong> The <strong>!Ref</strong> function serves as a means to access values within your template. It allows you to refer to and retrieve various identifiers, like AMIs or ARNs, from different sections of your template.</p><p>The <strong>!GetAtt</strong> function enables you to fetch specific attributes from a resource. To use it, you provide the logical resource name and specify the attribute you want to retrieve. In this context, EIP stands for Elastic IP, and it’s crucial when connecting it to a NAT gateway in a public subnet. By employing <strong>!GetAtt</strong>, you can obtain the allocationID of the Elastic IP while creating the NAT gateway, ensuring the connection’s success.</p><pre>NATGW:<br>    Type: AWS::EC2::NatGateway<br>    Properties:<br>      AllocationId: !GetAtt NatGatewayEIP.AllocationId<br>      SubnetId: !Ref PublicSubnet1<br>      Tags:<br>        - Key: Name<br>          Value: NATGateWay</pre><p>Mind you, I did run into various errors whilst executing change sets for this stack in AWS CloudFormation, it was not all successful at first, I faced little setbacks due to various misconfigurations, for example, I corrected the <strong>RoutetoNATGW1</strong> and<strong> RoutetoNATGW2 </strong>to use <strong>NatGatewayId</strong> instead of <strong>GatewayId</strong> to specify the NAT Gateway.</p><pre>(-)<br>RoutetoNATGW:<br>    Type: AWS::EC2::Route<br>    Properties:<br>      RouteTableId: !Ref PrivateRouteTable<br>      GatewayId: !Ref NATGW<br>      DestinationCidrBlock: 0.0.0.0/0<br>  RoutetoNATIGW:<br>    Type: AWS::EC2::Route<br>    Properties:<br>      RouteTableId: !Ref DBRouteTable<br>      GatewayId: !Ref NATGW<br>      DestinationCidrBlock: 0.0.0.0/0         <br><br>(+)<br>RoutetoNATGW1:<br>    Type: AWS::EC2::Route<br>    Properties:<br>      RouteTableId: !Ref PrivateRouteTable<br>      NatGatewayId: !Ref NATGW<br>      DestinationCidrBlock: 0.0.0.0/0<br><br>  RoutetoNATGW2:<br>    Type: AWS::EC2::Route<br>    Properties:<br>      RouteTableId: !Ref DBRouteTable<br>      NatGatewayId: !Ref NATGW<br>      DestinationCidrBlock: 0.0.0.0/0</pre><p>Fixed it and it was successfully deployed.</p><p><strong>Note:</strong> <strong>NAT Gateways in AWS are immutable</strong>, which means you cannot directly update them. If you need to make changes to a NAT Gateway, you typically need to create a new one and update your route tables to use the new NAT Gateway.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1012/1*EcDnsIQawD1HN1c4hkNJeQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GqHHbznTCgn4wCJ_YA-slw.png" /><figcaption><strong>VPC-Stack</strong></figcaption></figure><h3><strong>EC2-Stack</strong></h3><pre>AWSTemplateFormatVersion: &#39;2010-09-09&#39;<br><br>Description: |<br>  This template creates resources for deploying EC2 instances and an Application Load Balancer (ALB) <br>  within a specified Virtual Private Cloud (VPC). The template includes security groups, EC2 instances, <br>  and an ALB to support a multi-tier application setup.<br><br>Resources:<br>  # Key Pair (Optional - Uncomment if needed)<br>  # MyKeyPair:<br>  #   Type: &#39;AWS::EC2::KeyPair&#39;<br>  #   Properties:<br>  #     KeyName: my-new-key-pair<br><br>  # Security group for the Test Server<br>  TestServerSecurityGroup:<br>    Type: AWS::EC2::SecurityGroup<br>    Properties:<br>      GroupDescription: Security group for Test Server<br>      # Import the VPC ID from another stack (VPC-Stack)<br>      VpcId: !ImportValue 3tier-VPC<br>      SecurityGroupIngress:<br>        - CidrIp: 0.0.0.0/0<br>          IpProtocol: tcp<br>          FromPort: 22<br>          ToPort: 22<br>      Tags:<br>        - Key: Name<br>          Value: SecurityGroup1<br><br>  # Security group for PHP Server 1<br>  PHPServer1SecurityGroup:<br>    Type: AWS::EC2::SecurityGroup<br>    Properties:<br>      GroupDescription: Security group for PHP Server 1<br>      # Import the VPC ID from another stack (VPC-Stack)<br>      VpcId: !ImportValue 3tier-VPC<br>      # Allow inbound traffic from the Test Server&#39;s security group and ALB&#39;s security group<br>      SecurityGroupIngress:<br>        - SourceSecurityGroupId: !Ref TestServerSecurityGroup<br>          IpProtocol: tcp<br>          FromPort: 22<br>          ToPort: 22<br>        - SourceSecurityGroupId: !Ref MyALBSecurityGroup<br>          IpProtocol: tcp<br>          FromPort: 80<br>          ToPort: 80  <br>      Tags:<br>        - Key: Name<br>          Value: PHPSecurityGroup1<br><br>  # EC2 instance for the Test Server in PublicSubnet1<br>  TestServerInstance:<br>    Type: &#39;AWS::EC2::Instance&#39;<br>    Properties:<br>      InstanceType: t2.micro<br>      ImageId: ami-08f3d5d5f119fbb31 # Amazon Linux 2 AMI<br>      KeyName: my-new-key-pair<br>      SubnetId: !ImportValue 3tier-PublicSubnet1<br>      SecurityGroupIds:<br>        - !Ref TestServerSecurityGroup<br>      Tags:<br>        - Key: Name<br>          Value: test-server<br><br>  # EC2 instance for PHP Server 1 in PrivateSubnet1<br>  PHPServer1Instance:<br>    Type: &#39;AWS::EC2::Instance&#39;<br>    Properties:<br>      InstanceType: t2.micro<br>      ImageId: ami-08f3d5d5f119fbb31 # Amazon Linux 2 AMI<br>      KeyName: my-new-key-pair<br>      SubnetId: !ImportValue 3tier-PrivateSubnet1<br>      SecurityGroupIds:<br>        - !Ref PHPServer1SecurityGroup<br>      Tags:<br>        - Key: Name<br>          Value: php-server-1<br><br>  # EC2 instance for PHP Server 2 in PrivateSubnet2<br>  PHPServer2Instance:<br>    Type: &#39;AWS::EC2::Instance&#39;<br>    Properties:<br>      InstanceType: t2.micro<br>      ImageId: ami-08f3d5d5f119fbb31 # Amazon Linux 2 AMI<br>      KeyName: my-new-key-pair<br>      SubnetId: !ImportValue 3tier-PrivateSubnet2<br>      SecurityGroupIds:<br>        - !Ref PHPServer1SecurityGroup  <br>      Tags:<br>        - Key: Name<br>          Value: php-server-2<br><br>  # Application Load Balancer Security Group<br>  MyALBSecurityGroup:<br>    Type: AWS::EC2::SecurityGroup<br>    Properties:<br>      GroupDescription: Security group for ALB <br>      GroupName: ALB_SG<br>      VpcId: !ImportValue 3tier-VPC<br>      SecurityGroupIngress: <br>        - <br>          CidrIp: 0.0.0.0/0<br>          FromPort: 80<br>          ToPort: 80<br>          IpProtocol: tcp<br>      SecurityGroupEgress:<br>        -<br>          CidrIp: 0.0.0.0/0<br>          FromPort: 80<br>          ToPort: 80<br>          IpProtocol: tcp<br><br>  # Application Load Balancer<br>  MyALB:<br>    Type: AWS::ElasticLoadBalancingV2::LoadBalancer<br>    Properties:<br>      Name: MyALB<br>      Scheme: internet-facing<br>      Type: application<br>      Subnets: <br>        - !ImportValue 3tier-PublicSubnet1<br>        - !ImportValue 3tier-PublicSubnet2<br>      SecurityGroups: <br>        - !Ref MyALBSecurityGroup<br>      IpAddressType: ipv4<br><br>  # Application Load Balancer Target Group<br>  MyALBTargetGroup:<br>    Type: AWS::ElasticLoadBalancingV2::TargetGroup<br>    Properties:<br>      Name: MyALBTargetGroup<br>      Port: 80<br>      Protocol: HTTP<br>      VpcId: !ImportValue 3tier-VPC<br>      TargetType: instance<br>      HealthCheckIntervalSeconds: 180<br>      HealthCheckPath: /<br>      HealthCheckPort: 80<br>      HealthCheckProtocol: HTTP<br>      HealthCheckTimeoutSeconds: 60<br>      HealthyThresholdCount: 5<br>      Matcher: <br>        HttpCode: 200<br>      UnhealthyThresholdCount: 5<br>      Targets: <br>      - Id: !Ref PHPServer1Instance<br>      - Id: !Ref PHPServer2Instance     <br><br>  # Application Load Balancer Listener<br>  MyALBListener:<br>    Type: AWS::ElasticLoadBalancingV2::Listener<br>    Properties:<br>      LoadBalancerArn: !Ref MyALB<br>      Port: 80<br>      Protocol: HTTP<br>      DefaultActions: <br>        - <br>          TargetGroupArn: !Ref MyALBTargetGroup<br>          Type: forward    <br><br>Outputs:<br>  TestServerInstanceOutput:<br>    Description: ID of the Test Server EC2 instance<br>    Value: !Ref TestServerInstance<br>    Export:<br>      Name: 3tier-TestServerInstance<br><br>  PHPServer1InstanceOutput:<br>    Description: ID of the PHP Server 1 EC2 instance<br>    Value: !Ref PHPServer1Instance<br>    Export:<br>      Name: 3tier-PHPServer1Instance<br><br>  PHPServer2InstanceOutput:<br>    Description: ID of the PHP Server 2 EC2 instance<br>    Value: !Ref PHPServer2Instance<br>    Export:<br>      Name: 3tier-PHPServer2Instance<br><br>  TestServerSecurityGroupId:<br>    Description: ID of the Test Server Security Group<br>    Value: !Ref TestServerSecurityGroup<br>    Export:<br>      Name: 3tier-TestServerSecurityGroup<br><br>  PHPServer1SecurityGroupId:<br>    Description: ID of the PHP Server Security Group<br>    Value: !Ref PHPServer1SecurityGroup<br>    Export:<br>      Name: 3tier-PHPServer1SecurityGroup<br><br>  MyALBDNSName:<br>    Description: DNS name of the Application Load Balancer<br>    Value: !GetAtt MyALB.DNSName<br>    Export:<br>      Name: 3tier-MyALBDNSName<br><br>  MyALBSecurityGroupId:<br>    Description: ID of the Application Load Balancer Security Group<br>    Value: !Ref MyALBSecurityGroup<br>    Export:<br>      Name: 3tier-MyALBSecurityGroup<br><br>  MyALBId:<br>    Description: ID of the Application Load Balancer<br>    Value: !Ref MyALB<br>    Export:<br>      Name: 3tier-MyALB<br><br>  MyALBTargetGroupId:<br>    Description: ID of the Target Group associated with the ALB<br>    Value: !Ref MyALBTargetGroup<br>    Export:<br>      Name: 3tier-MyALBTargetGroup</pre><p><strong>AWSTemplateFormatVersion</strong>: I started off by defining the template format version.</p><p><strong>Description</strong>: I clearly stated that this template is designed to create resources for deploying EC2 instances and an Application Load Balancer (ALB) within a specified Virtual Private Cloud (VPC). The template includes the setup of various security groups, EC2 instances, and an ALB to support a multi-tier application configuration.</p><p><strong>Resources</strong>: I was creating all the AWS resources that I need for the EC2 infrastructure</p><p>The key pair was commented out because I could not download my generated key pair when it was created on my AWS Console, so I took the initiative to create one manually and download it on my local computer. <strong>Why</strong>? Well, I do need the downloaded key pair for securely accessing my EC2 instances through SSH.</p><h3><strong>EC2 Instances</strong></h3><p>These EC2 instances are created in the template to fulfill specific roles in a multi-tier application setup. They serve distinct purposes within the architecture to support the functionality of the overall system.</p><p><strong>TestServerInstance- This is a</strong>n EC2 instance for the Test Server in (PublicSubnet1). It is a <strong>t2.micro</strong> instance running <strong>Amazon Linux 2</strong> and associated with the <strong>TestServerSecurityGroup.</strong></p><p><strong>PHPServer1Instance- This is a</strong>n EC2 instance for PHP Server 1 in (PrivateSubnet1). It is a <strong>t2.micro</strong> instance running <strong>Amazon Linux 2</strong> and associated with the <strong>PHPServer1SecurityGroup</strong>.</p><p><strong>PHPServer2Instance- This is a</strong>n EC2 instance for PHP Server 2in (PrivateSubnet2). It is a <strong>t2.micro</strong> instance running <strong>Amazon Linux 2</strong> and associated with the <strong>PHPServer1SecurityGroup</strong>.</p><p>I used the <strong>!ImportValue</strong> while creating the instances, I needed the Subnets from the VPC, so this function is used to get the subnet ID from a different stack(VPC-Stack).</p><p>Also I used the <strong>!Ref</strong> function, which is used to get the value of the security groups as defined in the template.</p><h3>Security Groups</h3><p>I need security groups for these EC2 instances, so for each instance, a security group was attached to it. That is why you will see <strong>SecurityGroupIds </strong>property in each instance.</p><p>An example:</p><pre>SecurityGroupIds:<br> - !Ref SecurityGroups</pre><p>For each security group, there is an ingress security rules in which I had to include a <strong>CidrIp </strong>or a <strong>SourceSecurityGroupID.</strong></p><p>For the<strong> TestServerSecurityGroup, </strong>you can see that under the <strong>SecurityGroupIngress, t</strong>he configuration allows any IP address (0.0.0.0/0) to connect via TCP on port 22, typically used for SSH access.</p><p>For the<strong> PHPServer1SecurityGroup, under the SecurityGroupIngress, </strong>the first rule allows inbound TCP traffic on port 22 from the TestServerSecurityGroup, typically for SSH access.</p><p>The second rule permits inbound TCP traffic on port 80 from the MyALBSecurityGroup, usually for web traffic.</p><p>I did encounter some errors while creating the instances alongside associating them with the security groups, like in the TestServerInstance</p><pre>(-) <br>TestServerInstance:<br>    Type: &#39;AWS::EC2::Instance&#39;<br>    Properties:<br>      InstanceType: t2.micro<br>      ImageId: ami-08f3d5d5f119fbb31 # Amazon Linux 2 AMI<br>      KeyName: !Ref MyKeyPair<br>      # Associate the instance with the public subnet from your VPC<br>      SubnetId: !ImportValue VPC-Stack-PublicSubnet<br>      # Enable public IP auto-assignment<br>      AssociatePublicIpAddress: true<br><br>(+)<br>TestServerInstance:<br>    Type: &#39;AWS::EC2::Instance&#39;<br>    Properties:<br>      InstanceType: t2.micro<br>      ImageId: ami-08f3d5d5f119fbb31 # Amazon Linux 2 AMI<br>      KeyName: my-new-key-pair<br>      SubnetId: !ImportValue 3tier-PublicSubnet1<br>      SecurityGroupIds:<br>        - !Ref TestServerSecurityGroup<br>      Tags:<br>        - Key: Name<br>          Value: test-server</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G8huT2-1r4Rv5l6KjrbCAw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/647/1*YdUvie_6tf6TFkiHLwiIZQ.png" /><figcaption><strong>EC2-Stack (I)</strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XVLChwapxoQx3NU3_cadRA.png" /><figcaption><strong>EC2-Stack (II)</strong></figcaption></figure><p>For the <strong>MyALBSecurityGroup</strong>, this was specifically for the Application Load Balancer, that I would discuss more about later on.</p><ul><li>VpcId: !ImportValue 3tier-VPC: This associates the security group with the Virtual Private Cloud (VPC) specified in the imported value from another stack (VPC-Stack).</li><li>SecurityGroupIngress: I configured inbound rules. In this case, it allows incoming TCP traffic on port 80 (typically for HTTP) from any source with the CIDR IP <strong>&#39;0.0.0.0/0&#39;,</strong> effectively allowing any IP address to access the ALB on port <strong>80</strong>.</li><li>SecurityGroupEgress: I configured outbound rules. It allows the ALB to initiate outgoing TCP traffic on port <strong>80</strong> to any destination with the CIDR IP<strong> &#39;0.0.0.0/0</strong>&#39;.</li></ul><p>After creating the EC2 Instances, then I went further to check if I can connect with the servers using SSH.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*O4a0we64ZHXqg_J7-0Roqw.png" /><figcaption><strong>EC2-Instances</strong></figcaption></figure><p>I was able to login into the <strong>test-server </strong>using SSH alongside setting permissions for my already downloaded key-pair.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9_LA5gkiJ-saU5hUmUHdng.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZqVXvLH4W7iSmgXYfa6m7g.png" /><figcaption>TestServerInstance</figcaption></figure><p>After login into my<strong> test server</strong>, I tried logging into my <strong>php-server-1</strong> from the <strong>test server.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jyeMY3mydah27EA0SGQC5g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jyeMY3mydah27EA0SGQC5g.png" /></figure><p>After logging into my php server 1, I had to follow steps provided by AWS to install PHP and Apache on the server.</p><p>I will be deploying a<strong> </strong><a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-lamp-amazon-linux-2.html"><strong>LAMP</strong> <strong>(Apache web server with PHP and MySQL on Amazon Linux)</strong></a> application on AWS.</p><pre>sudo yum update -y    <br># installing required packages<br>sudo amazon-linux-extras install -y lamp-mariadb10.2-php7.2 php7.2<br># we do not require mariadb cause i made use of RDS in aws.<br>sudo yum install -y httpd m<br>sudo yum install -y httpd <br># start the Apache web server<br>sudo systemctl start httpd<br># enable the Apache web server<br>sudo systemctl enable httpd<br># verifying whether it is enabled<br>sudo systemctl is-enabled httpd<br><br><br>#checking whether the http service is enabled and working as it should<br>curl http://localhost</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0vmaZ8yXy4tA4JsivrP13w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*do9itY7aUYfwAlrAW3GUqQ.png" /><figcaption><strong>Apache web server</strong></figcaption></figure><p>Now I had to check whether the http service was enabled and working, using <strong>curl </strong><a href="http://localhost/"><strong>http://localhost</strong></a><strong>.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jyEe_jJhxq4QZHtM91Yx4A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zmKtmjSZCLos4I7daVFLgw.png" /><figcaption><strong>Checking…</strong></figcaption></figure><p>After successfully installing the <strong>Apache Web Server</strong>, I had to set file permissions. I needed to grant myself, as the <strong>ec2-user</strong>, the ability to manage files in the Apache document root located at <strong>/var/www/html.</strong></p><p>To achieve this, I took the step of modifying ownership and permissions for the directory.</p><pre>sudo usermod -a -G apache ec2-user<br>exit<br><br># ssh into the php server again<br>ssh -i &quot;your key pair&quot; ec2-user@privateip<br><br>groups<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>find /var/www -type f -exec sudo chmod 0664 {} \;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yjuQAdPzcq9fw3JGBz4yaA.png" /><figcaption><strong>setting file permissions</strong></figcaption></figure><h3><strong>Installing phpMyAdmin</strong></h3><p>I followed the procedures under Step 4 in the tutorial of <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-lamp-amazon-linux-2.html">Install LAMP on Amazon Linux 2</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*94qG4jpqqexaIlkmcnufKA.png" /><figcaption><strong>Installing phpMyAdmin</strong></figcaption></figure><h3>Load Balancers</h3><p>I went further to create an Application Load Balancer, and everything associated with it like the target groups and listeners.</p><pre># Application Load Balancer<br>  MyALB:<br>    Type: AWS::ElasticLoadBalancingV2::LoadBalancer<br>    Properties:<br>      Name: MyALB<br>      Scheme: internet-facing<br>      Type: application<br>      Subnets: <br>        - !ImportValue 3tier-PublicSubnet1<br>        - !ImportValue 3tier-PublicSubnet2<br>      SecurityGroups: <br>        - !Ref MyALBSecurityGroup<br>      IpAddressType: ipv4<br><br>  # Application Load Balancer Target Group<br>  MyALBTargetGroup:<br>    Type: AWS::ElasticLoadBalancingV2::TargetGroup<br>    Properties:<br>      Name: MyALBTargetGroup<br>      Port: 80<br>      Protocol: HTTP<br>      VpcId: !ImportValue 3tier-VPC<br>      TargetType: instance<br>      HealthCheckIntervalSeconds: 180<br>      HealthCheckPath: /<br>      HealthCheckPort: 80<br>      HealthCheckProtocol: HTTP<br>      HealthCheckTimeoutSeconds: 60<br>      HealthyThresholdCount: 5<br>      Matcher: <br>        HttpCode: 200<br>      UnhealthyThresholdCount: 5<br>      Targets: <br>      - Id: !Ref PHPServer1Instance<br>      - Id: !Ref PHPServer2Instance     <br><br>  # Application Load Balancer Listener<br>  MyALBListener:<br>    Type: AWS::ElasticLoadBalancingV2::Listener<br>    Properties:<br>      LoadBalancerArn: !Ref MyALB<br>      Port: 80<br>      Protocol: HTTP<br>      DefaultActions: <br>        - <br>          TargetGroupArn: !Ref MyALBTargetGroup<br>          Type: forward</pre><p>In the Application Load Balancer, it is named <strong>MyALB</strong>(it can be any naming of your choice, that is my preference). Also, it is configured to be <strong>internet-facing</strong>, meaning it can route traffic from the internet to the instances.</p><p>The <strong>ALB</strong> type is set to <strong>application. </strong>This means it can route HTTP and HTTPS traffic and it operates with IPv4 addresses.</p><ul><li>It’s associated with two public subnets, defined by the !ImportValue statements. (I took the subnets from the VPC Stack)</li><li>The ALB’s security groups are specified with !Ref MyALBSecurityGroup (I explained this security group earlier while talking about it)</li></ul><p>For the Target Group, it is named <strong>MyALBTargetGroup. </strong>The target group listens on port <strong>80</strong> and uses the <strong>HTTP</strong> protocol. It is associated with the VPC specified by !ImportValue 3tier-VPC. I set the target type to <strong>instance</strong>, which means it directs traffic to instances. The Targets section defines the instances that the ALB routes traffic to. Two instances are specified in this target group, and their IDs are referenced using !Ref. The <strong>ALB</strong> directs traffic to these instances to distribute incoming requests and load balance the application.</p><ul><li>Health checks are performed on the instances with an interval of <strong>180 seconds.</strong></li><li>The health check path is set to “/”, meaning it checks the root URL.</li><li>Health checks are conducted on port<strong> 80</strong> using <strong>HTTP.</strong></li><li>If instances don’t respond as expected, they are considered unhealthy after <strong>60 seconds</strong> of not passing health checks.</li><li>For an instance to be deemed healthy, it must pass five consecutive health checks.</li><li>The target group uses a matcher to check for an <strong>HTTP</strong> response code of 200.</li><li>If instances fail five consecutive health checks, they are marked as unhealthy.</li></ul><p>For the Listener, I named it as <strong>MyALBListener. </strong>It’s connected to the ALB specified with !Ref MyALB.</p><p>The listener listens on port 80 and uses the HTTP protocol and the default action forwards incoming traffic to the target group.</p><p>Then after defining my resources, I updated my EC2-Stack to include these in my applications.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*71pmmlUDyPcmzMLxzgUtsQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dU7L4NmLS79EANDF6UmDmg.png" /><figcaption><strong>ALB with Target Groups and Listeners</strong></figcaption></figure><p>Well, to be sure that these services were actually working, I had to check again.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EFHYsd-wEy4wfWhWMI7vVw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*x-ViP4d-ECh812BzIETkVw.png" /><figcaption><strong>Successful deployment(hahaha)</strong></figcaption></figure><p>Now, I went ahead to copy the DNS name of the ALB, to see whether the test page was working and it did, my Apache web server was working!!!. What a relief.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KZ4YCQ32kLsoVlqVuuEQJw.png" /><figcaption><strong>DNS of ALB working!!!</strong></figcaption></figure><h3><strong>DB-Stack</strong></h3><pre>Description: |<br>  This template provisions an Amazon RDS (Relational Database Service) instance<br>  in a multi-Availability Zone (AZ) setup within a DB subnet group. <br>  The RDS instance is configured with the specified database engine (MySQL), <br>  security groups, and other parameters.<br><br>Parameters:<br>  Az1:<br>    Type: AWS::EC2::AvailabilityZone::Name<br>    Default: us-east-2a  # Default Availability Zone<br><br>  DBUsername:<br>    Description: Enter a username to be used with the RDS database<br>    Type: String<br>    Default: admin<br><br>  DBPassword:<br>    Description: Enter a password to be used with the RDS database<br>    Type: String<br>    Default: password<br><br>Resources:<br>  # Create a DB subnet group for RDS<br>  DBSubnetGroup:  <br>    Type: AWS::RDS::DBSubnetGroup<br>    Properties: <br>      DBSubnetGroupDescription: Subnet group for RDS<br>      DBSubnetGroupName: db_subnet_group<br>      SubnetIds:  <br>        - !ImportValue 3tier-PrivateDBSubnet1<br>        - !ImportValue 3tier-PrivateDBSubnet2<br><br>  # Create a security group for the RDS instance<br>  DBTierSecurityGroup:<br>    Type: AWS::EC2::SecurityGroup<br>    Properties:<br>      GroupDescription: My DB Security Group<br>      VpcId: !ImportValue 3tier-VPC<br>      SecurityGroupIngress:<br>        - CidrIp: 0.0.0.0/0<br>          IpProtocol: tcp<br>          FromPort: 3306<br>          ToPort: 3306<br><br>  # Authorize inbound traffic from the PHP Server&#39;s security group<br>  MyDBSecurityGroupIngress:<br>    Type: &quot;AWS::EC2::SecurityGroupIngress&quot;<br>    Properties:<br>      GroupId: !GetAtt DBTierSecurityGroup.GroupId<br>      IpProtocol: tcp<br>      FromPort: 3306<br>      ToPort: 3306<br>      SourceSecurityGroupId: !ImportValue 3tier-PHPServer1SecurityGroup<br><br>  # Create the RDS instance<br>  RDSInstance:<br>    Type: AWS::RDS::DBInstance<br>    Properties:<br>      DBName: mydatabase<br>      AvailabilityZone: !Ref Az1<br>      DBInstanceClass: db.t3.micro <br>      DBSubnetGroupName: !Ref DBSubnetGroup<br>      VPCSecurityGroups: [!Ref DBTierSecurityGroup]<br>      Engine: mysql<br>      MultiAZ: false<br>      PubliclyAccessible: false<br>      StorageType: gp2<br>      MasterUsername: !Ref DBUsername<br>      MasterUserPassword: !Ref DBPassword<br>      AllocatedStorage: 20<br>      MaxAllocatedStorage: 22</pre><p>Honestly, this was the easiest template to put together very shortly, there is not much work going on here really.</p><p><strong>Description</strong>: The template’s purpose is to create an Amazon RDS (Relational Database Service) instance with specific configurations.</p><h3><strong>Parameters</strong></h3><ul><li>Az1: I set my desired AWS Availability Zone. The default is set to us-east-2a.</li><li>DBUsername: For my Database username. The default is admin.</li><li>DBPassword: And for my password. The default is password.</li></ul><h3><strong>Resources</strong></h3><p><strong>DBSubnetGroup</strong></p><ul><li>SubnetIds These are imported from other stacks for instance, I used the <strong>!ImportValue</strong> to get them from the VPC-Stack. It defines which subnets are associated with the RDS instance.</li></ul><p><strong>DBTierSecurityGroup</strong></p><ul><li>VpcId I used the <strong>!ImportValue</strong> to get the VPC from the VPC-Stack.</li><li>SecurityGroupIngress This is used to authorize incoming traffic.</li><li>CidrIp: 0.0.0.0/0 allows access from any source IP address.</li><li>IpProtocol: tcp specifies that only TCP traffic is allowed.</li><li>FromPort: 3306 and ToPort: 3306 defines that this security group allows <strong>MySQL</strong> traffic on <strong>port 3306.</strong></li></ul><p><strong>MyDBSecurityGroupIngress</strong></p><p>In this section, it authorizes inbound traffic to the RDS instance from the PHP Server’s security group in which we created from the EC2-Stack.</p><ul><li>GroupId is set to the security group created earlier, so I used the <strong>!GetAtt</strong> function to get it.</li><li>IpProtocol: tcp, FromPort: 3306, and ToPort: 3306 defines that the allowed traffic is TCP on <strong>port 3306 (MySQL).</strong></li><li>SourceSecurityGroupId This specifies the source security group, which allows the PHP Server&#39;s security group to access the RDS instance.</li></ul><p><strong>RDS Instance</strong></p><p>This is the main resource in our RDS Configuration. There is the DBName which is the name of the database. I had to specify the AvailabilityZone in which the RDS instance will be created. Also, we have the RDS instance type to <strong>db.t3.micro, </strong>the subnet and security groups too. Other properties needed for the RDS Instance are listed in the above template of the <strong>DB-Stack.</strong></p><p>Then, I had to deploy my template to CloudFormation and see whether it was working as expected.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/650/1*Jt1BsdHBV8ZkcVvdxEpW4w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3_rhG06bXgoJM1bsVHFyaQ.png" /><figcaption><strong>DB-Stack(I)</strong></figcaption></figure><p>As is my usual practice, I double-check for further clarity by referring to the services where the deployment has taken place to gather additional information.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tqlXBBbgngm6l-g0HnKBJQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tj_Q0MWVCaPpIdABnwWQQg.png" /><figcaption><strong>DB-Stack (II)</strong></figcaption></figure><p>This was my endpoint in my database, I needed it later on as i would explain.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YR-odxVmzhjkvdL-gNcTmA.png" /><figcaption><strong>Database Endpoint</strong></figcaption></figure><p>I went into the directory of <strong>phpMyAdmin</strong>, located the <strong>config.sample.inc.php</strong> file and renamed it into <strong>config.inc.php</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uEUAcxkPrFMq0AHzX9wJEA.png" /></figure><p>After renaming the file, I went further to open the file using the<strong> vi</strong> command, then I searched for <strong>localhost </strong>in this file, renamed it to use the DB connection address within the PHP application.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Nc0-i1KtQ7IxnyO1dgIgQA.png" /><figcaption><strong>Open the file.</strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QRS93ocALiS76uR6V-eoOw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZngAKCEbhtYu7lbFHhd1Aw.png" /><figcaption>Configuring host/server address</figcaption></figure><p>I navigated to my browser and went to <strong>/phpMyAdmin </strong>to check if the application was working or not. I also had to put in the username and password that I set earlier on in my RDS.</p><p><strong>It was working!! Huge relief :)</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*78dox_o8K1mcdMuSxjLH-g.png" /><figcaption><strong>Application working!!</strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JEfsYawtLL-lH0UWe3AP-A.png" /><figcaption><strong>RDS Credentials</strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6AXtqFyeSsMYljh0rElWLw.png" /><figcaption><strong>It is working!!!!!</strong></figcaption></figure><h3>Using cross-stack referencing</h3><p>One thing that stood out for me while working on this project was the ability to split this whole architecture into smaller templates. I would have decided to just include all the network related resources, instances and load balancer resources and database resources too, all in one template, but I did not do that.</p><p>It is easier to identify errors when the templates are smaller, rather than looking for errors when it is just big and trust me, very tiring. Also, I can re-use the templates more often as I would like. If I do not like any stack, just tear it down and redo it again, rather than just tearing everything down or reuse it for other use cases.</p><p>I had to define Outputs in the VPC-Stack and EC2-Stack to specify which resources I can use in other stacks.</p><p><strong>!Ref </strong>function (to<strong> </strong>reference a value from somewhere else in a template)</p><p><strong>!ImportValue</strong> function (for referencing the exported resource<strong>)</strong></p><p><strong>!GetAtt</strong> function (to retrieve the value of an attribute from an AWS resource defined within the same stack).</p><p>Hopefully this project makes sense, for more information about this project, please visit my <a href="https://github.com/Firdous2307/3-Tier-Architecture-with-AWS-CloudFormation">3-Tier-Architecture with AWS CloudFormation repository</a> on <strong>GitHub.</strong></p><p>Enjoy your reading, and I look forward to our next interaction! :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=419044db9587" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Navigating AWS with Confidence: A Beginner’s Guide to Amazon CloudWatch and Amazon Route 53]]></title>
            <link>https://medium.com/@mohammedfirdousaraoye/navigating-aws-with-confidence-a-beginners-guide-to-amazon-cloudwatch-and-amazon-route-53-38e1225cf0f0?source=rss-19706121782c------2</link>
            <guid isPermaLink="false">https://medium.com/p/38e1225cf0f0</guid>
            <dc:creator><![CDATA[Mohammed Firdous]]></dc:creator>
            <pubDate>Fri, 11 Aug 2023 21:47:24 GMT</pubDate>
            <atom:updated>2023-08-30T14:30:23.638Z</atom:updated>
            <content:encoded><![CDATA[<p>Entering the realm of cloud computing through Amazon Web Services (AWS) can feel like embarking on an exciting adventure. Amongst a diverse range of options, let’s take a deep dive into two essential tools — Amazon CloudWatch and Amazon Route 53. In this exploration, we will learn beginner-friendly approaches to harness their functionalities effectively.</p><h3>Amazon CloudWatch: Your Cloud Buddy for Insights</h3><p>With Amazon CloudWatch by your side, consider your applications, resources, and services under constant watch. Now, let’s embark on this adventure with a handful of easy-to-follow practices:</p><p>Custom Metrics — Tailored to your Needs: Apart from ready-made metrics, design your own to monitor application data unique to your requirements. It’s like having a personal dashboard for your app’s health.</p><p>Alarms — Your Proactive Alert System: Set up CloudWatch alarms. Think of them as early warning bells that ring when something’s not right. Make sure to set thresholds thoughtfully to avoid constant alarms.</p><p>CloudWatch Dashboards — Your Visual Command Center: Craft dashboards that show your metrics in one place. It’s like having a personalized control center to keep an eye on everything.</p><p>Logging — Your Pathway to Secrets: CloudWatch Logs collect and analyze logs from your applications. Use CloudWatch Logs Insights to uncover hidden insights from your logs.</p><p>Anomaly Detection — Your AI Assistant: Embrace CloudWatch Anomaly Detection. Think of it as an AI Assistant that vigilantly identifies atypical actions and prompts you to investigate further, ensuring you never miss a beat in maintaining your system’s stability and efficiency.</p><h3><strong>Amazon Route 53: Your Trusted Map for Online Exploration</strong></h3><p>Consider Amazon Route 53 as your cloud GPS, ensuring your applications effortlessly reach their destinations, making cloud journeys straightforward and hassle-free. During this journey of discovery, we will uncover user-friendly methods to efficiently utilize their capabilities, making them accessible to even beginners.</p><p>Latency-Based Routing — Fastest Route Always: With Latency-Based Routing, Route 53 finds the fastest route for your users. Think of it as a GPS that always finds the shortest path.</p><p>Health Checks — Your Regular Checkup: Establish routine health checks to ensure the vitality of your applications. With Route 53’s automated capabilities, it safeguards against directing users to underperforming or ailing applications.</p><p>Alias Records — Shortcut to Your Destination: Incorporate Alias records for swift navigation. It is like a shortcut to your favorite places, without wasting time on lookups.</p><p>Geolocation Routing — Personalized Guidance: Imagine Route 53 as your local guide. It intelligently directs users to the nearest server based on their location — like a personalized tour.</p><p>TTL — Your App’s Refresh Rate: Consider Time-to-Live (TTL) as the pace at which your app’s data refreshes. A lower TTL leads to faster updates, but keep in mind that it can result in more queries, impacting system resources.</p><h3>Friendly AWS Tips for All Beginners</h3><p>Prioritize Security: Safeguard your AWS environment with robust passwords and meticulous permissions. Consider it as fortifying your digital stronghold and locking the gates against potential threats.</p><p>Budget Smarts: Maximize your savings by heeding AWS Trusted Advisor’s insight. Adopt reserved instances for consistent expenses, like a season ticket.</p><p>Scalability Wisdom: Design apps to grow smoothly. Think of it as making space for more friends at a party.</p><p>Backup Buddy: Safeguard your data through routine backups. Amazon S3 serves as your digital vault, while RDS takes care of database backups.</p><p>Learn and Explore: AWS has a library of lessons and stories. It’s like reading a treasure map to find more ways to use AWS tools.</p><p>Organize with Labels: Tagging is like putting labels on your belongings. It helps you organize and find things easily.</p><p>Embrace Continuous Growth: Cloud tech keeps changing. Keep learning and trying new things. It’s like leveling up in your favorite game.</p><p>As you embark on your AWS journey, remember that even the most experienced professionals started as beginners. Embrace the learning process and use these beginner-friendly practices to become a pro at using Amazon CloudWatch and Amazon Route 53. Happy cloud adventures! 🚀</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=38e1225cf0f0" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>