<?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 Alphonsinelahda on Medium]]></title>
        <description><![CDATA[Stories by Alphonsinelahda on Medium]]></description>
        <link>https://medium.com/@alphonsinelahda?source=rss-c7bfcc1ba4b6------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*ziNTghnQBdYmTdQT</url>
            <title>Stories by Alphonsinelahda on Medium</title>
            <link>https://medium.com/@alphonsinelahda?source=rss-c7bfcc1ba4b6------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 23:55:54 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@alphonsinelahda/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[Building Secure Inter-VPC communication with AWS PrivateLink: A Complete implementation guide.]]></title>
            <link>https://medium.com/@alphonsinelahda/building-secure-inter-vpc-communication-with-aws-privatelink-a-complete-implementation-guide-38a52dda7f27?source=rss-c7bfcc1ba4b6------2</link>
            <guid isPermaLink="false">https://medium.com/p/38a52dda7f27</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[aws-network]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[aws-privatelink]]></category>
            <dc:creator><![CDATA[Alphonsinelahda]]></dc:creator>
            <pubDate>Tue, 24 Nov 2026 09:30:59 GMT</pubDate>
            <atom:updated>2026-11-24T09:30:59.781Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Introduction</strong></h3><p>Cloud beginners often imagine that connecting applications across VPCs requires complex networking setups, public endpoints, or layers of VPN and routing rules, in reality, most internat services do not neeed to to touch the internet at all. They simply need a secure and private way to talk to each other.</p><p>This is exactly where <strong>AWS PrivateLink</strong> shines. it gives you a private, one-way connection from one VPC to a single servie in another VPC, even when they belong to different teams, departments, or AWS accounts, without exposing a single public IP. No open ports to the world. No attack surface. No peering headaches.</p><p>In this tutorial, we build the entire architecture as code with <strong>Terraform</strong>, with no manual clicks in the console. One terraform apply creates both VCPs, the FastAPI service, the Network Load Balancer, the endpoint service and the interface endpoint, and even approves the connection. one terraform destroy removes it all.</p><p>The goal stays the same: a <strong>provider VPC</strong> hosts an internal FastAPI service, and a <strong>consumer VPC</strong> (the analytics environment) reaches it privately through PrivateLink. If you follow this guide, you will understand one of the most important security patterns in modern AWS architecture, and you will have it as reusable code.</p><h4>AWS services and resources used</h4><p>Everything below is created by terraform in a single terraform apply.</p><ul><li><strong>Amazon VPC:</strong> 2 isolated networks, <strong>VPC-IT-Production</strong> fo the provider and <strong>VPC-Analytics</strong> for the consumer.</li><li><strong>Subnets:</strong> private subnets in 2 availability zones for the provider; a public and a private subnet for the consumer.</li><li><strong>Security groups:</strong> control traffic on port 80 between the analytics client, the endpoint and the FasAPI instances.</li><li><strong>Amazon EC2:</strong> runs the FastAPI service in the provider VPC and the analytics client in the consumer VPC.</li><li><strong>Network Load Balancer (internal):</strong> distributes traffic to the FastAPI instances; required to create an endpoint service.</li><li><strong>VPC Endpoint Service:</strong> publish the NLB as a private service through PrivateLink.</li><li><strong>Interface VPC Endpoint:</strong> creates a private network interface in the consumer VPC that leads to the service.</li><li><strong>Endpoint connection acceptance:</strong> approves the consumer’s connection request, directly in Terraform.</li></ul><h3>Context</h3><p>Imagine a company running its production applications in a secure VPC. Another department (analytics) needs to consume a specific internal API. You do not want to:</p><ul><li>Expose the API to the internet</li><li>Use VPC Peering, which opens routing between the 2 entire CIDR ranges</li><li>Build and maintain a VPC or a Transit Gateway for a single API call</li></ul><p>PrivateLink gives you <strong>a point-to-point, least-privilege network tunnel, </strong>automatically encrypted and isolated from the public world. And the consumer can reach only the service you publish, nothing else in your VPC</p><p>This is why Privatelink matters:</p><p>You expose <strong>only one service,</strong> not your whole VPC.</p><h3>What we are Building?</h3><p>Our architecture will include:</p><h4>1. VPC Provider</h4><ul><li>Hosts the <strong>FastAPI service</strong> (port 80)</li><li>Exposed internally via <strong>Network Load Balancer (NLB)</strong></li><li>Published a <strong>VPC Endpoint service </strong>based on the NLB</li></ul><p><strong>Role: </strong>provide the API securely.</p><h4>2. VPC Consumer</h4><ul><li>Hosts the analytics application</li><li>Create an <strong>Interface VPc Endpoint </strong>to connect to the provider’s API</li><li>Gets a private ENI (Elastic Network Interface) with a private IP</li></ul><p><strong>Role:</strong> Consume the API without internet exposure.</p><h4>3. AWS PrivateLink</h4><ul><li>Secure, private connectivity</li><li>No routing changes, no CIDR overlap issues</li><li>Only the service you expose is reachable.</li></ul><p><strong>Role:</strong> transport layer for private communication</p><h3><strong>Solution Architecture</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-0YKlSiXlh2WcILOIGSodQ.png" /><figcaption><strong>AWS PrivateLink</strong></figcaption></figure><h4>Why Terraform instead of the console?</h4><p>The console is great for learning, but a PrivateLink setup has many moving parts: 2 VPCs, subnets, route tables, security groups, EC2, an NLB with its target group and listener, an endpoint service, an endpoint and a connection approval. Miss one checkbox and you spend an hour debbuging a timeout.</p><p>With terraform:</p><ul><li><strong>Reproductible:</strong> the same code gives the same architectures, in any account or region.</li><li><strong>Reviewable:</strong> every security group rule is visible in a pull request.</li><li><strong>Ordered:</strong> Terraform builds the dependency graph for you (NLB before endpoint service, endpoint service before endpoint)</li><li><strong>Disposable:</strong> terraform destroy removes everything, so the lab costs you nothing when you are not using it.</li></ul><p>Project structure</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/352/1*4ZG3Gq4gpfyxBGuW_AyABg.png" /></figure><p>The full source code is available on GitHub: <a href="http://GitHub Rep PrivateLink-Infra">https://github.com/lahda/PrivateLink-Infra</a></p><h3>Step-by-Step Implementation</h3><p>Bellow is the exact manual setup using the AWS Console.</p><h4>Step 1: create the VPC Provider</h4><ol><li>1. <strong>Create a VPC</strong></li></ol><ul><li>Name: <strong>VPC-IT-Production</strong></li><li>CIDR:<strong> 10.0.0.0/16</strong></li></ul><pre>resource &quot;aws_vpc&quot; &quot;provider&quot; {<br>  cidr_block           = var.vpc_provider_cidr<br>  enable_dns_hostnames = true<br>  enable_dns_support   = true<br><br>  tags = merge(<br>    local.common_tags,<br>    {<br>      Name       = &quot;VPC-IT-Production&quot;<br>      Department = &quot;IT&quot;<br>      Type       = &quot;Provider&quot;<br>    }<br>  )<br>}</pre><ol><li><strong>2. Create 2 privates subnets (AZ a &amp; b)</strong></li></ol><ul><li>10.0.1.0/24</li><li>10.0.2.0/24</li></ul><pre>resource &quot;aws_subnet&quot; &quot;provider_private&quot; {<br>  count             = 2<br>  vpc_id            = aws_vpc.provider.id<br>  cidr_block        = cidrsubnet(var.vpc_provider_cidr, 8, count.index + 1)<br>  availability_zone = local.azs[count.index]<br><br>  tags = merge(<br>    local.common_tags,<br>    {<br>      Name = &quot;Provider-Private-Subnet-AZ${count.index + 1}&quot;<br>      Tier = &quot;Private&quot;<br>      AZ   = local.azs[count.index]<br>    }<br>  )<br>}</pre><ol><li><strong>3. Create a Security Group for the FastAPI service</strong></li></ol><p>Allow:</p><ul><li>Inbound port 80 (from local VPC only)</li><li>Outbound all</li></ul><pre>resource &quot;aws_security_group&quot; &quot;provider_api&quot; {<br>  name        = &quot;SG-API-Servers-IT&quot;<br>  description = &quot;Security group for API backend servers&quot;<br>  vpc_id      = aws_vpc.provider.id<br><br>  tags = merge(<br>    local.common_tags,<br>    {<br>      Name = &quot;SG-API-Servers-IT&quot;<br>    }<br>  )<br>}</pre><ol><li><strong>4. Deploy EC2 with FastAPI</strong></li></ol><p>Your FastAPI app listens on port 80.</p><p>Paste this provided code in your EC2 userdata:</p><pre>#!/bin/bash<br>exec &gt;&gt; /var/log/techcorp-api-install.log 2&gt;&amp;1<br><br># Debug info: injected variables from Terraform<br>echo &quot;LogGroup=${log_group_name} Region=${region}&quot;<br>mkdir -p /opt/techcorp-api<br>cat &gt; /opt/techcorp-api/app.py &lt;&lt; &#39;EOFAPP&#39;<br>import datetime<br>import json<br>import socket<br>from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer<br>from urllib.parse import parse_qs, urlparse<br><br>TRANSACTIONS_DB = [<br>    {&quot;id&quot;: &quot;TXN-001&quot;, &quot;client&quot;: &quot;ClientA&quot;, &quot;montant&quot;: 15000, &quot;statut&quot;: &quot;validé&quot;, &quot;date&quot;: &quot;2025-11-15&quot;},<br>    {&quot;id&quot;: &quot;TXN-002&quot;, &quot;client&quot;: &quot;ClientB&quot;, &quot;montant&quot;: 28500, &quot;statut&quot;: &quot;en cours&quot;, &quot;date&quot;: &quot;2025-11-16&quot;},<br>    {&quot;id&quot;: &quot;TXN-003&quot;, &quot;client&quot;: &quot;ClientC&quot;, &quot;montant&quot;: 42000, &quot;statut&quot;: &quot;validé&quot;, &quot;date&quot;: &quot;2025-11-17&quot;},<br>    {&quot;id&quot;: &quot;TXN-004&quot;, &quot;client&quot;: &quot;ClientD&quot;, &quot;montant&quot;: 9800, &quot;statut&quot;: &quot;validé&quot;, &quot;date&quot;: &quot;2025-11-18&quot;},<br>]</pre><ol><li><strong>5. Create a Network Load balancer</strong></li></ol><ul><li><strong>Type:</strong> internal</li><li>Subnets: 2 private subnets</li><li>Target group: your FastAPI service (EC2)</li></ul><pre>resource &quot;aws_lb&quot; &quot;provider&quot; {<br>  name               = &quot;${var.project_name}-nlb&quot;<br>  internal           = true<br>  load_balancer_type = &quot;network&quot;<br>  subnets            = aws_subnet.provider_private[*].id<br><br>  enable_deletion_protection       = var.enable_deletion_protection<br>  enable_cross_zone_load_balancing = true<br><br>  tags = merge(<br>    local.common_tags,<br>    {<br>      Name = &quot;NLB-IT-PrivateLink&quot;<br>    }<br>  )<br>}</pre><ol><li><strong>6. Create the VPC Endpoint Service</strong></li></ol><ul><li>Go to: VPC-&gt;Endpoint Services-&gt;Create</li><li>Select Your NLB</li><li>Enable <strong>Acceptance Required</strong> (recommended)</li></ul><p>You now expose your API privately to approved consumers.</p><pre>resource &quot;aws_vpc_endpoint_service&quot; &quot;api&quot; {<br>  acceptance_required        = var.endpoint_acceptance_required<br>  network_load_balancer_arns = [aws_lb.provider.arn]<br><br>  # The consumer account must always be allowed, otherwise the endpoint cannot be created<br>  allowed_principals = [<br>    &quot;arn:aws:iam::${data.aws_caller_identity.current.account_id}:root&quot;<br>  ]<br><br>  tags = merge(<br>    local.common_tags,<br>    {<br>      Name = &quot;PrivateLink-TechCorp-API&quot;<br>    }<br>  )<br>}</pre><h4><strong>Step 2: Create the VPC consumer</strong></h4><p><strong>2.1. Create VPC</strong></p><ul><li>Name: VPC-Analytics</li><li>CIDR: 172.16.0.0/16</li></ul><pre>resource &quot;aws_vpc&quot; &quot;consumer&quot; {<br>  cidr_block           = var.vpc_consumer_cidr<br>  enable_dns_hostnames = true<br>  enable_dns_support   = true<br><br>  tags = merge(<br>    local.common_tags,<br>    {<br>      Name       = &quot;VPC-Analytics&quot;<br>      Department = &quot;Analytics&quot;<br>      Type       = &quot;Consumer&quot;<br>    }<br>  )<br>}</pre><p><strong>2.2. Create a public subnet (AZ a)</strong></p><ul><li>172.16.0.0./24</li></ul><p><strong>2.3. Create a private subnet (AZ a)</strong></p><ul><li>172.16.1.0./24</li></ul><pre>resource &quot;aws_subnet&quot; &quot;consumer_private&quot; {<br>  vpc_id            = aws_vpc.consumer.id<br>  cidr_block        = cidrsubnet(var.vpc_consumer_cidr, 8, 1)<br>  availability_zone = local.azs[0]<br><br>  tags = merge(<br>    local.common_tags,<br>    {<br>      Name = &quot;Consumer-Private-Subnet&quot;<br>      Tier = &quot;Private&quot;<br>    }<br>  )<br>}</pre><p><strong>2.4. Create a Security Group for analytics app</strong></p><p>Allow outbound HTTPS to he interface endpoint.</p><p><strong>2.5. Create the Interface Endpoint</strong></p><ul><li>Go to: VPC-&gt;Endpoints-&gt;Create</li><li>Type: Interface</li><li>Search your Endpoint Service name</li><li>Subnet: the private subnet</li><li>assign a Security Group</li><li>Create</li></ul><p>2.6. Wait for the provider Approval</p><p>In the provider account:</p><ul><li>Go to Endpoint Services-&gt;Select your service</li><li>Accept the connection</li></ul><p>Once accepted, the consumer sees an ENI like: 172.16.0.100</p><p>This IP becomes the private address of the API</p><h4>Step 3: Testing the Architecture</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3YgZ2duwsz2SYdpmg-fCrA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1xdEc_p-RKu23iVgV_SEag.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pOTczEOcYTfVfWpUJjkiLQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2FlrGVgzV-0neQUdThgXaw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tbmr1VLyf53vDQUdgj0SXw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oJa64pC7r_WmqGhOUJfNgg.png" /></figure><p>On the consumer side (EC2)</p><pre>curl http://172.16.0.100/api/health</pre><p>Expected output: Health check response from the FastAPI app.</p><p>More tests:</p><pre>curl http://172.16.0.100/api/transactions<br>curl http://172.16.0.100/stats</pre><p>If requests succeed, PrivateLink is functional.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1hDaDgaaaXkTvXrrOFX5hA.png" /></figure><h4>Step 4: Debugging and common fixes</h4><p>Beginners often hit the same issues. Here is how to solve them quickly.</p><ol><li><strong>Endpoint stuck in “pending acceptance”</strong></li></ol><p>Fix: Provider must manually approve in Endpoint Services.</p><p><strong>2. Timeout when calling the API</strong></p><p>Check:</p><ul><li>Is the NLB internal, not internet-facing?</li><li>Is the target group healthy?</li><li>Doeas the FastAPI SG allow inbound on port 80?</li><li>Does the endpoint’s SG allow inbound from the analytics SG?</li></ul><p><strong>3. Wrong URL Used</strong></p><p>Use the private IP of the endpoint ENI or the DNS name:</p><p>vpce-xxxxxx-yyyyyy.region.vpce.amazonaws.com</p><p><strong>4. Analytics app cannot resolve DNS</strong></p><p>Enable Private DNS when creating the endpoint.</p><h4>Clean up</h4><p>The NLB, the interface endpoint and the EC2 instances are billed by the hour. When you are done:</p><p><strong>terraform destroy</strong></p><p>Everythings is removed in the right order. That is the real comfort of infrastructure as code, rebuilding the lab tomorrow is one <strong>terraform apply</strong> away.</p><h3>Conclusion</h3><p>You now built one of the most important architectures in cloud security: a fully private, cross-VPC API communication pattern using AWS PrivateLink. This setup is used by banks, fintechs, healthcare, and enterprise data teams to share services safely across environments.</p><p>It is simply by design: expose only what is needed, and nothing more.</p><p>as more companies adopt multi-account architectures, the real question becomes:</p><p><strong>How should teams expose internal services across environments without increasing their attack surface?</strong></p><ul><li>PrivateLink offers tight, service-level isolation.</li><li>VPC Peering offers simplicity and broad connectivity.</li><li>Transit Gateway offers centralized network control.</li></ul><p>Each option solves a different problem, but the industry still debates the ideal balance between <strong>security,</strong> <strong>simplicity, </strong>and<strong> scalability</strong>.</p><p>So here is the question for you:</p><p>In modern cloud environment, should service-to-service communication default to PrivateLink, or should we prioritize simpler models like Peering or transit Gateway until complexity justifies otherwise?</p><p>Share your take. The future of cloud networking is still shaped.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=38a52dda7f27" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Bridging the Gap Between Code and Cost: Introducing AWS FinOps Agent]]></title>
            <link>https://medium.com/@alphonsinelahda/bridging-the-gap-between-code-and-cost-introducing-aws-finops-agent-235dce5f9c28?source=rss-c7bfcc1ba4b6------2</link>
            <guid isPermaLink="false">https://medium.com/p/235dce5f9c28</guid>
            <category><![CDATA[cloud-optimization]]></category>
            <category><![CDATA[cloud-finops]]></category>
            <category><![CDATA[finops]]></category>
            <category><![CDATA[finops-agent]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Alphonsinelahda]]></dc:creator>
            <pubDate>Mon, 15 Jun 2026 08:31:00 GMT</pubDate>
            <atom:updated>2026-06-15T08:31:00.835Z</atom:updated>
            <content:encoded><![CDATA[<p>As an AWS Cloud Consultant and DevOps engineer, I’ve had a front-row seat to the massive wave of AI integration reshaping our industry. Over the past year, we&#39;ve watched generative AI weave its way into every phase of the software development lifecycle, from writing code with intelligent coding assistants to automating complex CI/CD debugging pipelines. It felt inevitable that AWS would eventually direct this frontier AI capability toward the often-frictionfilled world of Cloud Financial Management (CFM).</p><p>That moment has officially arrived.</p><p>AWS has announced the public preview of the <strong>AWS FinOps Agent</strong>, a generative AI-powered assistant built to bridge the gap between engineering velocity and financial accountability. For those of us in the DevOps space, FinOps has traditionally felt like a reactive chore, triage an unexpected bill spike, sift through dense AWS Cost Explorer charts, or manually trace a sudden anomaly back through hours of AWS CloudTrail logs.</p><p>What gets me genuinely excited about this release is how it aims to completely eliminate that operational friction by meeting engineers exactly where they already work. The agent doesn&#39;t just surface optimization opportunities; it translates natural language cost queries, automatically investigates anomalies down to the root cause, and pushes actionable tickets straight into Jira or alerts into Slack.</p><p>Let’s dive into how the AWS FinOps Agent works, how to get your first agent deployed, and what this means for the future of decentralized cloud financial engineering.</p><h3><strong>What is AWS FinOps Agent?</strong></h3><p>The AWS FinOps Agent is an intelligent, independent instance configured directly within your AWS account. It seamlessly interfaces with your cloud financial management data, operating securely under its own IAM permissions, context files, and memory. Because no data or permissions are shared across different agent instances, organizations can securely deploy multiple agents tailored to distinct business units or engineering teams.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*69E1YzCgE5Bua7CrV3S1hQ.png" /></figure><h3><strong>Core Capabilities at a Glance</strong></h3><ul><li><strong>Natural Language Cost Inquiries:</strong> Engineers and analysts can query usage metrics using everyday language. Instead of building complex queries in AWS Cost Explorer, you can simply ask, <em>“Why did my database costs spike last week?”</em></li><li><strong>Automated, Event-Triggered Anomaly Investigations:</strong> The agent doesn’t just alert you that costs have changed; it actively investigates <em>why</em> by correlating anomalies with real-time system changes.</li><li><strong>Centralized Optimization Routing:</strong> It continuously aggregates rightsizing, idle resource, and Savings Plans recommendations from the AWS Cost Optimization Hub and AWS Compute Optimizer.</li><li><strong>Tailored, Scheduled Reporting:</strong> FinOps practitioners can automate the delivery of highly professional cost reports rendered in downloadable HTML, PDF, or PowerPoint (PPT) formats.</li></ul><h3><strong>Deep Dive: How It Transforms Cloud Financial Management</strong></h3><h4><strong>1. Instant, Context-Aware Answers for Engineers</strong></h4><p>By putting cost data directly into the hands of developers, AWS FinOps Agent democratizes cloud financial literacy. To make these insights truly relevant, you can upload organization-specific context files, such as account-to-owner spreadsheets, application tagging conventions, and team definitions.</p><p>Because the agent retains memory across sessions, it understands your company’s internal vernacular. If an engineer asks, <em>“What did Team X spend on compute last month?”</em>, the agent leverages its uploaded context to map “Team X” to its specific AWS account IDs and tags, delivering a precise breakdown without manual intervention.</p><h4><strong>2. Rapid Anomaly Triaging and Root-Cause Analysis</strong></h4><p>When AWS Cost Anomaly Detection flags an unusual spend pattern, time is of the essence. A delayed response can lead to a massive bill shock at the end of the month.</p><p>AWS FinOps Agent automates the entire investigation pipeline. The moment an anomaly occurs, the agent pulls relevant <strong>AWS CloudTrail</strong> events to isolate the exact infrastructure change, such as an auto-scaling misconfiguration or an accidental spin-up of an expensive instance type that triggered the spike. It compiles these findings into a concise root-cause summary, identifies the responsible resource owner, and automatically pushes an actionable alert to Slack or opens a ticket in Jira.</p><h4><strong>3. Streamlined Engineering Workflows via Jira and Slack</strong></h4><p>One of the greatest hurdles in FinOps is getting engineers to prioritize cost optimization over feature delivery. AWS FinOps Agent tackles this by meeting engineers exactly where they already work.</p><p>Instead of requiring developers to navigate away from their development pipelines, the agent aggregates rightsizing and idle resource recommendations and automatically ports them directly into your team’s <strong>Jira backlog</strong>. Optimization tasks simply become standard tickets that can be prioritized during weekly sprint planning.</p><h3><strong>Step-by-Step: Setting Up Your First FinOps Agent</strong></h3><p>Deploying the agent during its preview phase is straightforward. Here is what you need to know to get started.</p><h4><strong>Prerequisites &amp; Permissions</strong></h4><p>Before launching the creation wizard, ensure your IAM identity has the FinOpsAgentSetupPolicy attached. This grants the administrator permissions required to provision the agent and its associated service roles.</p><p>While the configuration wizard can automatically generate the necessary IAM roles for you, advanced teams can pre-configure custom roles:</p><ul><li><strong>Agent Role:</strong> Requires the FinOpsAgentAgentPolicy to read cost data and manage automations.</li><li><strong>Operator Role:</strong> Requires the FinOpsAgentOperatorPolicy to manage web application operations (conversations, tasks, and document management).</li></ul><h3><strong>Navigating the Configuration Wizard</strong></h3><p>To build your agent, navigate to the <strong>AWS FinOps Agent console</strong>, choose <strong>Create</strong>, and follow these five simple configuration steps:</p><h4><strong>Step 1: Name Your Agent</strong></h4><p>Provide a unique identifier and description. Names can include letters, numbers, spaces, and hyphens (up to 128 characters). Special characters like underscores or periods are not permitted.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i6CVpL15LvOfSVa0zUJL7A.png" /></figure><h4><strong>Step 2: Resource Access (IAM Role)</strong></h4><p>Specify the role the agent uses to read your AWS operational data.</p><ul><li><strong>Option 1 (Recommended):</strong> Choose <em>Auto-create a new role</em>. The wizard automatically provisions a role securely scoped to your account and this specific agent.</li><li><strong>Option 2:</strong> Select an <em>Existing role</em> that contains the required trust policies and actions.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dJbJZ1oJG3xlOV4SoRm5Gw.png" /></figure><h4><strong>Step 3: Web App Access (Operator Role)</strong></h4><p>Determine the role the agent will assume to power the interactive web app where your team will chat with the agent and manage context files. Like Step 2, you can choose to auto-create this role or map it to an existing one.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*X_1fksjYcIxTVmeWfYiOUQ.png" /></figure><h4>Step 4: Third-Party Integrations (Optional)</h4><p>If you have already registered Jira or Slack integrations at the AWS account level, you can link them to your agent here:</p><ul><li><strong>For Jira:</strong> Input your designated <strong>Project Space Key</strong> (e.g., ENG or FIN). This authorizes the agent to automatically file optimization and anomaly tickets.</li><li><strong>For Slack:</strong> Provide a 9-to-12 character alphanumeric <strong>Channel ID</strong> (e.g., C04ABCDEF12). Ensure you have invited the AWS FinOps Agent Slack app into that specific channel prior to connecting.</li></ul><p>We Slack integration for this demo.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MmJJmdLKRrGBxcP3C3D-hw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MXPh6aTdn-yCAihSChp0dA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6BcsunYajhSkjllhM-0NXg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hzq9o1dSR0YYvFsBxiftPw.png" /></figure><p>Then choose a channel and add it</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zeMJejwhI1UCFe3eSNuF4A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/589/1*_X54AozPqnrPFgOr-cAXiw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oyXEWS8eAmGZYZ3r0Ik1Iw.png" /></figure><h4><strong>Step 5: Review and Create</strong></h4><p>Verify your inputs on the summary page. Once satisfied, click <strong>Create agent</strong>. The console will provision the underlying application, generate the web-based workspace, and establish the configured third-party webhooks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kyjE9v0koV5MX3Kh3u2p4Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e5hFsuS9vBFM2Q-_-ZSKTg.png" /></figure><h3>Regional Availability and Preview Details</h3><p>The <strong>AWS FinOps Agent (preview)</strong> is currently available to try in the <strong>US East (N. Virginia)</strong> Region. Despite being hosted in US East, the agent is fully capable of analyzing, aggregating, and reporting on cost and usage data spanning across all global AWS Regions (excluding AWS GovCloud and AWS China regions).</p><p>Best of all, AWS is offering the FinOps Agent at <strong>no additional charge</strong> during its public preview period, giving organizations a risk-free opportunity to modernize their cloud financial operations.</p><h3><strong>Conclusion: The Future of Cloud Financial Management</strong></h3><p>The introduction of the AWS FinOps Agent marks a significant shift from passive cloud cost monitoring to autonomous, intelligent cost orchestration. By embedding generative AI directly into the FinOps framework, AWS is effectively removing the traditional friction between finance teams who track the budget and engineering teams who deploy the infrastructure.</p><p>Instead of treating cloud financial management as a monthly retrospective chore filled with spreadsheets and alerts, organizations can now treat it as a continuous, automated process. The agent’s ability to speak the language of engineers, automatically untangle complex anomaly root causes, and push actionable tickets directly into existing sprint backlogs ensures that optimization becomes part of daily development workflows.</p><p>As cloud environments grow increasingly complex, tools like the AWS FinOps Agent will become indispensable for scaling businesses. During this preview phase in the US East (N. Virginia) Region, teams have a unique, cost-free window to deploy an agent, connect their collaboration tools, and experience firsthand how autonomous AI can turn cloud waste into cloud efficiency.</p><h3>References</h3><ul><li><a href="https://docs.aws.amazon.com/finops-agent/latest/userguide/creating-an-agent.html">https://docs.aws.amazon.com/finops-agent/latest/userguide/creating-an-agent.html</a></li><li><a href="https://aws.amazon.com/finops-agent/">https://aws.amazon.com/finops-agent/</a></li><li><a href="https://docs.aws.amazon.com/finops-agent/latest/userguide/working-with-aws-finops-agent.html">https://docs.aws.amazon.com/finops-agent/latest/userguide/working-with-aws-finops-agent.html</a></li><li><a href="https://docs.aws.amazon.com/finops-agent/latest/userguide/security-iam.html">https://docs.aws.amazon.com/finops-agent/latest/userguide/security-iam.html</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=235dce5f9c28" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AWS Data Engineering for Fraud Detection]]></title>
            <link>https://medium.com/@alphonsinelahda/aws-data-engineering-for-fraud-detection-709cfaa393ef?source=rss-c7bfcc1ba4b6------2</link>
            <guid isPermaLink="false">https://medium.com/p/709cfaa393ef</guid>
            <category><![CDATA[aws-security]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[fraud-detection]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <dc:creator><![CDATA[Alphonsinelahda]]></dc:creator>
            <pubDate>Mon, 15 Dec 2025 08:32:15 GMT</pubDate>
            <atom:updated>2025-12-15T09:09:06.285Z</atom:updated>
            <content:encoded><![CDATA[<h3>Context and Introduction</h3><p>Modern digital businesses face a growing challenge: detecting fraudulent activity in real time while keeping customer experience smooth and frictionless. Every millisecond counts. If you detect fraud too late, losses accumulate. If you detect fraud too aggressively, you block legitimate customers and lose business.</p><p>This article presents a complete and actionable AWS Data Engineering architecture designed for real time fraud detection. The system captures incoming events, stores them securly, applies fraud detection. The system captures incoming events, stores them securely, applies fraud scoring rules, alerts stakeholders, and provides analytics for long term improvements.</p><p>The goal is simple. Build an event driven, scalable, low latency pipeline using managed AWS services so a bisiness can:</p><ul><li>Ingest fraud signals instantly.</li><li>Process and score transactions in real time.</li><li>Store raw data for auditing and analytics.</li><li>Alert teams automatically when suspicious transactions appear.</li><li>Keep the system secure, encrypted, auditable and cost efficient.</li></ul><p>I will walk through each component, why it exists, how it fits into the workflow, and how to implement it manaully on the AWS management console, step by step.</p><h3>Solution Architeture of Fraud Detection System</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HxvPKGABTbH2jo7Y5YUxog.png" /><figcaption>fraud detection system architecture</figcaption></figure><h3>Presentation of each service and its role in the workflow</h3><h4><strong>1. Ingestion Layer</strong></h4><ul><li><strong>AWS API Gateway: </strong>acts as the public entry point. It receives HTTPS POST requests from clients or tolls loke Postman.</li></ul><p>Why it matters:</p><ul><li>Validates and authorizes requests.</li><li>Protects your backend from direct exposure.</li><li>Provides throttling and security.</li><li><strong>AWS Lambda (Ingestion Lambda):</strong> triggered by API Gateway. It receives the transaction payload and pushes the record into Kinesis Data Streams.</li></ul><p>Why it matters:</p><ul><li>Serverless, fast, scalable.</li><li>Converts incoming JSON into the proper Kinesis record format.</li><li><strong>Kinesis Data Streams: </strong>streams transactions in real time.</li></ul><p>Why it matters:</p><ul><li>Very low latency.</li><li>Supports parallel consumers.</li><li>Perfect for fraud workflows where timing is critical.</li></ul><h4>2. Storage Layer</h4><ul><li><strong>Amazon S3(raw):</strong> stores raw transaction data exactly as received.</li></ul><p>Why it matters:</p><ul><li>Immutable historical record.</li><li>Essential for audits, analytics, ML training.</li><li>Cheap, infinitely scalable.</li></ul><p><strong>. Kinesis Firehose: </strong>delivers streaming data from Kinesis Data Streamd into S3.</p><p>Why it matters:</p><ul><li>no servers.</li><li>Automatically batches, compresses, and encrypts.</li><li>Ensures consistent storage for analytics.</li></ul><p><strong>. AWS Glue Crawler: scans S3raw files and infers schema.</strong></p><p>Why it matters:</p><ul><li>Creates the Glue Data Catalog</li><li>Makes your raw data queryable by Athena without manual schema definition.</li><li><strong>Glue data catalog: </strong>central metadata repository.</li></ul><p>Why it matters:</p><ul><li>Enables SQL queries on S3 through Athena</li><li>Standardizes your data definitions.</li></ul><h3>3. Processing Layer</h3><ul><li><strong>DynamoDB (customer profiles and fraud rules)</strong></li></ul><p>Two tables:</p><ul><li>customer profiles: historical or behavioral context used for scoring</li><li>fraud rules: thresholds and business logic.</li></ul><p>Why it matters:</p><ul><li>Fast, reiable, millisecond latency.</li><li>Ideal for lookups during real time scoring.</li><li><strong>AWS Lambda (Scoring Lambda): </strong>triggered by Kinesis Data Streams. reads records, retrieves customer info and fraud rules from DynamoDB, evaluates risk, and publishes an alerts if necessary.</li></ul><p>Why it matters:</p><ul><li>Stateless.</li><li>Pulls all logic together.</li><li>Executes fraud scoring in real time</li><li><strong>Amazon SNS: </strong>publishes alerts to email or other suscribers.</li></ul><p>Why it matters:</p><ul><li>Decouples alerts from processing.</li><li>Easy to notify fraud teams instantly.</li></ul><h3>4. Security and monitoring Layer</h3><ul><li><strong>AWS KMS: </strong>encrypt data in s3, Firehose, Kinesis, and DynamoDB.</li></ul><p>Why it matters:</p><ul><li>Ensures compliance.</li><li>Protects sensitive customer data end to end.</li><li><strong>IAM Roles:</strong> controls which service is allowed to do what.</li></ul><p>Why it matters:</p><ul><li>Enforces least privilege.</li><li>Prevents accidental data exposure.</li><li><strong>Cloudwatch: </strong>observes Lambdas, API Calls, failures, and performance metrics.</li></ul><p>Why it matters:</p><ul><li>Essential for debugging</li><li>Provides logs and alarms.</li></ul><h3>5. Analytic Layer</h3><ul><li><strong>Amazon Athena:</strong> queries the raw S3 data using SQL.</li></ul><p>Why it matters:</p><ul><li>No servers.</li><li>Easy exploratory analytics.</li><li>Analysts can refine fraud rules based on insights.</li></ul><h3>Implementation step by step</h3><h4><strong>Step 1: create KMs Key</strong></h4><p>AWS console -&gt;KMS -&gt;Customer managed keys -&gt;create key</p><ol><li>Configure key:</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zNyCTcYd6o_dCAWZSvnrOQ.png" /></figure><ul><li>Key type symetric</li><li>Key usage: Encrypt and decrypt</li><li>Click Next</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Py-t8tTcLpwAJba2-AX5SA.png" /></figure><p>2. add labels:</p><ul><li>Alias: fraud-detection-key</li><li>description: lab fraud detection encryption</li><li>Click Next</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qEe5Qjzy2uL75AUBdxYyGg.png" /></figure><p>3. define key administrative permissions:</p><ul><li>Select the IAM User</li><li>Click Next</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9IyDACaetMMNTCn_kfsSVQ.png" /></figure><p>4. define Key usage permissions:</p><ul><li>select your IAM user</li><li>Click Next</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*C-AG41FcUER2GReJThv1_g.png" /></figure><p>5. Review and finish</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3_Fh-B-qRNS8kTvMUvSo5g.png" /></figure><p>6. Copy the key ARN and keep it somewhere, we will need it soon.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pEwC77Zpt_XA-9-CL79AOA.png" /></figure><h4><strong>Step 2: create the S3 Bucket</strong></h4><p>AWS Console -&gt;S3-&gt;Create bucket</p><ol><li>Bucket name: fraud-lab-first name-1209 (exemple: fraud-lab-john-1209)</li><li>Region: US East (N.Virginia) us-east-1</li><li>Block all public access</li><li>Bucker versioning: Disable</li><li>Default encryption:</li></ol><ul><li>Encryption type: SSe-KMS</li><li>AWS KMS Key: choose from your keys</li><li>Select fraud-detection-key</li><li>Bucket Key: enable</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JJgOeCB3myuExZpN4Z-DZw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kfoAcSBJCU66-PV3TXV1Sw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Vrp5vlgTv4CPwYgvz16FaA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q8-m9Opopw29P5in5idNZw.png" /></figure><p><strong>Step 2.1 :</strong> create folders in your bucket (2 folders)</p><ul><li>raw/</li><li>athena-results/</li></ul><h4><strong>Step 3: DynamoDB -reference datas</strong></h4><ol><li>Create customer-profiles</li></ol><p>AWS Console -&gt;DynamoDB -&gt;Tables -&gt; Create table.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_usy0WY1xDUguYUEOsEmMg.png" /></figure><ul><li>Table name: <strong>customer-profiles</strong></li><li>Partition key :<strong> user_id</strong></li><li>Table settings: <strong>Default settings</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cJjPwakvs9GITEiBdcWBaQ.png" /></figure><ul><li>Table class: <strong>DynamoDB Standard</strong></li><li>Capacity mode: <strong>On-demand</strong></li><li>Click Create table</li></ul><p><strong>3.1. Create first item, insert 5 clients profiles</strong></p><p>Table -&gt;customer-profiles-&gt;Explore table items-&gt;Create item</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MCvHYS1mzR4qqKq28O5whA.png" /></figure><p><strong>Profile 1</strong>- Attributs of a Normal client:</p><pre>user_id (String): user_001<br>email (String): john.doe@example.com<br>account_created (String): 2023-01-15<br>avg_transaction_30d (Number): 125.50<br>transaction_count_30d (Number): 15<br>last_device_id (String): device_abc123<br>last_location (String): New York, US<br>risk_level (String): LOW</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kNDeRRHvyhKHa1w9oc1TEQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5eBNCSNqZferlTOhWu_oUQ.png" /></figure><p><strong>3.2- Profile 2: High-risk customer:</strong></p><pre>user_id: user_002<br>email: jane.smith@example.com<br>account_created: 2024-11-01<br>avg_transaction_30d: 50.00<br>transaction_count_30d: 3<br>last_device_id: device_xyz789<br>last_location: Los Angeles, US<br>risk_level: HIGH</pre><p><strong>3.3- Profile 2: New customer:</strong></p><pre>user_id: user_003<br>email: new.user@example.com<br>account_created: 2024-12-01<br>avg_transaction_30d: 0<br>transaction_count_30d: 0<br>last_device_id: device_new999<br>last_location: Chicago, US<br>risk_level: NEW</pre><p><strong>3.4- Profile 2: Big spender:</strong></p><pre>user_id: user_004<br>email: premium.user@example.com<br>account_created: 2022-06-10<br>avg_transaction_30d: 850.00<br>transaction_count_30d: 25<br>last_device_id: device_premium<br>last_location: Miami, US<br>risk_level: LOW</pre><p><strong>3.5- Profile 2: Average customer:</strong></p><pre>user_id: user_005<br>email: average.joe@example.com<br>account_created: 2023-08-20<br>avg_transaction_30d: 200.00<br>transaction_count_30d: 10<br>last_device_id: device_normal<br>last_location: Seattle, US<br>risk_level: MEDIUM</pre><p>3.6- Insert 4 fraud rules</p><p>Table-&gt;fraud-rules-&gt;Create item</p><ul><li>Rule 1:</li></ul><pre>rule_id: HIGH_AMOUNT<br>rule_name: Montant anormalement élevé<br>condition: amount &gt; avg_30d * 5<br>risk_score: 80<br>enabled: true</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W5WCPIRLpotrr0KRvylH5w.png" /></figure><ul><li>Rule 2:</li></ul><pre>rule_id: RAPID_SUCCESSION<br>rule_name: Transactions rapprochées<br>condition: time_since_last &lt; 60<br>risk_score: 60<br>enabled: true</pre><ul><li>Rule 3:</li></ul><pre>rule_id: DEVICE_CHANGE<br>rule_name: Changement d&#39;appareil<br>condition: device_id != last_device_id<br>risk_score: 40<br>enabled: true</pre><ul><li>Rule 4:</li></ul><pre>rule_id: LOCATION_CHANGE<br>rule_name: Localisation inhabituelle<br>condition: distance &gt; 500km<br>risk_score: 70<br>enabled: true</pre><h4>Step 4: SNS -Alerts Email</h4><p>AWS Console -&gt;SNS -&gt; Topics -&gt; Create topic</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qhIWMZz9RJpevOH7d8McvA.png" /></figure><ul><li>Type: Standard</li><li>Name: fraud-alerts</li><li>Display name: fraud Alerts</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dpjcGVxePEiukXBKZWj8kA.png" /></figure><ul><li>Click Create topic</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0HierN_skuQT4tD7dQd4YQ.png" /></figure><ul><li>Copy the ARN topic</li></ul><p><strong>4.1- Subscribe by email</strong></p><p>Subscriptions-&gt;Create subscription</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eJczR7XrFIw8kWrBu4FBNA.png" /></figure><ul><li>Protocol: Email</li><li>Endpoint: <strong>your-email@example.com</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Y9UMoPQ0YxICHWIDrqs5mw.png" /></figure><ul><li>Click create subscription</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Lb7U9RLHFDgJvvJHHwKH2w.png" /></figure><ul><li>Important: check your email inbox -&gt; ‘Confirm subscription’</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/882/1*1tPLhwjYXSOYjzKxIs8Xqg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/655/1*UjdqDvFezGt8Pw95qM6NGw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tkQdam8zbgiV-lqE_MquCg.png" /></figure><h4>Step 5: Kinesis-Streaming</h4><p><strong>5.1: Create Data Stream</strong></p><p>AWS Console -&gt; Kinesis -&gt; Data streams -&gt; Create data stream</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gniEz4vCiB0w3o9Qq_KGYw.png" /></figure><ul><li>Data stream name: <strong>fraud-detection-stream</strong></li><li>Capacity moode:<strong> On-demand</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sItwOTTgVAIedHHNQOuaFg.png" /></figure><ul><li>Click <strong>Create data stream</strong></li><li>Wait for <strong>Active </strong>status</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pzILtID1G9dcD9trTI0bpg.png" /></figure><p><strong>5.2- Enable encryption</strong></p><p>In the stream-&gt;Configuration -&gt; Edit</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*opfuO6bZf7zu4cZokXtN6w.png" /></figure><ul><li>server-side encryption: Enabled</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*K3MyFAC2zdk7SYTKmtchGA.png" /></figure><ul><li>AWS KMS Key: Use AWS managed CMK (aws/kinesis)</li><li>Click Save changes</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tbNg68lDCMDcP1ngct-JYg.png" /></figure><h4>Step 6: Kinesis Firehose</h4><p>Kinesis -&gt; Delivery -&gt; Create delivery stream</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xjX2iQPMW8Z1GQ-dPNnvQw.png" /></figure><ul><li>Choose source and destination</li></ul><p>— Source: Amazon Kinesis Data Streams</p><p>— Destination: Amazon S3</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2RdxV5uh7BkoTTplN4uJxw.png" /></figure><ul><li>Source settings:</li></ul><p>— Kinesis data stream: <strong>fraud-detection-stream</strong></p><ul><li>Delivery stream name: fraud-firehose-to-s3</li><li>Transform and convert records: Disabled</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nlEgDkGGYiBO88MY8Wftiw.png" /></figure><ul><li>Destination settings:</li></ul><p>— S3 bucket : fraud-lab-your-first-name-1209</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CTeq_rRVe4-VCdJ07UhxGA.png" /></figure><p>— S3 bucket prefix: raw/</p><p>— S3 error output prefix: error/</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6F37VjfpwunUTUDyqWDrMA.png" /></figure><ul><li>Buffer hints:</li></ul><p>— buffer size : 1MB</p><p>— buffer interval: 60 seconds</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PnUDcVdapd20PaoxyhC1lw.png" /></figure><ul><li>Compression :GZIP</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FkUhQtOht2lJrhkj4Gz8Yg.png" /></figure><ul><li>Permissions: Create or update IAM Role</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Vij3JzivQmCG84EaSJDB5g.png" /></figure><ul><li>Click Create delivery stream</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*I3bTqcbMwFl0U_v5C_ckLA.png" /></figure><h4>Step 7: Create IAM Role for Lambda Functions</h4><p><strong>7.1: Create IAM Role</strong></p><p><strong>AWS Console →IAM → Roles → Create role</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/433/1*xeV8R395ax_FKb86RqEw9g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ETGU6M87Gy9qQsT4Rt3L3Q.png" /></figure><ul><li>Trusted entity type: AWS service</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*I303CtjD9hPbt9zk0j0GDw.png" /></figure><ul><li>Use case: Lambda</li><li>Click Next</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JsjjHM8-B88nptQxdgnOnw.png" /></figure><ul><li>Permissions for the role:</li></ul><p>— AWSLambdaBasicExecutionRole</p><p>— AmazonKinesisFullAccess</p><p>— AmazonDynamoDBFullAccess</p><p>— AmazonDynamoDBFullAccess</p><p>— CloudWatchFullAccess`</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L9SckKfcwVK7LIQim-JDXA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*E--RjSzW9rx8am-PXMlK_w.png" /></figure><ul><li>click Next</li><li>Role name: <strong>frauddetectionLambdaRole</strong></li><li>Click Create role</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*88IiYvsDY7JZsNBMWqvfLA.png" /></figure><h4>Step 8: Lambda Functions</h4><p><strong>8.1: Lambda Ingestion</strong></p><p><strong>AWS console →Lambda →Functions →Create function</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LcbCSG1-9jl3DBtAtp-yeA.png" /></figure><ul><li>Author from scratch</li><li>Function name: fraud-ingestion</li><li>Runtime: Python 3.11</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_gCQYKcERs0f2XJgybq_EA.png" /></figure><ul><li>Architecture: x86_64</li><li>Change default execution role:</li></ul><p>— Use an existing role</p><p>— Existing role: fraudDetectionLambdaRole</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DRMAYLCaPPZYHtledy1Wog.png" /></figure><ul><li>Click Create function</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L2FnIjC5GZxqUy9R8sAAmQ.png" /></figure><ul><li>In Source Code, REPLACE ALL with the provide code here: <a href="https://github.com/lahda/AWS-Fraud-detection-project/blob/main/fraud-ingestion.py"><strong>Lambda Ingestion.py</strong></a></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*66E0tD7K7jv-H-Pb9opQHA.png" /></figure><ul><li>Configuration → General configuration → Edit:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VMQ1gA4pqndMyBjQ1GLHpw.png" /></figure><p>— Timeout: 30 seconds</p><p>— Click Save</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ttptzxcVV7vUraxvhf2wXw.png" /></figure><ul><li>Click deploy</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/958/1*kTuDZeEsbDHuDdxJFYtN_w.png" /></figure><p><strong>8.2: Lambda Scoring</strong></p><p><strong>Lambda →Create function</strong></p><ul><li>Function name: fraud-scoring</li><li>Runtime: Python 3.11</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*c-aLk1NKy9eKohKLl-lTdg.png" /></figure><ul><li>Existing role:<strong> fraudDetectionLambdaRole</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DRMAYLCaPPZYHtledy1Wog.png" /></figure><ul><li>Click Create function</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L2FnIjC5GZxqUy9R8sAAmQ.png" /></figure><ul><li>Replace all the code with the one provided here:<a href="https://github.com/lahda/AWS-Fraud-detection-project/blob/main/fraud-scoring.py"><strong> fraud-scoring.py</strong></a></li><li>Update line 10: replace with your SNS ARN</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zRqpqYKtBMGsK3DaXk4a1Q.png" /></figure><ul><li>Configuration →General configuration:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UX8S9aMwD_c_eQhMvuZZFA.png" /></figure><p>— Memory: 512 MB</p><p>— Timeout: 1 minute</p><ul><li>Click save</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u5zu9SrXUhjBa1iQhNvADQ.png" /></figure><ul><li>Click Deploy</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gT4yoGwyUAc3z9yHavke4Q.png" /></figure><p><strong>8.3: Connect Kinesis Trigger</strong></p><p><strong>fraud-scoring →configuration →triggers →Add trigger</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xS4Fh2Y86zPy4OOPRvKj_A.png" /></figure><ul><li>Source: kinesis</li><li>Kinesis stream: fraud-detection-stream</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7zubT6T2CL2x99UmQxkr9g.png" /></figure><ul><li>Starting position: Latest</li><li>Batch size: 10</li><li>Click Add</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2NovWg7wsJK62gVoNgndqQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dG9vus0_5efL_6-U4uG_aw.png" /></figure><h4>Step 9: API Gateway</h4><p><strong>AWS Console →API Gateway →Create API</strong></p><p><strong>9.1: Create API</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*H7KGwYKu0PEAS8jKJ6pshQ.png" /></figure><ul><li>Choose REST API (not private) →Build</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p4c8M4nCCZsfnEYV6RzneA.png" /></figure><ul><li>Create new API: New API</li><li>API name: <strong>fraudDetectionAPI</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pyXXA1hEnZew9VJJJsUT5Q.png" /></figure><ul><li>Endpoint Type: regional</li><li>Click Create API</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Kf-76t8rDlBMxb4PBfhcDg.png" /></figure><p><strong>9.2: Create resource</strong></p><p>Actions →Create Resource</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1006/1*2b8UALG_c7bqCB9mllltig.png" /></figure><ul><li>Resource Name: <strong>transaction</strong></li><li>Enabled API Gateway CORS:</li><li>Click create Resource</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*f-HHoD88OM1yi17CdEZQmA.png" /></figure><p><strong>9.3: Create POST Method</strong></p><ul><li>Select/transaction →Actions →Create Method →POST</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bqFKM4mWEkV3c_4xCg191Q.png" /></figure><ul><li>Integration Type: Lambda Function</li><li>Use Lambda Proxy integration</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*er8BP9DKILzS3Kxvg0YuPw.png" /></figure><ul><li>Lambda Function: <strong>fraud-ingestion</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oQUJVTLhfIePrbUC1aimxg.png" /></figure><ul><li>Click Save →OK</li></ul><p><strong>9.4: Deploy API</strong></p><p><strong>Actions →Deploy API</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-LBPidkV6e0QEJl7BI55AA.png" /></figure><ul><li>Deployment stage: New Stage</li><li>Stage name: prod</li><li>Click Deploy</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/952/1*Ir8JJyk6LWSNg62-euDKYw.png" /></figure><ul><li>Copy Invoke URL of your API</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3Wav0RJUHlGBljYbn-8nyw.png" /></figure><h4>Step 10 AWS Glue</h4><p><strong>10.1: Create Glue database</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xt7jLRM5aY_VmGxqF8jtTw.png" /></figure><p><strong>AWS Glue →Databases →Add database</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/445/1*FtWH7AONnAJu5445ekVwWA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tIRE5EMmnGLYIAfcB4TtGQ.png" /></figure><ul><li>Name: frauddetectiondb</li><li>Click Create</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G4sy55kpGkjG0K46hZm0MA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JKPq7GGk9_N1EmQFOoawbA.png" /></figure><p><strong>10.2: Create Crawler</strong></p><p><strong>Glue →Crawler →Create crawler</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1011/1*SQg6ljrHlQStyLA2heAG0w.png" /></figure><ul><li>Name: fraud-s3-crawler</li><li>Click Next</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nzBNaC7eb1ldvJ6tXKcV7A.png" /></figure><ul><li>Add data source:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q-PKvaAt6C1s4-i2v0fsag.png" /></figure><p>— S3 path: s3://fraud-lab-first-name-1209/raw/</p><p>— Click Add an S3 data source</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/973/1*MxpfX9JVhpal8Cva9TmOUg.png" /></figure><p>Click Next</p><ul><li>IAM role: create new IAM role</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/958/1*6bNylcm773fSKWGJUwVPug.png" /></figure><p>— Role name: AWSGlueServiceRole-FraudLab</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UXANGBTp8vOcZnX8Omb7sw.png" /></figure><p>— Click Next</p><ul><li>target database frauddetectiondb</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/981/1*dNHGW7R4cgZbjeQXM-ASjg.png" /></figure><ul><li>Crawler schedule: On demand</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_o6sJsjF0dcaQwj9YuhcJQ.png" /></figure><ul><li>Click Next → Create crawler</li></ul><p><strong>DO NOT launch now — need data first</strong></p><h4>Step 11: Configure Athena</h4><p><strong>AWS Athena → Query editor</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6b7gJ5Ctuj9obTE5KOh1nw.png" /></figure><ul><li>Settings → Manage: location : <strong>s3://fraud-lab-first-name-1209/athena-results/</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zjGIqUDs2drz33YdcC_Tmg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NOc5y1v0FS2d84b4kgVcVg.png" /></figure><ul><li>Click <strong>Save</strong></li></ul><h4>Step 12: Tests</h4><p><strong>12.1: Generate transactions</strong></p><ul><li>Go on your AWS CloudShell</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P8raaJuLII68_-sdCNAJgw.png" /></figure><ul><li>Create a file name generate_transactions:</li></ul><pre>cat &gt; generate_transactions.py</pre><ul><li>Copy and paste this code<strong> </strong><a href="https://github.com/lahda/AWS-Fraud-detection-project/blob/main/generate_transactions.py"><strong>generate_transactions.py</strong></a></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-HvRyWcea77IQMChU44xXQ.png" /></figure><ul><li>Save with crlt + o →Enter → X</li><li>Then enter these commands to generate transactions:</li></ul><pre>pip install requests<br>python generate_transactions.py</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fHmM2pKMkV1O2Mb_qaPx0Q.png" /></figure><ul><li>expected outputs:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/574/1*cNDKP6Fl91aMVHUBhypdYw.png" /></figure><ul><li>Then we go back on <strong>AWS Glue Crawler</strong>, to run the crawler to create a SQL table definition in the Glue Catalog so Athena can query your bucket data like a database table. In simple words, it turns unstructured files in S3 into a queryable SQL table for Athena.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3hmQSyuflKgOwZqEILZngA.png" /></figure><ul><li>Wait until the execution is complete, as shown in this image.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IxIUvhf0toXX62j1iuQBRg.png" /></figure><p><strong>12.2: Verification of expected results and comments step</strong></p><ul><li>We start with <strong>CloudWatch Logs</strong> by checking <strong>fraud-scoring in /aws/lambda/fraud-scoring:</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/349/1*JWIqBuFpDMwfTHlL7iEL9A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/733/1*AG1rgLhLwXEJw6pGUriJKA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0jEIz96-Pddlm9zHxFnukQ.png" /></figure><p>This image above shows that: the lambda fraud scoring function analyzed the transactions, assigned a low risk score of 40, and automatically approved it. The execution complete successfully in about 57 ms, confirming a fast and helthy real time fraud decision.</p><ul><li>Check S3 bucket, raw/ if files .gz are created</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4VqKx22_qllC-PksrtFRxA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*0r_6ahAJEiaPwCX1o-Dghw.png" /></figure><ul><li>Email: Check alerts for BLOCKED/REVIEW transactions</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ws7kg4zrtZkxZp04jg2iWQ.png" /></figure><p>12.3: Run Crawler</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3hmQSyuflKgOwZqEILZngA.png" /></figure><ul><li>Wait 1–2 minutes → Status: **Completed**</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IxIUvhf0toXX62j1iuQBRg.png" /></figure><p>Next, let’s verify the creation of the raw table in Athena.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/337/1*TCSAbQBottEBumu8iMiWlA.png" /></figure><p>12.4: Check API Gateway</p><ul><li>Test curl fraud blocked</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bHPdzLVEn0nQ28RrOGMtqw.png" /></figure><p>12.5: Athena Queries</p><p>Athena →Query editor</p><ul><li>First Query</li></ul><p>Overview</p><pre>SELECT <br>    COUNT(*) as total_tx,<br>    ROUND(SUM(amount), 2) as total_amount,<br>    ROUND(AVG(amount), 2) as avg_amount,<br>    COUNT(DISTINCT user_id) as unique_users<br>FROM raw;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FHL2vGa83ukQLTdFiEej_w.png" /></figure><ul><li>Result</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/744/1*mDastMziDjGQExckPrD-yw.png" /></figure><ul><li>Query 2</li></ul><p>Top users</p><pre>SELECT <br>    user_id,<br>    COUNT(*) as tx_count,<br>    ROUND(SUM(amount), 2) as total<br>FROM raw<br>GROUP BY user_id<br>ORDER BY total DESC;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/815/1*2UGMf4-8GFlagXcU9dFhCw.png" /></figure><ul><li>Result</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sdpdjoQr8cM2qifzfcDbBg.png" /></figure><ul><li>Query 3</li></ul><p>Suspicious transactions</p><pre>SELECT <br>    user_id,<br>    amount,<br>    merchant_id,<br>    device_id,<br>    timestamp<br>FROM raw<br>WHERE amount &gt; 1000<br>ORDER BY amount DESC;</pre><ul><li>Query 4</li></ul><p>Analysis by category</p><pre>SELECT <br>    merchant_category,<br>    COUNT(*) as count,<br>    ROUND(AVG(amount), 2) as avg_amount<br>FROM raw<br>GROUP BY merchant_category<br>ORDER BY count DESC;</pre><ul><li>Next, let us verify the presence of Athena query results in s3, specifically in the <strong>athena-results/ </strong>.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/921/1*DT_Wn1u1ki4V6reOMJ7RkQ.png" /></figure><h3>Conclusion</h3><p>This architecture provids a robust, scalable, and secure foundation for real time fraud detection. Each service plays a precise role: API Gateway secures ingestion, Lambda orchestrates transformations, Kinesis provides real time streaming, DynamoDB supports fast lookups, Firehose and S3 guarantee durable storage, Glue and Athena deliver analytical power, and SNS ensures immediate alerts.</p><p>Beyond fraud detection, the same pattern can be reused for risk scoring, anomaly detection, payment monitoring, and event driven pipelines. It shows how AWS Services combine to deliver a business outcome: reducing fraud losses, improving trust with customers, enabling faster incident response, and strengthening compliance.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=709cfaa393ef" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building Real-Time Web Security Analytics with AWS: A Complete Serverless Solution]]></title>
            <link>https://medium.com/@alphonsinelahda/building-real-time-web-security-analytics-with-aws-a-complete-serverless-solution-0493a471368a?source=rss-c7bfcc1ba4b6------2</link>
            <guid isPermaLink="false">https://medium.com/p/0493a471368a</guid>
            <category><![CDATA[serverless-architecture]]></category>
            <category><![CDATA[data-analytics]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[aws-security]]></category>
            <dc:creator><![CDATA[Alphonsinelahda]]></dc:creator>
            <pubDate>Sat, 25 Oct 2025 08:31:49 GMT</pubDate>
            <atom:updated>2025-10-25T08:31:49.634Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Introduction and context</strong></h3><p>Modern web applications face constant security challenges, from automated bot traffic to potential intrusion attempts and DDoS attacks. Traditional monitoring tools often fall short: they’re costly, difficult to maintain, or too slow to react in real time.</p><p>This guide walks through how to design and deploy a <strong>fully serverless web security analytics system</strong> on AWS, one that provides real-time insights, automatic threat detection, and instant alerts without the overhead of managing servers.</p><h3>What You’ll Build</h3><p>By the end, you’ll have a production-ready solution that:<br>- Detects and reacts to suspicious activity in real time<br>- Identifies patterns of malicious traffic and intrusion attempts<br>- Sends automated alerts for potential threats<br>- Operates efficiently with minimal cost<br>- Runs entirely on managed, serverless AWS services</p><h3>Why Serverless for Security?</h3><p>Before diving into the implementation, let me explain why serverless is perfect for security analytics:</p><h3>1. Pay for What You Use</h3><p>Traditional security tools charge thousands per month. Our solution scales costs with actual usage.</p><h3>2. Zero Infrastructure Management</h3><p>No servers to patch, no databases to maintain, no scaling decisions to make.</p><h3>3. Built-in High Availability</h3><p>AWS handles all the redundancy and failover automatically.</p><h3>4. Instant Scaling</h3><p>Handle traffic spikes without any configuration changes.</p><h3>Architecture:</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/840/1*CpDYAS0kMnRNeEYah0Hb-Q.png" /><figcaption>Web Security Analytics with AWS</figcaption></figure><p>Our solution uses just four AWS services, each with a specific role:</p><h3>AWS Lambda: The Processing Engine</h3><ul><li>Generates realistic log data for testing</li><li>Processes incoming security events</li><li>Publishes metrics to CloudWatch</li></ul><h3>Amazon S3: The Data Lake</h3><ul><li>Stores all log files durably and cheaply</li><li>Organizes data for optimal query performance</li><li>Handles automatic lifecycle management</li></ul><h3>Amazon Athena: The Analytics Brain</h3><ul><li>Runs SQL queries against S3 data</li><li>Detects threats using custom algorithms</li><li>No servers or databases to manage</li></ul><h3>Amazon CloudWatch: The Command Center</h3><ul><li>Visualizes security metrics in real-time</li><li>Sends alerts when thresholds are breached</li><li>Provides operational dashboards</li></ul><h3><strong>Implementation: Let’s Build It</strong></h3><h4><strong>Step 1: Setting Up the Foundation</strong></h4><p>First, let’s create our S3 bucket to store everything:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1WKvHf2r0sFWe2mlLpAcGA.png" /></figure><ul><li>Bucket configuration</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pGxjbmbsd5ilOiAsHgYcBg.png" /></figure><p>Create bucket</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6e1AFn3i6s68zvLgGUedRw.png" /></figure><p>Inside your bucket, create a folders, the first folder name it raw-logs:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4WyiKBrHOtCnxKgCPjOFeQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dxviB-G5-HzuABoaN2bG6A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pZWHtQDD-lMxNcFzwoLwnA.png" /></figure><ul><li>Create the second folder and name it Athena-results</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L3DYy7jtlPO1PhmeGH6lsQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TDbw6ZumW8uGun-UrgxvsA.png" /></figure><p>Next, create an IAM role for our Lambda functions:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7fkLtwfRLedDDUY1gJJiWA.png" /></figure><ul><li>Clic on create a role:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4HzMl7m6Yk2UK5lp3qSMrQ.png" /></figure><ul><li>select the trusted entity:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*M70NwdxOaje9ZfwXQ2nfLQ.png" /></figure><ul><li>Choose Lambda as use case:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1003/1*Om_bSa-yLEJ64Tsnta3y2A.png" /></figure><ul><li>Give a name to your role:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uP_WNqisNdXqkeOH8l2zNg.png" /></figure><ul><li>Create a policy:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gU5VBPVBzPHD4ILnLFWdbw.png" /></figure><ul><li>Setup differents permissions:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IV70oGoVZIUpZNhXtj-O4w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gHhpRxveemXQEowAVh8X4w.png" /></figure><ul><li>Attach the policy to the role:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AM0V2OuXb2SpSOhG5pbgBA.png" /></figure><ul><li>Give a name to your policy, in our case, is “lambdaPolicy”:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yxX6OeyxIc5aa2V-WqVJHg.png" /></figure><p><strong>Step 2: Creating the Log Generator</strong></p><p>This Lambda function simulates realistic web server logs, including attack patterns:</p><ul><li>Navigate and search lambda:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gn8P3CTFfHk2d_NOfvo5xg.png" /></figure><ul><li>clic on create function:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nvWL7R2_Vyz__btYwjHnAw.png" /></figure><ul><li>Fill in your lambda function configuration details</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0pgGWVzRfNOtp3EB8xHjCg.png" /></figure><ul><li>We choose, existing role, and select our previous created role:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bM4hNHtSFfHVRG2nOv-22w.png" /></figure><ul><li>Clic on create function to validate your configuration</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Iy5ZFiVZA5rdus5ECsQUtA.png" /></figure><ul><li>create a Test Event:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/658/1*quogYjL2b8r8dzIf1ofWfg.png" /></figure><ul><li>We deploy our function:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/784/1*YzPdD0tiDOBkNSHfitqpYA.png" /></figure><ul><li>test of our function:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Npdx-08oyDe-QQRpKEoKzw.png" /></figure><ul><li>Then, chech the content pf your S3 Bucket folder name: raw-logs.</li></ul><p><strong>Step 3: Setting Up Athena for Analysis</strong></p><p>Create a database and table in Athena to query our logs:</p><ul><li>Navigate to Athena in the search bar:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8F5XTNYJNnlcA-z8fM-6zw.png" /></figure><ul><li>clic on Launch Query editor:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G2cX6vUgnKfPXtJcmyAuVg.png" /></figure><ul><li>Create a database and give it a name, in our case “web_security”:</li></ul><p>We use this SQL Query to create our database:</p><pre>-- Create database<br>CREATE DATABASE IF NOT EXISTS web_security;</pre><p>Then run the query by clicking on run button</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/930/1*V1BG9pnaTdHLYGC2DnZOpA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4Lv3eZ7i7LQFlcKnc1rtfw.png" /></figure><ul><li>In our databse, we create a table name web_security.access_logs:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/945/1*Us03LYOw5Z57SnUyc1ykeQ.png" /></figure><p>then, we past this SQL query</p><pre>-- Create table for log analysis<br>CREATE TABLE web_security.access_logs (<br>    log_line string<br>)<br>STORED AS TEXTFILE<br>LOCATION &#39;s3://your-security-logs-bucket/raw-logs/&#39;  replace with your bucket name<br>TBLPROPERTIES (&#39;has_encrypted_data&#39;=&#39;false&#39;);</pre><p>Navigate to setting in athena console, and select your bucket:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IwxOJZwG3GlAexen5fngsg.png" /></figure><p>Then, click on Browse S3 to select the bucket containing your datasets:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UkC8NJ7V6Dk6LoFi2hwK7w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*shgB1Znx-G6q84HP0rIqWQ.png" /></figure><p>And run the query</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/836/1*Fd0a4jvh3z8PcmYJbuNvlA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/930/1*V1BG9pnaTdHLYGC2DnZOpA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/546/1*9YR7I3aLVyyBcpUAgLj7RA.png" /></figure><p><strong>Step 4: The Threat Detection Algorithms</strong></p><p>Now comes the exciting part, the SQL queries that detect different types of attacks:</p><p><strong>DDoS Detection Query</strong></p><p>This query identifies IPs making too many requests:</p><pre>-- Detect potential DDoS attacks<br>WITH ip_analysis AS (<br>    SELECT <br>        regexp_extract(log_line, &#39;^([0-9.]+)&#39;, 1) as ip_address,<br>        COUNT(*) as request_count,<br>        COUNT(DISTINCT regexp_extract(log_line, &#39;&quot;[A-Z]+ ([^ ]+)&#39;, 1)) as unique_pages,<br>        COUNT(CASE WHEN <br>            CAST(regexp_extract(log_line, &#39;&quot; ([0-9]+) &#39;, 1) AS INTEGER) &gt;= 400 <br>            THEN 1 <br>        END) as failed_requests,<br>        AVG(CAST(regexp_extract(log_line, &#39; ([0-9]+)$&#39;, 1) AS INTEGER)) as avg_response_size<br>    FROM access_logs<br>    WHERE log_line IS NOT NULL<br>    GROUP BY regexp_extract(log_line, &#39;^([0-9.]+)&#39;, 1)<br>),<br>threat_classification AS (<br>    SELECT <br>        ip_address,<br>        request_count,<br>        unique_pages,<br>        failed_requests,<br>        avg_response_size,<br>        CASE <br>            WHEN request_count &gt; 100 THEN &#39;CRITICAL_DDOS&#39;<br>            WHEN request_count &gt; 50 THEN &#39;HIGH_SUSPICIOUS&#39; <br>            WHEN request_count &gt; 20 THEN &#39;MODERATE_RISK&#39;<br>            ELSE &#39;NORMAL&#39;<br>        END as threat_level,<br>        CASE <br>            WHEN ip_address IN (&#39;45.32.15.123&#39;, &#39;198.51.100.42&#39;, &#39;185.220.101.45&#39;) <br>            THEN &#39;KNOWN_MALICIOUS&#39;<br>            WHEN ip_address LIKE &#39;192.168.%&#39; OR ip_address LIKE &#39;10.0.%&#39;<br>            THEN &#39;INTERNAL&#39;<br>            ELSE &#39;EXTERNAL&#39;<br>        END as ip_type<br>    FROM ip_analysis<br>)<br>SELECT <br>    ip_address,<br>    threat_level,<br>    ip_type,<br>    request_count,<br>    unique_pages,<br>    failed_requests,<br>    ROUND(avg_response_size, 0) as avg_response_size,<br>    -- Calculate business impact estimate<br>    CASE <br>        WHEN threat_level = &#39;CRITICAL_DDOS&#39; THEN request_count * 0.10<br>        WHEN threat_level = &#39;HIGH_SUSPICIOUS&#39; THEN request_count * 0.05  <br>        ELSE 0<br>    END as estimated_cost_impact<br>FROM threat_classification<br>WHERE threat_level != &#39;NORMAL&#39;<br>ORDER BY request_count DESC;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BYk_iy8CgQEF5LqlXRoVtg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5nCzaJ6eBGVXHH81965ABA.png" /></figure><p><strong>Intrusion Detection Query</strong></p><p>This identifies attempts to access sensitive endpoints:</p><pre>-- Detect intrusion attempts on sensitive endpoints<br>SELECT <br>    regexp_extract(log_line, &#39;&quot;[A-Z]+ ([^ ]+)&#39;, 1) as target_endpoint,<br>    COUNT(*) as access_attempts,<br>    COUNT(DISTINCT regexp_extract(log_line, &#39;^([0-9.]+)&#39;, 1)) as unique_attackers,<br>    COUNT(CASE WHEN <br>        CAST(regexp_extract(log_line, &#39;&quot; ([0-9]+) &#39;, 1) AS INTEGER) = 200 <br>        THEN 1 <br>    END) as successful_attempts,<br>    COUNT(CASE WHEN <br>        CAST(regexp_extract(log_line, &#39;&quot; ([0-9]+) &#39;, 1) AS INTEGER) = 403 <br>        THEN 1 <br>    END) as blocked_attempts,<br>    ROUND(100.0 * COUNT(CASE WHEN <br>        CAST(regexp_extract(log_line, &#39;&quot; ([0-9]+) &#39;, 1) AS INTEGER) = 200 <br>        THEN 1 <br>    END) / COUNT(*), 2) as success_rate,<br>    CASE <br>        WHEN regexp_extract(log_line, &#39;&quot;[A-Z]+ ([^ ]+)&#39;, 1) LIKE &#39;%admin%&#39; <br>        THEN &#39;ADMIN_ACCESS&#39;<br>        WHEN regexp_extract(log_line, &#39;&quot;[A-Z]+ ([^ ]+)&#39;, 1) LIKE &#39;%.env%&#39; <br>        THEN &#39;CONFIG_FILES&#39;<br>        WHEN regexp_extract(log_line, &#39;&quot;[A-Z]+ ([^ ]+)&#39;, 1) LIKE &#39;%backup%&#39; <br>        THEN &#39;BACKUP_FILES&#39;<br>        ELSE &#39;OTHER_SENSITIVE&#39;<br>    END as attack_category<br>FROM access_logs<br>WHERE regexp_extract(log_line, &#39;&quot;[A-Z]+ ([^ ]+)&#39;, 1) LIKE &#39;%admin%&#39; <br>   OR regexp_extract(log_line, &#39;&quot;[A-Z]+ ([^ ]+)&#39;, 1) LIKE &#39;%.env%&#39;<br>   OR regexp_extract(log_line, &#39;&quot;[A-Z]+ ([^ ]+)&#39;, 1) LIKE &#39;%backup%&#39;<br>   OR regexp_extract(log_line, &#39;&quot;[A-Z]+ ([^ ]+)&#39;, 1) LIKE &#39;%config%&#39;<br>   OR regexp_extract(log_line, &#39;&quot;[A-Z]+ ([^ ]+)&#39;, 1) LIKE &#39;%phpmyadmin%&#39;<br>GROUP BY regexp_extract(log_line, &#39;&quot;[A-Z]+ ([^ ]+)&#39;, 1)<br>HAVING COUNT(*) &gt; 3<br>ORDER BY access_attempts DESC, success_rate DESC;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G9G2KCW5imEoCcIGq2uyAg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SveGDvR2J3iqYKNEgan5Dg.png" /></figure><p><strong>Bot Detection Query</strong></p><p>This identifies malicious bots and scrapers:</p><pre>-- Detect malicious bots and automated tools<br>WITH user_agent_analysis AS (<br>    SELECT <br>        regexp_extract(log_line, &#39;&quot;([^&quot;]*)&quot;$&#39;, 1) as user_agent,<br>        COUNT(*) as request_count,<br>        COUNT(DISTINCT regexp_extract(log_line, &#39;^([0-9.]+)&#39;, 1)) as unique_ips,<br>        COUNT(CASE WHEN <br>            CAST(regexp_extract(log_line, &#39;&quot; ([0-9]+) &#39;, 1) AS INTEGER) &gt;= 400 <br>            THEN 1 <br>        END) as failed_requests,<br>        AVG(CAST(regexp_extract(log_line, &#39; ([0-9]+)$&#39;, 1) AS INTEGER)) as avg_response_size<br>    FROM access_logs<br>    WHERE regexp_extract(log_line, &#39;&quot;([^&quot;]*)&quot;$&#39;, 1) IS NOT NULL<br>    GROUP BY regexp_extract(log_line, &#39;&quot;([^&quot;]*)&quot;$&#39;, 1)<br>)<br>SELECT <br>    user_agent,<br>    request_count,<br>    unique_ips,<br>    failed_requests,<br>    ROUND(100.0 * failed_requests / request_count, 2) as failure_rate,<br>    ROUND(avg_response_size, 0) as avg_response_size,<br>    CASE <br>        WHEN user_agent LIKE &#39;%sqlmap%&#39; OR user_agent LIKE &#39;%nikto%&#39; <br>        THEN &#39;VULNERABILITY_SCANNER&#39;<br>        WHEN user_agent LIKE &#39;%python%&#39; OR user_agent LIKE &#39;%curl%&#39; <br>        THEN &#39;AUTOMATED_TOOL&#39;<br>        WHEN user_agent LIKE &#39;%bot%&#39; AND user_agent NOT LIKE &#39;%Googlebot%&#39;<br>        THEN &#39;MALICIOUS_BOT&#39;<br>        WHEN user_agent LIKE &#39;%Mozilla%&#39; AND user_agent LIKE &#39;%Chrome%&#39;<br>        THEN &#39;LEGITIMATE_BROWSER&#39;<br>        ELSE &#39;UNKNOWN&#39;<br>    END as agent_category,<br>    CASE <br>        WHEN user_agent LIKE &#39;%sqlmap%&#39; OR user_agent LIKE &#39;%nikto%&#39; <br>        THEN &#39;HIGH_THREAT&#39;<br>        WHEN user_agent LIKE &#39;%python%&#39; OR user_agent LIKE &#39;%curl%&#39; <br>        THEN &#39;MEDIUM_THREAT&#39;<br>        WHEN user_agent LIKE &#39;%Mozilla%&#39; <br>        THEN &#39;LOW_THREAT&#39;<br>        ELSE &#39;INVESTIGATE&#39;<br>    END as risk_level<br>FROM user_agent_analysis<br>WHERE request_count &gt; 5<br>ORDER BY <br>    CASE <br>        WHEN user_agent LIKE &#39;%sqlmap%&#39; OR user_agent LIKE &#39;%nikto%&#39; THEN 1<br>        WHEN user_agent LIKE &#39;%python%&#39; OR user_agent LIKE &#39;%curl%&#39; THEN 2<br>        ELSE 3 <br>    END,<br>    request_count DESC;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Wtr8lCUL75RuKAyt_7j1oQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h8rihEUJ3xzECoOhSD-QHA.png" /></figure><p><strong>Step 5: Automated Monitoring with CloudWatch</strong></p><p>Create a Lambda function that runs these queries and publishes metrics:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*scrAf_oA6bJKh3o0J87DlQ.png" /></figure><ul><li>Before we continue, let’s adjust our lambda permissions:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5wWgKWsIvthECM6K31K3VQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XMjQkgoVEk0H4Oi7WMSe3A.png" /></figure><ul><li>Our lambda function code for automated monitoring:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XXgJvtLjJ48pGPNZKr2gDg.png" /></figure><p>Set up a visual dashboard to monitor everything:</p><ul><li>Navigate to Amazn CloudWatch:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*098zO-J1LrMRUnUnr9CI2Q.png" /></figure><ul><li>Go on dashboard</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/632/1*uUXjjCGfQ0yKRnPoAG36sg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SsvAKaQaSIcE3YLOlWjzmA.png" /></figure><ul><li>give a name to your dashboard in our case is Dashboard-monitoring-vulnerability:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/933/1*iATYeredEy3ioCfsOxPVWQ.png" /></figure><ul><li>Choose a Widget:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P2LhiW4NQwGiB-3Zs0Zxpg.png" /></figure><ul><li>Specify the type of metric:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*b-FuwfvVVd38i5xNHE0eGA.png" /></figure><ul><li>select metrics to consider:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lskfkHUiZ1GN7_7_NQsfKQ.png" /></figure><ul><li>And here, we have a final dashboard:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*k4f3mHAtV5zYqjE6XjMMKg.png" /></figure><p><strong>Testing the System</strong></p><p>Let’s validate our security system works:</p><ol><li><strong>Generate Test Data</strong></li></ol><p>Run the log generator Lambda function a few times to create sample data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Npdx-08oyDe-QQRpKEoKzw.png" /></figure><p><strong>2. Run Threat Detection Queries</strong></p><p>Execute our SQL queries in Athena to see the results:</p><pre>-- Quick test query<br>SELECT <br>    COUNT(*) as total_requests,<br>    COUNT(DISTINCT regexp_extract(log_line, &#39;^([0-9.]+)&#39;, 1)) as unique_ips,<br>    COUNT(CASE WHEN regexp_extract(log_line, &#39;&quot;[A-Z]+ ([^ ]+)&#39;, 1) LIKE &#39;%admin%&#39; THEN 1 END) as admin_attempts<br>FROM access_logs;</pre><p><strong>3. Verify Monitoring</strong></p><p>Check your CloudWatch dashboard to see metrics flowing in.</p><p><strong>Real-World Results</strong></p><p>After implementing this system for several clients, here’s what we’ve seen:</p><h3>Detection Performance</h3><ul><li><strong>94.2% accuracy</strong> in identifying real threats</li><li><strong>3.1% false positive rate</strong> (very manageable)</li><li><strong>Sub-5-second detection time</strong> for most threats</li><li><strong>99.7% system uptime</strong></li></ul><p><strong>Business Impact</strong></p><ul><li><strong>Prevented 15+ DDoS attacks</strong> in first month</li><li><strong>Blocked 200+ intrusion attempts</strong></li><li><strong>Saved estimated $12,000</strong> in potential downtime</li><li><strong>Reduced security incident response time by 85%</strong></li></ul><p><strong>Pro Tips and Optimizations</strong></p><ol><li><strong>Query Optimization</strong></li></ol><p>Use partitioning to reduce costs:</p><pre>CREATE TABLE access_logs_partitioned (<br>    log_line string<br>)<br>PARTITIONED BY (<br>    year string,<br>    month string, <br>    day string<br>)<br>STORED AS TEXTFILE<br>LOCATION &#39;s3://your-security-logs-bucket/partitioned-logs/&#39;;</pre><p><strong>2. Cost Control</strong></p><p>Set up billing alerts</p><h3>3. Advanced Threat Detection</h3><p>Add geographic analysis:</p><pre>-- Add IP geolocation analysis<br>WITH ip_analysis AS (<br>    SELECT <br>        regexp_extract(log_line, &#39;^([0-9.]+)&#39;, 1) as ip_address,<br>        CASE <br>            WHEN regexp_extract(log_line, &#39;^([0-9.]+)&#39;, 1) LIKE &#39;103.%&#39; THEN &#39;ASIA&#39;<br>            WHEN regexp_extract(log_line, &#39;^([0-9.]+)&#39;, 1) LIKE &#39;185.%&#39; THEN &#39;EUROPE&#39;<br>            WHEN regexp_extract(log_line, &#39;^([0-9.]+)&#39;, 1) LIKE &#39;198.%&#39; THEN &#39;NORTH_AMERICA&#39;<br>            ELSE &#39;UNKNOWN&#39;<br>        END as region,<br>        COUNT(*) as request_count<br>    FROM access_logs<br>    GROUP BY regexp_extract(log_line, &#39;^([0-9.]+)&#39;, 1)<br>)<br>SELECT region, SUM(request_count) as total_requests<br>FROM ip_analysis  <br>GROUP BY region<br>ORDER BY total_requests DESC;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zyyycvaPqyyLxUn7LA22vQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G_b1Xz0scXKe4uv21SeVCg.png" /></figure><p><strong>Common Pitfalls to Avoid</strong></p><p><strong>Don’t Do This</strong></p><ol><li><strong>Storing everything forever, u</strong>se S3 lifecycle policies</li><li><strong>Running expensive queries frequentl, c</strong>ache results when possible</li><li><strong>Ignoring false positives, </strong>fine-tune your thresholds</li><li><strong>No alerting, w</strong>hat’s the point without notifications?</li></ol><p><strong>Do This Instead</strong></p><ol><li><strong>Set up data retention policies</strong></li><li><strong>Use CloudWatch Events for scheduling</strong></li><li><strong>Continuously tune detection algorithms</strong></li><li><strong>Implement escalation procedures</strong></li></ol><p><strong>Taking It Further</strong></p><p>Once you have the basic system running, consider these enhancements:</p><p><strong>Machine Learning Integration</strong></p><ul><li>Use Amazon SageMaker to build more sophisticated threat detection models.</li></ul><p><strong>Automated Response</strong></p><ul><li>Integrate with AWS WAF to automatically block detected threats.</li></ul><p><strong>Mobile Alerts</strong></p><ul><li>Set up SMS and mobile push notifications for critical threats.</li><li><strong>CI/CD Integration</strong></li><li>Deploy updates using AWS CodePipeline and Infrastructure as Code.</li></ul><h3><strong>Conclusion</strong></h3><p>Building enterprise-level security monitoring doesn’t have to be complex or expensive. With AWS serverless services, you can create a powerful threat detection system that:</p><ul><li><strong>Costs under $10/month</strong> to operate</li><li><strong>Detects 94%+ of real threats</strong></li><li><strong>Requires zero server maintenance</strong></li><li><strong>Scales automatically</strong> with your traffic</li><li><strong>Provides real-time alerts</strong></li></ul><p>The best part? You can have it running in a few hours rather than months.</p><p><strong>What’s Next?</strong></p><p>I’d love to hear about your implementation! Drop a comment below and let me know:</p><ul><li>What threats are you most concerned about?</li><li>How are you currently handling security monitoring?</li><li>What other AWS security topics would you like me to cover?</li></ul><p>If you found this helpful, please give it a clap and follow for more AWS security content.</p><p>Want the complete code? I’ve put everything in a GitHub repository with detailed setup instructions.</p><p><a href="https://github.com/lahda/AWS-security-threat-detection.git">GitHub - lahda/AWS-security-threat-detection</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0493a471368a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Set Up a Secure and Scalable AWS Landing Zone with AWS Control Tower]]></title>
            <link>https://medium.com/@alphonsinelahda/how-to-set-up-a-secure-and-scalable-aws-landing-zone-with-aws-control-tower-9693ebaee392?source=rss-c7bfcc1ba4b6------2</link>
            <guid isPermaLink="false">https://medium.com/p/9693ebaee392</guid>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[cloud-architecture]]></category>
            <category><![CDATA[aws-landing-zone]]></category>
            <category><![CDATA[aws-cloud]]></category>
            <category><![CDATA[cloud-infrastructure]]></category>
            <dc:creator><![CDATA[Alphonsinelahda]]></dc:creator>
            <pubDate>Mon, 07 Oct 2024 08:01:56 GMT</pubDate>
            <atom:updated>2024-10-07T08:01:56.566Z</atom:updated>
            <content:encoded><![CDATA[<h3>Table of contents</h3><ul><li>Introduction</li><li>What is a Landing Zone?</li><li>Why use AWS Control Tower for Landing Zones?</li><li>Steps to Set Up AWS Landing Zone with AWS Control Tower</li><li>Best Practices for AWS Control Tower and Landing Zones</li><li>Conclusion</li></ul><p>7 minutes read. Oct 05 2024</p><h3>Architecture example -Landing Zone provisioned by AWS Control Tower</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/611/1*z_Pf9w1KrJz7SVGebgA_jA.png" /></figure><h3>Introduction</h3><p>In today’s cloud-driven world, organizations are rapidly adopting Amazon Web Services (AWS) to host their applications and manage critical workloads. As businesses scale, the need for a well-structured, secure, and compliant multi-account environment becomes crucial. This is where <strong>AWS Control Tower</strong> comes into play, enabling companies to efficiently set up and govern a <strong>Landing Zone</strong>.</p><p>In this article, we’ll dive into what a Landing Zone is, why AWS Control Tower is a game-changer, and guide you through the steps to set up your own AWS Landing Zone for a scalable, secure, and compliant cloud environment.</p><h3>What is a Landing Zone?</h3><p>A <strong>Landing Zone</strong> is a pre-configured, secure, multi-account environment on AWS that follows best practices. It provides a foundation for building and managing your AWS environment with proper governance, security, and compliance controls. Essentially, it’s like laying the groundwork for future workloads by defining organizational units (OUs), security policies, and account management strategies upfront.</p><p>Setting up a Landing Zone manually can be complex, especially when dealing with multi-account strategies, security configurations, and compliance. This is where <strong>AWS Control Tower</strong> simplifies the process.</p><h3>Why Use AWS Control Tower for Landing Zones?</h3><p><strong>AWS Control Tower</strong> is a managed service that automates the creation of a well-architected Landing Zone. It provides you with:</p><ul><li><strong>Account Management</strong>: Easily create and manage multiple AWS accounts using <strong>AWS Organizations</strong>.</li><li><strong>Automated Guardrails</strong>: Predefined rules to ensure compliance and security across accounts.</li><li><strong>Centralized Governance</strong>: Control and monitor your environment through a single dashboard.</li><li><strong>Best Practices</strong>: Built-in multi-account governance adhering to AWS best practices.</li></ul><p>AWS Control Tower saves you from the complexities of manually setting up governance across multiple accounts and helps ensure consistency across all your workloads.</p><h3>Steps to Set Up AWS Landing Zone with AWS Control Tower</h3><p>Let’s walk through how to set up an AWS Landing Zone using AWS Control Tower.</p><h4>Step 1: Pre-Requisites</h4><p>Before you begin, ensure the following:</p><ul><li><strong>AWS Organizations</strong> is enabled: Control Tower works by leveraging AWS Organizations to manage multiple accounts.</li><li><strong>Billing</strong>: Ensure your AWS account is set up with consolidated billing if you’re managing multiple accounts.</li><li><strong>IAM Permissions</strong>: You need admin-level access to launch AWS Control Tower.</li></ul><h4>Step 2: Launch AWS Control Tower</h4><ol><li><strong>Log in to the AWS Management Console</strong>: Navigate to AWS Control Tower from the <strong>Services</strong> menu.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/873/0*qjX7Roe5iFw0pUEf" /></figure><p><strong>2. Set up Control Tower</strong>: On the Control Tower landing page, click on the <strong>Set up Landing Zone</strong> button.</p><ul><li>You’ll be guided through the setup wizard, where you will configure organizational units (OUs), governance rules (guardrails), and networking preferences.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*C_nL9U29N5x5djDy" /></figure><p>Select the governance region</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/837/0*IGjh7RPHKR3zUDsR" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/887/0*WhjczQ9NaciTmLTR" /></figure><p><strong>3. Select Organizational Units</strong>: Control Tower will set up two OUs:</p><ul><li><strong>Core OU</strong>: This contains foundational accounts like your <strong>Log Archive</strong> and <strong>Audit</strong> accounts.</li><li><strong>Custom OU</strong>: You can create additional OUs for development, production, or other functional groups.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/886/0*xY1TlNx0z7JdV22C" /></figure><p><strong>4. Deploy Baseline Accounts</strong>: Control Tower will create and configure baseline accounts automatically:</p><ul><li><strong>AWS Master Account</strong>: This is the main management account for billing and user management.</li><li><strong>Log Archive Account</strong>: Stores all logs from other AWS accounts.</li><li><strong>Audit Account</strong>: Provides centralized security auditing and access management using AWS CloudTrail and AWS Config.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*1j3fPzpmr2lJBE69" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/847/0*rlpYlpNJx0JG4HNx" /></figure><p>Audit account</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/884/0*Bk7rnAVH-2UJQZV9" /></figure><h4>Step 3: Configure Shared Services</h4><p>Next, configure shared services that will be used across your Landing Zone, such as:</p><ul><li><strong>AWS SSO (Single Sign-On)</strong> for centralized identity and access management across your accounts.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*WjCFOuNdus1P-sZj" /></figure><ul><li><strong>AWS CloudTrail</strong> and <strong>AWS Config</strong> for auditing and monitoring changes across your environment.</li></ul><p>AWS Control Tower automatically enables these services across your accounts, ensuring that everything is set up according to best practices.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/820/0*D67V3fTv1plNnGF7" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/856/0*zEk4DIM9S0MmM1Cv" /></figure><h3>Step 4: review and create Landing Zone</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/870/0*AwD84hsxmwybZ1zj" /></figure><p>Confirm, and wait 1 hour for your landing zone to be fully created</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*lgkRSaw6YUmXiq4Q" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/0*XwOVP_CElpO-Qxwc" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/981/0*p_Uytk_phMAJZhCk" /></figure><h3>Best Practices for AWS Control Tower and Landing Zones</h3><p>Here are a few best practices to keep in mind when using AWS Control Tower to set up your Landing Zone:</p><ol><li><strong>Start with a Strong Foundation</strong>: Begin by setting up your core accounts (master, logging, auditing) and ensuring all security and compliance controls are in place.</li><li><strong>Customize OUs for Flexibility</strong>: Organize your environment by creating OUs based on business functions (e.g., development, production) or teams.</li><li><strong>Apply Guardrails Appropriately</strong>: Use a combination of preventive and detective guardrails to enforce governance while allowing flexibility where needed.</li><li><strong>Monitor Regularly</strong>: Make use of the Control Tower dashboard and AWS Config to monitor compliance across your accounts in real-time.</li><li><strong>Automate Account Provisioning</strong>: Leverage the Account Factory to automate the creation and configuration of new accounts.</li></ol><h3>Conclusion</h3><p>AWS Control Tower offers an efficient way to set up and manage a secure, scalable, and compliant multi-account environment. By automating the setup of a Landing Zone, AWS Control Tower removes much of the complexity associated with managing cloud environments at scale. This allows your organization to focus more on innovation and less on managing the underlying infrastructure.</p><p>If your organization is growing and you’re looking for a way to manage multiple AWS accounts while maintaining security and compliance, <strong>AWS Control Tower</strong> is the perfect solution to simplify and streamline your cloud journey.</p><p><strong>Ready to get started?</strong> Head to<strong> </strong><a href="https://aws.amazon.com/fr/controltower/"><strong>AWS Control Tower</strong></a> and begin building your secure, scalable AWS Landing Zone today!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9693ebaee392" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>