<?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 Stephen Somuah on Medium]]></title>
        <description><![CDATA[Stories by Stephen Somuah on Medium]]></description>
        <link>https://medium.com/@ssomuahk?source=rss-2b7be465b232------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*ByEZesmoZ6p7I8ChaY7CSQ@2x.jpeg</url>
            <title>Stories by Stephen Somuah on Medium</title>
            <link>https://medium.com/@ssomuahk?source=rss-2b7be465b232------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 02:29:02 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ssomuahk/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[Cutting Silent AWS Costs: Automating S3 Backup Cleanup with Terraform]]></title>
            <link>https://towardsaws.com/cutting-silent-aws-costs-automating-s3-backup-cleanup-with-terraform-541ed79c1ccd?source=rss-2b7be465b232------2</link>
            <guid isPermaLink="false">https://medium.com/p/541ed79c1ccd</guid>
            <category><![CDATA[terraform]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[aws-s3]]></category>
            <category><![CDATA[cloud-cost-management]]></category>
            <dc:creator><![CDATA[Stephen Somuah]]></dc:creator>
            <pubDate>Sat, 17 Jan 2026 13:30:11 GMT</pubDate>
            <atom:updated>2026-01-20T09:16:31.960Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jLfl1AhQHpOEXOvjRxt_gw.png" /><figcaption>S3 Cleanup Via Lifecycle Policis</figcaption></figure><p>Continuing from my <a href="http://medium.com/@ssomuahk/deploying-openemr-on-aws-using-terraform-and-docker-a-cost-optimized-architecture-for-smes-9ed9fc8dd495?postPublishedType=repub">previous article</a> of how I deployed a low cost OpenEMR for a small dental clinic, one practical way to reduce cloud costs is by optimising how data is stored over time. You may have a healthy budget, but it is never infinite. Unused or forgotten resources quietly accumulate costs, and over time those costs add up.</p><p>One common example is backup data stored in Amazon S3. AWS charges per gigabyte of storage, so if backups are retained indefinitely, you end up paying for data that no longer provides value.</p><p>In this article, I walk through how I implemented automated S3 housekeeping using lifecycle policies defined in Terraform, ensuring backups are retained for only 30 days and deleted automatically thereafter.</p><h3>Why S3 Lifecycle Policies Matter</h3><p>When we talk about optimisation, it can mean:</p><ul><li>downsizing infrastructure when it’s no longer needed, or</li><li>cleaning up data that has outlived its usefulness.</li></ul><p>Backups are a classic candidate for this. They are critical, but only for a defined retention period. Beyond that, they simply consume storage.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4qd302vP3CdjKyQeKZBEkQ.png" /><figcaption>261 Objects in S3 bucket</figcaption></figure><p>In my case, I had an S3 bucket storing database backups for the <a href="http://medium.com/@ssomuahk/deploying-openemr-on-aws-using-terraform-and-docker-a-cost-optimized-architecture-for-smes-9ed9fc8dd495?postPublishedType=repub">OpenEMR deployment</a> . Over time, the bucket had grown to roughly 261 objects, consuming close to 15 GB of storage. Since a new backup is created daily, the object count naturally increases unless old backups are removed.</p><p>The goal was simple:</p><blockquote>Keep backups for 30 days and automatically delete anything older.</blockquote><p>This can be done manually via the AWS console, but for reproducibility, documentation, and consistency, I chose to implement everything using Terraform.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tBjHvq3ghbAWBWzo50F6Ow.png" /><figcaption>208 objects and up to 10GB of storage used</figcaption></figure><h3>Creating the S3 Bucket with Terraform</h3><p>Below is the Terraform configuration used to create the S3 bucket for database backups:</p><pre>resource &quot;aws_s3_bucket&quot; &quot;db_backup&quot; {<br>  bucket = &quot;openemr-db-backup-${var.environment}-${random_string.suffix.result}&quot;<br><br>  tags = {<br>    Name        = &quot;openemr-db-backup-${var.environment}&quot;<br>    Environment = var.environment<br>  }<br>}</pre><p>A random suffix is added to ensure global uniqueness, since S3 bucket names must be unique across AWS.</p><h3>Enabling Versioning</h3><p>Next, versioning is enabled on the bucket:</p><pre>resource &quot;aws_s3_bucket_versioning&quot; &quot;db_backup_versioning&quot; {<br>  bucket = aws_s3_bucket.db_backup.id<br><br>  versioning_configuration {<br>    status = &quot;Enabled&quot;<br>  }<br>}</pre><p>Versioning protects against accidental deletions or overwrites by keeping previous versions of objects.</p><p><strong>Important clarification:</strong><br><em>In this setup, each backup is uploaded once using a unique object key (for example, backup-2026–01–10.sql). Because objects are never overwritten, they never become noncurrent. As a result, versioning acts mainly as a safety net rather than an actively used feature in this particular workflow.</em></p><h3>Bucket Access Policy</h3><p>A bucket policy is used to restrict uploads to a specific IAM user: in this case, a user named terraform.</p><pre>resource &quot;aws_s3_bucket_policy&quot; &quot;db_backup_policy&quot; {<br>  bucket = aws_s3_bucket.db_backup.id<br><br>  policy = jsonencode({<br>    Version = &quot;2012-10-17&quot;,<br>    Statement = [<br>      {<br>        Effect = &quot;Allow&quot;,<br>        Principal = {<br>          AWS = &quot;arn:aws:iam::123456789:user/terraform&quot;<br>        },<br>        Action   = &quot;s3:PutObject&quot;,<br>        Resource = &quot;${aws_s3_bucket.db_backup.arn}/*&quot;<br>      }<br>    ]<br>  })<br>}</pre><p>This limits permissions to only what is required for backup uploads, following the principle of least privilege.</p><h3>Adding the Lifecycle Policy</h3><p>The final and most important piece is the lifecycle configuration. This policy ensures:</p><ul><li>current objects expire after 30 days</li><li>noncurrent versions (if any ever exist) are also cleaned up after 30 days</li></ul><pre>resource &quot;aws_s3_bucket_lifecycle_configuration&quot; &quot;openemr_lfc&quot; {<br>  bucket = aws_s3_bucket.db_backup.id<br><br>  rule {<br>    id     = &quot;backup&quot;<br>    status = &quot;Enabled&quot;<br><br>    expiration {<br>      days                         = 30<br>      expired_object_delete_marker = true<br>    }<br><br>    noncurrent_version_expiration {<br>      noncurrent_days = 30<br>    }<br>  }<br>}</pre><p>How This Works in Practice:</p><ul><li>Day 0: A backup object is uploaded.</li><li>Day 30: The object expires.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LJnSSBjZDbt4HkZ7KeLrTg.png" /><figcaption>Attached is how this looks like in the console.</figcaption></figure><h4>When Does the Cleanup Happen?</h4><p>Although Terraform applies the configuration immediately, S3 lifecycle rules are not enforced instantly. AWS states that lifecycle actions can take 24 to 72 hours to run.</p><p>For this particular project, the cleanup took effect within 24 hours. At any given time, only 30–31 objects remain in the bucket, which aligns perfectly with the daily backup schedule and the 30-day retention policy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mQnX0tsux8e7jM3MVVwOYg.png" /><figcaption>Cleaned up bucket</figcaption></figure><h3>Key Takeaways</h3><p><strong>Terraform makes cost control enforceable, not optional.</strong><br>When retention rules live in code, they survive team changes, console clicks, and “<em>we’ll clean it up later</em>” excuses. This turns cost optimisation from a good intention into a guaranteed outcome.</p><p><strong>S3 versioning is not a cost strategy by itself.</strong><br>Versioning only protects you if objects are overwritten. If your backups are immutable and uniquely named- as they should be — versioning becomes a safety net, not a cleanup mechanism. Without lifecycle rules, storage growth is inevitable.</p><p><strong>Lifecycle policies work quietly — but relentlessly.</strong><br>Once applied, there are no dashboards to babysit and no cron jobs to maintain. S3 enforces the policy in the background, removing old data automatically and keeping the bucket aligned with your retention window.</p><p><strong>If you are not defining retention, you are accepting waste.</strong><br>Backups are critical, but only for as long as they are recoverable and relevant. Anything beyond that is just silent spend accumulating month after montFinally</p><h3>Finally</h3><p>If you are storing backups in S3 and have never explicitly defined how long they should live, you are almost certainly paying for data you no longer need. The costs may look small today, but they compound quietly over time.</p><p>Lifecycle policies are one of the simplest, lowest-risk optimisations you can make in AWS . When defined in Terraform, they become permanent guardrails rather than one-off fixes.</p><p>Cost optimisation is rarely about dramatic architecture changes. More often, it’s about closing the small leaks you stopped noticing. S3 lifecycle rules are one of those leaks, and now you have no excuse to ignore them.</p><p>As mentioned in my previous article, there are more opportunities for to make the infrastructure for the OpenEMR more cost effective and security compliant. I’d be happy to share as I proceed to build a robust system.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=541ed79c1ccd" width="1" height="1" alt=""><hr><p><a href="https://towardsaws.com/cutting-silent-aws-costs-automating-s3-backup-cleanup-with-terraform-541ed79c1ccd">Cutting Silent AWS Costs: Automating S3 Backup Cleanup with Terraform</a> was originally published in <a href="https://towardsaws.com/">Towards AWS</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deploying OpenEMR on AWS Using Terraform and Docker: A Cost-Optimized Architecture for SMEs]]></title>
            <link>https://towardsaws.com/deploying-openemr-on-aws-using-terraform-and-docker-a-cost-optimized-architecture-for-smes-9ed9fc8dd495?source=rss-2b7be465b232------2</link>
            <guid isPermaLink="false">https://medium.com/p/9ed9fc8dd495</guid>
            <category><![CDATA[healthcare-technology]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[infrastructure-as-code]]></category>
            <category><![CDATA[aws-architecture]]></category>
            <category><![CDATA[cost-optimization]]></category>
            <dc:creator><![CDATA[Stephen Somuah]]></dc:creator>
            <pubDate>Mon, 17 Nov 2025 10:40:58 GMT</pubDate>
            <atom:updated>2025-11-18T01:40:19.858Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="OpenEMR on AWS" src="https://cdn-images-1.medium.com/max/252/1*a-_uF9UKrI8c24y-7higLg.jpeg" /></figure><p>I have a cousin who is a dentist, and after years of working in different large hospitals, she finally decided it was time to start her own clinic. Like most new entrepreneurs, she was full of vision- but also mindful of costs. Naturally, when it came to setting up her clinic’s IT systems, she called me, her “IT cousin”, same way I would refer to her as my “dentist cousin”.</p><p>You know, in my previous job at a pensions company, I created the IT department from nothing, and before I left, the company was offering the same services much bigger competitors were offering — and sometimes even better — at a much lower cost. So naturally, this was quite an easy feat for me. However, her biggest concern was an Electronic Medical Records (EMR) system to manage patient records, appointments, and billing. For someone like me who values open-source solutions for their flexibility, transparency, and freedom from vendor lock-in, the choice was obvious: OpenEMR.</p><p>But before touching any code or software, I had to think architecture.</p><p>This wasn’t a large hospital with multiple departments — it was a small dental clinic with one dentist at a specific time, a receptionist, and up to 20 patients a day. She also does door-to-door services, so secure cloud access was key. The goal wasn’t to build something complex or “enterprise-grade,” but something reliable, secure, and affordable — something that wouldn’t make her regret the decision later.</p><p>When you run a clinic, your biggest expenses are staff salaries, dental supplies, equipment maintenance, and electricity — not IT infrastructure. So, the system had to be functional but invisible in terms of cost.</p><p>I explored various options — from separating the database and application to using managed services like RDS — but each added unnecessary complexity and monthly costs. I’m also a full-time employee elsewhere and don’t want a side project turning into an on-call situation. A multi-tier setup might look impressive on paper, but for a clinic with one doctor, it offered no real-world benefit.</p><p>After lot of analysis and consideration of tradeoffs, I chose a <strong>simpler, smarter approach</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/954/1*JGq8TR6wl2yGGeb8NXugNA.jpeg" /></figure><h3>Architecture Overview</h3><p>Before writing a single line of code, I mapped out what the clinic actually needed , not what looks fancy in an AWS diagram. The whole point was to build something lean, predictable, and cheap to operate, without compromising reliability or security. Here’s the exact setup I deployed and why each piece exists:</p><p><strong>Terraform:</strong> Terraform provisions everything from VPC, security groups, EC2, IAM roles, S3 bucket, and more. This gives me repeatable, consistent deployments with zero guesswork. No clicking around the console, no “I swear this worked last week,” and no surprises during updates. Everything is in Git, version-controlled, and rebuildable within minutes. For a clinic where I’m the only technical person, this level of automation is non-negotiable. To be honest, the cloudflare was done manually though it’s possible to be done with Terraform</p><p><strong>Cloudflare (DNS &amp; Proxy):</strong> Cloudflare (DNS &amp; Proxy): Cloudflare gives me a friendly subdomain, automatic TLS, basic DDoS protection, and, most importantly, origin IP shielding. I don’t want the EC2 instance exposed directly to the world. Cloudflare sits in front, handles certificate renewal, filters junk traffic, and improves performance — all essentially free. In this first version, TLS terminates at Cloudflare’s edge and traffic from Cloudflare to the EC2 instance is plain HTTP on port 80. For this clinic, that trade-off is acceptable, but it can be extended later with NGINX or origin certificates for full end-to-end TLS. For SMEs, this is the easiest way to achieve “enterprise-looking” security without enterprise bills.</p><p><strong>EC2 Instance:</strong> One EC2 instance runs both OpenEMR and MariaDB using Docker Compose.<br>Why? Because a small clinic with one dentist doesn’t need a distributed system. A multi-tier setup with RDS, load balancers, and autoscaling only increases cost and operational burden. Running everything on a single, well-configured instance keeps things simple, stable, and easy to maintain.</p><p><strong>Secondary EBS Volume (gp3)</strong>: A dedicated gp3 volume holds all persistent data- MariaDB, sites/default, and logs.<br>This separation ensures that even if the EC2 instance is replaced or the root volume breaks, the clinic’s data remains intact. gp3 gives great performance for the price, and restores or migrations are painless.</p><p><strong>S3 Bucket: </strong>A nightly cron job sends MariaDB dumps and site configuration backups to S3.<br>This is the insurance policy. If something catastrophic happens — corruption, accidental deletion, server failure — the clinic can be recovered from S3 with minimal downtime. Everything is automated; nobody is remembering to back up anything manually. Only thing I need to do is to regularly test DB restorations as part of Disaster recovery.</p><p><strong>CloudWatch Logs: </strong>CloudWatch Logs: All container and key system logs are shipped to CloudWatch. The clinic doesn’t need long-term log archives; what we need is quick visibility when something breaks. Log groups have short retention configured in Terraform, so logs are available long enough to troubleshoot without quietly burning money. CloudWatch gives a simple, serverless way to access logs without running anything complicated. Enough observability to fix problems — nothing more.</p><p><strong>SSM Agent:</strong> SSM Agent: The EC2 instance runs the AWS SSM Agent for admin access through Session Manager. SSH isn’t used at all — the security group does not expose port 22, and I don’t bother with SSH keys or jump hosts. Everything runs through the AWS console or CLI over encrypted channels, with proper IAM controls and auditing. For healthcare data and for my own sanity, removing SSH as an access path is a massive win.</p><p><strong>No EFS, No ALB, No RDS: </strong>These services are great , but they solve problems this clinic simply does not have.<br>Adding them would only increase the monthly bill without improving reliability or patient experience. The goal was to avoid building a “mini-enterprise architecture” for one doctor and a receptionist.<br>This stack gives exactly what’s needed and nothing more.</p><p><strong>Result:</strong> a single EC2 host fronted by <strong>Cloudflare</strong>, with persistent <strong>EBS</strong>, daily <strong>S3</strong> backups, and <strong>CloudWatch</strong> observability, all brought up by Terraform in <strong>under 10 minutes</strong>, and easy to rebuild from code.</p><h3>Terraform Snippet — EBS, EC2, and S3</h3><p>I would share with you some snippets of the code here</p><blockquote>I wish I could share the the entire repository here, but not today, because what I have is tied directy to the project and is private. A public repo will be prepared and attached here soon.</blockquote><p>Below is a snapshot of the repository. I named it openemr-mono, because I had tested a microservice architecture and concluded it was quite a waste in many dimensions for this little project. Mono hence means a single Instance. Take note of the project structure. Sort of the standard for multi environment terraform.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KPHmBRPpHTkH6YoOUqgvcA.png" /></figure><h3>Root Module</h3><p>With the structure above, each environment has it’s root module and makes use of modules accessible to each environment. This was done with five (sub modules)- VPC, Security Groups, EC2,S3 and IAM.</p><pre>module &quot;vpc&quot; {<br>  source               = &quot;../../modules/vpc&quot;<br>  vpc_cidr_block       = var.vpc_cidr_block<br>  environment          = var.environment<br>  vpc_name             = var.vpc_name<br>  public_subnet_cidr   = var.public_subnet_cidr<br>  public_subnet_name   = var.public_subnet_name<br>  enable_dns_hostnames = var.enable_dns_hostnames<br>  enable_dns_support   = var.enable_dns_support<br>  region               = var.region<br>}<br><br>module &quot;security_groups&quot; {<br>  source              = &quot;../../modules/security_groups&quot;<br>  environment         = var.environment<br>  vpc_id              = module.vpc.vpc_id<br>  allowed_cidr_blocks = var.allowed_cidr_blocks<br>}<br><br><br>module &quot;ec2&quot; {<br>  source = &quot;../../modules/ec2&quot;<br><br>  openemr_ami              = var.openemr_ami<br>  instance_type            = var.openemr_instance_type<br>  subnet_id                = module.vpc.public_subnet_id<br>  security_group_ids       = [module.security_groups.openemr_sg_id]<br>  iam_instance_profile     = module.iam.openemr_instance_profile<br>  availability_zone        = var.availability_zone<br>  environment              = var.environment<br>  user_data_script_path    = var.user_data_script_path<br>  docker_compose_file_path = var.docker_compose_file_path<br>  s3_bucket_name           = module.s3.s3_bucket_name<br>  aws_region               = var.region<br><br><br>}<br><br>module &quot;s3&quot; {<br>  source      = &quot;../../modules/s3&quot;<br>  environment = var.environment<br><br>}<br><br>module &quot;iam&quot; {<br>  source      = &quot;../../modules/iam&quot;<br>  environment = var.environment<br>  bucket_name = module.s3.s3_bucket_name<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gMXm3z1AHdYAylxmRv9gSw.png" /><figcaption>Running EC2 instance</figcaption></figure><h3>User Data Script</h3><p>One of the things I’ve learned working with SMEs is that if your deployment requires manual steps, you’ve already failed. A clinic should never depend on someone remembering how to “fix” a setup at 9 p.m. on a Sunday. So I built the entire OpenEMR stack to bootstrap itself from a single EC2 User Data script. The moment the instance launches, it attaches the EBS volume, formats and mounts it, installs Docker, pulls OpenEMR and MariaDB, initializes the sites/default directory correctly, configures backups to S3, enables swap, wires up logging and observability, and injects database/OpenEMR credentials from Terraform variables into a local .env file consumed by Docker Compose. In a more heavily regulated environment I’d push those credentials into Parameter Store or Secrets Manager, but for this single-clinic deployment this is a pragmatic middle ground. Everything is automated from the first boot. No SSH, no manual configuration, no surprises. This script is what turns Terraform from “infrastructure as code” into a self-healing, self-configuring appliance for the clinic.</p><pre>#!/bin/bash<br>set -e<br><br>LOG_FILE=&quot;/var/log/openemr_setup.log&quot;<br>exec &gt; &gt;(tee -a &quot;$LOG_FILE&quot;) 2&gt;&amp;1<br>echo &quot;========== Starting OpenEMR setup at $(date) ==========&quot;<br><br>VOLUME_DEVICE=&quot;${volume_device}&quot;<br>mount_point=&quot;${mount_point}&quot;<br>s3_bucket_name=&quot;${s3_bucket_name}&quot;<br>DOCKER_COMPOSE_VERSION=&quot;${DOCKER_COMPOSE_VERSION}&quot;<br>region=&quot;${region}&quot;<br>environment=&quot;${environment}&quot;<br><br># Credentials supplied via Terraform/templatefile<br>MYSQL_ROOT_PASS=&quot;${mysql_root_pass}&quot;<br>MYSQL_USER=&quot;${mysql_user}&quot;<br>MYSQL_PASS=&quot;${mysql_pass}&quot;<br>OE_USER=&quot;${oe_user}&quot;<br>OE_PASS=&quot;${oe_pass}&quot;<br><br>echo &quot;Volume device: $VOLUME_DEVICE&quot;<br>echo &quot;Mount point: $mount_point&quot;<br>echo &quot;S3 bucket: $s3_bucket_name&quot;<br>echo &quot;Docker Compose version: $DOCKER_COMPOSE_VERSION&quot;<br>echo &quot;region: $region&quot;<br>echo &quot;environment: $environment&quot;<br><br># === Resolve EBS device for Nitro or Xen-based instances ===<br>if [[ -e /dev/nvme1n1 ]]; then<br>  ACTUAL_DEVICE=&quot;/dev/nvme1n1&quot;<br>else<br>  ACTUAL_DEVICE=$(readlink -f &quot;$VOLUME_DEVICE&quot; || echo &quot;$VOLUME_DEVICE&quot;)<br>fi<br><br># === Wait for EBS volume to appear ===<br>echo &quot;⏳ Waiting for EBS volume to be attached...&quot;<br>for i in {1..10}; do<br>  if [[ -e /dev/nvme1n1 ]]; then<br>    ACTUAL_DEVICE=&quot;/dev/nvme1n1&quot;<br>    echo &quot;✅ Found EBS volume at /dev/nvme1n1&quot;<br>    break<br>  elif [[ -e /dev/xvdf ]]; then<br>    ACTUAL_DEVICE=&quot;/dev/xvdf&quot;<br>    echo &quot;✅ Found EBS volume at /dev/xvdf&quot;<br>    break<br>  else<br>    echo &quot;❗️ EBS volume not found yet, retrying in 5 seconds...&quot;<br>    sleep 5<br>  fi<br>done<br><br>if [[ -z &quot;$ACTUAL_DEVICE&quot; ]]; then<br>  echo &quot;🚨 ERROR: EBS volume not found after waiting. Exiting.&quot;<br>  exit 1<br>fi<br><br>if ! [ -e &quot;$ACTUAL_DEVICE&quot; ]; then<br>  echo &quot;🚨 ERROR: Resolved device $ACTUAL_DEVICE does not exist. Exiting.&quot;<br>  exit 1<br>fi<br><br>echo &quot;✅ EBS volume found at $ACTUAL_DEVICE&quot;<br><br># === Install basic tools early ===<br>apt-get update<br>apt-get install -y file<br><br># === Format and mount EBS volume ===<br>if ! file -s &quot;$ACTUAL_DEVICE&quot; | grep -q ext4; then<br>  mkfs.ext4 &quot;$ACTUAL_DEVICE&quot;<br>fi<br><br>mkdir -p &quot;$mount_point&quot;<br>mount &quot;$ACTUAL_DEVICE&quot; &quot;$mount_point&quot;<br>echo &quot;$ACTUAL_DEVICE $mount_point ext4 defaults,nofail 0 2&quot; &gt;&gt; /etc/fstab<br>chown -R 1000:1000 &quot;$mount_point&quot;<br><br># === Install Docker, Docker Compose, AWS CLI ===<br>apt-get install -y docker.io unzip curl wget<br><br>curl &quot;https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip&quot; -o &quot;awscliv2.zip&quot;<br>unzip awscliv2.zip &amp;&amp; ./aws/install<br>rm -rf awscliv2.zip aws<br><br>COMPOSE_BIN=&quot;/usr/local/bin/docker-compose&quot;<br>COMPOSE_URL=&quot;https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-$(uname -s | tr &#39;[:upper:]&#39; &#39;[:lower:]&#39;)-$(uname -m)&quot;<br>curl -fsSL &quot;$COMPOSE_URL&quot; -o &quot;$COMPOSE_BIN&quot;<br>chmod +x &quot;$COMPOSE_BIN&quot;<br>ln -sf &quot;$COMPOSE_BIN&quot; /usr/bin/docker-compose<br><br># === Install SSM Agent for keyless Session Manager access ===<br>echo &quot;🛠️ Installing SSM Agent...&quot;<br>if ! apt-get install -y amazon-ssm-agent; then<br>  echo &quot;⚠️ Failed to install amazon-ssm-agent via apt-get, continuing without SSM.&quot;<br>else<br>  systemctl enable amazon-ssm-agent<br>  systemctl start amazon-ssm-agent<br>  echo &quot;✅ SSM Agent installed and running.&quot;<br>fi<br><br># === Install CloudWatch Agent ===<br>echo &quot;🛠️ Installing CloudWatch Agent...&quot;<br>wget https://amazoncloudwatch-agent.s3.amazonaws.com/ubuntu/amd64/latest/amazon-cloudwatch-agent.deb<br>dpkg -i amazon-cloudwatch-agent.deb<br>rm -f amazon-cloudwatch-agent.deb<br><br># === Create CloudWatch Agent config (metrics + system logs) ===<br>mkdir -p /opt/aws/amazon-cloudwatch-agent/etc<br><br>cat &lt;&lt;EOF &gt; /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json<br>{<br>  &quot;metrics&quot;: {<br>    &quot;metrics_collected&quot;: {<br>      &quot;disk&quot;: {<br>        &quot;measurement&quot;: [<br>          &quot;used_percent&quot;,<br>          &quot;inodes_free&quot;<br>        ],<br>        &quot;resources&quot;: [<br>          &quot;/&quot;,<br>          &quot;${mount_point}&quot;<br>        ],<br>        &quot;ignore_file_system_types&quot;: [<br>          &quot;sysfs&quot;,<br>          &quot;devtmpfs&quot;,<br>          &quot;tmpfs&quot;<br>        ]<br>      },<br>      &quot;mem&quot;: {<br>        &quot;measurement&quot;: [<br>          &quot;mem_used_percent&quot;<br>        ]<br>      }<br>    }<br>  },<br>  &quot;logs&quot;: {<br>    &quot;logs_collected&quot;: {<br>      &quot;files&quot;: {<br>        &quot;collect_list&quot;: [<br>          {<br>            &quot;file_path&quot;: &quot;/var/log/syslog&quot;,<br>            &quot;log_group_name&quot;: &quot;/system/syslog-${environment}&quot;,<br>            &quot;log_stream_name&quot;: &quot;{instance_id}&quot;<br>          },<br>          {<br>            &quot;file_path&quot;: &quot;/var/log/openemr_setup.log&quot;,<br>            &quot;log_group_name&quot;: &quot;/system/openemr-setup-${environment}&quot;,<br>            &quot;log_stream_name&quot;: &quot;{instance_id}&quot;<br>          },<br>          {<br>            &quot;file_path&quot;: &quot;/var/log/openemr_backup.log&quot;,<br>            &quot;log_group_name&quot;: &quot;/system/openemr-backup-${environment}&quot;,<br>            &quot;log_stream_name&quot;: &quot;{instance_id}&quot;<br>          }<br>        ]<br>      }<br>    }<br>  }<br>}<br>EOF<br><br># === Start CloudWatch Agent ===<br>echo &quot;🚀 Starting CloudWatch Agent...&quot;<br>/opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl \<br>  -a fetch-config -m ec2 \<br>  -c file:/opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json -s<br><br>echo &quot;✅ CloudWatch Agent setup complete.&quot;<br><br># === Create data folders ===<br>mkdir -p &quot;$mount_point/db&quot; &quot;$mount_point/log&quot;<br>chown -R 1000:1000 &quot;$mount_point&quot;<br><br># === Create 2GB Swap ===<br>echo &quot;🛠️ Creating 2GB swap space...&quot;<br>if ! [ -f /swapfile ]; then<br>  if ! fallocate -l 2G /swapfile; then<br>    echo &quot;⚠️ fallocate failed, falling back to dd...&quot;<br>    dd if=/dev/zero of=/swapfile bs=1M count=2048<br>  fi<br>fi<br>chmod 600 /swapfile<br>mkswap /swapfile<br>swapon /swapfile<br>if ! grep -q &#39;/swapfile&#39; /etc/fstab; then<br>  echo &#39;/swapfile none swap sw 0 0&#39; | tee -a /etc/fstab<br>fi<br>echo &quot;✅ Swap space created and enabled.&quot;<br><br># === Create .env file for Docker Compose ===<br>cat &lt;&lt;EOF &gt; /opt/.env<br>mount_point=${mount_point}<br>S3_BUCKET_NAME=${s3_bucket_name}<br>region=${region}<br>environment=${environment}<br>MYSQL_ROOT_PASS=${MYSQL_ROOT_PASS}<br>MYSQL_USER=${MYSQL_USER}<br>MYSQL_PASS=${MYSQL_PASS}<br>OE_USER=${OE_USER}<br>OE_PASS=${OE_PASS}<br>EOF<br><br># === Check if OpenEMR and MariaDB already initialized for upgrade purposes ===<br>SKIP_INIT=false<br>if [ -f &quot;$mount_point/db/ibdata1&quot; ] &amp;&amp; [ -f &quot;$mount_point/sites/default/sqlconf.php&quot; ]; then<br>  echo &quot;✅ Detected existing MariaDB and OpenEMR site config. Skipping init.&quot;<br>  SKIP_INIT=true<br>fi<br><br># === Step 1: Compose file WITHOUT sites mount (init phase) ===<br>cat &lt;&lt;&#39;EOF&#39; &gt; /opt/docker-compose.yml<br>version: &#39;3.1&#39;<br>services:<br>  mysql:<br>    image: mariadb:11.4<br>    restart: always<br>    command: [&#39;mariadbd&#39;, &#39;--character-set-server=utf8mb4&#39;]<br>    volumes:<br>      - ${mount_point}/db:/var/lib/mysql<br>    environment:<br>      MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASS}<br>    logging:<br>      driver: awslogs<br>      options:<br>        awslogs-group: /docker/openemr-mysql-${environment}<br>        awslogs-region: ${region}<br>        awslogs-stream: mysql<br><br>  openemr:<br>    image: openemr/openemr:7.0.3<br>    restart: always<br>    ports:<br>      - &quot;80:80&quot;<br>      - &quot;443:443&quot;<br>    volumes:<br>      - ${mount_point}/log:/var/log<br>      - ${mount_point}/log:/var/www/logs<br>    environment:<br>      MYSQL_HOST: mysql<br>      MYSQL_ROOT_PASS: ${MYSQL_ROOT_PASS}<br>      MYSQL_USER: ${MYSQL_USER}<br>      MYSQL_PASS: ${MYSQL_PASS}<br>      OE_USER: ${OE_USER}<br>      OE_PASS: ${OE_PASS}<br>    depends_on:<br>      - mysql<br>    logging:<br>      driver: awslogs<br>      options:<br>        awslogs-group: /docker/openemr-app-${environment}<br>        awslogs-region: ${region}<br>        awslogs-stream: openemr<br>EOF<br><br>if [ &quot;$SKIP_INIT&quot; = false ]; then<br>  docker-compose --env-file /opt/.env -f /opt/docker-compose.yml up -d<br><br>  # === Wait for OpenEMR initialization ===<br>  echo &quot;⏳ Waiting for OpenEMR to initialize sites/default...&quot;<br>  for i in {1..60}; do<br>    container_id=$(docker ps --filter &quot;name=openemr&quot; --format &quot;{{.ID}}&quot; | head -n1)<br>    if [[ -n &quot;$container_id&quot; ]]; then<br>      if docker exec &quot;$container_id&quot; test -f /var/www/localhost/htdocs/openemr/sites/default/sqlconf.php; then<br>        echo &quot;✅ Initialization complete!&quot;<br>        break<br>      fi<br>    fi<br>    echo &quot;Still waiting...&quot;<br>    sleep 5<br>  done<br><br>  # === Copy initialized `sites/default` to persistent volume ===<br>  mkdir -p &quot;$mount_point/sites&quot;<br>  docker cp &quot;$container_id&quot;:/var/www/localhost/htdocs/openemr/sites/default &quot;$mount_point/sites/&quot;<br>  chown -R 1000:1000 &quot;$mount_point/sites&quot;<br><br>  # === Restart containers WITH sites volume mounted ===<br>  docker-compose --env-file /opt/.env -f /opt/docker-compose.yml down<br>else<br>  echo &quot;🚫 Skipping OpenEMR reinitialization due to existing config.&quot;<br>fi<br><br># === Final Compose file WITH sites mount ===<br>cat &lt;&lt;&#39;EOF&#39; &gt; /opt/docker-compose.yml<br>version: &#39;3.1&#39;<br>services:<br>  mysql:<br>    image: mariadb:11.4<br>    restart: always<br>    command: [&#39;mariadbd&#39;, &#39;--character-set-server=utf8mb4&#39;]<br>    volumes:<br>      - ${mount_point}/db:/var/lib/mysql<br>    environment:<br>      MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASS}<br>    logging:<br>      driver: awslogs<br>      options:<br>        awslogs-group: /docker/openemr-mysql-${environment}<br>        awslogs-region: ${region}<br>        awslogs-stream: mysql<br><br>  openemr:<br>    image: openemr/openemr:7.0.3<br>    restart: always<br>    ports:<br>      - &quot;80:80&quot;<br>      - &quot;443:443&quot;<br>    volumes:<br>      - ${mount_point}/log:/var/log<br>      - ${mount_point}/log:/var/www/logs<br>      - ${mount_point}/sites:/var/www/localhost/htdocs/openemr/sites<br>    environment:<br>      MYSQL_HOST: mysql<br>      MYSQL_ROOT_PASS: ${MYSQL_ROOT_PASS}<br>      MYSQL_USER: ${MYSQL_USER}<br>      MYSQL_PASS: ${MYSQL_PASS}<br>      OE_USER: ${OE_USER}<br>      OE_PASS: ${OE_PASS}<br>    depends_on:<br>      - mysql<br>    logging:<br>      driver: awslogs<br>      options:<br>        awslogs-group: /docker/openemr-app-${environment}<br>        awslogs-region: ${region}<br>        awslogs-stream: openemr<br>EOF<br><br>docker-compose --env-file /opt/.env -f /opt/docker-compose.yml up -d<br><br>echo &quot;========== OpenEMR setup completed at $(date) ==========&quot;<br><br># === Create backup script ===<br>echo &quot;🛠️ Creating backup script...&quot;<br>mkdir -p /usr/local/bin<br><br>cat &lt;&lt;EOF &gt; /usr/local/bin/openemr_backup.sh<br>#!/bin/bash<br>set -e<br>LOG_FILE=&quot;/var/log/openemr_backup.log&quot;<br>TIMESTAMP=\$(date +&quot;%Y-%m-%d-%H-%M&quot;)<br>exec &gt;&gt; &quot;\$LOG_FILE&quot; 2&gt;&amp;1<br><br>echo &quot;===== Backup started at \$TIMESTAMP =====&quot;<br><br>source /opt/.env<br><br>mount_point=&quot;${mount_point}&quot;<br>S3_BUCKET_NAME=&quot;${s3_bucket_name}&quot;<br>DUMP_PATH=&quot;/tmp/openemr-\$TIMESTAMP.sql.gz&quot;<br><br>docker exec \$(docker ps -qf &quot;name=openemr&quot;) \<br>  sh -c &#39;mysqldump -h mysql -uroot -p&quot;${MYSQL_ROOT_PASS}&quot; --all-databases&#39; | gzip &gt; &quot;\$DUMP_PATH&quot;<br><br>aws s3 cp &quot;\$DUMP_PATH&quot; &quot;s3://\$S3_BUCKET_NAME/openemr-backup/\$TIMESTAMP/openemr.sql.gz&quot; --only-show-errors<br>rm -f &quot;\$DUMP_PATH&quot;<br>echo &quot;✅ Backup completed at \$(date)&quot;<br>EOF<br><br>chmod +x /usr/local/bin/openemr_backup.sh<br>echo &quot;✅ Backup script created at /usr/local/bin/openemr_backup.sh&quot;<br><br># === Cron job setup ===<br>echo &quot;🕒 Setting up cron job...&quot; | tee -a &quot;$LOG_FILE&quot;<br>cat &lt;&lt;EOF &gt; /etc/cron.d/openemr-backup<br>SHELL=/bin/bash<br>PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin<br># Database backup everyday at 6pm<br>0 18 * * * root /usr/local/bin/openemr_backup.sh<br>EOF<br><br>chmod 644 /etc/cron.d/openemr-backup<br>echo &quot;✅ Cron job created at /etc/cron.d/openemr-backup&quot; | tee -a &quot;$LOG_FILE&quot;A Few Small but Important Operational Details</pre><p>On paper, the architecture looks simple. In practice, there are a handful of “invisible” details in the userdata script that make the whole setup much more forgiving in the real world:</p><p><strong>Swap Space (2GB) : </strong>cheap insurance against OOM (Out of memory) crashes. I experienced such when a stubborn me tried a t2-micro instance to run this. Silly me!!! The script creates a 2GB swap file on the instance.<br>This is not about performance; it’s about survivability. OpenEMR, MariaDB, and Docker can occasionally spike memory — especially during upgrades, heavy queries, or backups. On a small instance type, that’s a quick route to the kernel’s OOM killer and a dead EMR in the middle of clinic hours.</p><p>Swap gives the instance a bit of breathing room. It’s not a replacement for proper sizing, but it’s a very cheap safety net for a cost-sensitive deployment. Need I mention again that I’m a full time worker and wouldn’t want any support calls taking my attention from my company’s client.</p><p><strong>Initialization Detection : </strong>safe to rebuild without wiping data. Before doing any OpenEMR “first run” setup, the script checks for:</p><ul><li>ibdata1 in the database directory (MariaDB data present)</li><li>sites/default/sqlconf.php in the sites directory (OpenEMR already configured)</li></ul><p>If both exist, it skips initialization.</p><p>That means you can:</p><ul><li>Stop the instance</li><li>Change instance type</li><li>Redeploy with the same EBS volume</li></ul><p>…and the script won’t blow away your data or reset the app. For a small clinic that can’t afford complex migrations, this “know when to leave things alone” logic is critical.</p><p><strong>Two-Phase OpenEMR Init</strong> : letting the app configure itself first</p><p>The script brings up OpenEMR once without the sites volume mounted, waits for it to generate sites/default, then copies that into the persistent EBS volume and restarts with the proper mount.</p><p>This avoids all the usual “empty sites folder” headaches and ensures OpenEMR initializes itself the way it expects, while still giving you persistent configuration on EBS. It’s a small trick that saves a lot of manual fiddling.</p><p><strong>CloudWatch Agent for Metrics + Log Files: </strong>Beyond container logs, the script configures the CloudWatch agent to ship:</p><ul><li>/var/log/syslog</li><li>/var/log/openemr_setup.log</li><li>/var/log/openemr_backup.log</li></ul><p>So you don’t just see what the containers are doing — you also see:</p><ul><li>Boot issues</li><li>Setup errors</li><li>Backup failures</li></ul><p>All in CloudWatch, grouped by environment. For a one-person “ops team,” which is me, having everything visible in one place means I don’t waste time SSH-ing in to chase problems.</p><p><strong>Automated Daily Backups to S3:</strong>The backup is not theoretical. The script:</p><ul><li>Runs mysqldump inside the running OpenEMR stack</li><li>Compresses the dump</li><li>Uploads it to s3://&lt;bucket&gt;/openemr-backup/&lt;timestamp&gt;/openemr.sql.gz</li><li>Is scheduled via cron to run every day at 6 p.m. server time (UTC in my case, which aligns with GMT)</li></ul><p>This is what turns “we have S3” into actual, restorable backups with timestamps. If the worst happens, I know exactly where to go and what file to restore.</p><p>Here is what the backup looks like</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*a6BfIvlnhY8zDdQ5ic_csA.png" /><figcaption>S3 Backup</figcaption></figure><p>Take note of the number of objects — in my case there were <strong>208</strong> backup folders, which is roughly 208 days, almost seven months. That’s fine for now, but I wouldn’t want to quietly pay for years of old backups I’ll never use.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*66Mff18o2pS-qDPo4vIBvw.png" /><figcaption>Total Bucket Size and Total number of Objects after 7 months</figcaption></figure><h3>Now the important question… Cost?</h3><p>Overall, the OpenEMR stack costs me roughly $15–$20/month on AWS which is roughly <strong>GH₵ 160 </strong>to<strong> GH₵ 220 </strong>a<strong> </strong>month since she (My dentist cousin) is in Ghana. Everything essential is included — compute, storage, logs, backups, and a static IP. Even with seven months of accumulated backups (208 objects totalling ~10GB), S3 still costs less than 30 cents per month. In other words, one patient visit pays for the entire month of infrastructure.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aRJOplWVAGv8JQsDoOqyiw.png" /><figcaption>Infrastructure Costs Breakdown- VAT exlusive</figcaption></figure><p>But, I still look at this and feel there are a few more opportunities for bringing down the cost.</p><ul><li>Automatically turning off the Instance every weekend and after work would save about 8 days of instance cost.</li><li>House keeping for S3 buckets to either archive old backups or keep just a month’s worth of backup data would minimize S3 costs as well.</li></ul><h3>When would I move beyond this ?</h3><p>This setup is intentionally “mono”: one EC2 instance. It’s perfect for a single-doctor clinic that just needs something reliable, secure enough, and affordable, under $30 when you include VAT. I would start looking at RDS, multi-AZ, and load balancers if:</p><ul><li>The clinic grows into multiple branches or multiple doctors working concurrently.</li><li>Uptime requirements move closer to 24/7 with financial penalties for downtime.</li><li>There’s a regulatory push for stricter availability SLAs and more formal audits.</li></ul><p>At that point, the extra AWS services start paying for themselves. For this clinic, they would just increase the bill and complexity without improving patient care.</p><h3>Security and Compliance Notes</h3><p>This setup is intentionally cost-optimised, but it already incorporates several responsible security practices that fit a small clinic. The deployment uses Cloudflare for TLS at the edge, encrypted EBS volumes for all persistent data, S3 for off-site backups, IAM-restricted EC2 roles, and keyless access via AWS SSM instead of SSH. Secrets are injected through Terraform Cloud variables into a local .env file, which is appropriate for a single-instance environment.</p><p>That said, there are a few areas I plan to tighten as the clinic grows:</p><ul><li>Move secrets out of EC2 User Data entirely and into AWS Systems Manager Parameter Store or Secrets Manager. The current .env approach is safe enough for a one-doctor setup, but Parameter Store gives versioning, rotation, and auditability.</li><li>Shift the instance into private subnets behind a load balancer if remote access requirements or compliance expectations change. Today, Cloudflare proxies and origin shielding keep things safe while keeping the cost close to zero. A load balancer becomes useful only when availability requirements justify the extra monthly cost.</li><li>Formalise backup restoration testing. Automated nightly backups are already running and restorable, but the process needs to be documented and tested on a schedule — not just “I know how to do it.” Even one drill per quarter would close this gap completely.</li></ul><p>Overall, the architecture already meets the practical security needs of a small clinic without inflating the bill. This article was written 7 months after deployment and there has been zero incidents to worry about.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9ed9fc8dd495" width="1" height="1" alt=""><hr><p><a href="https://towardsaws.com/deploying-openemr-on-aws-using-terraform-and-docker-a-cost-optimized-architecture-for-smes-9ed9fc8dd495">Deploying OpenEMR on AWS Using Terraform and Docker: A Cost-Optimized Architecture for SMEs</a> was originally published in <a href="https://towardsaws.com/">Towards AWS</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Terraforming WordPress on EC2: Setting the Stage for a Containerized Future]]></title>
            <link>https://towardsaws.com/terraforming-wordpress-on-ec2-setting-the-stage-for-a-containerized-future-69624cb33340?source=rss-2b7be465b232------2</link>
            <guid isPermaLink="false">https://medium.com/p/69624cb33340</guid>
            <category><![CDATA[iam-roles]]></category>
            <category><![CDATA[terraform]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[ec2]]></category>
            <category><![CDATA[wordpress]]></category>
            <dc:creator><![CDATA[Stephen Somuah]]></dc:creator>
            <pubDate>Wed, 01 Jan 2025 11:19:33 GMT</pubDate>
            <atom:updated>2025-01-02T08:59:47.146Z</atom:updated>
            <content:encoded><![CDATA[<p>About 13 years ago, during my university days, I was deeply immersed in developing web applications with PHP, HTML, and CSS. As my career progressed, I shifted from full-stack development to WordPress, driven by my growing interest in information security and cloud engineering. This shift not only allowed me to deliver websites to clients quickly as a side gig, but also distanced me from the foundational technologies I once relied on. However, stepping away offered me a unique perspective on how application deployment has evolved.</p><p>This article kicks off a series that explores transforming a WordPress application from a traditional monolithic architecture into a modern, containerized microservices approach using Kubernetes. Whether you’re revisiting old skills or exploring new deployment strategies, this journey aims to bridge past experiences with the future of scalable web development.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/739/1*-B0eJBNUm6Qod87-JMWJJg.jpeg" /></figure><h4>Infrastructure Setup and Deployment Guide</h4><p>Our implementation, available on GitHub at <a href="https://github.com/thebigstevo/wp-on-ec2/">wp-on-ec2</a> , uses a modular Terraform approach to deploy WordPress on AWS. Let’s walk through each module and its deployment process.</p><h3>Prerequisites</h3><ul><li>AWS Account with administrative access</li><li>Terraform installed locally</li><li>Hashicorp cloud for remote state management (optional)</li><li>AWS CLI configured with credentials</li><li>Git for repository access</li></ul><h4>Module 1: VPC Configuration</h4><p>This module creates our networking foundation:</p><pre>code module &quot;vpc&quot; {<br> source = &quot;./modules/vpc&quot;<br> vpc_cidr_block = var.vpc_cidr_block<br> subnet_cidr_block = var.subnet_cidr_block<br> enable_dns_support = var.enable_dns_support<br> enable_dns_hostnames = var.enable_dns_support<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GUuXvgIoL7sbx_AyJ09fBg.png" /><figcaption>VPC resource map</figcaption></figure><h4>Module 2: Security Groups</h4><p>Configures network access rules to provide access to the wordpress application.</p><pre>module &quot;security_groups&quot; {<br> source = &quot;./modules/security-groups&quot;<br> vpc_id = module.vpc.vpc_id<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hgKbLha4xoFmlfxk4MIXLw.png" /><figcaption>Security group rules showing HTTP/HTTPS inbound rules</figcaption></figure><h4>Module 3: IAM Configuration</h4><p>Sets up required permissions for Systems Manager. This allows us to access our EC2 instance without the need for SSH keys.</p><pre>module &quot;iam&quot; {<br> source = &quot;./modules/iam&quot; <br> environment = var.environment<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-JMsxgD-4bIG2NF009akYQ.png" /></figure><h4>Module 4: EC2 Instance</h4><p>Deploys and configures WordPress. As mentioned above, this doesn’t require an SSH key to log in. all log ins must be done by authorised persons via the AWS console.</p><pre>module &quot;ec2&quot; {<br> source = &quot;./modules/ec2&quot;<br> ami_id = var.ami_id<br> instance_type = var.instance_type<br> public_subnet_id = module.vpc.public_subnet_id<br> ssm_instance_profile = module.iam.ssm_instance_profile<br> associate_public_ip_address = var.associate_public_ip_address<br> vpc_security_group_ids = [module.security_groups.wordpress_sg_id]<br> database_password = var.database_password<br> instance_name = var.instance_name <br>}</pre><p>The entire magic for the wordpress installation within the instance happens in the bash script which was added as user data and executed at the time of deployment of the the instance.</p><pre>#!/bin/bash<br>touch /var/log/user_data.log<br>exec &gt; /var/log/user_data.log 2&gt;&amp;1<br>set -ex<br><br>DB_NAME=&quot;${DB_NAME}&quot;<br>DB_USER=&quot;${DB_USER}&quot;<br>DB_PASSWORD=&quot;${DB_PASSWORD}&quot;<br><br>echo &quot;Starting system update...&quot;<br>apt update -y &amp;&amp; apt upgrade -y<br>echo &quot;System update complete.&quot;<br><br>echo &quot;Installing Apache, PHP, and MySQL server...&quot;<br>apt install -y apache2 php mysql-server php-mysql unzip wget<br>systemctl start apache2<br>systemctl enable apache2<br><br>echo &quot;Downloading and setting up WordPress...&quot;<br>cd /var/www/html<br>rm -rf *  # Ensure no default files remain<br>wget https://wordpress.org/latest.zip<br>unzip latest.zip<br>mv wordpress/* .<br>rm -rf wordpress latest.zip<br><br># Configure Apache for WordPress<br>echo &quot;Configuring Apache for WordPress...&quot;<br>cat &lt;&lt;EOT &gt; /etc/apache2/sites-available/wordpress.conf<br>&lt;VirtualHost *:80&gt;<br>    ServerName localhost<br>    DocumentRoot /var/www/html<br><br>    &lt;Directory /var/www/html&gt;<br>        AllowOverride All<br>    &lt;/Directory&gt;<br><br>    ErrorLog /var/log/apache2/error.log<br>    CustomLog /var/log/apache2/access.log combined<br>&lt;/VirtualHost&gt;<br>EOT<br><br># Disable default site and enable WordPress site<br>a2dissite 000-default.conf<br>a2ensite wordpress.conf<br>a2enmod rewrite<br>systemctl reload apache2<br><br>chown -R www-data:www-data /var/www/html<br>chmod -R 755 /var/www/html<br><br>echo &quot;Starting MySQL server...&quot;<br>systemctl start mysql<br>systemctl enable mysql<br><br># Create WordPress database and user<br>mysql -u root &lt;&lt;EOF<br>CREATE DATABASE ${DB_NAME};<br>CREATE USER &#39;${DB_USER}&#39;@&#39;localhost&#39; IDENTIFIED BY &#39;${DB_PASSWORD}&#39;;<br>GRANT ALL PRIVILEGES ON ${DB_NAME}.* TO &#39;${DB_USER}&#39;@&#39;localhost&#39;;<br>FLUSH PRIVILEGES;<br>EOF<br><br>echo &quot;Configuring WordPress...&quot;<br>cd /var/www/html<br>cp wp-config-sample.php wp-config.php<br>sed -i &quot;s/database_name_here/${DB_NAME}/&quot; wp-config.php<br>sed -i &quot;s/username_here/${DB_USER}/&quot; wp-config.php<br>sed -i &quot;s/password_here/${DB_PASSWORD}/&quot; wp-config.php<br><br># Restart Apache to apply changes<br>systemctl restart apache2<br>echo &quot;Setup complete.&quot;<br></pre><p>Upon completion of the script which takes a about three minutes, you should have something like the image below. In summary, the script installs the necessary dependencies for wordpress, including mysql, apache</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PFRoGwkpJzyrLPRePSfAOQ.png" /><figcaption>EC2 dashboard showing running instance</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_YZOhhYiE2XNZN6zxrj6yQ.png" /><figcaption>Connecting via session manager, which is part of Systems Manager</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Qy8nV3C89FCn-Jaw2K1ZbQ.png" /><figcaption>Systems Manager session connected to instance</figcaption></figure><h4>Deployment Steps</h4><ol><li>Clone the repository</li></ol><pre>git clone https://github.com/thebigstevo/wp-on-ec2.git<br>cd wp-on-ec2</pre><p>2. Create terraform.tfvars:</p><pre>vpc_cidr_block = &quot;10.0.0.0/16&quot;<br>subnet_cidr_block = &quot;10.0.1.0/24&quot;<br>enable_dns_support = true<br>ami_id = &quot;ami-0735c191cf914754d&quot;<br>instance_type = &quot;t2.micro&quot;<br>instance_name = &quot;wordpress-instance&quot;<br>database_password = &quot;your_secure_password&quot;</pre><p>3. Initialize and apply:</p><pre>terraform init<br>terraform plan<br>terraform apply</pre><p>Note: I typically use HashiCorp Cloud for state management. With its VCS integration, a simple push or merge request can automatically trigger a terraform plan. Once the plan executes successfully, the subsequent merge clears the way for a terraform apply to provision the infrastructure. This is how the plan looks like.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*f-YDqvNiNv2mWIEqJaF-EA.png" /><figcaption>Hashicorp cloud Terraform plan</figcaption></figure><p>4. Verifying the Installation</p><ul><li>Access WordPress Setup: Navigate to your EC2 instance’s public IP</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NUqiTAQC4wcx6vMjODyGIQ.png" /></figure><p>2. Complete Configuration:<br>Follow the WordPress setup wizard</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*U3ZYy7WzI_hueLnt5rLG_w.png" /><figcaption>WordPress dashboard after setup</figcaption></figure><h4>Looking Ahead</h4><p>While this deployment provides a solid foundation for running WordPress on AWS, our next article will focus on containerization. This evolution will bring improved isolation and simplified management while maintaining our infrastructure’s simplicity. We’ll also address current limitations in areas like password management and application isolation and many more in subsequent write ups.</p><p>The complete implementation is available at <a href="https://github.com/thebigstevo/wp-on-ec2/">[github.com/thebigstevo/wp-on-ec2/]</a>. I encourage you to explore the code and join me on this journey of modernizing WordPress deployment.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=69624cb33340" width="1" height="1" alt=""><hr><p><a href="https://towardsaws.com/terraforming-wordpress-on-ec2-setting-the-stage-for-a-containerized-future-69624cb33340">Terraforming WordPress on EC2: Setting the Stage for a Containerized Future</a> was originally published in <a href="https://towardsaws.com/">Towards AWS</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[From On-Prem File Shares to AWS: A System Administrator’s Perspective]]></title>
            <link>https://towardsaws.com/from-on-prem-file-shares-to-aws-a-system-administrators-perspective-19b9a9566853?source=rss-2b7be465b232------2</link>
            <guid isPermaLink="false">https://medium.com/p/19b9a9566853</guid>
            <category><![CDATA[aws-efs]]></category>
            <category><![CDATA[aws-s3]]></category>
            <category><![CDATA[system-administration]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <dc:creator><![CDATA[Stephen Somuah]]></dc:creator>
            <pubDate>Thu, 24 Oct 2024 04:34:04 GMT</pubDate>
            <atom:updated>2024-10-24T04:34:04.412Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nXSx0-_lqjD9a7IDH7IoKg.jpeg" /></figure><p>During my tenure as a Windows system administrator, I specialized in managing file-sharing infrastructures. The environment typically consisted of multiple Windows servers with shared drives mapped to specific letters — a convention well understood by IT professionals. My team regularly handled permission management and storage optimization tasks.</p><p>The file-sharing infrastructure provided three key advantages:<br>- Storage optimization through centralized file management<br>- Enhanced security through Active Directory permissions<br>- Streamlined administration from a central point</p><p>When I transitioned to AWS, the landscape was notably different, though the fundamental concepts remained familiar. S3 emerged as the prevalent storage solution, but it didn’t quite align with traditional file-sharing requirements. While S3 excels at object storage, it lacks the direct file system interaction that users expect. This realization led me to explore Amazon EFS, which proved to be a more suitable solution for our needs.</p><h3>Understanding AWS File Cloud Storage Options</h3><h4><strong>Amazon EFS: Linux-Optimized Storage</strong></h4><p>Amazon EFS serves as the Linux-compatible equivalent of traditional file shares. It provides POSIX compliance for seamless file system integration and offers dynamic scaling capabilities to accommodate growing storage needs. Take a look at my implementation in my last <a href="https://awstip.com/streamlining-data-flow-aws-s3-to-efs-using-lambda-5a12535449b9#:~:text=endpoint%22%0A%20%20%7D%0A%7D-,Elastic%20File%20System,tags%20%3D%20%7B%0A%20%20%20%20Name%20%3D%20%22%24%7Bvar.project_name%7D%2Daccess%2Dpoint%22%0A%20%20%7D%0A%7D,-Lambda%20Function">post</a></p><p><strong>Key Features:</strong><br>- POSIX-compliant permissions<br>- NFSv4.1 protocol support<br>- Automatic storage scaling</p><h4><strong>Amazon FSx for Windows: Native Windows Integration</strong></h4><p>FSx for Windows File Server effectively replicates the familiar Windows file-sharing environment in the cloud. It maintains compatibility with existing Windows tools and workflows while adding cloud-specific advantages.</p><p>Key Features:<br>- Active Directory integration<br>- SMB protocol support<br>- NTFS permission system<br>- Distributed File System capabilities</p><h4>Amazon FSx for Lustre: High-Performance Storage</h4><p>FSx for Lustre addresses the requirements of performance-intensive workloads, offering enhanced speed and throughput for demanding applications.</p><p>Key Features:<br>- S3 integration capabilities<br>- High-performance architecture<br>- Parallel access support</p><h3>Selecting the Appropriate Storage Solution</h3><p>The choice of storage solution depends on your specific requirements:<br>- For Linux environments: Amazon EFS provides native compatibility<br>- For Windows workloads: FSx for Windows File Server ensures seamless integration<br>- For high-performance needs: FSx for Lustre delivers optimal speed</p><h3>Transitioning to Cloud Storage</h3><p>The migration to cloud storage represents an evolution rather than a revolution in file management. The fundamental principles of storage administration remain consistent, though they’re implemented through cloud-native services.</p><p>For organizations considering cloud migration, it’s worth noting that the technical transition is often straightforward. The cloud environment offers familiar concepts implemented through modern infrastructure, typically providing improved reliability and reduced maintenance requirements.</p><p>The cloud ultimately offers enhanced uptime and automated management capabilities, allowing system administrators to focus on strategic initiatives rather than routine maintenance.</p><p>You can find out about everything Amazon EFS from AWS <a href="https://docs.aws.amazon.com/efs/latest/ug/whatisefs.html">here</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=19b9a9566853" width="1" height="1" alt=""><hr><p><a href="https://towardsaws.com/from-on-prem-file-shares-to-aws-a-system-administrators-perspective-19b9a9566853">From On-Prem File Shares to AWS: A System Administrator’s Perspective</a> was originally published in <a href="https://towardsaws.com/">Towards AWS</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Streamlining Data Flow: AWS S3 to EFS Using Lambda]]></title>
            <link>https://awstip.com/streamlining-data-flow-aws-s3-to-efs-using-lambda-5a12535449b9?source=rss-2b7be465b232------2</link>
            <guid isPermaLink="false">https://medium.com/p/5a12535449b9</guid>
            <category><![CDATA[aws-s3]]></category>
            <category><![CDATA[aws-efs]]></category>
            <category><![CDATA[aws-ec2]]></category>
            <category><![CDATA[aws-lambda]]></category>
            <category><![CDATA[serverless]]></category>
            <dc:creator><![CDATA[Stephen Somuah]]></dc:creator>
            <pubDate>Mon, 22 Jul 2024 20:13:55 GMT</pubDate>
            <atom:updated>2024-07-25T18:45:30.684Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/751/1*oCZXusPuKBCSWxv9wQhzDQ.png" /></figure><p>In cloud computing, managing and transferring data between storage services is essential for optimizing workflows and maintaining robust infrastructures. This blog post presents a solution to streamline file transfers from Amazon S3 to Amazon Elastic File System (EFS) using AWS Lambda.</p><p>This approach bridges the gap between Amazon S3, ideal for storing large volumes of unstructured data, and Amazon EFS, a scalable file storage service suitable for use cases requiring a traditional file system. A common use case for Amazon Elastic File System (EFS) is to store libraries that need to be accessed by applications running on EC2 instances. This setup allows multiple EC2 instances and Lambda functions to access the shared data concurrently.</p><p>The demonstration will show how to create a Lambda-based solution that automates file transfers from S3 to EFS, ensuring data consistency and leveraging the strengths of each AWS service for more efficient data flow.</p><h4>Technical Implementation</h4><p>In this project, the following AWS services were utilized:</p><ul><li><strong>VPC</strong>: Provides network isolation and security.</li><li><strong>Lambda Function</strong>: Automates the transfer of files from S3 to EFS.</li><li><strong>EFS</strong>: Offers scalable and shared file storage.</li><li><strong>IAM</strong>: Manages access permissions for security.</li><li><strong>S3</strong>: Stores large volumes of unstructured data.</li><li><strong>Security Groups</strong>: Controls inbound and outbound traffic to ensure secure service communication.</li><li><strong>EC2 Instance:</strong> To access and confirm the transfer of files to EFS</li></ul><p>To replicate this project, you will need Terraform installed on your device and an AWS account. You can also look at my <a href="https://github.com/thebigstevo/s3-lambda-efs">GitHub</a> repository.</p><h4>Directory Structure</h4><p>Written with Terraform, a modular structure was employed to ensure better organization, easier management, code reuse, and support for future extensions.</p><pre>root/<br>  ├── main.tf<br>  ├── variables.tf<br>  ├── s3_to_lambda_to_efs.zip<br>  └── modules/<br>      ├── vpc/<br>      │   ├── main.tf<br>      │   ├── outputs.tf<br>      │   └── variables.tf<br>      ├── lambda/<br>      │   ├── main.tf<br>      │   ├── outputs.tf<br>      │   └── variables.tf<br>      ├── efs/<br>      │   ├── main.tf<br>      │   ├── outputs.tf<br>      │   └── variables.tf<br>      ├── iam/<br>      │   ├── main.tf<br>      │   ├── outputs.tf<br>      │   └── variables.tf<br>      ├── s3/<br>      │   ├── main.tf<br>      │   ├── outputs.tf<br>      │   └── variables.tf<br>      └── ec2/<br>          ├── main.tf<br>          ├── outputs.tf<br>          └── variables.tf</pre><p>VPC</p><p>A dedicated VPC (Virtual Private Cloud) is essential for this project, particularly for the EFS (Elastic File System). EFS functions like traditional file systems, requiring a network to enable devices on the same network to mount and access shared data. This setup involves creating three subnetworks to ensure redundancy for the mount points.</p><pre># VPC<br>resource &quot;aws_vpc&quot; &quot;s3toefs-vpc&quot; {<br>  cidr_block           = var.vpc_cidr<br>  enable_dns_hostnames = var.enable_dns_hostnames<br>  enable_dns_support   = var.enable_dns_support<br>  tags = {<br>    Name = &quot;${var.project_name}-vpc&quot;<br>  }<br>}<br><br>resource &quot;aws_subnet&quot; &quot;public_subnet&quot; {<br>  count = length(var.availability_zones)<br>  cidr_block        = var.subnet_cidrs[count.index]<br>  vpc_id            = aws_vpc.s3toefs-vpc.id<br>  availability_zone = var.availability_zones[count.index]<br>  map_public_ip_on_launch = var.map_public_ip_on_launch<br>  tags = {<br>    Name = &quot;${var.project_name}-public-subnet-${count.index + 1}&quot;<br>  }<br>}<br><br># Internet Gateway<br>resource &quot;aws_internet_gateway&quot; &quot;igw&quot; {<br>  vpc_id = aws_vpc.s3toefs-vpc.id<br>  tags = {<br>    Name = &quot;${var.project_name}-internet-gateway&quot;<br>  }<br>}<br><br># Route Table for Public Subnets<br>resource &quot;aws_route_table&quot; &quot;public_route_table&quot; {<br>  vpc_id = aws_vpc.s3toefs-vpc.id<br>  route {<br>    gateway_id = aws_internet_gateway.igw.id<br>    cidr_block = &quot;0.0.0.0/0&quot;<br>  }<br>  tags = {<br>    Name = &quot;${var.project_name}-public-route-table&quot;<br>  }<br>}<br><br># Route Table Association (use dynamic block for subnet associations)<br>resource &quot;aws_route_table_association&quot; &quot;public_subnet_association&quot; {<br>  count = length(var.availability_zones)<br><br>  route_table_id = aws_route_table.public_route_table.id<br>  subnet_id      = aws_subnet.public_subnet[count.index].id<br>}</pre><h3>Security Groups</h3><p>Security groups are crucial for controlling access to resources within the VPC. They act as virtual firewalls for the instances to control inbound and outbound traffic.</p><p>EFS Security Group allows traffic on port 2049 (NFS) within the VPC to ensure that EFS can communicate with the resources that need to access it.</p><p>EC2 Security Group permits SSH access on port 22 from any IP address, allowing management access to EC2 instances. This is vital for operations such as debugging and instance management.</p><p>Lambda Security Group enables traffic on port 2049 (NFS) within the VPC, ensuring that the Lambda function can access EFS for reading and writing files.</p><pre># EFS security group<br>resource &quot;aws_security_group&quot; &quot;efs_sg&quot; {<br>  name_prefix = &quot;efs_sg&quot;<br>  vpc_id      = var.vpc_id<br>  description = &quot;EFS security group&quot;<br><br>  ingress {<br>    from_port   = 2049<br>    to_port     = 2049<br>    protocol    = &quot;tcp&quot;<br>    cidr_blocks = [var.vpc_cidr ]  # Allow traffic from within the VPC<br>  }<br><br>  egress {<br>    from_port   = 0<br>    to_port     = 0<br>    protocol    = &quot;-1&quot;<br>    cidr_blocks = [&quot;0.0.0.0/0&quot;]<br>  }<br>}<br>#EC2 Security group<br>resource &quot;aws_security_group&quot; &quot;ec2_sg&quot; {<br>  name_prefix = &quot;ec2_sg&quot;<br>  vpc_id      = var.vpc_id<br>  description = &quot;EFS security group&quot;<br><br>  ingress {<br>    from_port   = 22<br>    to_port     = 22<br>    protocol    = &quot;tcp&quot;<br>    cidr_blocks = [&quot;0.0.0.0/0&quot;]  # Allow traffic from from outside the VPC<br>  }<br><br>  egress {<br>    from_port   = 0<br>    to_port     = 0<br>    protocol    = &quot;-1&quot;<br>    cidr_blocks = [&quot;0.0.0.0/0&quot;]<br>}<br>}<br># Lambda security group<br>resource &quot;aws_security_group&quot; &quot;lambda_sg&quot; {<br>  name_prefix = &quot;lambda_sg&quot;<br>  vpc_id      = var.vpc_id<br>  description = &quot;Lambda security group&quot;<br><br>  egress {<br>    from_port   = 0<br>    to_port     = 0<br>    protocol    = &quot;-1&quot;<br>    cidr_blocks = [&quot;0.0.0.0/0&quot;]<br>  }<br>}</pre><h4>Amazon S3</h4><p>Amazon S3 (Simple Storage Service) plays a critical role as the initial storage location for files that need to be transferred to Amazon EFS.<br>S3 Bucket: An S3 bucket is created to serve as the receiving bucket for files. The <em>force_destroy</em> parameter ensures that the bucket and its contents are deleted when the Terraform infrastructure is destroyed, preventing orphaned resources.</p><p>VPC Endpoint for S3: To securely connect the VPC to S3 without using the public internet, a VPC endpoint for S3 was created. This endpoint allows our Lambda function to access the S3 bucket within the private network, enhancing security and reducing latency.</p><pre># S3 bucket<br>resource &quot;aws_s3_bucket&quot; &quot;receiving_bucket&quot; {<br>  bucket        = &quot;sle24-bucket&quot;<br>  force_destroy = true<br>}<br><br>resource &quot;aws_vpc_endpoint&quot; &quot;s3_endpoint&quot; {<br>  vpc_id     = var.vpc_id<br>  service_name = &quot;com.amazonaws.${var.region}.s3&quot;<br>  route_table_ids = [var.route_table_id]<br>  tags = {<br>    Name = &quot;${var.project_name}-s3-endpoint&quot;<br>  }<br>}</pre><h4>Elastic File System</h4><p>Amazon EFS (Elastic File System) is used here to provide scalable, shared file storage that can be accessed from multiple instances and Lambda functions.</p><p>An EFS file system is created with a lifecycle policy to transition files to the Infrequent Access (IA) storage class after 30 days. This helps optimize storage costs by moving less frequently accessed data to a more cost-effective tier.</p><p>EFS Mount Targets: Mount targets are created in each public subnet within the VPC. These targets allow the EFS file system to be accessed from instances in those subnets. Security groups are applied to ensure proper access control and network security.</p><p>EFS Access Point: An EFS access point is configured to provide a specific entry point for accessing the EFS file system. It includes POSIX user settings for file ownership and permissions and specifies the root directory for file operations. This access point simplifies file management and ensures consistent permissions across different instances and Lambda functions as you would see on our EC2 instance and lambda function.</p><pre>#EFS file system<br>resource &quot;aws_efs_file_system&quot; &quot;efs_vol&quot; {<br>  lifecycle_policy {<br>    transition_to_ia = &quot;AFTER_30_DAYS&quot;<br>  }<br>  tags = {<br>    Name = &quot;${var.project_name}-file-system&quot;<br>  }<br>}<br># EFS mount targets<br>resource &quot;aws_efs_mount_target&quot; &quot;efs_mt&quot; {<br>  for_each = {<br>    for idx, subnet_id in tolist(var.public_subnet_ids) : idx =&gt; subnet_id<br>  }<br>  subnet_id = each.value # Access the value (subnet ID) from the loop<br>  security_groups = [var.efs_sg_id]<br>  file_system_id  = aws_efs_file_system.efs_vol.id<br>}<br><br># EFS access point<br>resource &quot;aws_efs_access_point&quot; &quot;efs_ap&quot; {<br>  file_system_id = aws_efs_file_system.efs_vol.id<br>  posix_user {<br>    gid = 1000<br>    uid = 1000<br>  }<br>  root_directory {<br>    path = &quot;/efs&quot;<br>    creation_info {<br>      owner_gid   = 1000<br>      owner_uid   = 1000<br>      permissions = &quot;777&quot;<br>    }<br>  }<br>  tags = {<br>    Name = &quot;${var.project_name}-access-point&quot;<br>  }<br>}</pre><h4>Lambda Function</h4><p>AWS Lambda is utilized to automate the transfer of files from Amazon S3 to Amazon EFS.</p><p>Lambda Function Configuration: We define a Lambda function which is triggered by events from S3. The function uses Python 3.10 and is configured with a handler to manage the transfer logic. The Lambda function is associated with a specific IAM role and is provided with the code packaged in a ZIP file. The code below provides permissions to invoke the lambda function via an S3 bucket notification</p><pre># Lambda permissions for S3<br>resource &quot;aws_lambda_permission&quot; &quot;with_s3&quot; {<br>  statement_id  = &quot;s3invokelambda&quot;<br>  action        = &quot;lambda:InvokeFunction&quot;<br>  function_name = aws_lambda_function.s3tolambdatoefs.function_name<br>  principal     = &quot;s3.amazonaws.com&quot;<br>  source_arn    = var.s3_bucket_arn<br>}<br><br># S3 bucket notification<br>resource &quot;aws_s3_bucket_notification&quot; &quot;s3toltoefs_notification&quot; {<br>  bucket = var.s3_bucket_id<br>  lambda_function {<br>    lambda_function_arn = aws_lambda_function.s3tolambdatoefs.arn<br>    events              = [&quot;s3:ObjectCreated:*&quot;]<br>  }<br>}</pre><p>VPC Integration: The Lambda function is configured to run within a VPC. This allows it to access the EFS file system securely. It is placed in public subnets and associated with security groups to control network access.</p><p>Environment Variables: Environment variables are used to pass configuration details to the Lambda function, including the ARN of the EFS access point.</p><p>File System Configuration: The Lambda function is set up with a file system configuration to mount the EFS file system at /mnt/efs. This setup allows the Lambda function to read from and write to the EFS file system.</p><pre># Lambda function<br>resource &quot;aws_lambda_function&quot; &quot;s3tolambdatoefs&quot; {<br>  function_name = &quot;s3_to_lambda_to_efs&quot;<br>  handler       = &quot;s3_to_lambda_to_efs.lambda_handler&quot;<br>  role          = var.lambda_role_arn<br>  runtime       = &quot;python3.10&quot;<br>  filename      = &quot;${path.module}/s3_to_lambda_to_efs.zip&quot;<br>  source_code_hash = filebase64sha256(&quot;${path.module}/s3_to_lambda_to_efs.zip&quot;)<br>  timeout       = &quot;120&quot;<br>  memory_size   = &quot;128&quot;<br>  vpc_config {<br>    security_group_ids = [var.lambda_security_group_ids]<br>    subnet_ids         =  var.public_subnet_ids<br>  }<br><br>  environment {<br>    variables = {<br>      aws_efs_access_point = var.lambda_security_group_ids<br>    }<br>  }<br><br>  file_system_config {<br>    arn              = var.efs_access_point_arn<br>    local_mount_path = &quot;/mnt/efs&quot;<br>  }<br>}</pre><h4>Source Code</h4><p>As shown below, the Lambda function code handles file transfers from S3 to EFS. It includes a retry mechanism to handle potential download failures from S3. The function downloads files to a temporary directory, ensures the EFS directory structure exists, and then copies the files from the temporary directory to EFS.</p><pre>import boto3<br>import os<br>import shutil<br>import time<br>import urllib.parse<br><br>s3 = boto3.client(&#39;s3&#39;)<br><br># Set the EFS mount path<br>efs_mount_path = &#39;/mnt/efs&#39;<br><br>def download_file_with_retries(bucket, key, download_path, retries=10, delay=5):<br>    for attempt in range(retries):<br>        try:<br>            # Ensure the key is properly encoded<br>            key = urllib.parse.unquote_plus(key)<br>            s3.head_object(Bucket=bucket, Key=key)  # Check if the object exists<br>            s3.download_file(bucket, key, download_path)<br>            print(f&quot;Successfully downloaded {key} on attempt {attempt + 1}&quot;)<br>            return<br>        except s3.exceptions.NoSuchKey:<br>            print(f&quot;Attempt {attempt + 1} failed: S3 object {key} not found&quot;)<br>            time.sleep(delay)<br>        except Exception as e:<br>            print(f&quot;Attempt {attempt + 1} failed with error: {str(e)}&quot;)<br>            time.sleep(delay)<br>    raise Exception(f&quot;Failed to download S3 object {key} after {retries} attempts&quot;)<br><br>def lambda_handler(event, context):<br>    print(f&quot;Received event: {event}&quot;)<br>    try:<br>        start_time = time.time()<br>        for record in event[&#39;Records&#39;]:<br>            bucket = record[&#39;s3&#39;][&#39;bucket&#39;][&#39;name&#39;]<br>            key = record[&#39;s3&#39;][&#39;object&#39;][&#39;key&#39;]<br><br>            print(f&quot;Processing file: s3://{bucket}/{key}&quot;)<br><br>            # Download the file from S3 to the /tmp directory<br>            tmp_path = f&#39;/tmp/{os.path.basename(key)}&#39;<br>            download_file_with_retries(bucket, key, tmp_path)<br>            print(f&quot;File downloaded to /tmp: {tmp_path}&quot;)<br><br>            # Ensure the EFS directory exists<br>            efs_dir = os.path.dirname(os.path.join(efs_mount_path, key))<br>            if not os.path.exists(efs_dir):<br>                os.makedirs(efs_dir)<br>                print(f&quot;Created EFS directory: {efs_dir}&quot;)<br><br>            # Copy the file from /tmp to EFS<br>            destination_path = os.path.join(efs_mount_path, key)<br>            shutil.copy(tmp_path, destination_path)<br>            print(f&quot;File copied to EFS: {destination_path}&quot;)<br><br>            elapsed_time = time.time() - start_time<br>            print(f&quot;Time taken to process {key}: {elapsed_time:.2f} seconds&quot;)<br><br>    except Exception as e:<br>        print(f&quot;Error: {str(e)}&quot;)<br><br>    print(&#39;File processing completed&#39;)</pre><h4>EC2 Instance</h4><p>The EC2 instance doesn’t serve any vital purpose in the flow but allows us to confirm that the files have been transferred successfully. Looking below, the file system is mounted on the EC2 instance where we can view all files.</p><pre># Select a random subnet from the list of public subnets<br>locals {<br>  random_subnet_id = element(var.public_subnet_ids, 0)<br>}<br><br># EC2 Instance<br>resource &quot;aws_instance&quot; &quot;test_server&quot; {<br>  ami                         = var.ami_id #Amazon Linux 2023 AMI 2023.5.20240708.0 x86_64 HVM kernel-6.1<br>  instance_type               = var.instance_type<br>  associate_public_ip_address = true<br>  subnet_id                   = local.random_subnet_id<br>  security_groups             = [var.ec2_security_group_ids]<br>  # EBS Block Device Mapping<br>  root_block_device {<br>    volume_size = 16<br>    volume_type = &quot;gp3&quot;<br>  }<br>  user_data = &lt;&lt;-EOF<br>    #!/bin/bash<br>    sudo mkdir efs<br>    sudo yum install -y amazon-efs-utils<br>    sudo mount -t efs -o tls,accesspoint=&quot;${var.efs_access_point_id}&quot; &quot;${var.efs_file_system_id}&quot;:/ efs<br>  EOF<br>    }</pre><h4>Root module</h4><p>In the root module, main.tf coordinates the deployment of the entire infrastructure by invoking various submodules for VPC, security groups, IAM roles, EFS, S3, Lambda, and EC2 instances. It specifies dependencies among these components to ensure a smooth and ordered deployment process. This centralized management simplifies the setup, ensuring all resources are correctly provisioned and integrated.</p><pre>module &quot;vpc&quot; {<br>  source       = &quot;./modules/vpc&quot;<br>  project_name = var.project_name<br>  vpc_cidr     = var.vpc_cidr<br>}<br>module &quot;security_groups&quot; {<br>  source     = &quot;./modules/security-groups&quot;<br>  vpc_id     = module.vpc.vpc_id<br>  vpc_cidr   = var.vpc_cidr<br>  depends_on = [module.vpc]<br>}<br>module &quot;iam&quot; {<br>  source               = &quot;./modules/iam&quot;<br>  s3_bucket_arn        = module.s3.s3_bucket_arn<br>  efs_access_point_arn = module.efs.efs_access_point_arn<br>  depends_on = [module.s3, module.efs]<br>}<br>module &quot;efs&quot; {<br>  source            = &quot;./modules/efs&quot;<br>  public_subnet_ids = module.vpc.public_subnet_ids<br>  efs_sg_id         = module.security_groups.efs_security_group_ids<br>  depends_on        = [module.vpc]<br>}<br>module &quot;s3&quot; {<br>  source         = &quot;./modules/s3&quot;<br>  vpc_id         = module.vpc.vpc_id<br>  route_table_id = module.vpc.public_route_table_id<br>  depends_on     = [module.vpc]<br>}<br>module &quot;lambda&quot; {<br>  source                    = &quot;./modules/lambda&quot;<br>  public_subnet_ids         = module.vpc.public_subnet_ids # List of subnet IDs<br>  efs_access_point_arn      = module.efs.efs_access_point_arn<br>  lambda_security_group_ids = module.security_groups.lambda_security_group_ids<br>  s3_bucket_arn             = module.s3.s3_bucket_arn<br>  lambda_role_arn           = module.iam.lambda_role_arn<br>  s3_bucket_id              = module.s3.s3_bucket_id<br>  depends_on                = [module.efs, module.iam, module.s3]<br>}<br><br>module &quot;ec2&quot; {<br>  source                 = &quot;./modules/ec2&quot;<br>  ec2_security_group_ids = module.security_groups.ec2_security_group_id<br>  public_subnet_ids      = module.vpc.public_subnet_ids<br>  ami_id                 = var.ami_id<br>  instance_type          = var.instance_type<br>  depends_on = [ module.vpc,module.efs ]<br>}</pre><h4>Testing the solution</h4><p>Drop an item into the S3 bucket</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EDPb-NfWHuF_GOlPqU2NqA.png" /><figcaption>Upload an object into the bucket</figcaption></figure><p>Once an object is dropped, the S3 event invokes the lambda function which then copies the file to the EFS file system, as you would see in the Cloudwatch logs below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V9_ecXu71Lg6EI9pTjGDDA.png" /><figcaption>Cloudwatch logs</figcaption></figure><p>The image below shows the uploaded file in the mounted directory</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/747/1*tn1qVSoE_AreBU1BihTF3A.png" /><figcaption>received file on EC2</figcaption></figure><p>This entire flow takes milliseconds to complete. Though it works, it may have some limitations, which I will be sharing in another blog.</p><h4>Use Cases</h4><p>Content Management: Automatically transfer media files from S3 to EFS for access by CMS on EC2 instances.<br>Data Lake Integration: Move raw data from S3 to EFS for processing by data analytics applications.<br>Machine Learning: Transfer training datasets from S3 to EFS for use by machine learning models on EC2 instances.<br>Backup and Recovery: Use EFS as a backup for critical data stored in S3.<br>Log Aggregation: Automatically move logs from S3 to EFS for aggregation and analysis.</p><h4>Conclusion</h4><p>Using AWS Lambda to automate file transfers from Amazon S3 to Amazon EFS offers a scalable and efficient solution for managing data workflows in the cloud. As read from above, this setup leverages the strengths of S3 for storage and EFS for scalable, shared access. By following this guide and the provided Terraform configuration, you can streamline your data flow, enhancing your cloud infrastructure’s efficiency and reliability. Once again, check out my <a href="https://github.com/thebigstevo/s3-lambda-efs/tree/main">GitHub</a> to find the entire terraform code.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5a12535449b9" width="1" height="1" alt=""><hr><p><a href="https://awstip.com/streamlining-data-flow-aws-s3-to-efs-using-lambda-5a12535449b9">Streamlining Data Flow: AWS S3 to EFS Using Lambda</a> was originally published in <a href="https://awstip.com/">AWS Tip</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Conquering the Cloud: My Journey to GCP Architect Certification]]></title>
            <link>https://medium.com/@ssomuahk/conquering-the-cloud-my-journey-to-gcp-architect-certification-dd26e7d0624a?source=rss-2b7be465b232------2</link>
            <guid isPermaLink="false">https://medium.com/p/dd26e7d0624a</guid>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[gcp-certification]]></category>
            <dc:creator><![CDATA[Stephen Somuah]]></dc:creator>
            <pubDate>Thu, 09 May 2024 23:27:24 GMT</pubDate>
            <atom:updated>2024-05-09T23:39:50.173Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*aUvpgXJIrd6Hj5tPrkS4Wg.png" /></figure><p>Cloud technology is on the rise, and as someone passionate about IT, I wanted to jump in. As I mentioned <a href="https://medium.com/@ssomuahk/my-cloud-journey-the-solutions-architect-associate-exam-68f77f00f98c">here</a>, AWS, the big player with the most services, seemed like the natural choice. But fate had other plans. My work opened doors to both AWS and Google Cloud Platform (GCP), and I dove headfirst into building cutting-edge solutions with both platforms.</p><p>GCP’s potential sparked a curiosity. Could I validate my knowledge by becoming a certified GCP Architect? The challenge was on!</p><p><strong>Training: A Steeper Climb than Expected</strong></p><p>The official training kicked off with a weekly virtual session, followed by hands-on labs on Qwiklabs. This prepared me for the next stage: 10 weeks of intensive training with 6 lab topics. Each topic came with step-by-step labs, culminating in a final “challenge lab” with minimal guidance. Let me tell you, those challenges were aptly named! You had to produce a specific result with limited instructions — a real test of your skills.</p><p>Out of the 6 challenges, completing 5 qualified you for an exam voucher. I conquered 5, but the 6th one remained elusive. Numerous attempts later, I had to accept defeat. But 5 out of 6 wasn’t bad! It was enough to secure my voucher and a shot at the official exam.</p><p>Outside the training, I also set up a GCP account and practised some labs with more freedom using the $300 trial credit provided by Google.</p><p><strong>Exam Prep: From Fumbling to Focused</strong></p><p>With a voucher in hand, I booked my exam 4 weeks out. Time to buckle down! I enrolled in a GCP practice exam with 5 sets of 65-question tests. If you don’t mind, you can check it out <a href="https://www.udemy.com/course/google-professional-cloud-architect-gcp-pca-exams/?couponCode=JUST4U02223">here</a>. Yeah, it costs some money, but my company funded it. The first attempt was a reality check — a score of 60 revealed significant knowledge gaps. But hey, that’s what practice exams are for! I used this to pinpoint my weak areas.</p><p>Next step: a comprehensive GCP architect course, again on Udemy, found <a href="https://www.udemy.com/share/104qEo3@SEw7Fqw58OjHxFZRG38ZQz10YHLNL0SVf6bL9LByRxkpfLTQJF5o9bwvkLUH5pU8/">here</a>. This covered every single topic in detail. I devoured the course content, focusing heavily on my weaknesses. Feeling more confident, I went back to the practice exam — only to score even lower! Discouraged but determined, I reviewed the first set of questions thoroughly, analyzing the answers and explanations. I repeated this process for each set, gradually solidifying my understanding. Finally, the last set arrived. This time, I aced it with an 85%!</p><p>With the exam just around the corner, I decided to take a break, recharge, and head into the test hall with a clear mind.</p><p><strong>Exam Day: Scenario-Based Challenges and a Kubernetes Test</strong></p><p>The whispers on the web were true — the first 10 questions were all scenario-based, drawing on the Google-provided case studies. The rest tested my grasp of a wide range of GCP services and how they work together to deliver the best solution. Here’s a tip: the elimination method can be your friend for some questions. But beware, some were tough calls! And remember, Google loves Kubernetes (GKE), so expect a healthy dose of GKE questions in the mix.</p><p><strong>Beyond the Exam: Putting My Skills to Work</strong></p><p>Thankfully, my company entrusted me with a project involving a GCP-using client. I’m excited to leverage these newfound skills to make a real impact. And here’s a challenge I’ve set for myself: replicating existing AWS architectures on GCP. The learning curve promises to be fun, and I can’t wait to share my experience with you all!</p><p>Not to brag, but <a href="https://www.credly.com/badges/2d54e220-6313-4e66-ac00-0c7bc52ed94c/public_url">here is my credly badge</a> for this certification</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dd26e7d0624a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Solving the ‘Exceeded File Size Limit’ Error in Terraform with Github]]></title>
            <link>https://medium.com/@ssomuahk/solving-the-exceeded-file-size-limit-error-in-terraform-with-github-ac5698ab58a4?source=rss-2b7be465b232------2</link>
            <guid isPermaLink="false">https://medium.com/p/ac5698ab58a4</guid>
            <dc:creator><![CDATA[Stephen Somuah]]></dc:creator>
            <pubDate>Tue, 31 Jan 2023 19:47:39 GMT</pubDate>
            <atom:updated>2023-01-31T19:47:39.379Z</atom:updated>
            <content:encoded><![CDATA[<p>Terraform is a popular tool among DevOps professionals, but running it locally can sometimes lead to challenges. One of the most common issues is encountering an error message when attempting to push code to Github.</p><pre>remote: error: File .terraform/providers/registry.terraform.io/hashicorp/aws/4.52.0/windows_amd64/terraform-provider-aws_v4.52.0_x5.exe<br> is 326.16 MB; this exceeds GitHub&#39;s file size limit of 100.00 MB<br>The error message indicates that a file size limit has been exceeded and can be frustrating, especially after completing the work.</pre><p>The error message typically pops up after sending the git push command. To resolve this issue, the following steps can be taken:</p><ol><li>Use the following Git command: git filter-branch -f --index-filter &#39;git rm --cached -r --ignore-unmatch .terraform/.</li><li>Follow it up with git push --force.</li></ol><p>Let’s take a closer look at the first command. The git filter-branch command is used to rewrite the branch history of a repository, and the -f option forces the rewrite, even if the resulting branch history would contain duplicate commits. The --index-filter option specifies the shell command to modify the index (staging area) of each visited branch.</p><p>The git rm command is used to remove files from the Git repository. The --cached option means to remove the file only from the Git index, not from the local file system. The -r option tells git rm to operate on directories recursively. The --ignore-unmatch option makes git rm return an exit status of 0 even if the specified file is not in the Git repository.</p><p>The second command git push --forceforces the remote repository to be replaced with the contents of the local repository.</p><p>By using these commands, DevOps practitioners can overcome the error and successfully push their code to Github. This solution is a straightforward way to resolve a common challenge encountered when working with Terraform and Github. With this information, DevOps professionals can continue with their work without any further interruptions or delays.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ac5698ab58a4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Install Git Gui on Ubuntu]]></title>
            <link>https://medium.com/@ssomuahk/install-git-gui-on-ubuntu-40f43fe39519?source=rss-2b7be465b232------2</link>
            <guid isPermaLink="false">https://medium.com/p/40f43fe39519</guid>
            <dc:creator><![CDATA[Stephen Somuah]]></dc:creator>
            <pubDate>Fri, 27 Jan 2023 15:10:07 GMT</pubDate>
            <atom:updated>2023-01-27T15:10:07.593Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DVcI2tqIfQasfmzELWQJOQ.png" /><figcaption>Git Gui</figcaption></figure><p>Git is an essential tool for developers and DevOps engineers. Commonly used commands include “add”, commit, “push”, and “pull”. For remote and distributed teams, branching and merging are also important.</p><p>During a recent refresher training on Git, I discovered a tool called Git Gui, which provides a graphical user interface for visualizing branches and commit history.</p><p>It’s worth remembering that there are other alternatives to Git Gui like GitKraken, GitLab, SourceTree, etc</p><p>To install Git Gui on Ubuntu, follow these steps:</p><ol><li>Open the terminal</li><li>Type in “sudo apt-get install git-gui” and press enter. You may be prompted to enter your password.</li><li>Verify the installation by typing “git citool” or “git gui” in the terminal.</li></ol><p>And that’s it!</p><p>Enjoy working with Git using the Git Gui tool for an easy and intuitive experience.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=40f43fe39519" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Convert .ppk to .pem in Linux]]></title>
            <link>https://medium.com/@ssomuahk/convert-ppk-to-pem-in-linux-6dff1cb22dbc?source=rss-2b7be465b232------2</link>
            <guid isPermaLink="false">https://medium.com/p/6dff1cb22dbc</guid>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[devops]]></category>
            <dc:creator><![CDATA[Stephen Somuah]]></dc:creator>
            <pubDate>Thu, 29 Sep 2022 12:07:33 GMT</pubDate>
            <atom:updated>2022-09-29T12:07:33.425Z</atom:updated>
            <content:encoded><![CDATA[<h3>Convert .ppk to .pem in Linux</h3><p>PPK and PEM files are file formats used in Public Key Infrastructure (PKI) and are used for keys and certificates. They are needed to ensure secure remote connections to your servers and other services. This post primarily talks about connections to remote servers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*lW9AgDiTREHG3oidV-4oFw.png" /></figure><p>PEM stands for Privacy Enhanced Mail. The name sounds strange in this context, right? It was invented to ensure email privacy many years ago. PEM files are used in PowerShell, Mac and Linux environments</p><p>PPK stands for Putty Private Key. Putty is an SSH client used to make remote connections in Microsoft Windows. PPK is used by an SSH client called Putty in windows environments.</p><p>It is therefore imperative to convert a .ppk or .pem file to the appropriate format in order to use it.</p><p>In Windows, converting .ppk to .pem and vice versa is a straightforward procedure when using a simple application called PuTTyGen. This goal can also be accomplished with a few commands in Linux.</p><p>The steps below provide a simple way to convert a .ppk to .pem in Linux -Ubuntu</p><p>Step 1</p><pre>apt-get install putty-tools</pre><p>Step 2</p><p>Do the conversion by using the PuTTyGen command line tool like below.</p><pre>puttygen mykey.ppk -O private-openssh -o mykey.pem</pre><p>Step 3</p><p>For security purposes, change the permission to read-only for the user. You know, the key is private for a reason. Some servers may not allow access if you don’t do this</p><pre>chmod 400 mykey.pem</pre><p>Step 4</p><p>Connect to your server</p><pre>ssh -i &quot;mykey.pem&quot; user@serverdnsname</pre><p>I created a script to save you time from copying and pasting. Check it out from my <a href="https://github.com/devksom/bash_scripts.git">GitHub</a>.</p><p>Thanks for reading.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6dff1cb22dbc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[My Cloud Journey-The Solutions Architect Associate Exam]]></title>
            <link>https://medium.com/@ssomuahk/my-cloud-journey-the-solutions-architect-associate-exam-68f77f00f98c?source=rss-2b7be465b232------2</link>
            <guid isPermaLink="false">https://medium.com/p/68f77f00f98c</guid>
            <category><![CDATA[aws-solutions-architect]]></category>
            <category><![CDATA[aws-certification]]></category>
            <category><![CDATA[cissp-certification]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Stephen Somuah]]></dc:creator>
            <pubDate>Fri, 02 Sep 2022 05:39:08 GMT</pubDate>
            <atom:updated>2022-09-02T12:07:48.800Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/810/1*S-6r9blVeY6BNTU8Ikflng.png" /></figure><p>The cloud industry continues to grow at an accelerated pace and I didn’t want to be left out. I therefore, decided to start my cloud journey with AWS since it has the largest market share in the cloud industry. I look forward to becoming a Cloud security specialist in the next few years.</p><p>I started with the cloud practitioner certification a couple of months back, and so far, the journey is going as planned. I went on to pass the AWS Solutions architect associate on the first attempt after three months of preparation. I kept hearing everyone talking about a 72% failure rate, which meant only 28% of those who wrote the Solutions architect exam were able to pass. That’s an incredibly scary statistic.</p><p>This statistic wasn’t new to me because I recall seeing something similar while preparing for my CISSP exam a few years ago. At that time, the CISSP exam consisted of 250 questions to be written in 6 hours, which I managed to write and pass on the first attempt. I had to replicate the plan I used to pass the CISSP exam for my Solutions architect associate exam.</p><h3>Set a Goal</h3><p>As a security professional, my ultimate goal in the next 5 years is to be a security specialist. To achieve this goal, I plan to land a remote role to accelerate this journey. With this in mind, I did a lot of reading online, watched youtube videos about AWS, and followed influencers who tweet or write about AWS on Linkedin. This put me in the mood to thirst for more.</p><h3>Learn From Others</h3><p>To get the best preparation, I did a lot of research online. I watched youtube videos and read blogs about what others did to pass their exams. Interestingly, I also saw videos of people who failed on their first attempt. Big lessons were learnt from these resources. I took the tips that worked for me and implemented them. In the same way, you don’t have to follow everything I have written here word for word since some of my recommendations may not work for you.</p><h3>Join A Community</h3><p>If you have the opportunity, join a study community. I was fortunate to be part of a community of learners called <a href="https://www.azubiafrica.org/">Azubi Africa</a>. They had instructors who had passed the solutions architect exams and were in a better position to steer us in the right direction. The community was vibrant as well, as I met people from various parts of my country and other African countries such as Kenya, Uganda, Tanzania, Nigeria, and Rwanda, etc. It’s fascinating how close we’ve all become through technology. Each member of the community had their own goals and were all convinced that the solutions architect associate certification was the surest way to achieve them.</p><h3>Read, Watch and Practice</h3><p>There are several materials online. Youtube, Udemy, and Whizlabs were my source for video tutorials. One important thing about your choice of materials is to ensure they are curated for the course at hand. Using unstructured materials can be so overwhelming and may throw you off your path. AWS white papers and FAQs are incredible sources of information when you need further explanations.</p><p>For practising, I had access to the Whizlabs lab environment which was provided by Azubi Africa. It gives you hands-on knowledge about the service you are learning about. It was a great resource, but my problem with it is the time limit for the labs. This is not a problem with Whizlabs, but a general issue with almost all other labs. I do understand the motive behind it so I can’t fault them. There is little time to understand what you are doing, so you end up following instructions till you meet the objective of the lab within the allotted time. Due to this, I used my AWS free tier account which I created while preparing for my cloud practitioner exam to practice more without time constraints. I had enough time to read more about why I am clicking a button or selecting a checkbox.</p><h3>Mindset</h3><p>All the solutions architect questions were scenario based, which meant that just reading about the services wasn’t enough. I needed to know how they were used in various use cases.</p><p>The CISSP questions were crafted the same way, so I had to recall how I went about that. “To pass a CISSP exam, one has to think like a CISSP”. Some of the multiple choice answers made so much sense, but aren&#39;t correct if you look at them from the CISSP’s perspective. I had to employ this same strategy for my solutions architect associate preparation. What do I mean by this?</p><p>The solutions architect associate exam is based on the 6 pillars of the Well architected framework. These are <em>Operational Excellence, security, reliability, cost optimization, sustainability, and performance efficiency. </em>Always have these pillars in mind and identify them when reading or watching tutorials.</p><h3>Schedule Your Exam</h3><p>Once the battle lines are drawn, you know what is at stake and would therefore prepare for it. I scheduled my exam and decided to work towards it. This brought in more urgency. I noticed the difference in my preparation before and after I scheduled the exam. I woke up at 3 am to practice one set of practice exams before setting off for work. when I returned in the evening, I spent two hours reviewing the test I did. That was my plan, and I was committed to it.</p><h3>Practice Exam</h3><p>Practice tests are not meant for you to pass and make you feel good about yourself. They are meant to bring out your weaknesses early so that you don’t have to exhibit these weaknesses on exam day. Reserve that 100% for the final exam. I had this mindset when I wrote my CISSP and didn’t regret it.</p><p>After each practice test, I went through all the wrong answers and read about why the wrong answers are wrong and why the right answers are right. After that, I went through the ones I had right. I knew I had guessed some of the questions I had right, hence the need to review them all.</p><p>One material that helped me was <a href="https://www.udemy.com/share/1064nS3@niGSEev9Wj6-chffvgHD0mK0ts6PLkFM-ErZalK_RKO-REiLaC6MTqa1mLPaNKah/">Jon Bonso’s practice exams on Udemy</a> and tutorial dojo. For this material, there are six sets of questions with well-explained answers. I preferred that to the questions on Whizlabs mainly due to how it was organised.</p><blockquote>A quick tip for using the practice test is not to go back to solve the questions you just reviewed. Move on to the next set of questions and return to the reviewed questions some days later. This will help give a clear picture of whether you understood the concepts or you just memorized the answer.</blockquote><p>John Bonso’s questions weren’t easy, but the practice test questions on Whizlabs were more difficult. After attempting all 6 sets of tests two times, I scored a minimum of 85 and used the newly acquired knowledge to attempt the Whizlabs practice tests. I must say my confidence went over the roof after I began getting good scores on the Whizlabs tests. 3 days before my exam, I felt ready and therefore took a break from answering questions to skim my handwritten notes.</p><p>Time management is important. I usually solved all 65 questions in 90 minutes. You should plan along these lines.</p><h3>Topics</h3><p>I would be doing you a great disservice if I told you the topics I met in my exam. This is because I discussed with two other colleagues what they met and it seemed they wrote an entirely different exam.</p><p>My tip is that you read about all the services you encounter in your curated tutorial.</p><p>Do not take anything for granted. Spend more time on the commonly used services. Identify the use cases of the given question; does the client want a highly available solution, a cost-effective one or both? Does the client want a solution with the least overhead? The criticality of a workload determines the kind of disaster recovery measures to put in place. One interesting tip I found during my preparation was the difference between managed and fully managed services. These are some of the scenarios you will encounter in your practice tests. Look out for keywords, while reading the questions and try to come up with your answer before going through the possible answers.</p><p>Also, get your fundamentals right. When I speak of fundamentals, I am talking about networking, subnetting, TCP IP, basic IT security, and the like. Once you grasp these concepts, the rest will be easy for you.</p><h3>The D Day</h3><p>I prefer to write my exams in the morning because there is less chance of any incident causing distraction. Time management is essential when you are writing. If you meet a troublesome question, select an answer, flag it, and move on. It is better to guess an answer than leave it blank. When you get to the last question, there will be enough time to review the flagged questions. I got to my final question in 70 minutes and spent the rest of my time reviewing my flagged questions.</p><p>The anxious part of this whole exam was the 24-hour wait to get my results. I knew I had put in so much and needed to pass so badly. Thankfully, all my work had paid off.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/810/1*wDH_kDfzE1PWmZJ2KCB82Q.jpeg" /></figure><h3>Conclusion</h3><p>One of the core values I picked up at Azubi Africa is <strong>Progressive Learning Attitude. </strong>We can all grow by maintaining a consistent learning attitude through knowledge sharing, open-mindedness &amp; exploration. I hope to keep up my learning attitude and share my knowledge with all in the coming weeks.</p><p>All the best to you if you are preparing for your exam.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=68f77f00f98c" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>