<?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 Florence Okoli on Medium]]></title>
        <description><![CDATA[Stories by Florence Okoli on Medium]]></description>
        <link>https://medium.com/@FlorenceOkoli?source=rss-76bffe9db278------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*vMUNuLUt8I4JxQFH7Gvq1w.jpeg</url>
            <title>Stories by Florence Okoli on Medium</title>
            <link>https://medium.com/@FlorenceOkoli?source=rss-76bffe9db278------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 13:14:32 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@FlorenceOkoli/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[From Amazon Bedrock Agents to AgentCore: Rethinking Agentic AI Deployment on AWS]]></title>
            <link>https://medium.com/@FlorenceOkoli/from-amazon-bedrock-agents-to-agentcore-rethinking-agentic-ai-deployment-on-aws-2401d908284c?source=rss-76bffe9db278------2</link>
            <guid isPermaLink="false">https://medium.com/p/2401d908284c</guid>
            <dc:creator><![CDATA[Florence Okoli]]></dc:creator>
            <pubDate>Tue, 27 Oct 2026 16:40:14 GMT</pubDate>
            <atom:updated>2026-10-27T16:40:14.877Z</atom:updated>
            <content:encoded><![CDATA[<p>When designing an agentic AI application on AWS, choosing a foundation model is only one part of the architecture. You also need to decide how the agent will execute, access tools and data, interact with the application, and operate within defined security boundaries.</p><p>I encountered this firsthand while building an AI-powered ordering assistant for a food business. My initial approach was to use Amazon Bedrock Agents for orchestration. However, because the workload was being developed in a new AWS account, I discovered that the service was no longer available to new customers.</p><p>That discovery prompted me to reconsider the deployment approach and explore Amazon Bedrock AgentCore.</p><p>For cloud engineers and AWS practitioners exploring agentic AI, I want to share three things from this experience: what changed in the AWS service landscape, how the components fit together in an agentic application, and the architectural questions worth asking before deploying an agent.</p><h3>1. First, what happened to Amazon Bedrock Agents?</h3><p>Amazon Bedrock Agents launched in November 2023 to simplify the development of AI agents. It provided managed orchestration for interpreting requests, coordinating foundation model interactions, retrieving information, and invoking actions through configured action groups.</p><p>On July 30, 2026, AWS moved the service to maintenance mode under the name <strong>Amazon Bedrock Agents Classic</strong>.</p><p>This distinction matters. The service has not been shut down. Existing customers with qualifying prior usage can continue using it, but AWS no longer allows new customers without qualifying account history to create agents through the legacy experience. AWS recommends Amazon Bedrock AgentCore for new agent development.</p><p>For my deployment, this was an account-level constraint with direct architectural implications.</p><p>It also highlighted an important practice: service lifecycle, account eligibility, regional availability, and deployment prerequisites should be checked before committing to an architecture.</p><p>Official reference: <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/agents-classic-maintenance-mode.html">Amazon Bedrock Agents Classic maintenance mode</a>.</p><h3>2. AgentCore introduces a different approach to agent execution</h3><p>Amazon Bedrock AgentCore is a platform for building, connecting, deploying, and operating AI agents. Its modular capabilities allow developers to select the infrastructure and operational features that fit their workloads.</p><p>One component is particularly relevant when discussing deployment: <strong>Amazon Bedrock AgentCore Runtime</strong>.</p><p>Runtime provides a managed execution environment for agent code. Developers can deploy code-defined agents built with supported frameworks, retaining control over their application logic while using AWS-managed infrastructure for execution.</p><p>AgentCore also offers a managed agent harness, which provides a configuration-driven approach to agent orchestration. The choice between the harness and a code-defined agent depends on the degree of control and customization the application requires.</p><p>This is an important distinction when evaluating AgentCore. Runtime is not synonymous with the entire AgentCore platform, and AgentCore is not simply a new name for Bedrock Agents Classic.</p><p>The architecture should begin with the application’s requirements, followed by a deliberate choice of execution model.</p><p>Official reference: <a href="https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/">Amazon Bedrock AgentCore Developer Guide</a>.</p><h3>3. How the components fit together</h3><p>For this food business, the goal was to build an AI ordering assistant that could interact with staff, use business information, and support order-related operations.</p><p>The architecture involved Amazon Cognito, Amazon API Gateway, Lambda functions, AgentCore Runtime, Amazon Bedrock foundation models, a Knowledge Base, and DynamoDB.</p><p>At a high level, the request path was designed as follows:</p><p><strong>Staff browser → Amazon Cognito → Amazon API Gateway → invocation Lambda → AgentCore Runtime → agent execution</strong></p><p>The agent also had supporting application functions and access to the relevant knowledge and data layers.</p><p>Each component had a distinct responsibility:</p><p><strong>Amazon Cognito</strong> handled user authentication for the application.</p><p><strong>Amazon API Gateway</strong> provided the API entry point for requests from the application.</p><p><strong>AWS Lambda</strong> handled discrete application functions. The implementation included an invocation function, order-related actions, order-record operations, and a Knowledge Base synchronization function.</p><p><strong>Amazon Bedrock AgentCore Runtime</strong> provided the managed environment for executing the agent.</p><p><strong>Amazon Bedrock and Claude Sonnet 4.5</strong> provided the foundation model used by the agent.</p><p><strong>Amazon Bedrock Knowledge Bases and Amazon S3</strong> supported access to reference content, while DynamoDB tables held application data, including menu information and order records.</p><p>The distinction between reference content and transactional data is worth emphasizing. A Knowledge Base can help an agent retrieve relevant information, but it should not automatically become the authoritative source for prices, order totals, or order status. Those values should come from the application’s designated data stores and business logic.</p><p>This is where architecture becomes more than a diagram of connected AWS services. Each component needs a clearly defined responsibility, and the application must enforce the rules that govern how data is read and modified.</p><h3>4. Why separate the agent from application operations?</h3><p>An agent can interpret a request and determine which tool to use, but the application still needs deterministic controls around business-critical operations.</p><p>Consider a staff member creating a catering order. The agent might interpret the request, identify the relevant menu items, and collect the required details. The application logic should validate the items, retrieve authoritative prices, calculate totals, and enforce the permitted order-state transitions.</p><p>This separation has several benefits:</p><ul><li>Business rules can be tested independently of the language model.</li><li>Data validation and authorization can be enforced at the application layer.</li><li>Order operations can be monitored and debugged separately from agent reasoning.</li><li>Changes to the business logic do not necessarily require redesigning the agent’s instructions.</li></ul><p>The same principle applies beyond ordering systems. An agent assisting with financial operations, customer support, or infrastructure management should not be treated as the authority for every action it proposes.</p><p>The model can help determine what to do. The application must enforce what it is allowed to do.</p><h3>5. What the AWS Well-Architected Agentic AI Lens adds</h3><p>A deployment can work during a demonstration and still have significant gaps in production readiness.</p><p>The <a href="https://docs.aws.amazon.com/wellarchitected/latest/agentic-ai-lens/agentic-ai-lens.html">AWS Well-Architected Agentic AI Lens</a> provides guidance for addressing the architectural challenges introduced by autonomous, model-driven systems. It extends the Well-Architected Framework across operational excellence, security, reliability, performance efficiency, cost optimization, and sustainability.</p><p>Three areas deserve particular attention when designing an agentic workload.</p><p><strong>Security and bounded autonomy</strong></p><p>An agent should operate within an explicitly defined scope. Its tools, data access, and execution permissions need appropriate controls. Least-privilege IAM policies, input validation, secure tool integrations, and human approval for consequential actions help limit the impact of unintended behavior.</p><p><strong>Reliability and failure handling</strong></p><p>An agentic workflow may involve several model calls, retrieval operations, and tool executions. A failure at any stage can affect the overall request. Consider timeouts, retries, idempotency for state-changing operations, downstream service failures, and recovery behavior as part of the design.</p><p><strong>Observability and evaluation</strong></p><p>Traditional infrastructure metrics do not fully explain agent behavior. Developers also need visibility into execution traces, tool calls, model interactions, errors, and the quality of the resulting behavior. Evaluation should test whether the agent completes the intended task within its defined boundaries, not simply whether it returns a plausible response.</p><p>The lens is useful because it turns these concerns into architectural questions that can be reviewed systematically rather than left until the application is ready for production.</p><h3>6. Questions I would ask before starting another agentic AI deployment</h3><p>Based on this experience and the AWS guidance, I would begin with the following questions:</p><ol><li>Is the selected service available to this account and in the intended Region?</li><li>Does the application need a managed agent harness or a code-defined agent?</li><li>Which operations belong to the agent, and which must remain enforced by application logic?</li><li>What are the authoritative data sources for business-critical information?</li><li>How will the application authenticate users and authorize agent actions?</li><li>How will execution failures, unexpected behavior, latency, and cost be monitored?</li><li>Which actions require explicit human approval?</li></ol><p>These questions help establish the architecture before implementation begins. They also make it easier to evaluate whether each AWS service has a clear purpose in the solution.</p><h3>Final thoughts</h3><p>Moving from my initial Bedrock Agents approach to AgentCore made me look more closely at the relationship between agent execution, application logic, data access, and operational controls.</p><p>For anyone exploring agentic AI on AWS, I recommend reading the AgentCore Developer Guide alongside the Well-Architected Agentic AI Lens. The combination provides both service-level implementation guidance and a broader framework for thinking about production readiness.</p><p>I am interested in how other AWS practitioners are approaching this transition, particularly those building code-defined agents with AgentCore Runtime.</p><p><strong>When designing a new agentic AI workload, how do you decide between a managed agent harness and a code-defined agent on Runtime? What architectural considerations influence your choice?</strong></p><p>I’d welcome your perspectives and lessons from your own implementations.</p><h3>Further reading</h3><ul><li><a href="https://docs.aws.amazon.com/bedrock/latest/userguide/agents-classic-maintenance-mode.html">Amazon Bedrock Agents Classic maintenance mode</a></li><li><a href="https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/">Amazon Bedrock AgentCore Developer Guide</a></li><li><a href="https://docs.aws.amazon.com/wellarchitected/latest/agentic-ai-lens/agentic-ai-lens.html">AWS Well-Architected Agentic AI Lens</a></li><li><a href="https://docs.aws.amazon.com/wellarchitected/">AWS Well-Architected Framework</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2401d908284c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How I Built and Deployed a Student Dropout Prediction Model on AWS]]></title>
            <link>https://medium.com/@FlorenceOkoli/how-i-built-and-deployed-a-student-dropout-prediction-model-on-aws-513972d50a60?source=rss-76bffe9db278------2</link>
            <guid isPermaLink="false">https://medium.com/p/513972d50a60</guid>
            <dc:creator><![CDATA[Florence Okoli]]></dc:creator>
            <pubDate>Fri, 20 Mar 2026 20:29:48 GMT</pubDate>
            <atom:updated>2026-03-20T20:29:48.635Z</atom:updated>
            <content:encoded><![CDATA[<p>I recently deployed a machine learning model on AWS that predicts which university students are at risk of dropping out before it is too late for anyone to help them.</p><p>In this article I will walk you through exactly how I did it, step by step, so you can follow along and build something similar yourself.</p><h3>What We Are Building</h3><p>We are building an end to end ML pipeline that:</p><ul><li>Takes student data (attendance, CGPA, financial status, and more) as input</li><li>Trains a machine learning model to predict which students are likely to drop out</li><li>Deploys that model to a live AWS endpoint that can make predictions in real time</li><li>Monitors the model automatically for performance drift over time</li></ul><p>The use case is a tertiary in Nigeria, where a 32% dropout rate costs the institution over NGN X million every year. Students are only flagged as at-risk after semester results come out, which is already too late. This model changes that by flagging students within the first 4 weeks of a semester.</p><h3>The Architecture</h3><p>Here is what the full deployment looks like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0kwl_hBc3MMvEMpImRPB3A.png" /><figcaption>Architectural Diagram for ML Student Dropout Prediction</figcaption></figure><h3>AWS Services We Used</h3><p><strong>Amazon S3:</strong> Stores our dataset, train/validation splits, and model output<br><strong>AWS IAM:</strong> Gives SageMaker permission to access S3 and CloudWatch<br><strong>SageMaker Notebook Instance: </strong>Where we write and run all our code<br><strong>SageMaker Training Jobs: </strong>Runs the model training on managed cloud compute<br><strong>SageMaker Automatic Model Tuning: </strong>Finds the best hyperparameters automatically<br><strong>SageMaker Endpoint: </strong>Serves real-time predictions<br><strong>SageMaker Model Monitor: </strong>Watches for data drift after deployment<br><strong>Amazon CloudWatch: </strong>Tracks latency, errors, and endpoint health</p><h3>The Dataset</h3><p>Before writing any code we need data. I generated a structured CSV dataset representing 1,500 Lxxxx students with 20 features including:</p><ul><li>Academic: CGPA, attendance rate, courses failed, study hours</li><li>Financial: Tuition payment status, financial aid, part-time job</li><li>Welfare: Mental health support accessed, extracurricular activities, parental education level</li><li>Target column: dropout (1 = dropped out, 0 = still enrolled)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ljjK7NzkEmxx5SAyyfApMw.png" /><figcaption>Dataset for student dropout prediction</figcaption></figure><p>For this project, you can generate your own dataset.</p><h3>Step 1: Create Your S3 Bucket</h3><p>S3 is where everything lives. Your raw data, processed splits, trained model artifacts, and monitoring outputs all go here.</p><ol><li>Go to <strong>AWS Console -&gt; S3 -&gt; Create bucket</strong></li><li>Bucket name: lxxxxx-dropout-prediction-ml</li><li>Region: us-east-1 (keep this consistent for every step)</li><li>Leave Block all public access turned ON</li><li>Enable Versioning then click <strong>Create bucket</strong></li></ol><p>Now create the folder structure inside the bucket:</p><pre>lxxxxx-dropout-prediction-ml/<br>    data/raw/<br>    data/train/<br>    data/validation/<br>    data/output/<br>    monitoring/<br>    notebooks/</pre><p>Then upload your CSV into data/raw/.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CmQs3kfHvQhpz97wiVBdLw.png" /><figcaption>S3 Bucket Folder Structure</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T01AFBpsi7l4xJ_iGXPisw.png" /></figure><h3>Step 2: Create an IAM Role for SageMaker</h3><p>SageMaker needs permission to read and write to S3 and to log metrics to CloudWatch. We give it those permissions through an IAM role.</p><ol><li>Go to <strong>AWS Console -&gt; IAM -&gt; Roles -&gt; Create role</strong></li><li>Trusted entity: <strong>AWS service</strong></li><li>Use case: <strong>SageMaker</strong> then click Next</li><li>The policy AmazonSageMakerFullAccess is pre-selected. Leave it.</li><li>Click Next, name the role lxxxxx-SageMakerExecutionRole, then Create role</li><li>Find the role you just created, click into it, then <strong>Add permissions -&gt; Attach policies</strong></li><li>Attach AmazonS3FullAccess</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G3aJKdXg5bSgxni1VZOspw.png" /><figcaption>IAM Role</figcaption></figure><h3>Step 3: Launch a SageMaker Notebook Instance</h3><p>This is your cloud development environment. Think of it as a Jupyter notebook running on AWS hardware, with direct access to all your AWS resources.</p><ol><li>Go to <strong>AWS Console -&gt; Amazon SageMaker AI -&gt; Notebook -&gt; Notebook instances -&gt; Create notebook instance</strong></li><li>Notebook instance name: lxxxxx-dropout-notebook</li><li>Instance type: ml.t3.xlarge</li><li>Under Permissions, select the IAM role you just created (lxxxxx-SageMakerExecutionRole)</li><li>Click <strong>Create notebook instance</strong> and wait for status to show <strong>InService</strong></li><li>Click <strong>Open JupyterLab</strong></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*okeCGhKdYwlaaYATZuso-g.png" /></figure><p>Once JupyterLab opens, click <strong>File -&gt; New -&gt; Notebook</strong>, select the <strong>Python 3 (Data Science)</strong> kernel, and rename the notebook to Lxxxxx_Dropout_Prediction.ipynb.</p><h3>Step 4: The Notebook Code</h3><p>From here everything runs inside the notebook. Add each block as a new cell and run it with <strong>Shift+Enter</strong>.</p><h4>Cell 1: Install missing packages and set up your session</h4><p>python</p><pre>!pip install -q seaborn</pre><pre>import boto3, sagemaker, pandas as pd, numpy as np<br>import matplotlib.pyplot as plt, seaborn as sns<br>from sagemaker import get_execution_role<br>from sagemaker.inputs import TrainingInput<br>from sagemaker.serializers import CSVSerializer<br>from sagemaker.deserializers import JSONDeserializer</pre><pre>role    = get_execution_role()<br>session = sagemaker.Session()<br>region  = session.boto_region_name<br>bucket  = &quot;lxxxxx-dropout-prediction-ml&quot;</pre><pre>print(&quot;Role:  &quot;, role)<br>print(&quot;Region:&quot;, region)<br>print(&quot;Bucket:&quot;, bucket)</pre><p>You do not need to type your role or region manually. get_execution_role() and session.boto_region_name fetch them automatically from your SageMaker environment. The only thing to confirm is that bucket matches the name you created in Step 1.<br>This image below should be your output when you run cell 1.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/808/1*XRUlJ0YmZj_bJSOi-vhpdQ.png" /></figure><h4>Cell 2: Load the dataset from S3</h4><pre>s3 = boto3.client(&quot;s3&quot;)<br>s3.download_file(bucket, &quot;data/raw/lxxxxx_student_dropout_dataset.csv&quot;,<br>                 &quot;lxxxxx_data.csv&quot;)</pre><pre>df = pd.read_csv(&quot;lxxxxx_data.csv&quot;)<br>print(&quot;Shape:&quot;, df.shape)<br>print(&quot;\nClass distribution:&quot;)<br>print(df[&quot;dropout&quot;].value_counts())<br>print(&quot;Dropout rate:&quot;, round(df[&quot;dropout&quot;].mean() * 100, 1), &quot;%&quot;)<br>df.head()</pre><p>When cell 2a above is run, this would be your output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kmHDo1v4uR2qbArlzq8HAg.png" /><figcaption>output showing shape (1500, 21) and the class distribution table</figcaption></figure><h4>Cell 2b: Exploratory Data Analysis</h4><p>Add this as a separate cell below Cell 2.</p><pre>fig, axes = plt.subplots(2, 3, figsize=(16, 10))<br>fig.suptitle(&quot;Lxxxxx Student Dropout - Exploratory Data Analysis&quot;,<br>             fontsize=14, fontweight=&quot;bold&quot;)<br><br>df[&quot;dropout&quot;].value_counts().plot(<br>    kind=&quot;bar&quot;, ax=axes[0,0], color=[&quot;#1A6B3C&quot;,&quot;#D04040&quot;])<br>axes[0,0].set_title(&quot;Dropout Distribution&quot;)<br>axes[0,0].set_xticklabels([&quot;No Dropout&quot;,&quot;Dropout&quot;], rotation=0)<br><br>df.boxplot(column=&quot;cgpa&quot;, by=&quot;dropout&quot;, ax=axes[0,1])<br>axes[0,1].set_title(&quot;CGPA by Dropout Status&quot;)<br>axes[0,1].set_xlabel(&quot;Dropout (0=No, 1=Yes)&quot;)<br><br>df.boxplot(column=&quot;attendance_rate&quot;, by=&quot;dropout&quot;, ax=axes[0,2])<br>axes[0,2].set_title(&quot;Attendance Rate by Dropout&quot;)<br><br>dept = df.groupby(&quot;department&quot;)[&quot;dropout&quot;].mean().sort_values()<br>dept.plot(kind=&quot;barh&quot;, ax=axes[1,0], color=&quot;#1A6B3C&quot;)<br>axes[1,0].set_title(&quot;Dropout Rate by Department&quot;)<br><br>tuit = df.groupby(&quot;tuition_payment_status&quot;)[&quot;dropout&quot;].mean()<br>tuit.plot(kind=&quot;bar&quot;, ax=axes[1,1], color=[&quot;#1A6B3C&quot;,&quot;#E08020&quot;,&quot;#D04040&quot;])<br>axes[1,1].set_title(&quot;Dropout by Tuition Status&quot;)<br>axes[1,1].tick_params(axis=&quot;x&quot;, rotation=15)<br><br>num_cols = [&quot;attendance_rate&quot;,&quot;cgpa&quot;,&quot;courses_failed&quot;,<br>            &quot;weekly_study_hours&quot;,&quot;age&quot;,&quot;dropout&quot;]<br>sns.heatmap(df[num_cols].corr(), annot=True, fmt=&quot;.2f&quot;,<br>            ax=axes[1,2], cmap=&quot;RdYlGn&quot;)<br>axes[1,2].set_title(&quot;Feature Correlations&quot;)<br><br>plt.tight_layout()<br>plt.savefig(&quot;lxxxxx_eda.png&quot;, dpi=120, bbox_inches=&quot;tight&quot;)<br>plt.show()</pre><p>Output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gEJpMD-pAEJYJIRGArKxNg.png" /><figcaption>6-panel EDA chart output</figcaption></figure><h4>Cell 3: Feature Engineering and Train/Validation Split</h4><p>This is where we prepare the data for the model. We encode text columns into numbers and create two new risk score features that combine multiple signals into a single value.</p><pre>from sklearn.preprocessing import LabelEncoder<br>from sklearn.model_selection import train_test_split</pre><pre>df_model = df.drop(columns=[&quot;student_id&quot;, &quot;state_of_origin&quot;])</pre><pre>cat_cols = [<br>    &quot;department&quot;, &quot;gender&quot;, &quot;financial_aid&quot;, &quot;hostel_resident&quot;,<br>    &quot;part_time_job&quot;, &quot;parent_education_level&quot;,<br>    &quot;tuition_payment_status&quot;, &quot;repeated_academic_year&quot;,<br>    &quot;mental_health_support_accessed&quot;, &quot;extracurricular_activities&quot;<br>]<br>le = LabelEncoder()<br>for col in cat_cols:<br>    df_model[col] = le.fit_transform(df_model[col])</pre><pre>df_model[&quot;academic_risk_score&quot;] = (<br>    (5 - df_model[&quot;cgpa&quot;]) * 0.4 +<br>    (100 - df_model[&quot;attendance_rate&quot;]) / 100 * 0.3 +<br>    df_model[&quot;courses_failed&quot;] * 0.3<br>).round(3)</pre><pre>df_model[&quot;financial_risk&quot;] = (<br>    df_model[&quot;tuition_payment_status&quot;] * 0.5 +<br>    (1 - df_model[&quot;financial_aid&quot;]) * 0.5<br>).round(3)</pre><pre>print(&quot;Total features:&quot;, df_model.shape[1] - 1)</pre><pre>cols = [&quot;dropout&quot;] + [c for c in df_model.columns if c != &quot;dropout&quot;]<br>df_model = df_model[cols]</pre><pre>train_df, val_df = train_test_split(<br>    df_model, test_size=0.2, random_state=42,<br>    stratify=df_model[&quot;dropout&quot;])</pre><pre>print(&quot;Train:&quot;, train_df.shape, &quot; | Val:&quot;, val_df.shape)<br>print(&quot;Train dropout rate:&quot;, round(train_df[&quot;dropout&quot;].mean() * 100, 1), &quot;%&quot;)<br>print(&quot;Val   dropout rate:&quot;, round(val_df[&quot;dropout&quot;].mean() * 100, 1), &quot;%&quot;)</pre><pre>train_df.to_csv(&quot;lxxxxx_train.csv&quot;,      index=False, header=False)<br>val_df.to_csv(&quot;lxxxxx_validation.csv&quot;,   index=False, header=False)</pre><pre>s3.upload_file(&quot;lxxxxx_train.csv&quot;,      bucket, &quot;data/train/lxxxxx_train.csv&quot;)<br>s3.upload_file(&quot;lxxxxx_validation.csv&quot;, bucket, &quot;data/validation/lxxxx_validation.csv&quot;)</pre><pre>print(&quot;Train and validation files uploaded to S3&quot;)</pre><p>Note: header=False is required. SageMaker&#39;s XGBoost container expects CSV files with no column headers.</p><p>Output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1012/1*j_6LUsCL_BuFPFkodRGyEw.png" /><figcaption>output showing feature count, split shapes, and matching dropout rates in both splits</figcaption></figure><h4>Cell 4: Train the Model with SageMaker</h4><p>SageMaker handles the training infrastructure for us. We just define what we want and it spins up a compute instance, trains the model, saves the artifacts to S3, and shuts down.</p><pre>from sagemaker.image_uris import retrieve</pre><pre>xgb_image = retrieve(&quot;xgboost&quot;, region, version=&quot;1.7-1&quot;)</pre><pre>xgb_estimator = sagemaker.estimator.Estimator(<br>    image_uri         = xgb_image,<br>    role              = role,<br>    instance_count    = 1,<br>    instance_type     = &quot;ml.m5.xlarge&quot;,<br>    output_path       = f&quot;s3://{bucket}/data/output/&quot;,<br>    sagemaker_session = session,<br>    base_job_name     = &quot;lxxxxx-dropout-xgb&quot;<br>)</pre><pre>xgb_estimator.set_hyperparameters(<br>    objective        = &quot;binary:logistic&quot;,<br>    num_round        = 150,<br>    max_depth        = 6,<br>    eta              = 0.1,<br>    subsample        = 0.8,<br>    colsample_bytree = 0.8,<br>    min_child_weight = 5,<br>    eval_metric      = &quot;auc&quot;,<br>    scale_pos_weight = 1<br>)</pre><pre>train_input = TrainingInput(<br>    f&quot;s3://{bucket}/data/train/&quot;, content_type=&quot;text/csv&quot;)<br>val_input = TrainingInput(<br>    f&quot;s3://{bucket}/data/validation/&quot;, content_type=&quot;text/csv&quot;)</pre><pre>print(&quot;Starting training job, this takes 3 to 5 minutes...&quot;)<br>xgb_estimator.fit(<br>    {&quot;train&quot;: train_input, &quot;validation&quot;: val_input},<br>    logs=True)<br>print(&quot;Training complete!&quot;)</pre><p>While this runs you can monitor it live in <strong>SageMaker Console -&gt; Training -&gt; Training Jobs</strong>.</p><p>Output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/724/1*ZCUSXyVWqF63sQS5pQ2ASg.png" /></figure><h4>Cell 5: Hyperparameter Tuning</h4><p>Instead of manually guessing the best settings, we let SageMaker run 10 experiments automatically and find the combination that gives the highest AUC score.</p><pre>from sagemaker.tuner import (<br>    IntegerParameter, ContinuousParameter, HyperparameterTuner)</pre><pre>tuner = HyperparameterTuner(<br>    estimator             = xgb_estimator,<br>    objective_metric_name = &quot;validation:auc&quot;,<br>    objective_type        = &quot;Maximize&quot;,<br>    hyperparameter_ranges = {<br>        &quot;max_depth&quot;:        IntegerParameter(3, 9),<br>        &quot;eta&quot;:              ContinuousParameter(0.01, 0.3),<br>        &quot;subsample&quot;:        ContinuousParameter(0.5, 1.0),<br>        &quot;num_round&quot;:        IntegerParameter(50, 300),<br>        &quot;min_child_weight&quot;: IntegerParameter(1, 10),<br>        &quot;colsample_bytree&quot;: ContinuousParameter(0.5, 1.0),<br>    },<br>    max_jobs          = 10,<br>    max_parallel_jobs = 2,<br>    base_tuning_job_name = &quot;lxxxxx-dropout-hpo&quot;<br>)</pre><pre>print(&quot;Launching hyperparameter tuning, 10 trials, takes 15 to 20 minutes...&quot;)<br>tuner.fit({&quot;train&quot;: train_input, &quot;validation&quot;: val_input},<br>          wait=True, logs=False)</pre><pre>best_job = tuner.best_training_job()<br>print(&quot;Best training job:&quot;, best_job)</pre><pre>analytics = tuner.analytics()<br>df_hpo = analytics.dataframe()<br>print(&quot;\nTop 3 results:&quot;)<br>print(df_hpo.sort_values(&quot;FinalObjectiveValue&quot;,<br>      ascending=False).head(3)[<br>      [&quot;max_depth&quot;,&quot;eta&quot;,&quot;num_round&quot;,&quot;subsample&quot;,&quot;FinalObjectiveValue&quot;]])</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/926/1*cdMHbEI6Lh7A569vZYbOsw.png" /><figcaption>Hyperparameter Tuning Jobs page showing all 10 trials and their AUC scores</figcaption></figure><h4>Cell 6a: Deploy to a Live Endpoint</h4><p>This takes the best model from the tuning job and deploys it to a real-time endpoint. Once this cell finishes, you have a live API that can accept student data and return a dropout risk score.</p><pre>print(&quot;Deploying endpoint, takes about 4 minutes...&quot;)<br>predictor = tuner.deploy(<br>    initial_instance_count = 1,<br>    instance_type          = &quot;ml.t2.medium&quot;,<br>    endpoint_name          = &quot;lxxxxx-dropout-endpoint&quot;,<br>    serializer             = CSVSerializer(),<br>    deserializer           = JSONDeserializer()<br>)<br>print(&quot;Endpoint live:&quot;, predictor.endpoint_name)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sD4MQiHSpMljYSPPietXUw.png" /></figure><h4>Cell 6b: Evaluate the Model</h4><pre>import json<br>from sklearn.metrics import (<br>    classification_report, roc_auc_score,<br>    roc_curve, ConfusionMatrixDisplay)<br><br>X_val = val_df.drop(columns=[&quot;dropout&quot;])<br>y_val = val_df[&quot;dropout&quot;].values<br><br>val_csv = X_val.to_csv(index=False, header=False)<br>preds_raw = predictor.predict(val_csv)<br><br>if isinstance(preds_raw, str):<br>    preds_raw = json.loads(preds_raw)<br>if isinstance(preds_raw, dict) and &quot;predictions&quot; in preds_raw:<br>    y_prob = np.array([p[&quot;score&quot;] for p in preds_raw[&quot;predictions&quot;]])<br>else:<br>    y_prob = np.array(preds_raw)<br><br>y_pred = (y_prob &gt; 0.50).astype(int)<br><br>print(&quot;=&quot; * 50)<br>print(&quot;Lxxxxx DROPOUT MODEL - EVALUATION REPORT&quot;)<br>print(&quot;=&quot; * 50)<br>print(classification_report(y_val, y_pred,<br>      target_names=[&quot;No Dropout&quot;, &quot;Dropout&quot;]))<br>auc = roc_auc_score(y_val, y_prob)<br>print(&quot;ROC-AUC Score:&quot;, round(auc, 4))<br><br>fig, axes = plt.subplots(1, 2, figsize=(13, 5))<br><br>ConfusionMatrixDisplay.from_predictions(<br>    y_val, y_pred,<br>    display_labels=[&quot;No Dropout&quot;, &quot;Dropout&quot;],<br>    ax=axes[0], cmap=&quot;Greens&quot;)<br>axes[0].set_title(&quot;Confusion Matrix&quot;)<br><br>fpr, tpr, _ = roc_curve(y_val, y_prob)<br>axes[1].plot(fpr, tpr, color=&quot;#1A6B3C&quot;, lw=2,<br>             label=&quot;AUC = &quot; + str(round(auc, 3)))<br>axes[1].plot([0,1],[0,1],&quot;--&quot;, color=&quot;gray&quot;)<br>axes[1].set_xlabel(&quot;False Positive Rate&quot;)<br>axes[1].set_ylabel(&quot;True Positive Rate&quot;)<br>axes[1].set_title(&quot;ROC Curve&quot;)<br>axes[1].legend()<br>plt.tight_layout()<br>plt.savefig(&quot;lxxxxx_evaluation.png&quot;, dpi=120)<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q1gMrHTiCU_pKh1lh9qyaw.png" /><figcaption>Two evaluation charts side by side showing the confusion matrix and ROC curve</figcaption></figure><h4>Cell 6c: Set Up Model Monitor</h4><p>This is what keeps the model healthy after deployment. Model Monitor watches the data coming into your endpoint and alerts you if it starts looking different from your training data, which usually means the model needs retraining.</p><pre>from sagemaker.model_monitor import DefaultModelMonitor<br>from sagemaker.model_monitor.dataset_format import DatasetFormat</pre><pre>monitor = DefaultModelMonitor(<br>    role              = role,<br>    instance_count    = 1,<br>    instance_type     = &quot;ml.m5.xlarge&quot;,<br>    volume_size_in_gb = 20,<br>    max_runtime_in_seconds = 3600<br>)</pre><pre>monitor.suggest_baseline(<br>    baseline_dataset = f&quot;s3://{bucket}/data/train/lxxxxx_train.csv&quot;,<br>    dataset_format   = DatasetFormat.csv(header=False),<br>    output_s3_uri    = f&quot;s3://{bucket}/monitoring/baseline/&quot;,<br>    wait             = False,<br>    logs             = False<br>)</pre><pre>print(&quot;Model Monitor baseline job submitted&quot;)<br>print(&quot;Monitoring output: s3://&quot; + bucket + &quot;/monitoring/&quot;)</pre><p>Output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UI5vhqg2EUigp22xtoon8g.png" /><figcaption>Model Monitor baseline job</figcaption></figure><h3>Step 5: Clean Up to Avoid Charges</h3><p>SageMaker endpoints run 24/7 and will keep billing you until you delete them. Run this when you are done testing:</p><pre>predictor.delete_endpoint()<br>print(&quot;Endpoint deleted. Billing stopped.&quot;)</pre><h3>Troubleshooting Tips</h3><p><strong>pip install fails with numpy build error -</strong> your kernel already has numpy. Run !pip install -q seaborn only and skip everything else.</p><p><strong>S3 download gives a 404 error - </strong>your file was likely uploaded with a slightly different name. Run s3.list_objects_v2(Bucket=bucket) to see exactly what is in your bucket.</p><p><strong>Syntax error with special characters - </strong>avoid copying code that contains checkmark symbols like \u2713. Stick to plain ASCII in print statements.</p><p><strong>Model Monitor fails with logs error - </strong>add logs=False to the suggest_baseline() call alongside wait=False.</p><h3>What We Built</h3><p><strong>Dataset</strong> 1,500 student records across 14 departments, with 20 input features and 1 target variable (dropout). Features span academic performance, financial status, welfare indicators, and demographics.</p><p><strong>Feature Engineering</strong> Two composite risk indices were created from raw data: academic_risk_score combining CGPA, attendance rate, and courses failed, and financial_risk combining tuition payment status and financial aid. These engineered features were the most predictive signals in the final model.</p><p><strong>Model</strong> An XGBoost binary classifier trained on SageMaker managed infrastructure using the built-in XGBoost 1.7–1 container on an ml.m5.xlarge instance. No manual server setup required.</p><p><strong>Hyperparameter Tuning</strong> 10 automated trials run via SageMaker Automatic Model Tuning, searching across 6 hyperparameters including learning rate, tree depth, and subsampling ratio. The best configuration was selected automatically by validation AUC.</p><p><strong>Live Endpoint</strong> The best model was deployed to a real-time SageMaker endpoint called lxxxxx-dropout-endpoint running on an ml.t2.medium instance, capable of returning a dropout risk score for any student in under 50ms.</p><p><strong>Evaluation</strong> A confusion matrix and ROC curve were generated against a held-out validation set of 300 students, giving a clear picture of where the model gets predictions right and where it does not.</p><p><strong>Monitoring</strong> SageMaker Model Monitor was configured with a baseline from the training data. Monthly drift detection jobs will automatically flag if the pattern of incoming student data shifts significantly from what the model was trained on, triggering a retraining review.</p><p>The same pipeline works for any binary classification problem. Swap out the dataset and adjust the features and you could predict loan defaults, customer churn, equipment failure, or any yes or no outcome you can get historical data for.</p><h3>What the Results Mean</h3><p>The model achieved an AUC of 0.694 on synthetic data. To put that in plain terms: AUC measures how well the model separates students who will drop out from those who will not, on a scale from 0.5 (random guessing) to 1.0 (perfect). At 0.694 on data with no real patterns, the model is already performing meaningfully above chance.</p><p>On real Lxxxx student data where genuine relationships exist between attendance, CGPA, tuition payment history, and dropout outcomes, the same architecture is expected to reach an AUC of 0.80 or above. That is the threshold at which the model becomes genuinely actionable for advisors.</p><p>At 0.80 AUC, translating the numbers into business impact:</p><ul><li><strong>85% of at-risk students identified</strong> within the first 4 weeks of semester, compared to 12% under the current manual process</li><li><strong>Dropout rate target of 18%</strong>, down from the current 32% baseline</li><li><strong>NGN X million preserved per cohort</strong> in tuition and government subvention revenue</li><li><strong>380% ROI</strong> on the total cost of running the AWS ML system annually</li><li><strong>Payback period of 4.1 months</strong> from the point of full deployment</li></ul><p>These numbers matter because they make the case for investment in a way that university administrators, not just data scientists, can act on. The model does not just predict dropout. It quantifies the cost of inaction.</p><p>The broader lesson is this: the hardest part of an ML project is rarely the model itself. It is identifying a problem worth solving, gathering the right data, and building something that real people will actually use. The technology on AWS makes the rest surprisingly manageable, even for a first-time deployment.</p><h3>Conclusion</h3><p>Building this dropout prediction system showed me something important: machine learning on AWS does not have to be complicated. With the right services and a clear problem to solve, you can go from raw data to a live prediction endpoint entirely through a web console, without touching a single server.</p><p>What made this project meaningful was not just the technology. It was the problem behind it. Every student who drops out of Lxxxxx represents a failed opportunity, not just for the institution, but for a young person whose academic journey ended earlier than it should have. A 32% dropout rate is not a statistic. It is 1 in every 3 students walking away, often because nobody noticed the warning signs early enough.</p><p>This system changes that equation. By combining CGPA trends, attendance patterns, financial pressure signals, and welfare indicators into a single risk score, it gives academic advisors something they have never had before: time. Time to reach a student before they have made up their mind. Time to connect them with financial aid before their fees become insurmountable. Time to refer them to counselling before disengagement becomes withdrawal.</p><p><em>Have questions or want to share what you built with this? Connect with me on </em><a href="https://www.linkedin.com/in/florence-okoli/"><em>LinkedIn.</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=513972d50a60" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deploying a Serverless Motivation App on AWS using Amplify, Lambda, DynamoDB and API Gateway]]></title>
            <link>https://medium.com/@FlorenceOkoli/deploying-a-serverless-motivation-app-on-aws-using-amplify-lambda-dynamodb-and-api-gateway-f80edb6f916a?source=rss-76bffe9db278------2</link>
            <guid isPermaLink="false">https://medium.com/p/f80edb6f916a</guid>
            <category><![CDATA[lambda]]></category>
            <category><![CDATA[serverless-computing]]></category>
            <category><![CDATA[cloud-engineering]]></category>
            <category><![CDATA[api-gateway]]></category>
            <dc:creator><![CDATA[Florence Okoli]]></dc:creator>
            <pubDate>Tue, 25 Mar 2025 14:34:58 GMT</pubDate>
            <atom:updated>2025-03-25T14:34:58.156Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*19tZ-sB3HZmW_9b1zydxTg.png" /><figcaption>Serverless Web App Architecture</figcaption></figure><h3>1. Introduction</h3><p>Imagine having an application that delivers motivational messages on demand — no servers to manage, no scaling concerns, just seamless automation. That’s the power of serverless computing.</p><h4>What is serverless computing?</h4><p>Serverless computing lets you build and run applications without managing servers. The cloud provider handles infrastructure, scaling, and maintenance, so you only focus on writing code.</p><h4>Why Go Serverless?</h4><ul><li><strong>No server management</strong> — No need to provision or maintain servers</li><li><strong>Auto-scaling</strong> — Handles high traffic automatically</li><li><strong>Pay-per-use</strong> — Costs only for actual execution, not idle time</li><li><strong>Faster deployment</strong> — Focus on features, not infrastructure</li></ul><p>In this guide, I’ll walk you through how to build a <strong>fully serverless motivation app</strong> using AWS services like <strong>Amplify,</strong> <strong>Lambda, API Gateway, and DynamoDB</strong>. This app will allow users to fetch inspirational messages stored in DynamoDB via an API exposed through API Gateway, with all backend logic handled by AWS Lambda.</p><p><strong>Here’s how it works:</strong></p><ul><li>The user clicks the <strong>Get Inspired</strong> button.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mIUCgrlNhcPgGdqsF3bUTQ.png" /></figure><ul><li>A request is sent to the serverless backend.</li><li>The API retrieves a motivational message from DynamoDB and displays it on the screen.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iYx_sD1Re8Q-358WgSWS3w.png" /></figure><p>If you want to see the complete code for this project, including the <strong>HTML, CSS, and JavaScript</strong>, you can find it on my GitHub:<br><a href="https://github.com/WendyOkoli/ServerlessDemo"> ➡ <strong>GitHub Repository</strong></a></p><p>By the end of this guide, you will:<br> ✔️ Understand the fundamentals of <strong>serverless architecture</strong><br> ✔️ Learn how to store and retrieve data using <strong>DynamoDB</strong><br> ✔️ Deploy a backend API using <strong>AWS Lambda and API Gateway</strong><br> ✔️ Build a simple frontend that interacts with the serverless backend</p><p>Let’s get started!</p><h3>Prerequisites</h3><p>Before building this project, ensure you have the following:</p><ol><li><strong>AWS Account</strong></li></ol><ul><li>Sign up for an AWS account if you don’t have one.</li><li>Configure IAM permissions to allow access to AWS services.</li></ul><p><strong>2. Basic Knowledge of AWS Services</strong></p><ul><li><strong>AWS Lambda</strong> — To run backend logic without managing servers.</li><li><strong>API Gateway</strong> — To expose the backend as a REST API.</li><li><strong>DynamoDB</strong> — To store motivational messages.</li><li><strong>AWS Amplify</strong> — Helps with API calls and frontend integration, making it easier to connect to the backend.</li></ul><p>3. <strong>Understanding of JavaScript</strong></p><p>With these in place, you’re ready to start building the serverless motivation app! 🚀</p><h3>Steps to Build the Serverless Motivation App</h3><h4>Step 1: Create a DynamoDB Table for Storing Motivation Messages</h4><p>DynamoDB will serve as the database for storing and retrieving motivational messages. Since this is a serverless app, DynamoDB is a great choice because it scales automatically, is fully managed, and has low-latency responses.</p><ul><li>In the AWS console, search for DynamoDB Search for <strong>DynamoDB</strong> in the services search bar and click on it.</li><li>Click <strong>Create Table</strong>.</li><li><strong>Table name:</strong> MotivationMessages (You can use a different name, but remember it for later).</li><li><strong>Primary key:</strong> id (Type: String)</li><li>Leave other settings as default and click <strong>Create Table</strong>.</li><li>Once the table is created: Go to the <strong>Items</strong> tab.</li><li>Click <strong>Create Item</strong>.</li><li>Add the following sample data (in JSON view):</li></ul><pre>{<br>  &quot;id&quot;: &quot;1&quot;,<br>  &quot;message&quot;: &quot;Believe in yourself and all that you are!&quot;<br>}</pre><ul><li>Click <strong>Save</strong>. Repeat the process to add more messages:</li></ul><pre>{<br>  &quot;id&quot;: &quot;2&quot;,<br>  &quot;message&quot;: &quot;You are stronger than you think!&quot;<br>}</pre><p>Now that we have a database, the next step is <strong>creating an IAM Role</strong> that will allow Lambda to read from this table. Ready to proceed?</p><h4>Step 2: Setting Up an IAM Role for Lambda</h4><p>Before our AWS Lambda function can interact with <strong>DynamoDB</strong> and <strong>API Gateway</strong>, it needs permission to access these services. This is where <strong>IAM (Identity and Access Management) roles</strong> come in.</p><p>IAM roles define what actions a service (like Lambda) can perform on AWS resources. Instead of manually providing credentials, we attach an <strong>IAM role</strong> to Lambda, granting it the required permissions securely.</p><p><strong>1. Create an IAM Role</strong></p><ul><li>Go to the <strong>IAM Console</strong> → <strong>Roles</strong> → <strong>Create role</strong>.</li><li>Select <strong>AWS Service</strong> → <strong>Lambda</strong> → <strong>Next</strong>.</li></ul><p><strong>2. Attach Permissions</strong></p><ul><li>Search for the permissions shown in the image below and select it.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3D6iCq5yTy6nyptxnIx6yQ.png" /></figure><p>Click <strong>Next</strong>, name the role, and create it.</p><p>Using IAM roles is more secure than access keys, as AWS manages permissions automatically. Now, let’s create the Lambda function.</p><h4>Step 3: Create a Lambda Function and Attach the IAM Role</h4><p>Now that we have an IAM role, let’s create the <strong>Lambda function</strong> that will fetch motivational messages from DynamoDB.</p><p><strong>1. Create a New Lambda Function</strong></p><ul><li>Go to <strong>AWS Lambda</strong> → Click <strong>Create function</strong>.</li><li>Choose <strong>Author from scratch</strong>.</li><li>Name it.</li><li>For the Runtime, I used python 3:12.</li><li>Under <strong>Execution role</strong>, select <strong>Use an existing role</strong> and choose the IAM role you created earlier.</li><li>Click <strong>Create function</strong>.</li></ul><p><strong>2. Add the Code to Fetch Messages from DynamoDB</strong></p><p>In the function editor, replace the default code with:</p><pre>import json<br>import boto3<br><br>dynamodb = boto3.resource(&quot;dynamodb&quot;)<br>table = dynamodb.Table(&quot;MotivationMessages&quot;)  # Replace with your table name<br><br>def lambda_handler(event, context):<br>    try:<br>        response = table.scan()<br>        messages = response.get(&quot;Items&quot;, [])<br><br>        return {<br>            &quot;statusCode&quot;: 200,<br>            &quot;headers&quot;: {<br>                &quot;Content-Type&quot;: &quot;application/json&quot;,<br>                &quot;Access-Control-Allow-Origin&quot;: &quot;*&quot;,<br>            },<br>            &quot;body&quot;: json.dumps({&quot;messages&quot;: messages}),<br>        }<br><br>    except Exception as e:<br>        return {<br>            &quot;statusCode&quot;: 500,<br>            &quot;body&quot;: json.dumps({&quot;error&quot;: str(e)}),<br>        }</pre><p><strong>3. Deploy the Function</strong></p><ul><li>Click <strong>Deploy</strong> to save and activate the function.</li></ul><p><strong>4. Test the Function</strong></p><ul><li>Click on <strong>Test</strong></li><li>Select <strong>Create new test event</strong></li><li>Name it.</li><li>Click <strong>Save</strong>, then click <strong>Test</strong>. If everything is set up correctly, you should see a 200 response with motivational messages from DynamoDB.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*up_ywe6OF8FBWc9EilV6Hw.png" /></figure><p>Now that our Lambda function is working, the next step is to <strong>expose it via an API Gateway</strong> so that users can access it from the frontend.</p><h4>Step 4: Create a with API Gateway</h4><p>Now that our Lambda function is working, we need to make it accessible via an API. For this, we’ll use <strong>Amazon API Gateway</strong> to create a <strong>REST API</strong>. API Gateway acts as the <strong>entry point</strong> for applications, allowing users to interact with our backend (Lambda). It handles:</p><ul><li><strong>Routing requests</strong> to the correct backend service</li><li><strong>Authentication and security</strong> (IAM, API keys, JWTs)</li><li><strong>Rate limiting and caching</strong> for performance</li><li><strong>Cross-Origin Resource Sharing (CORS)</strong></li></ul><p><strong>1. Create a REST API</strong></p><ul><li><strong>Go to AWS Console</strong> → Search for <strong>API Gateway</strong></li><li>Click <strong>Create API. </strong>Select <strong>REST API</strong></li><li><strong>Choose the type:</strong> <strong>“Regional”</strong> or <strong>“Edge Optimized”</strong></li><li>Click <strong>Create API</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vFloScOCJYF4SWzLDcVl1Q.png" /></figure><p><strong>2. Create GET Method (Fetch Messages)</strong></p><ul><li>Click on create method as shown below:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4xHaSio76r_T4f1K-Vw55Q.png" /></figure><ul><li>Select <strong>GET</strong> from the dropdown. <strong>Integration Type:</strong> Select <strong>Lambda Function. </strong>Use the lambda function you created earlier<br>Click on create method. See image below:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AwKpsuPOSN2VQ-TSu46sfA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4rQjLTkQu5U2QA7bQNgM9Q.png" /></figure><p><strong>3. Enable CORS</strong><br>But why enable CORS??</p><ul><li>CORS (<strong>Cross-Origin Resource Sharing</strong>) allows a frontend (like a website or app) to access an API hosted on a different domain. Without it, browsers block requests for security reasons. Since our motivation app will call the API from a frontend, we must enable CORS in API Gateway to allow the frontend to <strong>send and receive data</strong>.</li><li>If we don’t enable CORS:<br> ❌ The browser will block requests<br> ❌ Users won’t be able to fetch or post messages</li></ul><p>By enabling CORS, we ensure smooth communication between the frontend and backend.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Dklhmkjh_lu8je3OJv-M3g.png" /></figure><p><strong>4. Deploy the API</strong></p><ul><li>Next, let’s deploy the API. Click <strong>Actions</strong> → <strong>Deploy API</strong></li><li>Create a <strong>New Stage</strong></li><li><strong>Stage Name:</strong> prod</li><li>Click <strong>Deploy. </strong>After deployment, go to <strong>Stages</strong> → <strong>prod</strong></li></ul><p>Copy the <strong>Invoke URL </strong><em>“https://4t0ypwqb11.execute-api.us-east-1.amazonaws.com/prod&quot;; </em>for the<strong> GET method </strong>and add it to your javascript file<strong> </strong>so the frontend can communicate with the backend.</p><pre>const apiUrl = &quot;https://4t0ypwqb11.execute-api.us-east-1.amazonaws.com/prod&quot;;<br><br>document.getElementById(&quot;quoteBtn&quot;).addEventListener(&quot;click&quot;, async function() {<br>    let quoteElement = document.getElementById(&quot;quote&quot;);<br>    quoteElement.innerText = &quot;Fetching a motivational message... ⏳&quot;;<br><br>    try {<br>        const response = await fetch(apiUrl);<br>        let data = await response.json(); <br>        <br>        console.log(&quot;RAW API RESPONSE:&quot;, data); // 🔹 Log full API response<br><br>        // Parse `body` since it&#39;s a stringified JSON<br>        let parsedBody = JSON.parse(data.body);<br>        console.log(&quot;PARSED BODY:&quot;, parsedBody);<br><br>        if (!parsedBody.messages || !Array.isArray(parsedBody.messages) || parsedBody.messages.length === 0) {<br>            throw new Error(&quot;No messages found in API response.&quot;);<br>        }<br><br>        let randomIndex = Math.floor(Math.random() * parsedBody.messages.length);<br>        quoteElement.innerText = parsedBody.messages[randomIndex].message; // <br><br>    } catch (error) {<br>        console.error(&quot;Error fetching data:&quot;, error);<br>        quoteElement.innerText = &quot;No motivational messages found. Try again later! ❌&quot;;<br>    }<br>});</pre><p>Now that the frontend is connected to the API, let’s deploy it using <strong>AWS Amplify</strong>. Ready? 🚀</p><h4>Step 5: Deploying the Frontend with AWS Amplify</h4><p>Now that your frontend is ready and connected to the API, let’s deploy it using <strong>AWS Amplify</strong> so it’s accessible online.</p><ol><li><strong>Connect Your GitHub Repository to Amplify</strong></li></ol><p><strong>Go to the AWS Amplify Console. </strong>Click <strong>“New app”</strong> → <strong>“Host web app”<br></strong>Choose <strong>“GitHub”</strong> as the source and authenticate your GitHub account.<br>Select your repository and branch (e.g., main).<br>Click <strong>“Next”</strong>, review the settings, and then <strong>Save and Deploy</strong>.</p><p><strong>2. Test Your Live App</strong></p><p>Once the deployment is complete, Amplify will provide a <strong>public URL</strong> (e.g., <a href="https://your-app.amplifyapp.com)./">https://your-app.amplifyapp.com).</a> Open the URL in your browser. <br>Click <strong>“Get Inspired”</strong> and verify that motivational messages are fetched from <strong>DynamoDB</strong> via <strong>API Gateway and Lambda</strong>.<br>If you encounter <strong>CORS issues</strong>, ensure CORS is enabled in API Gateway.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DgqaFfDFCOH_FprTMR7QJw.png" /></figure><p>🎉 <strong>Congratulations!</strong> Your <strong>fully serverless motivation app</strong> is now live!</p><h3>Conclusion</h3><p>Congratulations! You have successfully built and deployed a fully serverless motivation app using AWS Lambda, API Gateway, DynamoDB, and Amplify. This project has taken you through the key steps of setting up a <strong>scalable, cost-effective</strong>, and <strong>fully managed</strong> backend without worrying about servers.</p><p>By following this guide, you’ve learned how to:<br> ✅ Set up <strong>DynamoDB</strong> for storing motivational messages<br> ✅ Create a <strong>Lambda function</strong> to process API requests<br> ✅ Expose the function through <strong>API Gateway</strong><br> ✅ Deploy the frontend with <strong>AWS Amplify</strong></p><p>Serverless development is a powerful approach that simplifies infrastructure management while ensuring scalability. Whether you use it for small projects or enterprise applications, understanding <strong>how to architect serverless solutions properly</strong> is key.</p><p>I appreciate you following along! If you have <strong>questions, feedback, or suggestions</strong>, feel free to <strong>reach out on </strong><a href="https://www.linkedin.com/in/florence-okoli/"><strong>LinkedIn</strong></a>. I’d love to hear about your experience and how you’re applying serverless in your own projects! 🚀</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f80edb6f916a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Setting up WordPress on Ubuntu using the LAMP Stack.]]></title>
            <link>https://medium.com/@FlorenceOkoli/setting-up-wordpress-on-ubuntu-using-the-lamp-stack-10e2dba79182?source=rss-76bffe9db278------2</link>
            <guid isPermaLink="false">https://medium.com/p/10e2dba79182</guid>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[wordpress]]></category>
            <category><![CDATA[lamp]]></category>
            <category><![CDATA[ubuntu]]></category>
            <category><![CDATA[cloud-engineer]]></category>
            <dc:creator><![CDATA[Florence Okoli]]></dc:creator>
            <pubDate>Sun, 26 May 2024 22:08:39 GMT</pubDate>
            <atom:updated>2024-05-27T05:48:54.158Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IDXQEshRb-ToVNNGNJB6Vw.png" /></figure><p>Let’s say you are a blogger or even a small business owner looking for a way to share your insights or products with the world at large. For this, you would need a perfect platform for your website that is also flexible with a vast array of plugins.<br>Well, here comes <strong>WordPress</strong> to the rescue.</p><p>You now have a great platform, but you may want the freedom to customize your server environment and ensure that every aspect of your website runs exactly as you want, without relying on managed hosting services.<br>Okay. <strong>Ubuntu</strong> comes into play and combined with the power of the <strong>LAMP</strong> stack (Linux, Apache, MySQL, PHP) gives you complete control over your website.</p><p>All these may seem daunting at first but in this guide, I will walk you through the process of hosting WordPress on Ubuntu using the LAMP stack.</p><p><strong>Overview of Key Components<br></strong>Before we delve into the step-by-step process, let’s take a brief look at what WordPress, Ubuntu, and the LAMP stack are, and their roles in this project:</p><ul><li><strong>WordPress</strong> — WordPress is a widely used content management system (CMS) for creating and managing websites. It is well-known for its user-friendly interface and extensive library of plugins and themes. With WordPress, you can build anything from basic blogs to advanced e-commerce sites without requiring advanced technical skills. In this guide, WordPress will serve as the platform for creating and managing your website&#39;s content.</li><li><strong>Ubuntu</strong> — Ubuntu is a popular, open-source Linux operating system known for its stability, security, and ease of use. In this project, Ubuntu serves as the foundation, hosting the web server and other essential software components.</li><li><strong>LAMP Stack</strong> — LAMP is a set of open-source software for creating web servers, comprising Linux (Ubuntu as the operating system), Apache (webserver), MySQL (database), and PHP (scripting language). Each component is important and here is what they will do in this project:<br> Linux: Provides the Operating System foundation.<br> Apache: Handles browser requests and serves web pages.<br> MySQL: Manages the WordPress database.<br> PHP: Processes dynamic content and interacts with the <br> database.</li></ul><p><strong>Prerequisites</strong></p><ol><li>An Ubuntu Server: You can use either a local machine(Vagrant virtual box)or a cloud-based virtual private server from AWS, Digital Ocean or Google Cloud.</li><li>A basic understanding of Linux commands.</li></ol><p><strong>Steps</strong></p><ol><li><strong>Update your package index</strong> with this command sudo apt update</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/612/1*e7FWYTKL6UWnZNk2PyPazA.png" /><figcaption>Sudo apt update</figcaption></figure><p>2. Install <strong>Dependencies</strong><br>To install Apache2 and PHP, run the following command</p><pre>sudo apt install apache2 \<br>                 ghostscript \<br>                 libapache2-mod-php \<br>                 mysql-server \<br>                 php \<br>                 php-bcmath \<br>                 php-curl \<br>                 php-imagick \<br>                 php-intl \<br>                 php-json \<br>                 php-mbstring \<br>                 php-mysql \<br>                 php-xml \<br>                 php-zip</pre><p>To avoid errors, please copy and paste this command into a text file before pasting it into your virtual environment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/738/1*UA3fz3HLw8Tb7xiPDB2dAw.png" /><figcaption>Installing Dependencies</figcaption></figure><p>3. <strong>Install WordPress</strong></p><ul><li>Let’s create a new directory first and change the ownership of this directory to the user www-data to ensure that the web server has the appropriate access to these files.</li></ul><pre>sudo mkdir -p /srv/www<br>sudo chown www-date: /srv/www</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/638/1*jAKsS66nzOe9XM3zviQYbg.png" /></figure><ul><li>Next, let’s download the latest version of WordPress and extract it into the /srv/www directory.</li></ul><pre>curl https://wordpress.org/latest.tar.gz | sudo -u www-data tar zx -C /srv/www</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HcCmrlMyZTeTtX1DnqUqog.png" /><figcaption>Download the latest version of WordPress</figcaption></figure><blockquote>Here is what this code does<br>This curl https://wordpress.org/latest.tar.gzcommand uses curl to download the file at the given URL, which is the latest version of WordPress in a gzipped tarball format. <br>The pipe | command takes the output of the command on its left and uses it as the input to the command on its right.<br>sudo -u www-data This runs the following command as the www-data user. This is done because the /srv/www directory is owned by www-data, which we set earlier if you can remember <br>This commandtar zx -C /srv/www extracts the gzipped tarball. The z option tells tar to uncompress the file (as it is gzipped), the x option tells it to extract the files from the tarball, and the -C /srv/www option tells it to change to the /srv/www directory before doing so.</blockquote><p>To confirm you followed the above step correctly, run this command</p><pre>ls -l /srv/www/wordpress</pre><p>You are on track if you see an image like the one below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/796/1*qnTkIFDBdNQ28r1dBH9dGA.png" /></figure><p>4.<strong> Configure Apache</strong></p><ul><li>To configure Apache for WordPress, run this command to create and edit the WordPress configuration file</li></ul><pre>sudo vi /etc/apache2/sites-available/wordpress.conf</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*k_caBQK_UTcvJvErYbaO4A.png" /><figcaption>Create a wordpress.conf file</figcaption></figure><ul><li>The command above opens up an empty configuration file. Copy the codes below and paste them into the configuration file. Then, save it</li></ul><pre>&lt;VirtualHost *:80&gt;<br>    DocumentRoot /srv/www/wordpress<br>    &lt;Directory /srv/www/wordpress&gt;<br>        Options FollowSymLinks<br>        AllowOverride Limit Options FileInfo<br>        DirectoryIndex index.php<br>        Require all granted<br>    &lt;/Directory&gt;<br>    &lt;Directory /srv/www/wordpress/wp-content&gt;<br>        Options FollowSymLinks<br>        Require all granted<br>    &lt;/Directory&gt;<br>&lt;/VirtualHost&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/757/1*Yuq_cMt3Y7J3hgCiESRAOQ.png" /><figcaption>WordPress Conf file</figcaption></figure><ul><li>When this is done, enable the site using this command — sudo a2ensite wordpress and then enable URL rewriting using this command sudo a2enmod rewrite lastly, disable the default site using sudo a2dissite 000-default</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/574/1*ydPTHDPiuiTv2DCgcbrC3A.png" /></figure><ul><li>To finish up with this step, reload apache2 to apply all these changes</li></ul><pre>sudo service apache2 reload</pre><p>5.<strong> Configure MySQL Database</strong></p><ul><li>Before we proceed, it is important to note that MySQL commands end with ; or /g</li><li>Let’s begin with opening up the MySQL CLI using this command</li></ul><pre>sudo mysql -u root</pre><ul><li>This command opens the MySQL command-line client as the root user</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/710/1*H-WM25Z9vMFm_kKzpfrWLQ.png" /></figure><ul><li>Now, we create a database called wordpress, create a user for this database and give it a unique password. Next, we grant privileges to this user and with the flush privileges command, we reload the user privileges from the grant tables in the MySQL database.<br>Here is the code at play:</li></ul><pre>CREATE DATABASE wordpress;<br>CREATE USER wordpress@localhost IDENTIFIED BY &#39;&lt;your-password&gt;&#39;;<br>GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,ALTER ON wordpress.* TO wordpress@localhost;<br>FLUSH PRIVILEGES;<br>quit</pre><ul><li>Please note that these commands should be copied one after the other into the CLI to avoid errors.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WT7kUTTKRYjQ5WJFfIwtjg.png" /></figure><ul><li>To apply these changes we made, let&#39;s enable the MySQL service with this command here — sudo service mysql start</li></ul><p>6. <strong>Configure WordPress to connect to the database</strong></p><ul><li>First, let’s create a new configuration file for WordPress by copying the sample configuration file to wp-config.php</li></ul><pre>sudo -u www-data cp /srv/www/wordpress/wp-config-sample.php /srv/www/wordpress/wp-config.php</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yTwK5tA_dle62MpAVlVjZg.png" /><figcaption>Copy WordPress Sample Config file</figcaption></figure><ul><li>Next, we configure the credentials in the configuration file. Please note that the only thing you are expected to change in the commands below is your password. <br>Remember the unique password you created when you were creating the MySQL database? Yeah, that’s the one.</li></ul><pre>sudo -u www-data sed -i &#39;s/database_name_here/wordpress/&#39; /srv/www/wordpress/wp-config.php<br>sudo -u www-data sed -i &#39;s/username_here/wordpress/&#39; /srv/www/wordpress/wp-config.php<br>sudo -u www-data sed -i &#39;s/password_here/&lt;your-password&gt;/&#39; /srv/www/wordpress/wp-config.php</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kbWOYHHmNq3gqGXWzg2-Eg.png" /></figure><ul><li>Now we need to edit the WordPress config file. Use this command to open and edit the config file sudo -u www-data /srv/www/wordpress/wp-config.php</li><li>In your config file, scroll down to where you will find the commands below:</li></ul><pre>define( &#39;AUTH_KEY&#39;,         &#39;put your unique phrase here&#39; );<br>define( &#39;SECURE_AUTH_KEY&#39;,  &#39;put your unique phrase here&#39; );<br>define( &#39;LOGGED_IN_KEY&#39;,    &#39;put your unique phrase here&#39; );<br>define( &#39;NONCE_KEY&#39;,        &#39;put your unique phrase here&#39; );<br>define( &#39;AUTH_SALT&#39;,        &#39;put your unique phrase here&#39; );<br>define( &#39;SECURE_AUTH_SALT&#39;, &#39;put your unique phrase here&#39; );<br>define( &#39;LOGGED_IN_SALT&#39;,   &#39;put your unique phrase here&#39; );<br>define( &#39;NONCE_SALT&#39;,       &#39;put your unique phrase here&#39; );</pre><ul><li>Now delete these commands above and replace them with the content you will find <a href="https://api.wordpress.org/secret-key/1.1/salt/">here</a>. (This address is a randomiser that returns completely random keys each time it is opened.) <br>See mine below</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tcgx9KjBD_SXAyy1b97udA.png" /></figure><blockquote>This step is important to ensure that your site is not vulnerable to attacks.</blockquote><p>Save the changes.</p><p>7. <strong>Customize WordPress to serve your web pages</strong></p><ul><li>On your terminal, run this command ip a to copy the IP address of your local machine. Copy and then paste the address on your browser. You will see an image similar to the one below upon loading your browser. Click on &quot;continue&quot; to customize WordPress for hosting your web pages.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8o5jQ93tAAcPm7pOuNajqg.png" /></figure><ul><li>Next, enter the title of your new site, username, password, and <br> a valid e-mail address. Note that the username and password you <br> choose here are for the WordPress site and not the ones you <br> used for the MySQL database earlier.<br> <br> Click on Install WordPress to continue</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cUHTkwGQDK7DyLJtP17L-g.png" /></figure><ul><li>Now, let’s log in with our details</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/613/1*IBYOJa9hlOf6ll4YFqXhDg.png" /></figure><ul><li>Once you log in to the WordPress dashboard, you will find a variety of icons and options to customize your website according to your preferences.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tong7XOJx5zzrKiTSgvD4w.png" /></figure><p>C’est fini!!!</p><p>Congratulations on taking the first step toward creating your own WordPress website on Ubuntu using the powerful LAMP stack! By following this guide, you’ve set up a flexible and customizable platform for sharing your insights, products, or even services with the world.</p><p>I hope you found this tutorial helpful and easy to follow.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=10e2dba79182" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Automate your tasks and schedule cronjobs with a script]]></title>
            <link>https://medium.com/@FlorenceOkoli/automate-your-tasks-and-schedule-cronjobs-with-a-script-fef22119e098?source=rss-76bffe9db278------2</link>
            <guid isPermaLink="false">https://medium.com/p/fef22119e098</guid>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[bash-script]]></category>
            <category><![CDATA[cronjob]]></category>
            <category><![CDATA[devops]]></category>
            <dc:creator><![CDATA[Florence Okoli]]></dc:creator>
            <pubDate>Thu, 23 May 2024 12:31:35 GMT</pubDate>
            <atom:updated>2024-05-23T12:31:35.166Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7gnDP0VvIt1MzfOW6BGLKA.png" /><figcaption>Cover Photo</figcaption></figure><p>Have you ever wondered how computers can do tasks all by themselves without anyone touching them? It’s like magic, but there’s a special way to tell the computer what to do, step by step. This is called scripting. <br>This article will explore the basics of Bash scripting, provide practical examples, and guide you through creating your scripts.<br>Let’s dive in!</p><p><strong>Introduction</strong></p><ul><li>What is Bash Scripting?</li></ul><p>Bash scripting is a powerful tool for automating tasks on Unix-like operating systems, such as Linux and macOS. <br>Bash, short for the “Bourne Again Shell,” is a powerful scripting language that enables users to automate repetitive tasks, streamline complex workflows, and efficiently manage system operations instead of doing them manually.<br>Overall, bash scripting is an essential skill for system administrators, developers, and anyone looking to optimize their computing tasks.</p><p>In Bash scripting, the Shebang #!/bin/bash serves as the interpreter used to execute tasks on any script. In other words, it tells the system to use the specified interpreter to run the script.</p><p><strong>Prerequisite</strong></p><ul><li>Vagrant virtual machine</li><li>Good understanding of Linux commands</li></ul><p><strong>Basics to Know Before Writing a Bash Script</strong><br>Before diving into writing Bash scripts, it’s essential to understand some fundamental concepts and components of Bash scripting. Here are the basics you need to know:</p><ul><li>Familiarize yourself with basic Unix commands like mkdir, touch, and echo.</li><li>Understand file permissions and how to change them using chmod. For example, to make your script executable, use chmod +x. The x stands for execution</li><li>Use a text editor like Nano or Vim to write and edit scripts. <br> For Nano — nano myscript.shFor Vim — vi myscript.sh</li><li>Add comments in your scripts using the # symbol. They help explain what the script does and are ignored during execution. # This is a comment</li><li>Always start your script with a Shebang. It specifies the interpreter to be used.</li><li>Lastly, for every script, you must make sure to follow the syntax which includes the spacing, indentation, and punctuation.</li></ul><p>Let’s begin</p><p><strong>Practical Examples of Bash Scripting</strong></p><p>Let’s start by creating a new directory that will house all our scripts. Once the directory is created using the mkdir command, cd into the folder and create a file with the .sh extension. The .sh tells you that the file is a script.</p><pre>mkdir bashscript<br>cd bashscript<br>touch myscript.sh</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/794/1*4lIay5FRF44Y3eSz8opOYg.png" /><figcaption>Create a new directory and file for your script</figcaption></figure><p>Let’s make our newly created script executable. This will enable us to run our script.</p><pre>chmod +x myscript.sh</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/952/1*6bELnEk8ZWvN97HUmaYhXA.png" /><figcaption>Execute Script and check file permission</figcaption></figure><p>The ll command shows the permissions for the myscript.sh file</p><p>Next, let’s play around with automation.</p><p>To do this, let’s write a script that updates and upgrades our system.</p><p>This command vi myscript.sh opens the file named script.sh in the vi text editor.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/797/1*sqK5d9HtIaUaKpV3VS9Rrw.png" /><figcaption>Open Script</figcaption></figure><p>When the file is opened in the Vim text editor, write the following codes in your script</p><pre>#!/bin/bash<br>sudo apt update -y<br>sudo apt upgrade -y</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/699/1*vS9K5KDzYrOXxziEK0X3xg.png" /><figcaption>System update and upgrade</figcaption></figure><p>Close your text editor and run this command — ./myscript.sh</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m3WbhfE8TFeRudov_LJr6Q.png" /><figcaption>Run Script</figcaption></figure><p>Now, that we have seen what automation looks like using a bash script, let’s get more practical.</p><ol><li><strong>Statements in Bash Scripting</strong></li></ol><p>i. <strong>Printing statements</strong> using the echo command. The echo command in Bash scripting is used to print output to the terminal. Let’s try it out.</p><blockquote>First, create a script. I called my script myscript.sh Then use the Vim text editor to open it vi myscript.sh Remember to start your script with the Shebang #!/bin/bash interpreter followed by the echo command and your text in quotes. Then close the editor</blockquote><pre>#!/bin/bash<br>echo &quot;Florence is a Cloud Engineer who loves bash scripting&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/974/1*mUA6yog6ONhi7oXqIsrlpA.png" /><figcaption>Echo command</figcaption></figure><p>Run your script using the ./&lt;name of your script&gt;The output will look like the image below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/866/1*_xEBgGuuR3Kr-9nEaYgamg.png" /><figcaption>Output of the echo command</figcaption></figure><p>ii. <strong>Declaring variables. </strong><br>Variables in bash scripting are used to store data and can be referenced in your script to perform operations.</p><blockquote>Here is how to declare a variable</blockquote><pre>#!/bin/bash<br>name=&quot;Florence&quot;<br>job=&quot;Cloud Engineer&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1013/1*76mOOraMbGuHk_OX_m63iQ.png" /><figcaption>Declare Variables</figcaption></figure><blockquote>There should be no spaces around the equals sign. The value can be a number, a string, or the result of a command.</blockquote><blockquote>To read or use the value stored in a variable, you prepend the variable name with a dollar sign ($). For example:</blockquote><pre>#!/bin/bash<br>echo &quot;My name is $name and I&#39;m a $job&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/621/1*BPfvZWZC6bRmQKavxlTQ6w.png" /></figure><p>When this script is run using the ./myscript.sh this is what it will look like</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/790/1*9xAYYu03KiWbex-0FdlyQw.png" /></figure><p>iii. <strong>If Statements</strong><br>The If statement allows your script to make decisions and perform different actions depending on whether a condition is true or false. In the example below, we are going to run a script that checks whether a given number is an even or odd number.</p><pre>#!/bin/bash<br><br>read -p &quot;Enter a number: &quot; number<br><br>if (( $number % 2 == 0 )); then<br>   echo &quot;$number is an even number&quot;<br>else<br>   echo &quot;$number is an odd number&quot;<br>fi </pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/987/1*0Y3ZXqvJCMDYdMhstdG-5Q.png" /><figcaption>A snippet of the if statement code</figcaption></figure><p>A breakdown of the script:</p><blockquote>read -p &quot;Enter a number: &quot; number: Prompts the user to enter a number and stores it in the number variable.<br>if (( number % 2 == 0 )); then: Checks if the number is even.<br>echo &quot;The number $number is even.&quot;: Prints that the number is even if the condition is true.<br>else: Executes the following code if the number is not even.<br>echo &quot;The number $number is odd.&quot;: Prints that the number is odd.<br>fi: Ends the if statement.</blockquote><p>When the above script is run, here is what the result will look like</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/786/1*tnt9OXmuf0bKfoeYP_wX8g.png" /></figure><p>iv. While Loop<br>In Bash scripting, the while loop allows you to repeatedly execute a block of code as long as a specified condition remains true. Once the condition becomes false, the loop stops executing. This is similar to a washing machine cycle: it keeps running until the timer reaches zero.</p><p>Let’s write a script that checks if a particular directory exists or not. In this case, we are checking if the ~bash/loopdir exists in our system.</p><pre>#!/bin/bash<br><br>while [ -d ~bash/loopdir ]; do<br>    echo &quot;Directory exists&quot;<br>done<br>    echo&quot;Directory does not exist&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/816/1*fIF6rWoA5UZ59GbbOCMKAA.png" /><figcaption>A snippet of the while loop</figcaption></figure><p>A breakdown of the script:</p><blockquote>while [ -d ~/bash/loopdir]; do: Starts a while loop that checks if the directory ~/bash/loopdir exists.<br> echo “Directory exists”: Prints “Directory exists” if the directory actually exists.<br> done: Ends the while loop when the directory no longer exists.<br>echo “Directory does not exist”: Exits the loop and prints “Directory does not exist” when the directory is no longer present.</blockquote><p>Now, that you have gotten to this point, let’s do something interesting. Let’s create a script that monitors the uptime of a server and logs it periodically. In this script, we are also going to incorporate a cronjob that will record the server’s uptime at specified intervals.</p><p>Before we start, let me explain what a cronjob does and why it is needed.</p><blockquote>A a cron job is just like that magical clock for your computer! It helps your computer remember to do certain tasks automatically, without you having to tell it every time.<br>Let me be more technical now. <br>A cron job is a time-based job scheduler in Unix-like operating systems, including Linux. It allows users to schedule commands or scripts to run periodically at fixed times, dates, or intervals. These scheduled tasks are referred to as cron jobs, and they can automate repetitive tasks, such as backups, uptime monitoring, log rotation, system maintenance, etc.</blockquote><p>Now, let&#39;s create that script!</p><p>With this command sudo vi log_uptime.sh I will create a script for this particular task and make it executable using sudo chmod +x log_uptime.sh</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/683/1*Cx9Cp1vqHckQMZeVC23xaw.png" /></figure><p>Let’s write the script.</p><pre>#!/bin/bash<br><br># Define the log file<br>LOG_FILE=&quot;$HOME/uptime_log.txt&quot;<br><br># Create the log file if it doesn&#39;t exist<br>if [ ! -f &quot;$LOG_FILE&quot; ]; then<br>    touch &quot;$LOG_FILE&quot;<br>    echo &quot;Log file created at $LOG_FILE&quot;<br>fi<br><br># Get the current date and uptime<br>CURRENT_DATE=$(date &#39;+%Y-%m-%d %H:%M:%S&#39;)<br>UPTIME=$(uptime -p)<br><br># Append the uptime to the log file<br>echo &quot;$CURRENT_DATE - Uptime: $UPTIME&quot; &gt;&gt; &quot;$LOG_FILE&quot;<br>echo &quot;Uptime logged at $CURRENT_DATE&quot;<br><br># Define the cron job command<br>CRON_JOB=&quot;0 * * * * $HOME/log_uptime.sh&quot;<br><br># List existing cron jobs<br>echo &quot;Current Cron Jobs:&quot;<br>crontab -l<br><br># Add the cron job<br>echo &quot;Adding new cron job:&quot;<br>echo &quot;$CRON_JOB&quot; | crontab -<br><br># Confirmation of added cron job<br>echo &quot;New cron job added:&quot;<br>crontab -l<br></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/688/1*adlgDXzGOAIyoOJJdUboTQ.png" /><figcaption>Script</figcaption></figure><p>When this script is run using the ./log_uptime.sh command, here is what the output will be</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/544/1*7kQTAsATGsFAbApNmXiP3Q.png" /><figcaption>Result</figcaption></figure><p><strong>Conclusion</strong></p><p>Scripting in Bash is like giving instructions to your computer to do tasks automatically. This article introduced the basics of Bash scripting, providing practical examples by creating readable scripts. With Bash scripting, you can automate repetitive tasks and manage system operations efficiently.</p><p>Your feedback is very important to me. Were the explanations clear? Did the examples make sense? Let me know if there’s anything specific you’d like me to cover in more detail. I’m here to ensure I meet your needs.</p><p>Thank you for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fef22119e098" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hosting a static website on an S3 bucket using Amazon CloudFront]]></title>
            <link>https://medium.com/@FlorenceOkoli/hosting-a-static-website-on-an-s3-bucket-using-amazon-cloudfront-041814520bea?source=rss-76bffe9db278------2</link>
            <guid isPermaLink="false">https://medium.com/p/041814520bea</guid>
            <category><![CDATA[amazon-cloudfront]]></category>
            <category><![CDATA[aws-s3]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[static-websites]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Florence Okoli]]></dc:creator>
            <pubDate>Sun, 12 May 2024 18:56:35 GMT</pubDate>
            <atom:updated>2024-05-12T23:08:08.952Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rFytO-sQec0MBHOjL1lQUg.png" /><figcaption>Cover photo</figcaption></figure><p>Imagine you’re an aspiring photographer, eager to share your stunning portfolio with the world. You’ve spent countless hours perfecting your website, featuring captivating images that showcase your talent. You would want viewers from across the globe to visit your website and explore your work. Here is where Amazon S3 bucket and CloudFront come in.</p><p>Here is what happens when you deploy your photography website using Amazon S3 bucket and CloudFront. S3 securely stores your high-resolution images and website files in a bucket on the AWS cloud, while CloudFront ensures that these objects are delivered swiftly to visitors worldwide.</p><p>In this guide, we will host a static website on an Amazon S3 bucket(private bucket) but with a public read policy assigned, using CloudFront for Content Delivery Network.</p><p><strong>Introduction</strong></p><ul><li>Static Website</li></ul><p>A static website is a lightweight, fast-loading, and easy-to-maintain website that presents fixed content to users using basic web technologies. A static website consists of only client-side technologies such as HTML, CSS, and JavaScript. It doesn’t require a server to generate or serve content dynamically.</p><ul><li>Amazon S3</li></ul><p>An Amazon S3 (Simple Storage Service) bucket is a fundamental component of Amazon Web Services (AWS) that provides scalable object storage in the cloud. An Amazon S3 (Simple Storage Service) bucket serves as a fundamental storage container within the S3 service.</p><ul><li>Amazon CloudFront</li></ul><p>Amazon CloudFront is a content delivery network service provided by AWS. Its primary function is to deliver content, such as web pages, videos, images, and other static or dynamic assets, to users with low latency and high transfer speeds.</p><p>By integrating these two services, you can easily store your website’s content on Amazon S3 and deliver it quickly to your users using CloudFront’s content delivery network (CDN)</p><p><strong>Prerequisite</strong></p><ul><li>An AWS account</li><li>Files or folders for your static website. I used this template [<a href="https://startbootstrap.com/theme/agency">here</a>]</li></ul><p><strong>Follow the steps below to host a static website on an S3 bucket using CloudFront.</strong></p><p><strong>1. Create an Amazon S3 bucket</strong></p><ul><li>Log in on your AWS management console and search for the S3 service. Proceed to create a bucket as seen below:</li></ul><figure><img alt="Create S3 Bucket" src="https://cdn-images-1.medium.com/max/1024/1*va9kpoVGBzbQk1hyaIzQ3A.png" /><figcaption>Create S3 Bucket</figcaption></figure><ul><li>Select the general purpose type for your bucket and a unique name for your bucket. If the name is not unique, you won’t be able to create a bucket.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0DW9hvysaB0NBcI3YHMjow.png" /><figcaption>Bucket type and name</figcaption></figure><ul><li>Leave all other settings on default. Scroll down and click on Create Bucket.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2kGmwbCTmrTfSAlTOUHqXQ.png" /><figcaption>Click on Create bucket</figcaption></figure><ul><li>Once the bucket has been successfully created, click on <strong>view details</strong> or your bucket name to view the details of the bucket created.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bH93evXCRrj6TY6hKM0-ww.png" /><figcaption>Click on view bucket details</figcaption></figure><p><strong>2. Upload files into the S3 bucket</strong></p><ul><li>In the bucket overview page, under the objects tab, click on upload to upload the files/folders of your website.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6dajsg4yjj6WIOhI4eDAbg.png" /><figcaption>Click on Upload</figcaption></figure><ul><li>Drag and drop your files or add them as files/folders.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XM8IULg-_LuDFx_fX_1NVQ.png" /><figcaption>Add files or folder</figcaption></figure><ul><li>Scroll to the end of the page and click on upload.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NfxvWz_kRLxvJOhPdzXc3w.png" /><figcaption>Upload files</figcaption></figure><ul><li>Once the upload is successful, close the page as shown in the image below.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZAlE6QqIWLKwDtmL6myiBA.png" /><figcaption>Close page</figcaption></figure><p><strong>3. Create a CloudFront Distribution</strong></p><ul><li>On the AWS management console, search for CloudFront and click on it. Then proceed to create a CloudFront distribution</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*C9n1D9CSf5oGSRnWeUDXQw.png" /><figcaption>CloudFront Service</figcaption></figure><ul><li>Next, enter an origin name. The name of your bucket should be the same as the name you use for it. <br>Proceed to create a new Origin Access Control.</li></ul><p>The reason for introducing Origin Access Control is to restrict access to the bucket. Remember we are trying to make our S3 bucket private right? The Origin Access Control will do that for us.</p><ul><li>See the image below:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NttOMGmrIVQM16rkfKI42g.png" /><figcaption>Enter Origin name</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/840/1*iTU___t0NA9coSCpmoVU4A.png" /><figcaption>Create new Origin Access Control</figcaption></figure><ul><li>Set your WAF to <strong>Do not enable security protection</strong> since this is for practice.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6KBtilggf3GzZjQ5D9DOoA.png" /><figcaption>Disable security protections</figcaption></figure><ul><li>Leave every other setting on default and proceed to create your distribution</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J9Sis4zUKf5jOGVK0lgQKQ.png" /><figcaption>Create distribution</figcaption></figure><ul><li>To complete the distribution configuration, copy the policy and click on <strong>Go to S3 permissions to update the policy</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AA6xFGufxoBCI1om44fUxg.png" /></figure><ul><li>On the permissions tab under your bucket, scroll to bucket policy and click edit. Then paste the policy you copied. Here is what it should look like</li></ul><pre>{<br>        &quot;Version&quot;: &quot;2008-10-17&quot;,<br>        &quot;Id&quot;: &quot;PolicyForCloudFrontPrivateContent&quot;,<br>        &quot;Statement&quot;: [<br>            {<br>                &quot;Sid&quot;: &quot;AllowCloudFrontServicePrincipal&quot;,<br>                &quot;Effect&quot;: &quot;Allow&quot;,<br>                &quot;Principal&quot;: {<br>                    &quot;Service&quot;: &quot;cloudfront.amazonaws.com&quot;<br>                },<br>                &quot;Action&quot;: &quot;s3:GetObject&quot;,<br>                &quot;Resource&quot;: &quot;arn:aws:s3:::florence-okoli/*&quot;,<br>                &quot;Condition&quot;: {<br>                    &quot;StringEquals&quot;: {<br>                      &quot;AWS:SourceArn&quot;: &quot;arn:aws:cloudfront::xxxxxxxxxxxx:distribution/E1FC6K30Z0Z15Y&quot;<br>                    }<br>                }<br>            }<br>        ]<br>      }</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*w2v70tghGoJ1Y6UgybsFNQ.png" /><figcaption>New Bucket Policy</figcaption></figure><ul><li>Save changes, proceed to your CloudFront page and copy your Distribution domain name. Paste it on your browser and add /index.html to it. Make sure to use your distribution domain name.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cFYuCb0LxPCHDgcGlTMklQ.png" /><figcaption>Copy distribution domain name</figcaption></figure><ul><li>Finally, the outcome of your page should look like this</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Sm0pnCV0Rw2TJea1VEkwRg.png" /><figcaption>Static website hosted on a private S3 bucket with public read access policy assigned</figcaption></figure><p>To avoid incurring charges on AWS, delete the resources you used in this guide, including S3 buckets and the CloudFront Distribution.</p><p><strong>Conclusion</strong></p><p>Congratulations on successfully hosting your static website on an S3 bucket using CloudFront! <br>By combining the benefits of storage durability with the global performance optimization of a content delivery network (CDN), you have created a fast and reliable website for users worldwide to enjoy. <br>By configuring your CloudFront with an Origin Access Identity (OAI), you have ensured that your S3 bucket remains private while delivering content swiftly and securely.</p><p>Let’s Connect:</p><p><a href="https://www.linkedin.com/in/florence-okoli/">LinkedIn</a><br>For collaboration and gigs: <a href="http://florenceokoli91@gmail.com/">Gmail</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=041814520bea" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to host a custom web page with Apache.]]></title>
            <link>https://medium.com/@FlorenceOkoli/how-to-host-a-custom-web-page-with-apache-54d922d800ba?source=rss-76bffe9db278------2</link>
            <guid isPermaLink="false">https://medium.com/p/54d922d800ba</guid>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[ubuntu]]></category>
            <category><![CDATA[cloud-engineer]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[apache]]></category>
            <dc:creator><![CDATA[Florence Okoli]]></dc:creator>
            <pubDate>Mon, 29 Apr 2024 15:25:14 GMT</pubDate>
            <atom:updated>2024-05-04T17:21:18.944Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ezVzCu6FKOE5f0R-INEIYw.png" /></figure><p>Deploying websites on cloud servers has become a standard practice due to its scalability, flexibility, and accessibility. This article delves into the process of hosting a custom web page on Amazon Web Services (AWS) using Apache as the web server and Ubuntu as the operating system.</p><p>Table of Contents<br>1. Introduction<br>2. Set up EC2 Instance<br>3. Install Apache web server<br>4. Deploy your custom web page<br>5. Conclusion</p><p><strong>1. Introduction</strong></p><p><em>The Apache web server is like a reliable backbone that confidently handles the traffic powering websites and applications worldwide. Its versatility goes beyond simply hosting web pages. It is a powerhouse of features designed to keep your online presence secure, performant, and easily customizable.<br>In other words, Apache is a widely used open-source web server software that serves web content over the internet with key functionalities such as HTTP protocol handling, content delivery, virtual hosting among others. Apache is also highly compatible with various operating systems (e.g., Linux, Unix, Windows)<br>This article provides a detailed guide on how to host your custom web page with Apache.</em></p><p><em>Let’s begin!</em></p><p><strong>2. Set up EC2 instance</strong><br><em>Log in to your AWS console. If you don’t have an account, sign up </em><a href="https://portal.aws.amazon.com/"><em>here</em></a><em> for a free tier account. On the search bar, type in EC2. On your EC2 dashboard, scroll down and proceed to launch an instance.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SA_-otgp7ciBlFNKGd3kDQ.png" /></figure><p><em>Choose a name for your EC2 instance.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*1t2ghFOyc_GI8W9S.png" /></figure><p><em>Proceed to select your AMI(Amazon Machine Image). For this article, we will select the Ubuntu AMI.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*NX5nQXGEXjX6JiGT.png" /></figure><p><em>Scroll down to generate your key pair. We need it to be able to connect to the terminal. If you already have a key pair, you can use it at this point.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QVjUdnoKvKfbvNKUFP23rQ.png" /></figure><p><em>Let’s create a key pair. Choose a name for your key pair, select the key pair type and proceed to create it.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*em9w6Ft1ALOROjiYzW5YvQ.png" /></figure><p><em>On the security group settings, set the SSH, HTTPS and HTTP to allow traffic from anywhere and also from the internet.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wMSslkl2ZBj5SHXCB3KHcw.png" /></figure><p><em>Leave every other setting on default and proceed to launch your instance.<br>Once the EC2 instance has been launched successfully, you will see 2/2 checks passed underneath the status check.</em></p><p><em>Next, click on the instance ID</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W56M8vF2LeiF-zbOs9s6CQ.png" /></figure><p><em>And connect via the EC2 Instance Connect. <br>See the images below</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8pGvaPf--YI8lVvs2DgBpg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oxJB5NGRC1Nca7i5-Ofjqw.png" /></figure><p><em>Take note of the public IP address.</em></p><p><strong>3. Install Apache Web Server</strong></p><p><em>Once you have connected and are in the terminal, run this command first to update your packages and dependencies.</em></p><pre>sudo apt update</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GZ_7L4i6ZPIUrObi2v5G1g.png" /></figure><p><em>Next, install apache2.</em></p><pre>sudo apt install apache2 -y</pre><p><em>The “-y” flag in the command above instructs the package manager to proceed with the installation without asking for confirmation. In other words, it bypasses the user’s input during installations.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9wQa3iGJEPu5a3TxEbhqCA.png" /></figure><p><em>Once the installation is done successfully, load your public IP address(remember the one I said you should take note of? That’s the one) in a new tab on your browser and you will see that it has the Apache default web page.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bg1NDxIyjEuec5v71bjnoA.png" /></figure><p><strong>4. Deploy your custom web page <br></strong>i.<em> Let’s install git since we will be cloning a Github repo for this article.</em></p><pre>sudo apt install git</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*PVBsj3vKqU7jQp3BSGe0dQ.png" /></figure><p>ii. <em>Create a directory. This directory will be the location where you clone your Github repo.</em></p><pre>mkdir Florence</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/681/1*Ql5EyJOSRsNBNpN8q36HHw.png" /></figure><p><em>Let’s change our directory to the one we just created.</em></p><pre>cd Florence/</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/532/1*lgVda6Oy1WU2RIb3EVHCdw.png" /></figure><p><em>iii. Let’s initialize git in the Florence directory.</em></p><pre>git init</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iVSBT_uSQTobGJ2DmWBZrQ.png" /></figure><p><em>Let’s clone our GitHub repository. This is the [</em><a href="https://github.com/WendyOkoli/AltSchool-Assignment-3)"><em>link</em></a><em>] to my GitHub repository. <br>See the image below on how to copy the link</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-P4u6YEcTUo-Jp2Uy3zzog.png" /></figure><p><em>To clone the GitHub repo</em></p><pre>git clone https://github.com/WendyOkoli/AltSchool-Assignment-3</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*z0y_Uaua-mp1b9XLxkS4gw.png" /></figure><p><em>Let’s change directory to the repo we cloned.</em></p><pre>cd AltSchool-Assignement-3</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/809/1*aL181Itdmysh5bpowAmPQA.png" /></figure><p>iv. <em>Let’s make another directory but this time the directory will store web server files like </em><strong><em>index.html, index.css</em></strong><em>, etc.<br>To do this, let’s run this command:</em></p><pre>sudo mkdir /var/www/FlorenceOkoli</pre><p><em>Whatever name you choose to call your directory, please note that the ‘/var/www/’should be in it for it to achieve the purpose of storing web server files.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fYQD_9YT1iGxSDvYFtFpLg.png" /></figure><p>v. Let’s copy the content of our ‘Florence’ directory into the one we just created.</p><pre>sudo mkdir cp -R ./* /var/www/FlorenceOkoli</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*X8xsG0lcb8jhh8QvC8ynOQ.png" /></figure><p>Here’s a breakdown of the command:</p><ul><li>sudo: This stands for &quot;superuser do&quot;. This command allows you to run other commands with administrative (root) privileges. It&#39;s necessary for commands that change system settings or modify system files, like this one.</li><li>cp: This is the command to copy files and directories.</li><li>-R: This option tells cp to copy directories recursively, meaning it will copy all the files and subdirectories within any directory you specify.</li><li>.*: This is a wildcard that matches all files and directories in the current directory.</li><li>/var/www/FlorenceOkoli: This is the destination directory where the files and directories will be copied.</li></ul><p>vi. <em>Let’s create a new file named </em><strong><em>FlorenceOkoli.conf</em></strong></p><pre>sudo touch /etc/apache2/sites-available/FlorenceOkoli.conf</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xjpoB8Oij26s9d7FlUBWZQ.png" /></figure><p>The command sudo touch /etc/apache2/sites-available/FlorenceOkoli.conf creates a new empty file named FlorenceOkoli.conf in the /etc/apache2/sites-available/ directory.</p><p><em>vii. Let’s create a copy of the default Apache site configuration file and name it FlorenceOkoli.conf.<br>To do this, let’s run the command below:</em></p><pre>sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/FlorenceOkoli.conf</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Kqtl_z4lpKAJKq42dafLcg.png" /></figure><p><em>viii. Now that the FlorenceOkoli.conf has been created, let’s edit it to add the configuration of our new site.</em></p><pre>sudo nano /etc/apache2/sites-available/FlorenceOkoli.conf</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MOaVO0SeKXw5_V6Cecdmag.png" /></figure><p><em>Your conf file should look exactly like the image below. Edit the DocumentRoot to be</em><strong><em> ‘/var/www/name of your conf file’.</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T9TSJjINM9zSllHWFGxPOw.png" /></figure><p><em>Save your file and exit.</em></p><p><em>ix. Enable the </em><strong><em>FlorenceOkoli.conf</em></strong><em> file and disable the 000-default.conf file<br>First, enable the </em><strong><em>FlorenceOkoli.conf </em></strong><em>file</em></p><pre>sudo a2ensite FlorenceOkoli.conf</pre><p><em>To disable the 000-default.conf file,</em></p><pre>sudo a2dissite 000-default.conf </pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2fivprejdWF0xdKLCQdKew.png" /></figure><p><em>When these commands are run, it enables the site in FlorenceOkoli.conf file and disables the site in 000-default.conf file.</em></p><p><em>To activate these new configurations in the conf file, run this command:</em></p><pre>sudo systemctl reload apache2</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*13kj7cpbtw0bquZQkglbmA.png" /></figure><p><em>Finally, on your web browser where you have the displayed Apache web page, reload it and you will see your custom web page displayed. <br>If you used my GitHub repo, the output of your web page should look like the image below:</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OZ6LWxU5bUKMB_bXuYWvgA.png" /></figure><p><em>As soon as you are done following this guide, please terminate your EC2 instances to avoid incurring costs from AWS. Let the images below guide you on how to terminate your instance.</em></p><p><em>Go back to your console where you have your instance ID. Expand the Instance state box and click on terminate instance.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*njB6CAtpesWiQFQbIbKItg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pB06dNtpbVym0PMf6X28kQ.png" /></figure><p><em>Once this is done, you will find a pop-up like the image below to show that your instance has been successfully terminated.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*96wSaha4133RqjYazLoDUQ.png" /></figure><p><strong>5. Conclusion</strong></p><p><em>Congratulations on successfully hosting your custom web page using Apache on AWS! In this guide, we covered the essential steps to set up an EC2 instance, install an Apache web server, and deploy a custom web page. By leveraging cloud infrastructure and open-source tools like Git and Apache, you’ve created a scalable and accessible platform for showcasing your web page.<br>Remember to terminate your EC2 instance to avoid unnecessary costs. Follow the provided steps to gracefully shut down your resources and manage your AWS environment efficiently.<br>I encourage you to explore further with Apache and AWS, experiment with different configurations, and customize your web hosting setup to meet your specific needs. Your feedback is valuable to me— please feel free to share your thoughts and experiences with this guide. I’m here to assist and improve based on your insights.</em></p><p><em>Thank you!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=54d922d800ba" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SMTP & mailutils: How to send your mails via the Linux terminal.]]></title>
            <link>https://medium.com/@FlorenceOkoli/smtp-mailutils-how-to-send-your-mails-via-the-linux-terminal-6d95803a1104?source=rss-76bffe9db278------2</link>
            <guid isPermaLink="false">https://medium.com/p/6d95803a1104</guid>
            <category><![CDATA[cloud-engineer]]></category>
            <category><![CDATA[smtp]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[linux]]></category>
            <dc:creator><![CDATA[Florence Okoli]]></dc:creator>
            <pubDate>Mon, 29 Apr 2024 06:32:30 GMT</pubDate>
            <atom:updated>2024-04-29T15:23:43.383Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OkubmkK1KbkJpD-lVNKO5A.png" /></figure><p><strong>Introduction</strong></p><p><em>Imagine being able to compose, attach files and send emails directly from your CLI using a few concise Linux commands. Well, the Linux terminal offers a streamlined and efficient alternative for sending emails using mailutils and the Simple Mail Transfer Protocol (SMTP).</em></p><p><em>What is SMTP?<br>SMTP stands for Simple Mail Transfer Protocol. It is a protocol used by email servers to send and receive email messages over the Internet. For instance, the email you send is transferred over the internet from one server to the other using SMTP.</em></p><p><em>What is `mailutils`?<br>The `mailutils` is a set of versatile utilities that manages emails directly from the CLI or Linux terminal using SMTP and other protocols. Some of the utilities include: <br>`mail`: This utility allows you to read and send emails interactively from the command line. <br>`movemail`: A utility that moves mail from one location to another.<br>`frm`: A utility to list the subject lines of email in a mailbox.<br>`readmsg`: A utility to read and print messages.</em></p><p><em>This article will provide a guide on how to send mail seamlessly via the Linux terminal using SMTP and mailutils.</em></p><p><em>Now, let’s get started.</em></p><p><strong>Prerequisite</strong><br><em>For this article, you will need:<br>i. A Google account for your app password generation<br>ii. A Linux terminal. I used the AWS console. You can sign up for a free 1yr tier account </em><a href="https://portal.aws.amazon.com/"><em>here</em></a></p><p><strong>Generate Google App Password</strong><br><em>On your Google account, locate the settings icon and click on manage your Google account. Take a look at the image attached below:</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/971/1*gkbon7noqrqc4qKt9PkNKQ.png" /></figure><p>Next, go to the security settings and turn on your 2-step verification.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V0JxZi5ZB-H9NaWD96q9ag.png" /></figure><p><em>Scroll down the 2-step verification page and click on the App passwords. Type a name for your app and a password will be generated automatically. Make sure to copy and save this password as we will need it later.<br>See the images attached below:</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qoVTe18BZIuDdb-5kGa-7Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_hV_WglRd9PqkfK3crxwIg.png" /></figure><p><strong>Launch EC2 Instance</strong><br><em>Once you log in on your AWS console, in the search bar, type EC2 and click on EC2. Click on instance and choose a name for your instance. See image below:</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NhXPPt3CsgL3HE0Y5KCEtQ.png" /></figure><p><em>Select your AMI. For this article, we will use the Ubuntu AMI. So, go ahead and select your Ubuntu AMI.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VZsur5LXBbu82Zfbsete9w.png" /></figure><p><em>Click on Launch instance.</em></p><p><em>Next, click on instance ID. See the image below</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_aPigtqg0zOBg5bhEYK0Ug.png" /></figure><p><em>Then connect to the terminal</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*c6KzvFeGtw247uJXIlrXAw.png" /></figure><p><strong>Configuration of SMTP</strong><br><em>i. On your terminal, run</em></p><pre>sudo apt update</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fW-UNRmWiaewWO2HQFl7EA.png" /></figure><p><em>This command is run before installing new software with apt install to ensure you get the latest versions of packages and all their dependencies.</em></p><p><em>ii. Install mailutils</em></p><pre>sudo apt install mailutils</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oD9T9ip-2HC3smL941R5qA.png" /></figure><p><em>Please note that while the installation is running, a postfix configuration will pop up, select the internet site option using your arrow keys and then click ok to finish up with the installation.</em></p><p><em>iii. Install SSMTP</em></p><p><em>Why install SSMTP?</em></p><p><em>SSMTP is a simple mail transfer agent (MTA) used to send emails from a Linux system. In other words, it forwards emails to another SMTP server for delivery.</em></p><p><em>To install SSMTP</em></p><pre>sudo apt install ssmtp</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mRRS-MQUq7vm1lUyTOLjFQ.png" /></figure><p><em>iv. Configuration of SSMTP file<br>To configure the ssmtp file run this command below</em></p><pre>sudo nano /etc/ssmtp/ssmtp.conf</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/774/1*s-jAyQdeFzDSPONWevKOBw.png" /></figure><p><em>With the arrow keys, edit your ssmtp configuration file to look exactly like the images attached below</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Mp5jVxDBIqkWqbBOKlhD6w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/794/1*S7ytoCn28oSmXSVJhbSE8A.png" /></figure><p><em>In the configuration file,<br>Your root should be your email address. <br>Your AuthUser should be your email address. <br>Your AuthPass should be the 16-character string generated from the app password in your Google account. When typing it in, remember not to include the spaces.<br>The rewriteDomain should be gmail.com, but if you are not using Gmail’s SMTP server to send your email, replace gmail.com with your domain.<br>Lastly, uncomment the FromLineOverride as shown in the image above. <br>Save your file.</em></p><p><strong>Write and send your mail</strong></p><p><em>To send your mail, run the command below</em></p><pre>echo &quot;I&#39;m a Cloud Engineer&quot; | mail -s &quot;Hello there!&quot; your email address</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h5u80OPVkYmVJnYIhPyopw.png" /></figure><p><em>Once this is done, check your Gmail to see the mail.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hpZsvMr9gy6dCSrTpZCr8A.png" /></figure><p><em>This is how to use SMTP and mailutils to send emails from the Linux terminal.</em></p><p><em>As soon as you are done following this guide, please terminate your EC2 instances to avoid incurring costs from AWS. Let the images below guide you on how to terminate your instance.</em></p><p><em>Go back to your console where you have your instance ID. Expand the Instance state box and click on terminate instance. Follow the prompt thereafter to terminate your instance.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1ZHDh40yOcLg9mYGegj-MQ.png" /></figure><p><em>Once this is done, you will find a pop-up like the image image below</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Iz2j2MUCh-eDNcG3H-sPdw.png" /></figure><p><strong>Conclusion</strong></p><p><em>Congratulations on successfully setting up your Linux terminal to send emails using SMTP and mailutils! You’ve learned how to configure your environment step by step, from generating a Google App password to launching an EC2 instance and configuring SSMTP.</em></p><p><em>Sending emails from the command line can be a powerful and efficient way to handle communications, especially in automated scripts or remote environments. By following this guide, you’ve gained valuable insights into how SMTP works and how to leverage it within your Linux terminal.</em></p><p><em>Your feedback is important to me! If you encounter any issues or have suggestions for improvement, please don’t hesitate to share your thoughts. Your insights can help refine this guide and make it even more helpful for others.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6d95803a1104" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introduction To Linux: Getting Started with Basic Linux Commands]]></title>
            <link>https://medium.com/@FlorenceOkoli/introduction-to-linux-getting-started-with-basic-linux-commands-2730cc90b1ed?source=rss-76bffe9db278------2</link>
            <guid isPermaLink="false">https://medium.com/p/2730cc90b1ed</guid>
            <dc:creator><![CDATA[Florence Okoli]]></dc:creator>
            <pubDate>Sun, 24 Mar 2024 18:13:08 GMT</pubDate>
            <atom:updated>2024-03-24T19:15:30.875Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3fmDQWhKCBfuMfUC6mZr9Q.jpeg" /></figure><p>What is Linux???</p><p>Linux is like the boss of your computer, managing everything and making sure it runs smoothly. It’s the language your computer speaks to understand what you want it to do. It’s a behind-the-scenes hero that helps your computer be awesome!</p><p>Let’s get more technical now.</p><p>Like any other operating system, Linux manages your computer&#39;s hardware and software resources while allowing programs to interact with the computer&#39;s hardware. It is similar to Windows or macOS and it is <strong>free and open-source</strong>, making it accessible to everyone. <strong>Linus Torvalds</strong> developed the Linux operating system<strong><em>.</em></strong></p><p>As a Cloud DevOps Engineer or a Systems Administrator, mastering Linux commands will help you automate tasks, manage your cloud infrastructure, access remote servers, scale cloud services, optimize workflows, and ensure the reliability and security of your applications and infrastructure deployments.</p><p>There is so much you can do with Linux commands. But before we get started here are some of the basic ones and what they do:<br><strong><em>pwd</em></strong><em>: prints your current working directory<br></em><strong><em>ls: </em></strong><em>lists the content of your working directory<br></em><strong><em>cd</em></strong><em>: changes directory. It allows you to navigate between directory<br></em><strong><em>touch</em></strong><em>: creates a new empty file<br></em><strong><em>mkdir: </em></strong><em>makes a new directory</em></p><p>Now, let’s take this a notch higher by practising more. This is where it gets interesting and I would like you to practice along with me. Ready? Let’s go!</p><p>1. Create a login user from your root user. You can try this out on your Gitbash terminal or Vagrant virtual machine.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LTt822zDMAYK9JOeoUrG4Q.png" /></figure><p><strong><em>The sudo </em></strong><em>command stands for </em><strong><em>“superuser do” </em></strong><em>and it allows you</em><strong><em> </em></strong><em>to execute commands with the privileges of another user, typically the superuser or root.</em><strong><em><br></em></strong><em>The </em><strong><em>adduser </em></strong><em>command allows you to create a login user with a password.</em></p><p><em>After creating your user, let’s give the user </em><strong><em>wendy </em></strong><em>admin privileges that will enable the user to create more users, and groups and also edit configuration settings. Check the image below on how to do it.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/462/1*M74Rdeanz9CUe2jDHp8JEg.png" /></figure><p><em>The </em><strong><em>sudo visudo</em></strong><em> command will take you to the configurations page where you get to make your user an admin. On the configuration page, use your arrow keys to scroll down to where you can see</em><strong><em> “User Privilege Specification”. </em></strong><em>Now under root, type the name of your user and copy all settings as root.<br>To exit the configuration page:<br>i. “CTRL + O” to save the changes<br>ii. press your “enter” button to confirm the changes <br>iii. “CTRL + X” takes you out of the page and back to your terminal</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ltgbDdWZ1-TNrUt3T0SLUA.png" /></figure><p>2. Switch user from vagrant (root user) to the login user you created</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/456/1*HHzLIwi70P2u3tVkjqadKA.png" /></figure><p><em>The </em><strong><em>su </em></strong><em>command allows you to temporarily switch your user identity to that of another user without logging out.</em></p><p>3. Create sub-directories and name them <strong>code, misc, personal, &amp; tests.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*5n1Ht2krptmpJJS3U-w46A.png" /></figure><p><em>Before we go further, let me quickly explain what a Home Directory (</em><em>cd /home) and Root Directory (</em><em>cd /). <br>The home directory (</em><em>cd /home) is where each user on the system has their directory for storing files and settings while the root directory (</em><em>cd /) is the top-level directory in the Linux file system hierarchy containing system files and directories.</em></p><p><em>Let’s continue.</em></p><p>4. Change the directory to the directory using absolute pathname.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/549/1*BCHLH860zJa20aQ9aen5Cg.png" /></figure><p><em>Let me explain what an absolute pathname means.<br>An absolute pathname is the complete and exact location of a file or directory in a computer’s file system. It specifies the full path from the root directory to the desired file or directory on your computer.<br>Put simply, an absolute pathname is like giving the full address of a place, starting from the country, state, city, street, and finally the house number.</em></p><p>5. Change the directory to the <strong>tests </strong>directory using the relative pathname.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/481/1*UynZ0mOPluMTMCeOnEHv-A.png" /></figure><p><em>The relative pathname specifies the path to a file or directory based on your current location in the file system, rather than starting from the root directory. More simply, relative pathname helps you navigate your computer’s file system by providing directions based on your current location, making it easier to find what you’re looking for without needing to know the whole path.</em></p><p>6. Use<strong> echo </strong>command to create a file named fileA with text content ‘Hello A’ in the misc directory. Please note that everything in each step should be done in the home directory of the user you created. In my case, my user is <strong>wendy.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/762/1*mIaq9KJgXzbp8hrixGvPpg.png" /></figure><p><em>The </em><strong><em>echo </em></strong><em>command is used to output/print text or variables into the terminal or a file. It can also be used to redirect its output to a file using the redirection operator (&gt;).<br>Because we are creating and using all commands in the home directory of the user we created, we will have to echo into </em><strong><em>misc/fileA</em></strong><em> following the specified path of misc.<br> The</em><strong><em> ls -al </em></strong><em>command checks for all directories, files and everything else within that directory.<br>In Linux, a folder can contain subfolders, and a folder is equivalent to a directory.</em></p><p>7. Create an empty file named fileB in the misc directory. The fileB should have some dummy content.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/1*zbG5yYy0uygHFngRUrapcg.png" /></figure><p><em>The</em><strong><em> touch misc/fileB</em></strong><em> command creates a new file in the misc directory<br>The</em><strong><em> echo</em></strong><em> command fills the fileB with some dummy content<br>The</em><strong><em> cat</em></strong><em> command displays the content of fileB</em></p><p>8. Copy contents of fileA into fileC</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/599/1*D6ePX_JqRhn2WbsWl6Gh5A.png" /></figure><p><em>The </em><strong><em>cp</em></strong><em> commands stand for copy. It is used to copy content between files. The cp command also create files as seen above. To be sure we copied correctly, we have to </em><strong><em>cat </em></strong><em>the contents of fileC.</em></p><p>9. Move contents of fileB into fileD</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/714/1*nbvuJ76xBGrX1tbfOokKhg.png" /></figure><p><em>The </em><strong><em>mv</em></strong><em> command can be used to move the contents of a file or directory to another. It is also used to rename files or directories. When the content of a file is moved using the mv command, the files ceases to exist and its content is moved to the next file. You can check that by using the </em><strong>cat</strong><em> command to display the contents of fileD.</em></p><p>10. Create a tar archive called misc.tar for the contents of the misc directory.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/520/1*P_rNTShTJXSvLvU6QXsR4Q.png" /></figure><ul><li><em>tar: Invokes the tar command, used for creating or extracting archive files.</em></li><li><em>cvf: Specifies the operation to create a new archive file.</em></li><li><em>misc.tar: Specifies the name of the archive file to be created. In this case, it will be named &quot;misc.tar&quot;.</em></li><li><em>misc: Specifies the directory whose contents will be archived. In this case, it&#39;s the &quot;misc&quot; directory.<br>So, when you run the command as seen in the image above, it will compress all the files and directories within the “misc” directory into a single file named “misc.tar”.</em></li></ul><p>10. Compress the tar archive to create a misc.tar.gz file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/868/1*BG5ps5VO2zfZjczOLuPrGw.png" /></figure><p><em>The</em><strong><em> gzip misc.tar </em></strong><em>command compresses the “misc.tar” file into a smaller file size. When this command is run, the compressed file will have a “.gz” extension appended to its name (e.g., “misc.tar.gz”), indicating that it has been compressed using gzip. Check the image above for more context.</em></p><p>11. Create a user and force the user to change his/her password upon login.</p><p><em>First, we create a user with </em><strong><em>sudo useradd Vicky </em></strong><em>command. I will call my user </em><strong><em>Vicky </em></strong><em>and then we force this user to change their password upon login using the </em><strong><em>sudo chage -d 0 Vicky</em></strong><em> command.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hFnkxysMu7GI6jeMPC5GTA.png" /></figure><p><em>The </em><strong><em>sudo chage -d 0</em></strong><em> is a command used to force a user to change their password upon the next login by setting the date of the last password change to the current date.<br>The </em><strong><em>chage is </em></strong><em>used to change user password expiry information while the </em><strong><em>-d 0</em></strong><em> specifies the date of the last password change. Setting it to 0 means setting the date of the last password change to the current date.</em></p><p><em>This command is essential for Cloud DevOps Engineers or System Administrators in maintaining a secure and compliant environment, protecting sensitive data, and mitigating the risks associated with unauthorized access.</em></p><p>12. Lock a users password.</p><p><em>To lock a users password, we use the </em><strong><em>sudo passwd -l Vicky. </em></strong><em>When this is done, it will prevent the user Vicky from logging in. This command will effectively disable the user Vicky from authentication or accessing the system.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/709/1*msUcW9ETluZuXOl7chbkxA.png" /></figure><p><em>The </em><strong><em>sudo</em></strong><em> command as I explained before is used to execute other commands with superuser (or root) privileges. It allows a permitted user to execute a command as the superuser or another user.<br>The</em><strong><em> passwd </em></strong><em>command is typically used to change a user’s password. However, when it is used with the</em><strong><em> -l </em></strong><em>option, it locks the specified user account.</em></p><p>13. Create a user with no login shell.<br><em>Let’s create another user but this time, we are using the “nologin” shell to prevent the user from logging into the system interactively via SSH, terminal or any other method.<br>To do this, we use the </em><strong><em>sudo useradd -s /sbin/nologin Florence</em></strong><em> command. Let’s see how that looks on the terminal.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TtTho3F5C8cFlmLjuGZcIw.png" /></figure><p><em>To be sure we created the user Florence with nologin shell, we will use the </em><strong><em>cat /etc/passwd | grep Florence</em></strong><em> to display the contents of the user Florence. The “|” is a pipe symbol used to redirect the output of a command into another command which is the </em><strong><em>grep.</em></strong></p><p>14. Disable password based authentication and root login for SSH.<br><em>To do this, we start by using the </em><strong><em>sudo nano /etc/ssh/sshd_config</em></strong><em> command to allow the user to edit the SSH server configuration file using </em><strong><em>nano </em></strong><em>as our text editor. <br>Open the configuration file, use your arrow keys locate the ‘Password Authentication’ and set it to no. Automatically, it is set to no.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/930/1*JNWk3XtkKimQTvhFuzibZQ.png" /></figure><p>To disable root login for SSH, use the same process as above. Use the ‘sudo nano /etc/ssh/sshd_config’ command and scroll down to permit root login and set it to no.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*X0cki7DBQd-1Ihxm6pcdVg.png" /></figure><h4><strong>Conclusion:</strong></h4><p><em>Whether you’re a Cloud DevOps Engineer or an enthusiast, Linux commands offer a pathway to automation, efficiency, and enhanced technical skills.<br>Linux isn’t merely an operating system — it’s a powerful tool that empowers users to control computers precisely and effectively. As you explore the command line, keep in mind the vast range of functions and possibilities it provides. Don’t be afraid to experiment, keep learning, and delve deeper into the boundless opportunities Linux presents. I am excited to see what you achieve using the Linux commands!</em></p><p><em>Let’s connect:<br></em><a href="https://www.linkedin.com/in/florence-okoli/"><em>LinkedIn.</em></a><em><br></em><a href="https://github.com/WendyOkoli"><em>GitHub</em></a><em><br>I’m open to collaborations —</em><a href="http://florenceokoli91@gmail.com/"><em> Gmail</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2730cc90b1ed" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>