<?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 Hilda Machando on Medium]]></title>
        <description><![CDATA[Stories by Hilda Machando on Medium]]></description>
        <link>https://medium.com/@hildamachando4?source=rss-59bdf2526b43------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*at9akFzeLGokUAYeEcST2w.png</url>
            <title>Stories by Hilda Machando on Medium</title>
            <link>https://medium.com/@hildamachando4?source=rss-59bdf2526b43------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 16:49:59 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@hildamachando4/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[How Trusted Proxy Chains Actually Work]]></title>
            <link>https://medium.com/@hildamachando4/how-trusted-proxy-chains-actually-work-eb9cad6851e3?source=rss-59bdf2526b43------2</link>
            <guid isPermaLink="false">https://medium.com/p/eb9cad6851e3</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[proxy]]></category>
            <category><![CDATA[how-to]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[technology]]></category>
            <dc:creator><![CDATA[Hilda Machando]]></dc:creator>
            <pubDate>Mon, 02 Nov 2026 12:31:01 GMT</pubDate>
            <atom:updated>2026-11-02T12:31:01.538Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pAC8U4OvcpSwiIBhPnt20g.png" /></figure><p>One of the things that came up after looking at X-Forwarded-For behind CloudFront was the idea that the solution is simple: either trust the first IP, or trust the last IP. The problem is that both statements can be wrong depending on the architecture, on paper, X-Forwarded-For normally looks something like this:</p><pre>X-Forwarded-For: client, proxy1, proxy2</pre><p>which makes the debate seem straightforward because the leftmost address is conventionally the original client, while the rightmost address is the most recent proxy that handled the request. MDN describes the header in essentially this way, but with an important qualification: that interpretation assumes the client and proxies are behaving properly. And that qualification is where most of the security discussion begins.</p><h3>Start with a simple proxy</h3><p>Suppose we have:</p><pre>Client<br>   |<br>   v<br>Reverse Proxy<br>   |<br>   v<br>Application</pre><p>The client has an IP of:</p><pre>203.0.113.10</pre><p>When the client connects to the proxy, the proxy can observe that address from the actual network connection and add:</p><pre>X-Forwarded-For: 203.0.113.10</pre><p>The application itself does not directly see the client anymore because its TCP connection is coming from the reverse proxy, which means something like REMOTE_ADDR might contain the proxy address instead.</p><p>So far this is fairly simple.</p><p>The application trusts the proxy and therefore trusts the client information that the proxy added.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ymSLX-LOBc215iSLt6r3jw.png" /></figure><p>The CDN sees the client first and forwards the request, then the load balancer sees the CDN and forwards it again, which means we might eventually have something like:</p><pre>X-Forwarded-For: 203.0.113.10, 198.51.100.20</pre><p>where:</p><pre>203.0.113.10 = client<br>198.51.100.20 = CDN</pre><p>and the application itself sees the load balancer as the immediate network peer.</p><p>At this point simply asking for “the client IP” has already become slightly more complicated because there are now three different addresses involved, all representing something legitimate at different points in the request path.</p><h3>Then the attacker gets a vote</h3><p>The real problem starts because X-Forwarded-For is an HTTP header, which means a client can often send one themselves.</p><p>Suppose the attacker sends:</p><pre>X-Forwarded-For: 1.2.3.4</pre><p>and our CDN follows the normal behaviour of appending the address it actually observes.</p><p>We could end up with:</p><pre>X-Forwarded-For: 1.2.3.4, 203.0.113.10</pre><p>Then another proxy adds its information and eventually the application sees something like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q2e9SMDVUxPDhdUEjvAJ9Q.png" /></figure><p>Now look at the addresses again.</p><pre>1.2.3.4        = attacker supplied<br>203.0.113.10   = actual client observed by the CDN<br>198.51.100.20  = intermediary proxy</pre><p>This is why “the leftmost address is always the client” immediately breaks down for security purposes.</p><p>Yes, according to the convention the first address represents the original client, but nothing about the header itself guarantees that the original client did not write that value.</p><p>MDN makes the same distinction quite explicitly: values added by trusted proxies can be relied on, while anything outside that trusted portion of the chain may be spoofed.</p><h3>So use the rightmost IP?</h3><p>This is normally where the opposite advice appears:</p><blockquote><em>Just work from the right.</em></blockquote><p>That is much closer to how trusted proxy evaluation actually works, but even then the rule is not simply “the rightmost IP is the client”.</p><p>Take:</p><pre>X-Forwarded-For: 1.2.3.4, 203.0.113.10, 198.51.100.20</pre><p>If I blindly take the rightmost value, I get:</p><pre>198.51.100.20</pre><p>which may simply be another proxy.</p><p>So the point of moving from right to left is not to find the last address.</p><p>It is to <strong>remove the infrastructure you already trust</strong>.</p><p>That is a very different idea.</p><h3>Think of it as peeling the chain backwards</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZwiI4OHJjpdT6SxvDDGu6g.png" /></figure><p>Suppose the application receives a connection from:</p><pre>10.0.2.15</pre><p>and we know that 10.0.2.15 belongs to our load balancer.</p><p>We trust it, so we move one step backwards.</p><p>The next address in the chain might be:</p><pre>198.51.100.20</pre><p>and suppose that belongs to our CDN.</p><p>We trust that too, so again we move backwards.</p><p>The next value is:</p><pre>203.0.113.10</pre><p>and that is not one of our trusted proxies.</p><p>So we stop.</p><p>Conceptually, the reasoning is:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FH7HOWzY_aipWhcGY85NcQ.png" /></figure><p>That first address outside your trusted proxy chain is the interesting one.</p><p>It may be the actual end user, or it may be another untrusted proxy the user happened to be using, but from your application’s perspective that is the point where your ability to establish trust ends.</p><p>MDN describes the trusted proxy list approach in essentially the same way: start from the rightmost side, skip addresses belonging to trusted proxies and use the first address that does not match the trusted proxy list.</p><h3>Trusted proxy count vs trusted proxy identity</h3><p>There are generally two ways systems try to solve this.</p><p>The first is by <strong>counting hops</strong>.</p><p>If you know there are always exactly three proxies in front of your application, you can say, effectively:</p><pre>skip the infrastructure contributed by those three proxies<br>then use the next address</pre><p>This can work, but it is fragile because infrastructure rarely stays perfectly static.</p><p>Maybe tomorrow another CDN gets added.</p><p>Maybe requests from one region take a different path.</p><p>Maybe an internal reverse proxy gets introduced for certain endpoints.</p><p>Now your assumption that there are always exactly three intermediaries is wrong and the address you select can shift. The stronger model is usually to define <strong>which proxies are actually trusted</strong>, normally using known IPs or network ranges, then walk backwards while the addresses belong to those trusted systems. Symfony works using this kind of trusted proxy model because you configure which reverse proxies it is allowed to trust and which forwarded headers it should accept from them.</p><p>So rather than saying:</p><pre>trust the third address from the right</pre><p>you are effectively saying:</p><pre>trust these infrastructure boundaries</pre><p>which is much closer to what we actually mean from a security perspective.</p><h3>The immediate connection matters too</h3><p>There is another subtle part of this that is easy to overlook.</p><p>Imagine your application receives:</p><pre>X-Forwarded-For: 203.0.113.10</pre><p>and that address is perfectly plausible.</p><p>That still tells you very little if anybody on the internet can connect directly to the application. Because an attacker could simply do:</p><pre>Attacker<br>   |<br>   | X-Forwarded-For: 203.0.113.10<br>   |<br>   v<br>Application</pre><p>and now there is no trusted proxy involved at all.</p><p>This is why trusted proxy handling starts with the <strong>immediate peer</strong>, not just the contents of X-Forwarded-For.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*I5pGcRtm_NQghcodFYUgGA.png" /></figure><p>If the connection reaching your application is not coming from something you trust, you should not suddenly trust proxy headers simply because they happen to look correctly formatted.</p><p>Symfony makes exactly this warning when discussing configurations where proxy addresses change dynamically: if you are going to broadly trust the incoming proxy, you first need to make sure your application cannot also receive requests directly from untrusted clients.</p><p>So the real chain is not just:</p><pre>X-Forwarded-For</pre><p>It is closer to:</p><pre>REMOTE_ADDR<br>      +<br>X-Forwarded-For<br>      +<br>known network architecture<br>      =<br>trusted client boundary</pre><h3>Several proxies make this more interesting</h3><p>Now imagine a slightly more realistic cloud setup:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DYkvdCdfZh-FrlIOaGmffA.png" /></figure><p>At this point asking “is the first or last IP correct?” is really the wrong question.</p><p>The questions I would actually want answered are:</p><pre>Can clients connect directly to CloudFront?</pre><pre>Can they bypass CloudFront and reach the ALB?</pre><pre>Can they bypass the ALB and reach NGINX?</pre><pre>Which layer replaces X-Forwarded-For?</pre><pre>Which layers append to it?</pre><pre>Which address ranges belong to Cloudflare?</pre><pre>Which belong to CloudFront?</pre><pre>Which headers does the ALB modify?</pre><pre>Which of those systems does Symfony trust?</pre><p>Because only after answering those questions can you safely interpret the chain.</p><p>This is why something as simple as a client IP eventually becomes an architecture problem rather than an HTTP problem.</p><h3>One more reason not to parse this yourself</h3><p>There are also several annoying edge cases that tend to appear once people start implementing their own XFF parser.</p><p>For example, a request can contain more than one X-Forwarded-For header, and those values need to be interpreted as one logical list rather than simply reading whichever header happens to be returned first by your framework. There are IPv6 addresses to handle. there may be malformed or deliberately strange values, there may also be private addresses, multiple internal proxies and different request paths depending on where the traffic originated.</p><p>MDN specifically warns that incorrect parsing of X-Forwarded-For can have security consequences and recommends processing the complete list when the value is being used for security-sensitive purposes. Which is another reason why:</p><pre>explode(&#39;,&#39;, $_SERVER[&#39;HTTP_X_FORWARDED_FOR&#39;])</pre><p>followed by picking whichever element feels right is probably not where you want your security model to live.</p><h3>So which IP is the real client?</h3><p>After all of that, the slightly unsatisfying answer is: <strong>it depends on which proxies you trust. </strong>The leftmost address is conventionally the original client address, but it may also be attacker-controlled while the rightmost XFF address is normally closest to your application, but it may simply identify another proxy, so instead of treating either end of the list as authoritative, establish the request path you trust and work backwards through it.</p><p>The mental model I find easiest is:</p><pre>Start with the system that connected directly to me.</pre><pre>Do I trust it?<br>        |<br>       Yes<br>        |<br>Move backwards one hop.</pre><pre>Do I trust that proxy?<br>        |<br>       Yes<br>        |<br>Move backwards again.</pre><pre>First address I cannot establish as trusted?<br>        |<br>        v<br>That is my client boundary.</pre><p>And I think <strong>client boundary</strong> is actually a more useful phrase than “real client IP”, because beyond that point there may be NAT, VPNs, corporate proxies, privacy networks or other intermediaries that your application has no way of seeing through anyway. The objective is not to somehow discover the human sitting behind the browser, it’s simply to determine the first network identity outside the infrastructure you control and trust.</p><p>Once you frame the problem that way, the “first IP vs last IP” argument becomes a lot less confusing.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eb9cad6851e3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[When X-Forwarded-For “Lies” aka the Client IP Problem Behind CloudFront, AWS WAF and Symfony]]></title>
            <link>https://awstip.com/when-x-forwarded-for-lies-aka-the-client-ip-problem-behind-cloudfront-aws-waf-and-symfony-236fe7a409e3?source=rss-59bdf2526b43------2</link>
            <guid isPermaLink="false">https://medium.com/p/236fe7a409e3</guid>
            <category><![CDATA[aws-waf]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[aws-cloudfront]]></category>
            <category><![CDATA[symfony]]></category>
            <category><![CDATA[usability]]></category>
            <dc:creator><![CDATA[Hilda Machando]]></dc:creator>
            <pubDate>Wed, 02 Sep 2026 11:04:24 GMT</pubDate>
            <atom:updated>2026-09-03T10:54:19.817Z</atom:updated>
            <content:encoded><![CDATA[<p>Client IP addresses seem simple until you put a CDN, WAF, load balancer and an application framework between the user and your application, and then one day you look at a header like this:</p><pre>X-Forwarded-For: 203.0.113.50, 198.51.100.27, 10.0.1.14</pre><p>and have to answer a surprisingly difficult question: <strong>Which of those addresses can I actually trust?</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*90SLOfs1RoLmX-t9RRqOHQ.png" /></figure><p>I recently came across this problem while looking at a Symfony application sitting behind Amazon CloudFront because the application trusted its proxies and ultimately treated the leftmost value in X-Forwarded-For as the client IP, and to be honest at first glance it seemed perfectly normal since X-Forwarded-For is conventionally represented as:</p><pre>X-Forwarded-For: client, proxy1, proxy2</pre><p>So surely the first address would be the client, except there’s a problem and herein lies the question: what happens when the “client” is allowed to supply that first address themselves? That takes us into one of those infrastructure security problems where everything can look perfectly reasonable on paper, every component can be behaving exactly as documented, and yet the final outcome can still be unsafe because the real issue sits somewhere in the assumptions between those components.</p><h3>The innocent-looking assumption</h3><p>Imagine my actual public IP address is:</p><pre>198.51.100.25</pre><p>I connect to CloudFront normally, without supplying an X-Forwarded-For header, CloudFront sees my source IP from the network connection and sends something like:</p><pre>X-Forwarded-For: 198.51.100.25</pre><p>Nothing particularly interesting there because the application receives the header, sees the first address and correctly identifies me as 198.51.100.25, but now let’s suppose I deliberately send this:</p><pre>X-Forwarded-For: 1.2.3.4</pre><p>You might expect CloudFront to throw my value away and replace it with the address it actually observed, but the kicker is that it doesn’t. CloudFront’s documented behaviour is that if an incoming request already contains X-Forwarded-For, it obtains the actual viewer IP from the connection and <strong>appends it to the existing value</strong>, so what eventually gets forwarded looks like this:</p><pre>X-Forwarded-For: 1.2.3.4, 198.51.100.25</pre><p>And suddenly the security implication becomes obvious because the value on the right was observed by CloudFront, while the value on the left came from me. If your application blindly asks <em>“what’s the first IP?”</em> it gets:</p><pre>1.2.3.4</pre><p>which means I have effectively chosen my own IP address.</p><p>That alone is enough to make the issue interesting, but it becomes much more important when the application is doing more than simply displaying the address somewhere in a debug page, because in a real environment that same value may quietly feed into rate limiting, access control, fraud detection, geolocation decisions, authentication alerts and even forensic logging.</p><h3>This isn’t really an X-Forwarded-For problem</h3><p>It is tempting to conclude that X-Forwarded-For itself is insecure, but that is not quite the right lesson because the real issue here is <strong>trust</strong>. A forwarded header is simply information carried in an HTTP request, and whether that information is useful or dangerous depends entirely on who was allowed to write it, modify it and pass it on. Consider this chain:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G3ssgpuXJmUlpWc8yez51Q.png" /></figure><p>Every hop changes what the next system can reliably know, so if the application eventually receives something like:</p><pre>X-Forwarded-For: attacker-value, viewer-ip, cloudfront-ip</pre><p>you cannot simply decide that:</p><pre>first = client</pre><p>and you cannot safely decide that:</p><pre>last = client</pre><p>either.</p><p>The more useful question is: <em>which proxies do I trust, and which address remains once I have accounted for the addresses contributed by those trusted proxies?</em></p><p>That distinction matters because the rightmost address is not magically trustworthy simply because it is rightmost, just as the leftmost address is not automatically the real user simply because the X-Forwarded-For convention says the client should appear first. An address becomes meaningful when you know which system supplied it, you trust that system, and you also know the request could not have bypassed that system altogether. And that is really why proxy trust needs to be treated as a <strong>chain</strong>, rather than as a string-parsing exercise.</p><h3>Symfony actually understands this model</h3><p>Symfony has explicit support for trusted proxies, which is important because this is exactly the kind of problem a framework should be handling rather than leaving every developer to reinvent it. You tell Symfony which proxies it should trust and which forwarded headers those proxies are allowed to provide, and Symfony can then work backwards through the request path using that trust configuration instead of blindly assuming that whatever appears first in a header must be genuine.</p><p>There is also an important architectural point here because trusting a proxy only makes sense if the request actually came through that proxy. If your origin can also be reached directly from the internet, then an attacker can simply bypass the trusted layer and send the same headers themselves, which means your application has no reliable way of distinguishing a genuine proxy-generated value from one the attacker invented.</p><p>That is a much stronger security model than doing something like:</p><pre>$ip = explode(&#39;,&#39;, $_SERVER[&#39;HTTP_X_FORWARDED_FOR&#39;])[0];</pre><p>because the latter is simply parsing a string, while the former is trying to establish provenance, and provenance is what we actually care about.</p><p>If I were reviewing an application and found the equivalent of “trust every proxy and take the first XFF address”, I would immediately want to understand what that value is being used for because once the application treats that IP as authoritative, the impact can spread quite quickly into areas like:.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hi-7TA36y1Ajmfe7n-JT3g.png" /></figure><p>Imagine, for example, an audit log confidently telling you:</p><pre>Failed login from: 8.8.8.8</pre><p>when the attacker simply typed 8.8.8.8 into the request header.</p><p>The log looks precise, it looks useful and it may even make its way into a SOC alert or an incident report, but it is still wrong, and in some cases misleading telemetry can actually be worse than missing telemetry because investigators think they have evidence when what they really have is attacker-controlled input dressed up as attribution.</p><h3>Then I looked at AWS WAF</h3><p>This is where the problem became much more interesting because AWS WAF also supports forwarded IP configurations, and for Geo Match, ASN Match and rate-based statements you can tell WAF to obtain the client address from a forwarded HTTP header such as X-Forwarded-For. The part that immediately caught my attention was that for these forwarded-IP configurations, AWS WAF evaluates the <strong>first IP address</strong> in the configured header. So taking our earlier request again:</p><pre>X-Forwarded-For: 1.2.3.4, 198.51.100.25</pre><p>if WAF is configured to determine the client using the first IP in that header, then it sees:</p><pre>1.2.3.4</pre><p>and not:</p><pre>198.51.100.25</pre><p>At that point my immediate reaction was to theorise that this would make the WAF rule spoofable too, because if the client can influence the leftmost value and WAF is explicitly being told to trust that same leftmost value, then surely a user could choose the address used for rate limiting, geo decisions or ASN matching.</p><p>In trying to understand this properly, I found that the answer is potentially yes, but with one very important qualification, and that is <strong>where your WAF is actually running and why you are using forwarded IP configuration in the first place.</strong></p><h3>CloudFront + WAF has an important distinction</h3><p>Suppose AWS WAF is associated directly with the CloudFront distribution, in which case the request flow is effectively:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TxaIaeWptB2meEdckwyZag.png" /></figure><p>In that situation, WAF already has access to the request’s originating source IP because it is evaluating the request at the CloudFront edge before CloudFront forwards anything to your origin.</p><p>So you generally do <strong>not</strong> need to tell a CloudFront-associated WAF rule to derive the client address from X-Forwarded-For.</p><p>A normal rate-based rule, for example, can aggregate on the request origin IP rather than using FORWARDED_IP, and those are two distinct things. One means “use the source address of the request WAF is currently processing”, while the other means “go into this forwarded header and use the first address I find there.”</p><p>The same principle applies to Geo Match because WAF can use the request origin IP by default, while forwarded IP configuration exists for situations where the actual client has already been hidden behind some other proxy before the request reaches WAF.</p><p>That gives us a very useful rule:</p><blockquote><strong>If WAF is attached directly to CloudFront, don’t switch to XFF merely because your application sits behind CloudFront.</strong></blockquote><p>At the WAF layer, CloudFront has not hidden the viewer from WAF in the same way it later hides the viewer from your application, so where the architecture allows it, use the request’s origin IP because doing that removes the spoofable XFF question entirely for those rules.</p><h3>So why does AWS WAF support “first IP” at all?</h3><p>This is the part that initially felt a little counterintuitive because if the first address can be client-controlled, why would a security service deliberately provide an option that reads that value?</p><p>The answer starts making more sense when you remember that AWS WAF is not designed exclusively around a simple:</p><pre>Internet -&gt; CloudFront -&gt; WAF</pre><p>architecture.</p><p>There are environments where WAF receives traffic after some other trusted proxy, gateway or CDN, and in those cases the network source WAF sees might be the proxy rather than the real end user.</p><p>Traditionally, an X-Forwarded-For chain looks like:</p><pre>client, proxy1, proxy2</pre><p>so under that convention the first address represents the original client, and AWS WAF’s forwarded-IP feature is designed to support those kinds of architectures.</p><p>The important thing to understand, though, is that the documentation is describing <strong>header semantics</strong>, not guaranteeing the authenticity of the value, and those are two very different things.</p><p>“First IP represents the client” does not mean:</p><blockquote>AWS guarantees the first IP was supplied by a trusted system.</blockquote><p>What it really means is:</p><blockquote>If you configure WAF to use this forwarded header, this is the position WAF will interpret as the client.</blockquote><p>You’re still responsible for making sure the architecture around that header makes the value trustworthy, and therein lies the trap because it’s very easy to read “client IP” in documentation and mentally promote that value from “this is the field we inspect” to “this value must be genuine.”</p><h3>The clean solution starts with the architecture</h3><p>At this point it becomes clear that there is no clever header-parsing trick that solves the whole problem because the real answer starts much earlier, with the network path itself. A healthy architecture should look something like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/864/1*YsA7D8y47xhaWucTZu3cXw.png" /></figure><p>What you do not want is this:</p><pre>Attacker -----------------------&gt; Origin</pre><p>because the moment the origin is independently reachable, every assumption about CloudFront-generated headers becomes weaker.</p><p>You can configure Symfony perfectly, you can pick the right header and you can build elegant middleware around it, but if an attacker can connect directly to the origin and send:</p><pre>X-Forwarded-For: 1.2.3.4</pre><p>then the application still needs a reliable way to determine whether that header came through the expected infrastructure or whether the attacker supplied it themselves. So the clean solution begins by restricting access to the origin, for example by allowing inbound traffic only from CloudFront-facing infrastructure, using appropriate security groups, AWS-managed CloudFront prefix lists where suitable, private networking or authenticated origin mechanisms depending on the design.</p><p>The exact implementation will vary, but the principle stays the same: <strong>the application should only trust CloudFront-derived identity information if requests cannot bypass CloudFront.</strong></p><h3>CloudFront-Viewer-Address makes the application side cleaner</h3><p>Once the origin path is properly restricted, there is another option that I think makes the application-side story easier to reason about, and that is CloudFront’s CloudFront-Viewer-Address header.</p><p>CloudFront can add this header to the origin request and it contains the viewer IP address together with the source port, for example:</p><pre>CloudFront-Viewer-Address: 198.51.100.25:49152</pre><p>What I like about this approach is that it avoids making the application reconstruct the client identity from a potentially messy X-Forwarded-For chain.</p><p>Instead of receiving:</p><pre>X-Forwarded-For: attacker-value, viewer-ip, proxy-ip, proxy-ip</pre><p>and trying to reason about who added what, the application can consume a value that CloudFront generated based on the viewer connection it actually observed. But even here the same caveat applies because the header is only meaningful if the request is known to have come through CloudFront.</p><p>If the origin is directly reachable, an attacker can simply send:</p><pre>CloudFront-Viewer-Address: 1.2.3.4:1234</pre><p>themselves.</p><p>So once again we arrive at the same conclusion: the header itself does not create trust, the <strong>path the request took</strong> creates trust.</p><h3>What I would actually implement</h3><p>If I were designing or reviewing this setup, I would split the problem into two separate trust decisions because WAF and the application sit at different points in the request path and therefore have access to different information. For AWS WAF, if WAF is associated directly with CloudFront, I would prefer the request origin IP for IP-based rate limiting, Geo Match and ASN decisions rather than configuring those rules to use X-Forwarded-For.</p><p>So instead of unnecessarily telling WAF:</p><pre>ForwardedIPConfig:<br>    HeaderName: X-Forwarded-For</pre><p>I would let WAF use the source IP it already sees at the CloudFront layer.</p><p>That means the client cannot simply influence the WAF decision by injecting another address into X-Forwarded-For, because WAF is no longer depending on that header in the first place. If, however, WAF genuinely sits behind another proxy or CDN and therefore does need a forwarded header to recover the original client, then the architecture needs to ensure that the proxy immediately in front of WAF is trusted and that the forwarded address cannot simply be injected or bypassed by the client.</p><p>For the application side, I would first make sure the origin cannot be reached outside the intended CloudFront path, and then either configure Symfony’s trusted proxy handling properly or deliberately use a CloudFront-generated header such as CloudFront-Viewer-Address, depending on how the rest of the stack is structured.</p><p>The end result would ideally look something like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/864/1*rw5Uq301pL8bK-FRekUbPA.png" /></figure><p>That is a much easier model to reason about because WAF is using the client information available at its point in the request path, while the application receives a CloudFront-derived viewer identity after you have already established that traffic can only reach it through CloudFront.</p><h3>Why “just use the rightmost IP” is also incomplete</h3><p>Another argument I came across while looking into this was that the fix is simply to trust the rightmost address in X-Forwarded-For, since each proxy appends the address it sees to the end of the list. That is closer to the right idea than blindly trusting the leftmost address, but it is still too simplistic.</p><p>Suppose the request eventually looks like this:</p><pre>X-Forwarded-For: attacker-value, viewer-ip, cloudfront-ip</pre><p>The rightmost value may be a CloudFront edge or another proxy address rather than the actual viewer. So the correct logic is not really:</p><pre>pick the first IP</pre><p>or:</p><pre>pick the last IP</pre><p>but rather something closer to:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3iVJfbmUnr1AYRJN9U5AgQ.png" /></figure><p>And this is really why frameworks like Symfony provide trusted proxy handling in the first place, because once you have multiple proxies involved, manually splitting a string and picking a position is an increasingly fragile way to make security decisions.</p><h3>There is another WAF detail worth knowing</h3><p>There is one more AWS WAF nuance that confused me initially because not every forwarded-IP feature behaves exactly the same way. For Geo Match, ASN and rate-based forwarded IP configurations, WAF uses the first address in the forwarded header, but forwarded IP configuration for IP Set statements can also support positions such as:</p><pre>FIRST<br>LAST<br>ANY</pre><p>which gives you more control over which addresses in the header are inspected. That can be useful in the right architecture, but it still does not solve the fundamental trust question.</p><p>Choosing LAST does not suddenly authenticate the value.</p><p>Choosing FIRST does not automatically make it malicious.</p><p>And choosing ANY certainly does not mean every address in the chain is trustworthy.</p><p>Those options only tell WAF <strong>which part of the header to inspect</strong>, while the architecture determines whether the information found there can actually be relied upon.</p><h3>Why this matters beyond rate limiting</h3><p>The reason I think this problem deserves more attention than it usually gets is because client IP addresses quietly influence a surprisingly large number of security decisions. We routinely make statements like:</p><pre>&quot;This login came from Zimbabwe.&quot;</pre><pre>&quot;This account suddenly authenticated from Germany.&quot;</pre><pre>&quot;This IP exceeded 2,000 requests.&quot;</pre><pre>&quot;This request came from a blocked ASN.&quot;</pre><pre>&quot;This user is connecting from our corporate network.&quot;</pre><pre>&quot;This IP has generated repeated failed logins.&quot;</pre><p>All of those statements sound objective, but every single one depends on an earlier and much less glamorous question:</p><p><strong>Where did the IP address come from?</strong></p><p>If the answer is “a header the client was allowed to influence”, then every downstream control relying on that value deserves another look.</p><ol><li>The geo database may be perfectly accurate.</li></ol><p>2. The rate limiter may be working exactly as designed.</p><p>3. The SIEM rule may be functioning normally.</p><p>4. The fraud engine may be evaluating the correct logic.</p><p>5. The audit logger may be faithfully recording what it was given.</p><p>And yet the overall outcome can still be wrong because the identity attribute feeding all of those systems was never trustworthy in the first place.</p><h3>This is where architecture diagrams become security controls</h3><p>One of the useful things this problem reinforced for me is how valuable a simple request-flow diagram can be during a security review because once you draw the path, the trust assumptions become much easier to interrogate. Take:</p><pre>User -&gt; CloudFront -&gt; WAF -&gt; ALB -&gt; Symfony</pre><p>and for each hop ask:</p><pre>What is the source IP here?</pre><pre>What does this component think the client IP is?</pre><pre>What happens to X-Forwarded-For?</pre><pre>Does this component append to the header or replace it?</pre><pre>Can the client supply the same header themselves?</pre><pre>Can this layer be bypassed?</pre><pre>Which addresses does the next component trust?</pre><pre>Which value does the security rule actually inspect?</pre><p>Those questions sound basic, but they force you to follow the data instead of assuming that every component has the same view of the request.</p><p>They also generalise well beyond AWS because the exact same trust problem appears with Cloudflare, Akamai, Fastly, NGINX, HAProxy, Kubernetes ingress controllers, API gateways, service meshes and just about any environment where requests travel through multiple intermediaries before they reach the application, so any time a security decision depends on metadata that passed through several systems, the question is not simply “what does this field say?”</p><p>The better question is:</p><p><strong>who had the ability to write it?</strong></p><h3>The rule of thumb I would take away</h3><p>If I had to reduce all of this into a few principles, the first would be that you should never trust an IP address merely because it appears in X-Forwarded-For. Instead, trust it because a proxy you trust established it and because the request path guarantees that the proxy could not have been bypassed.</p><p>The second would be that forwarded headers should be treated as security-sensitive input whenever they affect security decisions, because once a value feeds rate limiting, fraud detection, geolocation, allowlists or incident logging, it has moved far beyond being just another HTTP header.</p><p>The third would be that each layer should use the IP information that makes sense at its own position in the request chain. WAF attached directly to CloudFront can usually rely on the source IP it already sees, while the application behind CloudFront needs a safe way of recovering the viewer address after CloudFront has become the immediate network peer.</p><p>And lastly, I would avoid rules like “always trust the first IP” or “always trust the last IP” because neither statement really captures how proxy trust works. The correct answer depends on the actual request path.</p><h3>The bigger lesson is about trust boundaries, not headers</h3><p>When people think about application security, we tend to think about the obvious things first: SQL injection, exposed secrets, weak authentication, missing patches or vulnerable dependencies. A comma-separated HTTP header does not exactly sound like the beginning of an interesting security problem but that’s what makes this one worth paying attention to because a very small configuration decision can quietly influence WAF rules, application rate limiting, authentication telemetry, geographic restrictions, fraud controls and even the evidence used during an investigation.</p><p>And perhaps the most interesting part is that none of the systems involved necessarily have to be “broken”; CloudFront can behave exactly as documented, AWS WAF can inspect exactly the address you configured it to inspect, Symfony can process the proxy headers exactly as you instructed it to and your application can still end up trusting the wrong person. The weakness sits in the assumption between those systems, and I think that’s a useful reminder because some of the hardest cloud security problems are not caused by a single component failing, but by several correctly functioning components being connected together under the wrong trust model. That, more than anything else, is what I took away from this rabbit hole.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=236fe7a409e3" width="1" height="1" alt=""><hr><p><a href="https://awstip.com/when-x-forwarded-for-lies-aka-the-client-ip-problem-behind-cloudfront-aws-waf-and-symfony-236fe7a409e3">When X-Forwarded-For “Lies” aka the Client IP Problem Behind CloudFront, AWS WAF and Symfony</a> was originally published in <a href="https://awstip.com/">AWS Tip</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AWS Managed Policies and Why They Are Trickier Than They Look]]></title>
            <link>https://aws.plainenglish.io/aws-managed-policies-and-why-they-are-trickier-than-they-look-adead956774f?source=rss-59bdf2526b43------2</link>
            <guid isPermaLink="false">https://medium.com/p/adead956774f</guid>
            <category><![CDATA[privilege-escalation]]></category>
            <category><![CDATA[aws-iam]]></category>
            <category><![CDATA[governance]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[managedpolicies]]></category>
            <dc:creator><![CDATA[Hilda Machando]]></dc:creator>
            <pubDate>Thu, 04 Jun 2026 09:56:00 GMT</pubDate>
            <atom:updated>2026-09-08T09:58:54.796Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j7nCcp21UgYUoa-NaB2g-g.png" /></figure><h3>Part 2: Moving From Convenience to Control</h3><p>So now that we’ve agreed AWS managed policies are not evil, just dangerously convenient, the obvious question becomes: what do you actually do about it? Because it’s easy to critique, but it’s much harder to untangle a real production environment where <em>PowerUserAccess</em> has been floating around for two years, three teams rely on it, and nobody quite remembers why it was attached in the first place. This is the part where theory meets reality.. the goal is not to rip every managed policy out overnight and break half your workloads but rather to move from blind convenience to intentional control. And that shift starts with something surprisingly simple: you need to look at what is actually being used… Not what you think is being used. Not what someone says is being used. What is <strong>actually </strong>being called.</p><p>Most organizations that rely heavily on AWS managed policies end up with one or more of the following:</p><ul><li>Roles with <em>AdministratorAccess</em> in production</li><li>Developers with <em>PowerUserAccess</em> long after initial setup</li><li>Broad service-level full access policies such as <em>AmazonEC2FullAccess</em> attached to automation roles</li><li>ReadOnly policies that expose far more metadata than intended</li></ul><p>The first step is not rewriting policies. The first step is understanding effective permissions.</p><p>AWS gives you tools for this, and yet I have seen so many environments where nobody ever opens them and<a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_last-accessed.html"> IAM Access Advisor</a> is one of them because it shows you which services a role has accessed and when, and if a role has <em>AmazonEC2FullAccess</em> attached but has not touched EC2 in six months, that is not a small detail, that’s actually a signal, and if a role has <em>AmazonS3FullAccess</em> but only ever performs <em>PutObject</em> and <em>GetObject</em> on a single bucket, that is an even stronger signal.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*lptVEmOiPvaMNUn6.jpg" /></figure><p>There is also <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/access-analyzer-policy-generation.html">IAM Access Analyzer’s policy generation</a> feature, which can look at CloudTrail activity and help you draft a policy based on actual usage. While it’s not perfect and won’t magically give you a flawless least privilege policy, it’ll still move you from guessing to evidence, but at the end of the day that shift matters because one of the biggest myths in IAM is this: “We need all those permissions,&quot; when in practice, most roles use a fraction of what they are granted, and the rest is just unused surface area waiting for the wrong day.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/701/0*dYO9sRxXCR2rFP4q.jpg" /></figure><p>Once you have visibility, the next step feels obvious but often meets resistance: you replace AWS managed policies with customer managed policies, right here is where people get uncomfortable because when you attach AmazonS3FullAccess, it feels safe because AWS wrote it but when you write your own policy JSON, it feels risky. What if you miss something? What if you break production?, but here’s the quiet truth: the managed policy is risky precisely because it was not written for you.</p><p>Let’s go back to that earlier example. A developer needs to upload files to one bucket. Instead of attaching AmazonS3FullAccess, you <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies.html">write a policy</a> that allows PutObject and GetObject on arn:aws:s3:::my-app-bucket/* and ListBucket on arn:aws:s3:::my-app-bucket, that’s it, nothing else:</p><pre>{<br>  &quot;Version&quot;: &quot;2012-10-17&quot;,<br>  &quot;Statement&quot;: [<br>    {<br>      &quot;Effect&quot;: &quot;Allow&quot;,<br>      &quot;Action&quot;: [<br>        &quot;s3:PutObject&quot;,<br>        &quot;s3:GetObject&quot;<br>      ],<br>      &quot;Resource&quot;: &quot;arn:aws:s3:::my-app-bucket/*&quot;<br>    },<br>    {<br>      &quot;Effect&quot;: &quot;Allow&quot;,<br>      &quot;Action&quot;: &quot;s3:ListBucket&quot;,<br>      &quot;Resource&quot;: &quot;arn:aws:s3:::my-app-bucket&quot;<br>    }<br>  ]<br>}</pre><p>You have not removed functionality, rather you’ve removed excess, and yes, the first time you do this, you might see an AccessDenied error but thats not a failure, just information that tells you exactly which permission is missing so that you can add it intentionally, not accidentally, and not by default.</p><p>Now let’s talk about something that managed policies almost never consider properly: conditions; managed policies are broad because they have to be by default, they cannot assume your network boundaries, your VPC endpoints, your MFA requirements, or your tagging strategies they just grant actions and rarely incorporate context specific to your environment so when you write customer managed policies, you unlock the power of conditions allowing you to restrict access based on source IP</p><pre>&quot;Condition&quot;: {<br>  &quot;IpAddress&quot;: {<br>    &quot;aws:SourceIp&quot;: &quot;203.0.113.0/24&quot;<br>  }<br>}</pre><p>or require MFA for sensitive operations</p><pre>&quot;Condition&quot;: {<br>  &quot;Bool&quot;: {<br>    &quot;aws:MultiFactorAuthPresent&quot;: &quot;true&quot;<br>  }<br>}</pre><p>or even require that resources carry specific tags or, enforce that certain actions only occur through a specific VPC endpoint.</p><pre>&quot;Condition&quot;: {<br>  &quot;StringEquals&quot;: {<br>    &quot;aws:SourceVpce&quot;: &quot;vpce-1234567890abcdef&quot;<br>  }<br>}</pre><p>This is where IAM becomes intelligent instead of just permissive, and this is also where you start reducing blast radius in a way that managed policies simply cannot.</p><p>Another reality we need to address is maintenance because one of the reasons teams love AWS managed policies is because AWS updates them. When a new API action is released, the managed policy might quietly expand to include it. That feels helpful. It saves you effort.</p><p>But think about what that means from a governance perspective.</p><p>You approved a permission set last year. AWS expands it this year. Your users inherit new capabilities without review, without change control, and without explicit authorization. In some industries, that alone is a compliance problem. Suppose you decide to replace managed policies across your environment. That sounds good in theory. In practice, this is where governance becomes critical because without standards, customer managed policies can become just as messy as managed ones.</p><p>You might end up with:</p><ul><li>Ten slightly different S3 policies</li><li>Inconsistent naming conventions</li><li>Policies that overlap unpredictably</li><li>Old unused policies never cleaned up</li></ul><p>Security maturity is not simply removing managed policies it’s building structure around how access is defined and reviewed and organizations that do this well typically:</p><ul><li>Centralize IAM policy design</li><li>Use Infrastructure as Code to version control policies</li><li>Review policies during pull requests</li><li>Periodically audit policy attachments</li></ul><p>When you move to customer managed policies, you accept responsibility for updates, while that sounds like more work (which it is), it also means every new permission is consciously granted so you trade convenience for control and in security, control is rarely a bad trade.</p><p>There is also a more subtle advantage: when a customer managed policy is too restrictive, something breaks loudly but when a managed policy is too broad, nothing breaks and the risk just sits there quietly. One is noisy. One is silent. I’d much rather deal with noise.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*keAJaYORFisBdsz_.png" /></figure><p>Now let’s talk about privilege escalation, because this is where things get genuinely interesting, many teams think that avoiding iam:* permissions is enough to prevent escalation so they attach <em>PowerUserAccess</em> and feel relatively safe because it excludes IAM management and on paper, that sounds reasonable but <em>PowerUserAccess</em> allows creating EC2 instances, Lambda functions, ECS tasks, and other resources that assume IAM roles. If there is a <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_job-functions.html">privileged role</a> in your account with an overly permissive trust policy, someone with <em>PowerUserAccess</em> can potentially launch a resource that assumes that role without ever touching IAM directly or even editing a policy, they’d just simply use the permissions they were given. A practical and sustainable pattern looks something like this:</p><p>Start broad only when necessary to unblock progress then immediately observe actual usage and tighten.</p><p>For example:</p><ol><li>Attach <em>AmazonS3FullAccess</em> temporarily to an application role.</li><li>Let it run in a controlled environment.</li><li>Capture <a href="https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-user-guide.html">CloudTrail</a> activity.</li><li>Generate a scoped policy based on real calls.</li><li>Replace the managed policy with the scoped one.</li><li>Remove the broad policy.</li></ol><p>This pattern acknowledges the reality that teams need to move quickly but speed does not mean permanent overexposure. Managed policies are generic and they can’t account for your trust relationships or understand which roles in your account are sensitive because thats your architecture, not AWS’s. This is why relying on broad managed policies in complex environments becomes dangerous as interactions between services, roles, and trust policies create pathways that are not obvious at first glance. Read this cool article I came across during my research that dives deeper into <a href="https://signmycode.com/blog/what-is-privilege-escalation-in-aws-recommendations-to-prevent-it">priviledge escalation</a>.</p><p>And here’s where we have to talk about culture: if you try to tighten IAM in an environment where “just attach Admin for now” has been normal practice, you will meet resistance, not because people are reckless, but because they are busy and are now used to broad policies that make friction disappear, frictionless systems “feel” productive. But friction in security is often a feature, like how an <em>AccessDenied</em> error forces a conversation and forces someone to ask whether the requested permission is appropriate, in that pausing to question is where true security and governance lives. The key is to find a sweet spot and not to block teams indefinitely but instead create repeatable patterns. One pattern I have seen work well is this: use managed policies as scaffolding, not structure so in cases of early development or sandbox accounts, attach the broad policy temporarily, capture CloudTrail activity and observe what is actually used, using that, you can then generate a scoped customer managed policy based on <strong>real </strong>usage and be able to replace the broad policy with the scoped one moving away from the managed policy keeping velocity high without cementing risk permanently into your environment. This process also creates documentation since the customer managed policy becomes a living artifact of what the workload actually needs.</p><p>There is also a practical governance angle here, once you begin writing customer managed policies, you should treat them like code and store them in version control reviewing them through pull requests, naming them consistently and documenting their purpose just like youd do with code. IAM should not be something configured impulsively in the console during an incident response call. And yes, that means security becomes part of your engineering process instead of an afterthought.</p><p>Let’s also address something uncomfortable: cleanup. If you already have dozens of roles with attached AWS managed policies, unwinding that will take time because you cannot just flip a switch. You’ll need to analyze role by role, coordinate with application owners and occasionally break something in non-production environments while testing tighter permissions. That’s completely normal, and to some extent expected. What’s not normal is pretending that the current state is fine because nothing has exploded yet.</p><p>So are AWS managed policies bad? Still no. They are accelerators, useful tools in sandboxes, training environments, and temporary access scenarios, also appropriate for break-glass roles that are tightly monitored and rarely used…. the problem is not their existence, rather permanence without review. If you never revisit a managed policy, you have effectively outsourced part of your access model to a generic template maintained by someone who does not know your risk profile, and thats not good governance, that’s delegation without oversight.</p><p>If Part 1 was about exposing the illusion of safety, then this Part 2 is about reclaiming intentionality so you can move from attaching policies because they are easy to designing policies because they are appropriate, the difference between a cloud environment shaped by convenience and one shaped by intention is the difference between hoping nothing goes wrong and knowing your blast radius is contained. In Part 3, we’ll go deeper into organizational guardrails, service control policies, permission boundaries, and how to prevent managed policy sprawl across multiple accounts because IAM does not exist in isolation and if you don’t design that system deliberately, convenience will design it for you.</p><pre>                     ┌───────────────────────────────────────┐<br>                     │             PART 3 PREVIEW            │<br>                     │        Advanced IAM Governance        │<br>                     └───────────────────────────────────────┘<br>                                      │<br>                                      │<br>        ┌─────────────────────────────┼─────────────────────────────┐<br>        │                             │                             │<br>        │                             │                             │<br><br>┌─────────────────────┐     ┌─────────────────────┐     ┌─────────────────────┐<br>│                     │     │                     │     │                     │<br>│  SERVICE CONTROL    │     │  PERMISSION         │     │  ORGANIZATIONAL     │<br>│  POLICIES (SCPs)    │     │  BOUNDARIES         │     │  GUARDRAILS         │<br>│                     │     │                     │     │                     │<br>│ Organization-wide   │     │ Define the maximum  │     │ Prevent dangerous   │<br>│ rules that override │     │ permissions a role  │     │ configurations      │<br>│ IAM permissions     │     │ can ever receive    │     │ across accounts     │<br>│                     │     │                     │     │                     │<br>└─────────────────────┘     └─────────────────────┘     └─────────────────────┘<br><br>                                      │<br>                                      │<br>                         ┌───────────────────────────┐<br>                         │                           │<br>                         │  PREVENTING POLICY SPRAWL │<br>                         │                           │<br>                         │ Strategies for managing   │<br>                         │ IAM across many AWS       │<br>                         │ accounts without letting  │<br>                         │ managed policies spread   │<br>                         │ everywhere                │<br>                         │                           │<br>                         └───────────────────────────┘</pre><h3>Before you go</h3><ul><li>Please take a moment to like the post and follow the writer!</li><li>Did you know that over 400,000 developers share what they’re building, learning, and discovering across our platforms every month? Learn how you can contribute <a href="https://plainenglish.io/write-for-us">here</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=adead956774f" width="1" height="1" alt=""><hr><p><a href="https://aws.plainenglish.io/aws-managed-policies-and-why-they-are-trickier-than-they-look-adead956774f">AWS Managed Policies and Why They Are Trickier Than They Look</a> was originally published in <a href="https://aws.plainenglish.io/">AWS in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AWS Managed Policies and Why They Are Trickier Than They Look]]></title>
            <link>https://aws.plainenglish.io/aws-managed-policies-and-why-they-are-trickier-than-they-look-7528d60b6be4?source=rss-59bdf2526b43------2</link>
            <guid isPermaLink="false">https://medium.com/p/7528d60b6be4</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[aws-iam]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[aws-policies]]></category>
            <category><![CDATA[aws-s3]]></category>
            <dc:creator><![CDATA[Hilda Machando]]></dc:creator>
            <pubDate>Mon, 06 Apr 2026 09:41:01 GMT</pubDate>
            <atom:updated>2026-09-08T09:58:48.941Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Part 1: The Comfort Blanket That “Might” Be on Fire</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5uR6co9-QCth5Nn8nBMtsg.png" /></figure><p>I want to tell you about a mistake I’ve seen made hundreds of times, and honestly, one I’ve made myself; you open the IAM console, maybe you need to give someone access to S3 so you type “S3” into the search bar, a neat list appears, and one of them says <em>AmazonS3FullAccess</em>. It has the AWS logo next to it. It feels official. It feels safe. It feels… correct; so you attach it. Job done. Right?</p><p>Except, not quite.</p><p>AWS managed policies are one of the most widely used and widely misunderstood features in all of IAM. They promise convenience, standardisation, and alignment with best practice. What they often deliver instead is subtle over-permissioning, hidden risk, and a long-term security debt that quietly compounds over time. I want to unpack why AWS managed policies are trickier than they look, particularly why they <em>feel</em> safe when they sometimes aren’t, and how to use them intelligently without turning your cloud environment into a wide-open playground.</p><p>This is Part 1 of a deep dive. We’ll start with fundamentals and build from there.</p><h3>What Exactly Is an AWS Managed Policy?</h3><p>An AWS managed policy is a pre-created IAM policy written and maintained by AWS. You don’t author it or maintain it, you simply attach it to users, groups, or roles. These policies are designed to grant permissions for common use cases, e.g., AdministratorAccess, AmazonS3ReadOnlyAccess, AmazonEC2FullAccess, and PowerUserAccess. On paper, this sounds ideal since AWS understands their own services better than anyone so surely their policies represent sensible, safe, and practical permission sets and sometimes they do but here’s where things start to get interesting.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/742/0*chmhDQ9zxeMFcuUn.png" /></figure><h3>The Illusion of Safety</h3><p>When you attach an AWS managed policy, it feels like you’re following best practice, again, AWS wrote it, so surely it’s been vetted and reviewed, surely it aligns with security principles, however the subtle but important reality is this: <strong>AWS managed policies are designed for functionality, not for your specific security posture. </strong>AWS doesn’t know your environment, your data classification levels, your regulatory obligations, or whether you’re a startup building a side project or a bank handling customer financial records. So when AWS writes something like <em>AmazonS3FullAccess</em>, they’re solving for capability. They’re not solving for least privilege <em>in your context</em>.</p><p>And then there’s <em>AdministratorAccess</em>. If you inspect the <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_job-functions.html#jf_administrator">policy JSON</a>, you’ll find something beautifully simple and quietly terrifying:</p><pre>{<br>  &quot;Effect&quot;: &quot;Allow&quot;,<br>  &quot;Action&quot;: &quot;*&quot;,<br>  &quot;Resource&quot;: &quot;*&quot;<br>}</pre><p>That’s it. This is the cloud equivalent of handing someone the master key to every building, every safe, every filing cabinet, and every server rack in your organization. Convenient? Absolutely. Safe by default? Not even remotely.</p><h3>The Over-Permissioning Problem</h3><p>Let me walk through a scenario I see constantly in the real world: A developer needs access to upload files to one S3 bucket, basically just one bucket and nothing else so you search IAM, and see <a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/access-policy-language-overview.html"><em>AmazonS3FullAccess</em>,</a> it “sounds” right (it shouldn&#39;t!), and you attach it. That developer now has permission to:</p><ul><li>Delete any S3 bucket in the account</li><li>Modify bucket policies</li><li>Enable public access on any bucket</li><li>Change object ownership</li><li>Access every other bucket in the account</li></ul><p>You intended to grant permission to upload to a single bucket but instead you handed over full control of every S3 resource you own and this is exactly how security drift begins, rarely if ever through malice or incompetence, but through convenience.</p><p>Something that I’ve found catches a lot of teams off guard is the fact that <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_managed-vs-inline.html#aws-managed-policies"><strong>managed policies are not static</strong></a><strong>. </strong>AWS updates them whenever new services or API actions are released, and when they do, every user, group, or role with that policy attached immediately inherits the new permissions. So before you use these policies its important to think about what that means in practice because today you attach a managed policy, but what happens in a couple months when AWS releases new API actions for that service and quietly updates the policy to include them.. now all of a sudden, your users have access to capabilities that didn’t exist when you originally approved their access. No change request or review in sight, no explicit authorisation; just a quiet expansion of permissions, and in a regulated environment, this alone is enough reason to treat AWS managed policies with serious caution.</p><h3>The “It Works” Trap</h3><p>Let me be honest about something I’ve witnessed in nearly every team I’ve worked with or consulted for: the priority is always making things work so if someone can’t deploy? then just attach <em>PowerUserAccess, </em>and if <em>s</em>omeone else can’t access logs? just give them <em>AdministratorAccess</em> temporarily; the phrase <em>“just for now”</em> does so much heavy lifting in production environments and has created more security incidents than most attackers ever will, especially also when you’re trying to make sure security isn’t seen as a blocker to progress, and AWS managed policies enable this culture because they remove the friction since they’re so easy to attach; they basically solve problems immediately, and they almost never break functionality, but they also quietly accumulate risk.</p><p>And here’s the thing about IAM that makes this especially dangerous: <strong>permissions are cumulative</strong>. Every attached policy expands the total permission set unless something is explicitly denied, i.e., managed policies stack, and once you have a few of them layered onto a role, the combined effective permissions can become enormous often far beyond what anyone originally intended.</p><h3>The Myth of “ReadOnly”</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*LVfqycH0Vb4140CA.JPG" /></figure><p>Another big risk avenue are ReadOnly policies… they sound harmless, I mean, what damage can read-only access really do? my answer is always quite a lot, actually (and then everyone looks at me like I’m crazy); but as an example lets take <em>AmazonEC2ReadOnlyAccess; </em>it allows viewing EC2 instances, AMIs, volumes, network interfaces, and metadata, that includes internal IP addresses, instance IDs, attached IAM roles, security group configurations, and load balancer associations. In a mature attack chain, reconnaissance is everything, so read-only access often provides a complete blueprint of your entire environment, which is exactly the kind of information an attacker needs to plan their next move. I’m not saying read-only policies are bad. I’m saying they’re not harmless, and again security is rarely about intent: it’s about exposure.</p><p>AWS’s <a href="https://aws.amazon.com/compliance/shared-responsibility-model/">shared responsibility model</a> is clear: AWS secures the infrastructure, and you secure access to your resources so ultimately managed policies sit squarely in your responsibility domain. AWS provides them as tools, but you decide whether and how to use them and its always important to remember that the existence of a policy in the AWS console does not imply that it’s appropriate for your workload.</p><h3>The Subtle Risk of Service Expansion</h3><p>One of the trickier aspects of managed policies is service expansion.. lets say you attach <em>PowerUserAccess</em> to a developer because they need broad control but you want to keep them away from IAM. It feels like a reasonable compromise; it&#39;s safer than <em>AdministratorAccess </em>but still<em> </em>functional enough for most needs and most importantly PowerUserAccess doesn’t allow IAM management so that feels reassuring, but it does include access to create EC2 instances, Lambda functions, ECS tasks, and other services that assume IAM roles so if your role design has any gaps, a developer with <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_job-functions.html">PowerUserAccess </a>can potentially launch resources that assume privileged roles, achieving indirect privilege escalation without ever touching IAM directly. Managed policies are written generically and they can’t account for your specific trust relationships or role assumptions and that’s where complexity enters, and where things can go quietly wrong. At their best, AWS managed policies are accelerators, they can help you bootstrap environments quickly and are genuinely useful for sandbox accounts, training environments, and proof-of-concept work but on the flip side at their worst, they become permanent fixtures in production accounts because nobody ever revisited them.</p><p>The danger isn’t in using them, they’re alright as a starting point. The danger is in never going back to question them. It must continue to be said that security isn’t and is never a one-time configuration, it’s a continuous process of refinement and while managed policies encourage initial velocity they don’t encourage long-term governance and worse still, once a managed policy is attached and workloads depend on it, removing it becomes genuinely painful and if you try to tighten permissions later, you often discover that nobody actually knows which permissions are truly required, now there’s also the fear of breaking production systems so instead of refining access, organizations leave broad managed policies in place indefinitely, the classic “if it’s not broken, don’t touch it” mentality.. The problem is that in security, what isn’t broken today might be exploitable tomorrow.</p><h3>So Are AWS Managed Policies Bad?</h3><p>No. They’re tools, and like any tool, their value depends on how thoughtfully you use them, while they’re genuinely useful for rapid prototyping, temporary access, learning environments, and initial role scaffolding, the problem arises when they become permanent substitutes for thoughtful policy design. The uncomfortable truth is this: AWS managed policies are optimized for usability at scale. They are not optimized for least privilege in <em>your</em> account and that responsibility belongs solely to you, so if <em>AdministratorAccess</em> ends up on a production role, it’s not AWS who made that decision. It was you.</p><p>In Part 2, I’ll cover how to safely transition from managed policies to customer managed policies, how to analyse actual permission usage, how to reduce blast radius without breaking workloads, and practical patterns for avoiding over-permissioning.. but for now, the takeaway is simple, I hope: AWS managed policies are easy <strong>BUT </strong>security rarely is. And if something feels too convenient in cloud security, it probably deserves a second look.</p><h3>Before you go</h3><ul><li>Please take a moment to like the post and follow the writer!</li><li>Did you know that over 400,000 developers share what they’re building, learning, and discovering across our platforms every month? Learn how you can contribute <a href="https://plainenglish.io/write-for-us">here</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7528d60b6be4" width="1" height="1" alt=""><hr><p><a href="https://aws.plainenglish.io/aws-managed-policies-and-why-they-are-trickier-than-they-look-7528d60b6be4">AWS Managed Policies and Why They Are Trickier Than They Look</a> was originally published in <a href="https://aws.plainenglish.io/">AWS in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Build Your Own Secret Rotation with Parameter Store + Lambda (Step-by-Step)]]></title>
            <link>https://towardsaws.com/build-your-own-secret-rotation-with-parameter-store-lambda-step-by-step-cda4089312dd?source=rss-59bdf2526b43------2</link>
            <guid isPermaLink="false">https://medium.com/p/cda4089312dd</guid>
            <category><![CDATA[rotation]]></category>
            <category><![CDATA[key-rotation]]></category>
            <category><![CDATA[aws-lambda]]></category>
            <category><![CDATA[parameter-store]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Hilda Machando]]></dc:creator>
            <pubDate>Mon, 30 Mar 2026 09:26:00 GMT</pubDate>
            <atom:updated>2026-03-30T09:26:00.616Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GHIgMLQolGLOTEU4qs0J9g.png" /></figure><p>If you’ve read my previous article on <a href="https://medium.com/@hildamachando4/aws-parameter-store-vs-secrets-manager-which-should-you-use-for-sensitive-information-c37a71efeab6">AWS Parameter Store vs. Secrets Manager</a>, and you’ve decided to keep sensitive values in <strong>AWS Systems Manager Parameter Store</strong> (SecureString), but you still want <strong>automatic rotation</strong> like you’d get from Secrets Manager and are not sure how to get that set up, then this article is for you. Here I try to give you a practical, copy-pasteable guide to build your own rotation pipeline with <strong>Lambda + EventBridge</strong>, with notes for zero-downtime patterns and real-world hiccups. This guide is by no means the holy grail or only way to tackle this challenge but just an example of what worked for me and what you can easily customise for your own environment.</p><h3>What you’ll build</h3><p>A scheduled Lambda that:</p><ol><li>Pulls the current secret from <strong>Parameter Store</strong></li><li>Generates a <strong>new credential</strong></li><li><strong>Applies</strong> that credential to the target system (example: rotate an RDS user password)</li><li><strong>Writes</strong> the new value back to Parameter Store (as a SecureString, KMS-encrypted)</li><li>Optionally <strong>gracefully retires</strong> the old credential after a delay</li></ol><h3>Choose your rotation pattern (important)</h3><p>Pick one that matches your target system and downtime tolerance.</p><ul><li><strong>Single-credential swap</strong> (this is the simplest):<br> Overwrite the one user’s password, update Parameter Store, restart clients if needed. Accepts a brief reconnect blip.</li><li><strong>Dual-user, alternating</strong> (tad more complicated but is zero-downtime friendly):<br> Maintain two users with identical permissions (e.g., app_user_a and app_user_b).<br> Store the <strong>currently active user + password</strong> in Parameter Store.<br> On each rotation:</li></ul><ol><li>Create/reset the <strong>inactive</strong> user with a new password</li><li>Update Parameter Store to point clients at the inactive (now new active) user</li><li>After a grace window, drop or disable the old user<br> This lets clients fetch the new creds without breaking existing connections.</li></ol><p>The steps below show both approaches; the code included is for the <strong>single-credential</strong> path with notes added for the dual-user application.</p><h3>Prereqs</h3><ul><li>A <strong>KMS key</strong> to encrypt the SecureString parameter (CMK or AWS-managed; CMK recommended).</li><li>A <strong>Parameter Store path</strong>, e.g. /prod/db/app/credentials (JSON payload), with type=SecureString and your KMS key.</li><li>If rotating <strong>RDS</strong>:</li><li>Lambda needs <strong>VPC access</strong> (same subnets/security groups as DB) or a reachable endpoint.</li><li>A <strong>DB admin</strong> or a role with permission to alter user passwords.</li></ul><p><strong>Example Parameter Value (JSON)</strong></p><pre>{<br>  &quot;username&quot;: &quot;app_user&quot;,<br>  &quot;password&quot;: &quot;current-strong-password&quot;,<br>  &quot;engine&quot;: &quot;mysql&quot;,<br>  &quot;host&quot;: &quot;mydb.cluster-xyz.us-east-1.rds.amazonaws.com&quot;,<br>  &quot;port&quot;: 3306,<br>  &quot;database&quot;: &quot;appdb&quot;<br>}</pre><h3>IAM: execution role for the Lambda</h3><p>Minimal starting point (scope ARNs to your env):</p><pre>{<br>  &quot;Version&quot;: &quot;2012-10-17&quot;,<br>  &quot;Statement&quot;: [<br>    { &quot;Effect&quot;: &quot;Allow&quot;, &quot;Action&quot;: [&quot;ssm:GetParameter&quot;, &quot;ssm:PutParameter&quot;], &quot;Resource&quot;: &quot;arn:aws:ssm:us-east-1:123456789012:parameter/prod/db/app/credentials&quot; },<br>    { &quot;Effect&quot;: &quot;Allow&quot;, &quot;Action&quot;: [&quot;kms:Decrypt&quot;,&quot;kms:Encrypt&quot;,&quot;kms:GenerateDataKey&quot;], &quot;Resource&quot;: &quot;arn:aws:kms:us-east-1:123456789012:key/your-kms-key-id&quot; },<br>    { &quot;Effect&quot;: &quot;Allow&quot;, &quot;Action&quot;: [&quot;logs:CreateLogGroup&quot;,&quot;logs:CreateLogStream&quot;,&quot;logs:PutLogEvents&quot;], &quot;Resource&quot;: &quot;*&quot; }<br>  ]<br>}</pre><p>If the Lambda connects to RDS over the network, it doesn’t need extra AWS IAM privileges for the DB change itself since it’ll authenticate with the DB user you provide. If you’re using <strong>RDS Data API (Aurora)</strong>, add rds-data:* on the DB resource.</p><p><strong>KMS key policy</strong> must allow the Lambda role to use the key (Encrypt/Decrypt/GenerateDataKey).</p><h3>Schedule: EventBridge (CloudWatch Events)</h3><p>Create a rule such as <strong>every 30 days</strong>:</p><ul><li>Schedule expression: rate(30 days)</li><li>Target: your Lambda function</li><li>(Optional) Constant JSON input to pass parameter path, rotation mode, grace period, etc.</li></ul><h3>The Lambda function (Python 3.11)</h3><p>This example:</p><ul><li>Fetches the SecureString JSON from Parameter Store</li><li>Generates a new strong password</li><li>Updates a <strong>MySQL</strong> user via PyMySQL</li><li>Writes the new creds back to Parameter Store (overwrites SecureString)</li><li>Logs versioning info so you can roll back if needed</li></ul><blockquote><em>For Postgres, swap PyMySQL for </em><em>psycopg2 and adjust the SQL.</em></blockquote><p><strong>Dependencies</strong></p><ul><li>Add a Lambda layer for PyMySQL (or zip it with your function).</li><li>boto3 is preinstalled in Lambda.</li></ul><pre>import json<br>import os<br>import random<br>import string<br>import pymysql<br>import boto3</pre><pre>ssm = boto3.client(&#39;ssm&#39;)</pre><pre># -------- helpers --------<br>def strong_password(length=24):<br>    alphabet = string.ascii_letters + string.digits + &quot;!@#$%^&amp;*()-_=+[]{}&quot;<br>    while True:<br>        pwd = &#39;&#39;.join(random.SystemRandom().choice(alphabet) for _ in range(length))<br>        # basic strength checks<br>        if (any(c.islower() for c in pwd)<br>            and any(c.isupper() for c in pwd)<br>            and any(c.isdigit() for c in pwd)<br>            and any(c in &quot;!@#$%^&amp;*()-_=+[]{}&quot; for c in pwd)):<br>            return pwd</pre><pre>def load_param(path):<br>    resp = ssm.get_parameter(Name=path, WithDecryption=True)<br>    return json.loads(resp[&#39;Parameter&#39;][&#39;Value&#39;]), resp[&#39;Parameter&#39;][&#39;Version&#39;]</pre><pre>def put_param(path, value, kms_key_id=None):<br>    kwargs = {<br>        &quot;Name&quot;: path,<br>        &quot;Value&quot;: json.dumps(value),<br>        &quot;Type&quot;: &quot;SecureString&quot;,<br>        &quot;Overwrite&quot;: True<br>    }<br>    if kms_key_id:<br>        kwargs[&quot;KeyId&quot;] = kms_key_id<br>    resp = ssm.put_parameter(**kwargs)<br>    return resp[&#39;Version&#39;]</pre><pre>def rotate_mysql_password(host, port, admin_user, admin_pass, target_user, new_pass, database=None):<br>    conn = pymysql.connect(host=host, port=port, user=admin_user, password=admin_pass, db=database or &quot;&quot;, connect_timeout=10)<br>    try:<br>        with conn.cursor() as cur:<br>            # MySQL 8+<br>            cur.execute(f&quot;ALTER USER `{target_user}` IDENTIFIED BY %s;&quot;, (new_pass,))<br>        conn.commit()<br>    finally:<br>        conn.close()</pre><pre>def handler(event, context):<br>    # config can come from EventBridge constant input or env vars<br>    param_path = (event.get(&quot;param_path&quot;)<br>                  or os.environ.get(&quot;PARAM_PATH&quot;)<br>                  or &quot;/prod/db/app/credentials&quot;)<br>    kms_key_id = event.get(&quot;kms_key_id&quot;) or os.environ.get(&quot;KMS_KEY_ID&quot;)</pre><pre>    # load current secrets<br>    secret, old_version = load_param(param_path)<br>    engine   = secret[&quot;engine&quot;]<br>    host     = secret[&quot;host&quot;]<br>    port     = int(secret.get(&quot;port&quot;, 3306))<br>    database = secret.get(&quot;database&quot;)<br>    username = secret[&quot;username&quot;]<br>    password = secret[&quot;password&quot;]</pre><pre>    # admin creds: you can store these in a separate SecureString or use the same one if acceptable<br>    admin_user = event.get(&quot;admin_user&quot;) or os.environ.get(&quot;ADMIN_USER&quot;) or username<br>    admin_pass = event.get(&quot;admin_pass&quot;) or os.environ.get(&quot;ADMIN_PASS&quot;) or password</pre><pre>    # generate new password<br>    new_password = strong_password()</pre><pre>    # apply to target system<br>    if engine.lower() == &quot;mysql&quot;:<br>        rotate_mysql_password(host, port, admin_user, admin_pass, username, new_password, database)<br>    else:<br>        raise ValueError(f&quot;Unsupported engine: {engine}&quot;)</pre><pre>    # write new value to Parameter Store<br>    new_secret = dict(secret)<br>    new_secret[&quot;password&quot;] = new_password<br>    new_version = put_param(param_path, new_secret, kms_key_id=kms_key_id)</pre><pre>    # tip: you can emit a custom metric or SNS notification here<br>    return {<br>        &quot;status&quot;: &quot;rotated&quot;,<br>        &quot;parameter&quot;: param_path,<br>        &quot;old_version&quot;: old_version,<br>        &quot;new_version&quot;: new_version<br>    }</pre><h3>Dual-user tweak (near zero-downtime)</h3><p>Store both users in the parameter, e.g.:</p><pre>{<br>  &quot;activeUser&quot;: &quot;app_user_a&quot;,<br>  &quot;users&quot;: {<br>    &quot;app_user_a&quot;: &quot;current-pass-A&quot;,<br>    &quot;app_user_b&quot;: &quot;current-pass-B&quot;<br>  },<br>  &quot;engine&quot;: &quot;mysql&quot;,<br>  &quot;host&quot;: &quot;…&quot;,<br>  &quot;port&quot;: 3306<br>}</pre><p>Rotation steps:</p><ol><li>Identify the <strong>inactive</strong> user (app_user_b if activeUser is app_user_a).</li><li>Set a new password for the inactive user in DB.</li><li>Update Parameter Store: activeUser = app_user_b, and set its password.</li><li>After a grace period (say 1–7 days), disable or reset the former active user.<br> Your Lambda can switch activeUser and keep both passwords, letting clients fetch the new creds without dropping existing connections.</li></ol><h3>Parameter management tips</h3><h4>Versioning and Rollback</h4><p>One of the strengths of Parameter Store is that it automatically versions every change you make to a parameter. Each time your Lambda function writes a new secret value, AWS keeps track of it as a new version rather than overwriting the old one entirely. This gives you a built-in safety net: if your rotation script introduces a bad value, or if your downstream application fails because of a misconfigured credential, you don’t have to scramble to guess what the previous secret was. Instead, you can explicitly request an earlier version of the parameter and restore it. For example, ssm get-parameter --name /prod/db/app/credentials --version 5 --with-decryption will fetch the fifth version, allowing you to roll back quickly. This kind of versioning is especially useful in production, where downtime or failed deployments need immediate fixes.</p><h4>Throughput and Parameter Tiers</h4><p>Parameter Store has two tiers: <strong>Standard</strong> and <strong>Advanced, </strong>and they differ in both throughput and features. Standard parameters are free but limited to <strong>40 requests per second, per account, per Region</strong>. That might be fine for small workloads, but if your application or rotation process involves multiple secrets fetched very frequently, you may hit throttling. Advanced parameters, on the other hand, support <strong>1000 requests</strong> per second and allow you to attach policies like expiration dates. They do come with a small cost per parameter per month, but they scale much better. If you are rotating secrets for dozens of services every few minutes, Advanced parameters are often a necessity, otherwise your Lambda or client applications may start failing with throttling errors. In other words, planning for scale isn’t optional, you need to match your workload to the right tier.</p><h3>Schema and Structure of Parameters</h3><p>While you could store a password or API key as a single value, in practice it’s way better to store secrets as structured JSON objects. This way, you can include all the context your applications need in one place. For example, instead of only storing &quot;mypassword&quot;, you might store:</p><pre>{<br>  &quot;username&quot;: &quot;app_user&quot;,<br>  &quot;password&quot;: &quot;super-strong-pass&quot;,<br>  &quot;engine&quot;: &quot;mysql&quot;,<br>  &quot;host&quot;: &quot;db.example.com&quot;,<br>  &quot;port&quot;: 3306<br>}</pre><p>This approach means your applications or rotation function can pull one parameter and get everything they need to connect, rather than juggling multiple parameters for user, host, and password. It also makes future changes simpler eg if you add a new field like sslMode, you don’t have to create a new parameter path; you just extend the JSON. It’s cleaner, easier to version, and scales better as your environment grows.</p><h3>Least Privilege and Access Controls</h3><p>Because Parameter Store integrates tightly with KMS for encryption, and because sensitive credentials live inside it, access control is critical. The golden rule here is <strong>least privilege</strong>: only grant your Lambda rotation function and consuming applications the exact permissions they need. For example, if your Lambda only rotates a single parameter, scope its IAM policy to that one parameter ARN instead of ssm:* on all parameters. Likewise, scope KMS access so the Lambda can only use the specific key that encrypts that parameter. This reduces blast radius if that Lambda role is ever compromised, the attacker can’t read or write every parameter in your account, only the one it’s allowed to. In large organizations, where many teams may use Parameter Store, tight scoping like this prevents accidental exposure and enforces accountability.</p><h3>Setting up Clients to Pick Up New Secrets</h3><p>Rotating a secret is only half the job , the other half is making sure your applications actually notice and use the new values. How you approach this depends on whether your workloads are containerized apps, databases, or monitoring setups.</p><p>For applications running on <strong>ECS, EKS, or EC2</strong>, avoid baking credentials permanently into environment variables at deployment time. If you do, the app will never see updated values until you redeploy. Instead, design your services to fetch secrets dynamically. One option is to pull them from Parameter Store on startup and periodically refresh them in memory (every few minutes, for example). Another approach is to trigger a rolling restart after each rotation, which forces tasks or pods to pick up the latest credentials. With ECS you can issue a force-new-deployment, and on EKS you can roll pods to achieve the same effect.</p><p>For <strong>databases that rely on connection pools</strong>, expect some “turbulence” when you rotate credentials using the single-credential swap model because connections built on the old password will break once the new password takes effect. The dual-user pattern helps smooth this out, since new connections can use the alternate account while existing connections wind down naturally.</p><p>Finally, don’t forget about <strong>visibility and auditing</strong>. Enable CloudTrail logging for ssm:GetParameter and ssm:PutParameter so you can see when secrets are read or changed, and turn on KMS key usage logs. Build alerts for failures or unusual activity such as repeated decryption errors which can act as early warning signs of misconfiguration or misuse.</p><p>Consider a production web service running in ECS Fargate that connects to an RDS MySQL database. The service retrieves its database credentials from Parameter Store, where they’re stored as a SecureString. Every 30 days, a scheduled Lambda rotates the RDS user’s password and updates the value in Parameter Store.</p><p>Without additional planning, the ECS tasks would continue running on the old password, and once the rotation happened, their connection pool would start throwing authentication errors. To prevent this, the DevOps team would add an <strong>automated rolling deployment</strong> step to their pipeline: after the Lambda finishes rotating the secret, it calls aws ecs update-service --force-new-deployment. This command gracefully drains old tasks and starts new ones that fetch the updated credentials at startup. The rotation becomes invisible to end users = no downtime, no failed queries.</p><p>Later, the team can improve resilience by moving to the <strong>dual-user rotation pattern </strong>by mantaining<strong> </strong>two database accounts with identical privileges (app_user_a and app_user_b). The Parameter Store entry initially always points to the “active” user. During rotation, the Lambda updates the inactive account with a fresh password, switches the Parameter Store entry, and lets ECS tasks pick it up during the rolling deployment. Existing connections using the old user continue working until they naturally time out, eliminating mid-session failures altogether.</p><h3>Monitoring and Observability</h3><p>When you’re building a custom rotation workflow, observability is as important as the rotation itself. You want to know immediately if something fails, and you need enough detail in your logs to trace issues back to a specific change.</p><p>A good starting point is to have your Lambda function emit <strong>custom CloudWatch metrics</strong> each time it runs for example, SecretRotationSuccess and SecretRotationFailure. This gives you a clear signal to track over time, and lets you visualize rotation health alongside other operational metrics.</p><p>On top of that, configure <strong>CloudWatch Alarms</strong> for consecutive failures. A single missed run might not be catastrophic, but repeated failures likely mean clients are about to start breaking. Tie these alarms to an <strong>SNS topic</strong> so your on-call team is notified immediately through email, Teams, Jira or Slack.</p><p>Finally, make sure your logging is detailed enough to support troubleshooting. Every time a rotation occurs, log the <strong>parameter name, version number, and timestamp</strong>. This way, if client applications suddenly start failing, you can quickly correlate the outage with the exact rotation event that introduced the change. Having this audit trail will save hours of guesswork during an incident.</p><h3>Common gotchas (and fixes)</h3><ul><li><strong>Lambda can’t connect to DB:</strong> Add the function to the right VPC subnets and a security group that can reach the DB (and allow egress).</li><li><strong>KMS AccessDenied:</strong> Update the <strong>key policy</strong> to include the Lambda role. IAM alone isn’t enough if key policy blocks it.</li><li><strong>Clients still use old creds:</strong> They’re likely caching. Add a restart hook or polling refresh. For ECS, call update-service --force-new-deployment post-rotation.</li><li><strong>Payload too big:</strong> Parameter Store standard/advanced limits (4 KB / 8 KB). If you need more (e.g., cert chains), split parameters or consider Secrets Manager (64 KB limit).</li></ul><h3>What if you’re not rotating a DB?</h3><p>Same skeleton; just swap the “apply credential” function:</p><ul><li><strong>API tokens</strong>: call vendor API to issue a new token, store it, then revoke the old one after your grace window.</li><li><strong>SSH keys</strong>: generate a new key pair, distribute public key, store private key, and prune old keys on hosts.</li></ul><p>Parameter Store <strong>can</strong> handle sensitive values safely and cheaply — but <strong>rotation is on you</strong>. With a small Lambda, a schedule, some keyboard crunching and a clean pattern (single-credential or dual-user), you can get almost all the ergonomics you’d expect from a managed rotation system while keeping costs down and control in your hands.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cda4089312dd" width="1" height="1" alt=""><hr><p><a href="https://towardsaws.com/build-your-own-secret-rotation-with-parameter-store-lambda-step-by-step-cda4089312dd">Build Your Own Secret Rotation with Parameter Store + Lambda (Step-by-Step)</a> was originally published in <a href="https://towardsaws.com/">Towards AWS</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding AWS Backup for S3: Lifecycle, Costs, and Best Practices]]></title>
            <link>https://medium.com/@hildamachando4/understanding-aws-backup-for-s3-lifecycle-costs-and-best-practices-9d3d46b5a49b?source=rss-59bdf2526b43------2</link>
            <guid isPermaLink="false">https://medium.com/p/9d3d46b5a49b</guid>
            <category><![CDATA[finops]]></category>
            <category><![CDATA[cost-optimization]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[s3]]></category>
            <dc:creator><![CDATA[Hilda Machando]]></dc:creator>
            <pubDate>Sat, 28 Feb 2026 15:31:01 GMT</pubDate>
            <atom:updated>2026-02-28T15:31:01.052Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Y5rYwu5i2UnLYAQXGzoyCA.jpeg" /></figure><p>AWS Backup provides a centralised way to automate and manage backups across various AWS services, including Amazon S3. However, as users have discovered, there are limitations and cost implications associated with using AWS Backup for S3, particularly regarding storage transitions and recovery points (RP). This article addresses a common concern raised by users: Why are S3 backup recovery points not transitioning to cold storage, and how can costs be optimised? A common scenario is configuring AWS Backup with a lifecycle rule to move recovery points to cold storage after a certain period. However, in practice, all recovery points will remain in warm storage. The key issue here is that <strong>AWS Backup does not support cold storage transitions for S3 backups</strong>. This is clearly stated in AWS documentation:</p><blockquote>“<a href="https://docs.aws.amazon.com/aws-backup/latest/devguide/s3-backups.html">Cold storage transition of S3 backups is not supported.</a>”</blockquote><p>This means that regardless of the lifecycle rules set within AWS Backup, S3 backups will remain in warm storage indefinitely unless manually deleted.</p><h3>Understanding AWS Backup Costs for S3</h3><p>A major concern with AWS Backup for S3 is cost, specifically the WarmStorage-ByteHrs-S3 cost, which accumulates as long as recovery points exist. Let’s break down how backup costs are calculated:</p><ul><li>Each RP represents a snapshot of the S3 state at a given time. If your backup retention policy is long, costs will increase over time.</li><li>When objects are added, modified, or deleted in S3, AWS Backup must retain those changes across RPs. Overwritten or deleted objects continue to contribute to storage costs unless their associated RPs are deleted.</li><li>If versioning is enabled, all versions of objects are retained, increasing backup storage consumption and costs.</li></ul><h3>Optimizing AWS Backup Costs for S3</h3><p>Given that S3 backups remain in warm storage and can accumulate significant costs, here are some strategies to optimize costs:</p><h4>1. Review and Reduce Recovery Point Retention</h4><p>If RPs are being stored for extended periods (e.g., 1–5 years), consider reducing retention to only the required period (e.g., 7–30 days). The fewer RPs you retain, the lower your costs will be.</p><h4>2. Use S3 Lifecycle Rules Instead of AWS Backup for Long-Term Storage</h4><p>Since AWS Backup does not transition S3 backups to cold storage, a more cost-effective alternative is <strong>S3 Object Lock with lifecycle policies</strong>. This allows you to:</p><ul><li>Apply retention policies directly at the bucket level.</li><li>Move objects to <strong>Glacier or Glacier Deep Archive</strong> for long-term storage.</li><li>Reduce backup costs while maintaining compliance with data retention policies.</li></ul><h4>3. Analyze Your S3 Backup Needs</h4><p>Consider whether full S3 backups are necessary. If your use case allows, <strong>alternative solutions like S3 replication and versioning with lifecycle rules may be more cost-effective</strong> than AWS Backup.</p><h4>4. Monitor and Manage Versioning</h4><p>If S3 versioning is enabled, ensure that lifecycle policies are in place to delete older versions when no longer needed. Unmanaged versioning can lead to excessive storage consumption and high costs.</p><h3>Key Takeaways</h3><ul><li>AWS Backup does not support transitioning S3 backups to cold storage.</li><li>Backup costs grow based on the number of RPs and changes to objects within S3.</li><li>Reducing RP retention, using S3 lifecycle policies, and managing versioning can significantly reduce costs.</li><li>Consider alternative solutions like Object Lock with lifecycle rules for long-term storage instead of AWS Backup.</li></ul><p>By understanding these limitations and implementing cost-saving strategies, AWS users can optimise their backup strategies while minimising unnecessary expenses.</p><p>The key principles of FinOps emphasise cost visibility, accountability, and continuous optimisation to ensure efficient cloud expenditure management. When managing backups, FinOps best practices include setting clear retention policies, leveraging cost-effective storage tiers, and continuously monitoring backup expenses to align with business needs.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9d3d46b5a49b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Navigating AWS Cost Visibility Discrepancies in FinOps]]></title>
            <link>https://medium.com/@hildamachando4/navigating-aws-cost-visibility-discrepancies-in-finops-c0f0e492b852?source=rss-59bdf2526b43------2</link>
            <guid isPermaLink="false">https://medium.com/p/c0f0e492b852</guid>
            <category><![CDATA[quicksight]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[cost-optimization]]></category>
            <category><![CDATA[finops]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Hilda Machando]]></dc:creator>
            <pubDate>Thu, 29 Jan 2026 10:52:01 GMT</pubDate>
            <atom:updated>2026-01-29T10:52:01.628Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BKH29pRBHM__KwTeI-W06w.jpeg" /></figure><p>Imagine you’re launching a FinOps program at a large organization, eager to bring cost efficiency and transparency across teams. However, you quickly hit a roadblock: different teams have access to AWS Billing and Cost Management (B &amp; CM), but they see inconsistent cost data. While you, as a FinOps lead, see accurate daily costs through Cost Explorer — including discounts and negotiated pricing — other teams only see on-demand rates, leading to inflated savings claims.</p><p>For instance, one team, which spent a total of $3.3 million last year, claims they can save $3 million this year based on their view in Cost Optimizer and the AWS Pricing Calculator. That would mean saving nearly their entire spend — an unrealistic outcome caused by the disconnect in cost visibility. You don’t control their permissions, so how can you ensure everyone sees consistent, accurate cost data?</p><h3>Understanding the Cost Visibility Challenge</h3><p>AWS offers multiple ways to view costs, but not all of them factor in enterprise-level pricing adjustments:</p><ul><li><strong>Cost Explorer</strong> (with payer account access) reflects actual amortized costs, including enterprise discounts.</li><li><strong>AWS Pricing Calculator</strong> shows standard pricing without applying organization-specific discounts or credits.</li><li><strong>Compute Optimizer and Cost Optimizer</strong> suggest savings based on list prices, potentially misleading teams who lack full cost context.</li><li><strong>AWS QuickSight Dashboards</strong> can consolidate cost data but require proper setup for role-based access.</li></ul><h3>Solving the Discrepancy: Unifying Cost Visibility</h3><p>To mitigate misunderstandings and prevent teams from making misguided financial decisions, consider these approaches:</p><h4>1. Implement AWS QuickSight Dashboards for Unified Cost Reporting</h4><p>Several organizations have successfully used <strong>AWS QuickSight</strong> to create a Cost Explorer dashboard with row-level security, ensuring teams see only the relevant costs while incorporating discounts and amortized expenses.</p><ul><li>Set up a dashboard that displays amortized costs by team or division.</li><li>Restrict views so users access only their respective cost centers.</li><li>Eliminate reliance on individual B &amp; CM access by centralizing reporting.</li></ul><p><strong>AWS Well-Architected Labs provides a guide on setting up Cloud Intelligence Dashboards:</strong><br><a href="https://www.wellarchitectedlabs.com/cloud-intelligence-dashboards/">Cloud Intelligence Dashboards</a></p><h4>2. Enable Cost Optimization Hub at the Payer Level</h4><p>By activating the <strong>Cost Optimization Hub</strong> at the <strong>payer account level</strong>, you ensure that Compute Optimizer recommendations already factor in organizational discounts, reducing inflated savings claims.</p><h4>3. Educate Teams on AWS Pricing Variability</h4><p>Since AWS does not consistently reflect private pricing in every service, teams should be aware that:</p><ul><li>Some discounts are built into rates.</li><li>Others appear as credits post-billing cycle.</li><li>Savings plans and reserved instances affect amortized costs differently.</li></ul><p>Regular training sessions and knowledge-sharing forums can help bridge these gaps.</p><p>Achieving cost transparency in AWS requires more than just data access — it demands alignment on <strong>which data to trust</strong> and how teams interpret savings. By centralizing cost visibility via QuickSight, enforcing uniform cost optimization settings, and educating stakeholders, you can ensure that teams make informed financial decisions and avoid misleading savings projections.</p><p>In FinOps, consistency is key. The more aligned your teams are on cost data, the better your organization can optimize cloud spending strategically.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c0f0e492b852" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Ensuring AWS Secrets Manager Updates Reflect in ECS Tasks]]></title>
            <link>https://medium.com/@hildamachando4/ensuring-aws-secrets-manager-updates-reflect-in-ecs-tasks-f80c190d2986?source=rss-59bdf2526b43------2</link>
            <guid isPermaLink="false">https://medium.com/p/f80c190d2986</guid>
            <category><![CDATA[aws-secrets-manager]]></category>
            <category><![CDATA[cloud-security]]></category>
            <category><![CDATA[secrets]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <dc:creator><![CDATA[Hilda Machando]]></dc:creator>
            <pubDate>Mon, 10 Nov 2025 11:11:58 GMT</pubDate>
            <atom:updated>2025-11-10T11:11:58.896Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*y0dB6dqdQ4O8kvUWoGed0A.jpeg" /></figure><p>AWS Secrets Manager is a powerful tool for securely storing and retrieving secrets such as database credentials, API keys, and other sensitive configurations. When running applications in Amazon ECS with AWS Fargate, you can integrate Secrets Manager to dynamically fetch and use these secrets at runtime.</p><p>However, a common challenge arises when new secrets are added or updated in AWS Secrets Manager but do not reflect in running ECS tasks. This issue often leads to confusion about whether newly deployed code will pick up the latest secrets or continue using old values.</p><p>This article walks through why this happens, how ECS handles secrets, and the best practices to ensure that ECS tasks always use the latest secrets stored in AWS Secrets Manager.</p><h3>Understanding the Problem</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/313/1*CKV0JWRC9FRxsz1Zzh-lEQ.png" /></figure><p>A user updated new environment variables in AWS Secrets Manager but did not see the changes reflected in their ECS tasks. Here’s a breakdown of what likely happened:</p><ol><li><strong>Secrets in AWS Secrets Manager Were Updated</strong>: The user added or modified secrets within AWS Secrets Manager.</li><li><strong>ECS Task Definition Was Not Updated</strong>: The ECS task definition was still using an older revision without the updated secrets.</li><li><strong>Running ECS Tasks Did Not Restart</strong>: Even after creating a new task definition revision with the updated secrets, the running ECS tasks did not automatically restart.</li><li><strong>Deployment Pipeline Concerns</strong>: The user was unsure if redeploying the application through CircleCI would apply the new secrets.</li></ol><h3>How AWS ECS Handles Secrets</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/328/1*2ObRY_SBJoLFeWzkM_jEWw.png" /></figure><p>ECS allows you to reference secrets in task definitions, but these references do not update dynamically. If you update a secret in Secrets Manager, your running ECS tasks do not automatically restart to fetch the new value. Instead, the workflow is:</p><ol><li>You define secrets in AWS Secrets Manager.</li><li>These secrets are referenced in the ECS task definition (under the secrets array in JSON).</li><li>When you create a new revision of the task definition and update the ECS service, only then do the new secrets take effect.</li></ol><h3>Steps to Ensure ECS Uses Updated Secrets</h3><h3>1. Verify That Secrets Are Properly Referenced</h3><p>When defining an ECS task definition, secrets should be referenced using valueFrom. This ensures the values are pulled dynamically from AWS Secrets Manager at runtime.</p><h4>Example Task Definition with Secrets</h4><pre>{<br>  &quot;family&quot;: &quot;my-app&quot;,<br>  &quot;containerDefinitions&quot;: [<br>    {<br>      &quot;name&quot;: &quot;my-app-container&quot;,<br>      &quot;image&quot;: &quot;${ACCOUNT_ID}.dkr.ecr.eu-west-1.amazonaws.com/my-app:latest&quot;,<br>      &quot;cpu&quot;: 512,<br>      &quot;memory&quot;: 1024,<br>      &quot;secrets&quot;: [<br>        {<br>          &quot;name&quot;: &quot;DB_PASSWORD&quot;,<br>          &quot;valueFrom&quot;: &quot;arn:aws:secretsmanager:eu-west-1:${ACCOUNT_ID}:secret:db-password&quot;<br>        }<br>      ]<br>    }<br>  ],<br>  &quot;executionRoleArn&quot;: &quot;arn:aws:iam::${ACCOUNT_ID}:role/ecsTaskExecutionRole&quot;,<br>  &quot;networkMode&quot;: &quot;awsvpc&quot;,<br>  &quot;requiresCompatibilities&quot;: [&quot;FARGATE&quot;],<br>  &quot;cpu&quot;: &quot;512&quot;,<br>  &quot;memory&quot;: &quot;1024&quot;<br>}</pre><h3>2. Create a New Revision of the Task Definition</h3><p>When you update secrets in AWS Secrets Manager, create a new revision of the ECS task definition to ensure the latest references are included.</p><pre>aws ecs register-task-definition --cli-input-json file://task-definition.json</pre><h3>3. Update the ECS Service</h3><p>Once the new task definition revision is created, update the ECS service to use it.</p><pre>aws ecs update-service --cluster my-cluster --service my-service --task-definition my-app:2</pre><p>This forces ECS to use the new task definition, ensuring that any new task fetches the latest secrets.</p><h3>4. Manually Force a Redeploy (If Needed)</h3><p>If your ECS service is running existing tasks, they won’t restart automatically. To force ECS to pull the new secrets, manually trigger a service redeployment:</p><pre>aws ecs update-service --cluster my-cluster --service my-service --force-new-deployment</pre><p>This will terminate existing tasks and start new ones using the latest secrets.</p><h3>5. Ensure Continuous Deployment Handles Secret Updates</h3><p>If using CircleCI or another CI/CD pipeline, modify the deployment process to include:</p><ul><li>Creating a new task definition revision.</li><li>Updating the ECS service with the new revision.</li><li>Forcing a new deployment to ensure new tasks pick up updated secrets.</li></ul><h4>Example CircleCI Configuration:</h4><pre>version: 2.1<br>jobs:<br>  deploy:<br>    docker:<br>      - image: amazon/aws-cli<br>    steps:<br>      - checkout<br>      - run: |<br>          aws ecs register-task-definition --cli-input-json file://task-definition.json<br>          aws ecs update-service --cluster my-cluster --service my-service --task-definition my-app:2<br>          aws ecs update-service --cluster my-cluster --service my-service --force-new-deployment</pre><h3>Additional Considerations</h3><h3>Automating ECS Task Restart on Secret Updates</h3><p>Unlike Kubernetes, which restarts pods when secrets change, ECS does not do this natively. However, you can automate restarts by:</p><ul><li><strong>AWS Lambda</strong>: Create a Lambda function that listens for AWS Secrets Manager changes and triggers an ECS deployment.</li><li><strong>CloudWatch Events</strong>: Set up an event rule to trigger the Lambda function when secrets change.</li><li><strong>CI/CD Triggers</strong>: Modify your deployment pipeline to check for secret updates and trigger a redeployment.</li></ul><h3>Debugging Issues</h3><p>If secrets are not updating:</p><ul><li>Check if the new task definition revision is actually being used.</li><li>Verify secrets are properly referenced (valueFrom should point to the correct ARN).</li><li>Ensure ECS logs are not showing authentication or permission errors.</li><li>Manually retrieve secrets to confirm their values:</li></ul><pre>aws secretsmanager get-secret-value --secret-id db-password</pre><p>AWS Secrets Manager is a robust way to store sensitive information securely, but its integration with ECS requires careful handling. Always create a new task definition revision and force a new deployment when secrets are updated. Automating these steps in your CI/CD pipeline ensures a smooth workflow without manual intervention. By following these best practices, you can ensure that your ECS tasks always use the latest secrets without running into inconsistencies.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f80c190d2986" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Integrating OAuth2 PKCE and SCRAM Authentication with Amazon Cognito]]></title>
            <link>https://medium.com/@hildamachando4/integrating-oauth2-pkce-and-scram-authentication-with-amazon-cognito-3358fa5527f5?source=rss-59bdf2526b43------2</link>
            <guid isPermaLink="false">https://medium.com/p/3358fa5527f5</guid>
            <category><![CDATA[security]]></category>
            <category><![CDATA[oauth2]]></category>
            <category><![CDATA[amazon-web-services]]></category>
            <category><![CDATA[cognito]]></category>
            <category><![CDATA[scram]]></category>
            <dc:creator><![CDATA[Hilda Machando]]></dc:creator>
            <pubDate>Wed, 08 Oct 2025 10:47:00 GMT</pubDate>
            <atom:updated>2025-10-08T10:47:00.004Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-7GZmH0ecQ6KgylClF6bsw.png" /></figure><p>Amazon Cognito offers a powerful and secure identity management service for applications, allowing developers to easily add user sign-up, sign-in, and access control functionalities. For those integrating Cognito with OAuth2 authorisation flows and exploring SCRAM (Salted Challenge Response Authentication Mechanism) as a secure means of handling authentication, understanding the right approach and available options is key. In this article, we’ll explore how to integrate the OAuth2 authorisation code grant flow (with PKCE) in Cognito and provide insights into SCRAM, highlighting Cognito’s support and best practices for managing authentication. Amazon Cognito supports OAuth2 authorisation code grant flow, including the PKCE (Proof Key for Code Exchange) extension. PKCE is used to enhance the security of public clients (such as mobile apps) by preventing code interception attacks. According to the <a href="https://docs.aws.amazon.com/cognito/latest/developerguide/authorization-endpoint.html">Cognito documentation</a>, it supports the code_challenge_method parameter as part of the OAuth2 flow, specifically supporting the S256 method.</p><p>This support allows developers to implement secure authentication flows where an authorisation code is exchanged for tokens, and an additional security layer is added through PKCE to prevent malicious code interception during the exchange.</p><h3>OAuth2 Authorization Flow in Cognito (with PKCE)</h3><p>When setting up OAuth2 in Cognito, you can utilise the authorisation code grant flow with PKCE. Here’s how it works:</p><ol><li><strong>Client Initiates Authorisation Request</strong>: The user is redirected to the Cognito authorisation endpoint to initiate the OAuth2 authorisation code flow. During this step, PKCE parameters like code_challenge and code_challenge_method are included in the request.</li><li><strong>User Authorisation</strong>: The user authorises access, and Cognito responds with an authorisation code.</li><li><strong>Exchange Authorisation Code for Tokens</strong>: The client exchanges the authorisation code for access and refresh tokens at the Cognito token endpoint. The exchange process uses code_verifierthe original secret used to create the requestcode_challenge to confirm the integrity of the request.</li></ol><p>By supporting the PKCE extension, Cognito enhances the security of this flow, especially for public clients that cannot securely store client secrets.</p><h3>Does Cognito support SCRAM authentication?</h3><p>While Cognito offers robust options for authentication, such as SRP (Secure Remote Password) and standard password authentication, it does not natively support SCRAM (Salted Challenge Response Authentication Mechanism). SCRAM is commonly used for handling password authentication securely in distributed environments, but unfortunately, Amazon Cognito does not currently provide built-in support for SCRAM.</p><p>However, there are alternatives and workarounds you can consider:</p><h4>SRP (Secure Remote Password Protocol)</h4><p>Cognito supports SRP as an alternative to SCRAM. SRP is a password authentication protocol that allows secure authentication without exposing the password over the network. It’s a highly secure protocol and is the recommended approach for secure password-based authentication in Cognito.</p><p>SRP is supported in Cognito user pools and can be easily integrated by using the AWS SDK for your application. SRP operates by leveraging a verifier (which is a hashed version of the password) and allows users to authenticate with Cognito without directly sending passwords, similar to how SCRAM works.</p><p>For more information on using SRP with Cognito, check the <a href="https://docs.aws.amazon.com/cognito/latest/developerguide/amazon-cognito-user-pools-authentication-flow.html#Using-SRP-password-authentication">Cognito SRP documentation</a>.</p><h4>Custom Authentication Flows</h4><p>For users needing to implement SCRAM-like functionality, custom authentication flows in Cognito provide an avenue for deeper customisation. In a custom flow, you can manage authentication mechanisms like SCRAM yourself by creating your own Lambda triggers. This could involve handling the authentication logic, including managing the password store, but it would require you to build out the system yourself.</p><p>If you decide to go this route, you’ll need to manage the password store securely, as Cognito doesn’t provide direct access to hashed passwords (by design). As a result, a custom authentication flow may require you to build the necessary password hashing and verification mechanism, which could be complex and security-critical.</p><h4>Managing Sessions in Custom Authentication</h4><p>Regarding the need to manage sessions when using a custom authentication flow, it’s important to note that while Cognito can handle session management for standard authentication mechanisms, custom flows would require you to manage this session logic as well. This includes handling secure session creation, maintenance, and expiration based on your custom authentication logic.</p><p>You won’t have access to the stored passwords in Cognito (again, by design), so for a SCRAM-like flow, you would need to implement your own system for verifying user credentials. This system could include a password store and the logic necessary to generate SCRAM-based responses.</p><p>If you are looking to integrate OAuth2 with PKCE in Cognito, you’re on the right path, as Cognito fully supports the authorisation code grant flow with PKCE. For SCRAM, while Cognito doesn’t offer native support, you can leverage SRP for secure password authentication, or if necessary, implement a custom authentication flow. When using custom flows, ensure you carefully consider security best practices, particularly around password storage and session management. Alternatively, leveraging SRP within Cognito provides a well-supported and secure solution without needing to manage the complexities of a full custom implementation.</p><p>Cognito offers a flexible platform for user authentication and identity management, but the right approach depends on your specific use case and security requirements.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3358fa5527f5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[From a Problem to an Idea to Published App: My Journey with Cloud Cost Guard and AWS Serverless…]]></title>
            <link>https://towardsaws.com/from-a-problem-to-an-idea-to-published-app-my-journey-with-cloud-cost-guard-and-aws-serverless-66de9397349d?source=rss-59bdf2526b43------2</link>
            <guid isPermaLink="false">https://medium.com/p/66de9397349d</guid>
            <category><![CDATA[dashboard]]></category>
            <category><![CDATA[finops]]></category>
            <category><![CDATA[apps]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Hilda Machando]]></dc:creator>
            <pubDate>Fri, 03 Oct 2025 09:59:17 GMT</pubDate>
            <atom:updated>2026-09-09T14:27:46.890Z</atom:updated>
            <content:encoded><![CDATA[<h3>From a Problem to an Idea to Published App: My Journey with Cloud Cost Guard and AWS Serverless Application Repository</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RCHC8N-U81VcfpwwbGgE7Q.png" /></figure><p>A while back, I ran into a recurring problem that kept nagging me. In the non-prod environments I worked with, costs would quietly creep up, and half the time no one realized until the bill landed. On top of that, resources were often left untagged or mis-tagged, making it almost impossible to know who owned what or why it even existed.</p><p>After struggling with this more than once, I thought: <em>there has to be a better way to spot cost spikes early and hold resources accountable through proper tagging.</em> That thought turned into an idea, and eventually into a project I called <a href="https://console.aws.amazon.com/serverlessrepo/home?region=us-east-1#/published-applications/arn:aws:serverlessrepo:us-east-1:318312872182:applications~cloud-cost-guard"><strong>Cloud Cost Guard</strong></a>.</p><p>At first, it was just a tool I built for myself comprised of a pair of Lambda functions, a dashboard, and some alerts to keep my environments under control. But the moment it worked, I realized this wasn’t just my problem. Countless other AWS users deal with the same headaches in their non-prod accounts. That’s when I knew I wanted to polish it, document it, and make it something anyone could deploy with a single click.</p><p>And today, that journey has come full circle: <a href="https://console.aws.amazon.com/serverlessrepo/home?region=us-east-1#/published-applications/arn:aws:serverlessrepo:us-east-1:318312872182:applications~cloud-cost-guard"><strong>Cloud Cost Guard</strong></a><strong> is live on the AWS Serverless Application Repository (SAR)!!!.</strong> This article is about how I got here, the lessons I learned fighting through errors and IAM policies, and the fulfillment of publishing my very first AWS application for the world to use.</p><h3>Starting with an idea</h3><p>Working in security, compliance, and risk, one pain point I kept seeing was how <strong>non-prod environments spiral out of control</strong> with forgotten resources and missed tags. Costs creep up, governance gets messy, and surprises show up on invoices.</p><p>I wanted a lightweight tool that would:</p><ul><li>Check for <strong>daily cost spikes</strong> in non-prod.</li><li>Audit resources for missing or invalid <strong>tags</strong>.</li><li>Show results in a simple <strong>dashboard</strong>.</li><li>Send <strong>email alerts</strong> when spend jumped unexpectedly.</li></ul><p>Once I decided I wanted to solve this problem, I knew I had to break it down into smaller pieces, or it would feel overwhelming. I started by imagining the flow: how could I collect the information I needed, make sense of it, and then share it in a way that was actually useful?</p><p>The first pieces I built were the “brains” of the tool, with one part to spot sudden jumps in costs and another to check whether resources were tagged the way they should be. Once that worked, I needed a home for the results, somewhere they could be saved and pulled up later without me digging around.</p><p>I quickly realised that I didn’t just want the data sitting quietly in a corner. If something important happened, I wanted to <em>know right away</em>. That’s when I added alerts, so I’d never miss a spike or a tagging issue again. And because I didn’t want to manually run it every day, I set it up to check things on a schedule, automatically.</p><p>Finally, I thought about how it should <em>look</em> to anyone using it. I didn’t want a jumble of numbers hidden in files. I wanted a clean, friendly dashboard that could tell the story at a glance. When I finally saw those charts and summaries come alive, it felt like the idea had truly become real.</p><h3>Building it out step by step</h3><ol><li><strong>Define the architecture in YAML</strong><br> I started with a template.yaml using the AWS Serverless Application Model (SAM).</li></ol><pre>Resources:   CostSpikeChecker:     <br>Type: AWS::Serverless::Function     <br>Properties:       CodeUri: src/cost_spike_checker/       <br>Handler: app.handler</pre><p><strong>2. Next step was to write the Lambda functions</strong></p><ul><li><em>CostSpikeChecker</em> calls the Cost Explorer API to fetch spend.</li><li><em>TagAuditChecker</em> calls the Resource Groups Tagging API to validate tags.</li></ul><pre># Example from TagAuditChecker <br>import boto3 rg = boto3.client(&#39;resourcegroupstaggingapi&#39;)  <br>def handler(event, context):     <br>resp = rg.get_resources(TagFilters=[{&#39;Key&#39;: &#39;Environment&#39;}])     <br>return resp[&#39;ResourceTagMappingList&#39;]</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/531/1*DRQvtHN8H7sYnWZRqsfmkQ.png" /></figure><p><strong>3. Then I had to configure my outputs to S3</strong><br> Each Lambda writes a JSON file into an S3 bucket (summary.json, tag_audit.json).</p><p><strong>4. Set up alerting</strong><br> I created an SNS topic for cost spikes:</p><pre>AlertsTopic:   Type: AWS::SNS::Topic</pre><p><strong>5. Schedule daily checks</strong><br> Using EventBridge cron expressions, I made sure checks run every morning.</p><p><strong>6. Design the dashboard</strong><br> I created a static HTML + Chart.js + <a href="https://tailwindcss.com/">TailwindCSS</a> dashboard that fetches the JSON from S3 and renders KPIs, charts, and a tagging audit table.</p><pre>&lt;canvas id=&quot;costTrend&quot;&gt;&lt;/canvas&gt; <br>&lt;script&gt;   <br>const data = await <br>fetch(&#39;summary.json&#39;).then(r=&gt;r.json());   <br>new Chart(document.getElementById(&#39;costTrend&#39;), <br>{     type: &#39;line&#39;,     data: { labels: data.dates, datasets: [{ data: data.costs }] }   }); <br>&lt;/script&gt;</pre><p><strong>7. Test locally, then deploy</strong></p><ul><li>sam validate → catch template issues.</li><li>sam build → compile dependencies.</li><li>sam deploy → deploy stack into AWS.</li></ul><p><strong>8. Host the frontend</strong><br> I used AWS Amplify Hosting (my new fav AWS service btw) to connect my GitHub repo and auto-deploy changes to the dashboard.</p><h4>And WALAA… Cloud Cost Guard is LIVE!</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/782/1*cqbhpuFHwhhlMMxzZT2-4g.png" /></figure><h3>Hurdles along the way</h3><p>Of course, no journey is without a few bumps. What looked straightforward on paper often broke down once I started building, and each hurdle forced me to pause, rethink, and learn something new.</p><p>One of the first challenges was with my <strong>template files</strong>. CloudFormation kept throwing the error <em>“Invalid template property or properties [TagAuditChecker]”</em>. After some head scratching, I discovered it was nothing more than a YAML indentation mistake. Running sam validate and revisiting the CloudFormation template anatomy docs helped me see just how sensitive these files are to structure.</p><p>Then came <strong>S3 ACL errors</strong>. I tried to give my reports public read access with ACL: public-read, only to hit <em>“AccessControlListNotSupported when calling the PutObject operation.”</em> The fix was realizing that Amazon S3 has moved away from ACLs in favor of Block Public Access settings and bucket policies. It was a small but important lesson in keeping up with evolving best practices.</p><p>Next, I ran into <strong>permissions issues</strong> when my tag audit function tried to call the tagging API. The dreaded <em>AccessDeniedException</em> made me realize my Lambda role didn’t have the right actions. Attaching the managed policy ResourceGroupsandTagEditorReadOnlyAccess resolved it, and taught me the value of checking the Tagging API actions reference closely.</p><p>Finally, there was the <strong>runtime mismatch</strong>. SAM kept failing with <em>“Binary validation failed for python3.12”</em> because my environment didn’t have that version available. Rather than wrestle with local installs, I switched to python3.9 and used AWS CloudShell, which comes preloaded with compatible runtimes. That decision saved me a lot of frustration.</p><p>Each of these setbacks was frustrating in the moment, but overcoming them gave me new tools and confidence. By the end, I wasn’t just building Cloud Cost Guard, I was building my own resilience as a cloud builder.</p><h3>TLDR: Lessons learnt</h3><ul><li>Validate early (sam validate) to catch YAML mistakes.</li><li>IAM errors are inevitable but reading error messages closely reveals the missing permission.</li><li>AWS CloudShell removes local setup pain.</li><li>Drop ACLs, use bucket policies. Cloud best practices evolve.</li><li>Persistence is everything, each fix is a small win that stacks up.</li><li><strong>READ </strong>the AWS docs, they will save your life.</li></ul><p>The moment I ran sam publish and saw <strong>Cloud Cost Guard</strong> appear in the <strong>AWS Serverless Application Repository</strong>, it felt different from just another internal tool. This was <strong>mine</strong>. A tool I designed, built, debugged, documented, and now published for the world to try and it’s more than visibility; to me it’s a milestone and solid proof that ideas can be turned into tangible products.</p><h3>What’s next</h3><p>Cloud Cost Guard is just the beginning. I want to:</p><ul><li>Add stacked service-level cost trends.</li><li>Expand tagging rules.</li><li>Collect feedback from other AWS users.</li></ul><p>And most importantly, keep building and publishing.</p><p>If you’re sitting on an idea, my advice is simple: <strong>start small, break down the errors, and keep going.</strong> The moment your app goes live is worth every bit of the struggle.</p><p>✨ <a href="https://console.aws.amazon.com/serverlessrepo/home?region=us-east-1#/published-applications/arn:aws:serverlessrepo:us-east-1:318312872182:applications~cloud-cost-guard"><em>Cloud Cost Guard</em></a><em> is live on the AWS Serverless Application Repository. Try it, break it, improve it and let me know what you think:).</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=66de9397349d" width="1" height="1" alt=""><hr><p><a href="https://towardsaws.com/from-a-problem-to-an-idea-to-published-app-my-journey-with-cloud-cost-guard-and-aws-serverless-66de9397349d">From a Problem to an Idea to Published App: My Journey with Cloud Cost Guard and AWS Serverless…</a> was originally published in <a href="https://towardsaws.com/">Towards AWS</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>