<?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 Hari Om on Medium]]></title>
        <description><![CDATA[Stories by Hari Om on Medium]]></description>
        <link>https://medium.com/@hari27om?source=rss-403dd53dc117------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Wyqy9J0xOvk5HOCwScaXNw.png</url>
            <title>Stories by Hari Om on Medium</title>
            <link>https://medium.com/@hari27om?source=rss-403dd53dc117------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 01:09:42 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@hari27om/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[Day 6 — AWS Lambda Fundamentals & Execution Model]]></title>
            <link>https://hari27om.medium.com/day-6-aws-lambda-fundamentals-execution-model-fb1430db88e4?source=rss-403dd53dc117------2</link>
            <guid isPermaLink="false">https://medium.com/p/fb1430db88e4</guid>
            <dc:creator><![CDATA[Hari Om]]></dc:creator>
            <pubDate>Mon, 07 Sep 2026 13:11:15 GMT</pubDate>
            <atom:updated>2026-09-07T13:11:15.147Z</atom:updated>
            <content:encoded><![CDATA[<h4>Serverless, Execution Environments, Cold Starts, Handlers, Memory, Timeout, /tmp, Environment Variables &amp; IAM</h4><h3>1. What Is AWS Lambda?</h3><p>The textbook definition is:</p><blockquote><em>AWS Lambda is a serverless compute service that runs code in response to events without requiring you to provision or manage servers.</em></blockquote><p>That’s correct.</p><p>But for the exam, we need a better mental model.</p><p>Think of Lambda as:</p><pre>Event occurs</pre><pre>     ↓</pre><pre>AWS finds or creates<br>an execution environment</pre><pre>     ↓</pre><pre>Your code executes</pre><pre>     ↓</pre><pre>Result returned / event processed</pre><pre>     ↓</pre><pre>Environment may remain available<br>for another invocation</pre><p>You provide:</p><pre>CODE<br>+<br>CONFIGURATION</pre><p>AWS manages much of the underlying compute infrastructure.</p><h3>2. What Does “Serverless” Actually Mean?</h3><p>Serverless does <strong>not</strong> mean:</p><pre>There are no servers.</pre><p>There are obviously servers somewhere.</p><p>It means:</p><pre>YOU do not provision or directly manage<br>the underlying servers.</pre><p>Compare EC2:</p><pre>Developer<br>   │<br>   ├── Choose instance<br>   ├── Provision server<br>   ├── Patch OS<br>   ├── Capacity planning<br>   ├── Scaling<br>   └── Application</pre><p>with Lambda:</p><pre>Developer<br>   │<br>   ├── Code<br>   ├── Runtime/config<br>   ├── Permissions<br>   └── Application logic</pre><pre>AWS<br>   │<br>   ├── Compute infrastructure<br>   ├── Execution environments<br>   ├── Infrastructure scaling<br>   └── Underlying host management</pre><p>Serverless therefore means:</p><blockquote><strong><em>Abstract the server-management layer away from the developer.</em></strong></blockquote><h3>3. Lambda Is Event Driven</h3><p>Lambda becomes much easier when you stop thinking:</p><pre>&quot;I start my application.&quot;</pre><p>and instead think:</p><pre>&quot;Something happened.&quot;</pre><pre>↓</pre><pre>&quot;Run my function.&quot;</pre><p>Examples:</p><pre>HTTP request<br>     ↓<br>API Gateway<br>     ↓<br>Lambda</pre><pre>File uploaded<br>     ↓<br>S3<br>     ↓<br>Lambda</pre><pre>Message available<br>     ↓<br>SQS<br>     ↓<br>Lambda</pre><pre>Database item changed<br>     ↓<br>DynamoDB Stream<br>     ↓<br>Lambda</pre><pre>Scheduled event<br>     ↓<br>EventBridge<br>     ↓<br>Lambda</pre><p>This is <em>Event-Driven Architecture.</em></p><h3>4. The Lambda Function</h3><p>Suppose we’re building an order API.</p><p>Node.js example:</p><pre>export const handler = async (event) =&gt; {</pre><pre>   console.log(&quot;Received event:&quot;, event);</pre><pre>    return {<br>        statusCode: 200,<br>        body: JSON.stringify({<br>            message: &quot;Order received&quot;<br>        })<br>    };<br>};</pre><p>The important function is: <strong><em>handler</em></strong></p><p>This is the entry point AWS invokes.</p><h3>5. The Lambda Handler</h3><p>Every Lambda function needs an entry point.</p><p>Conceptually:</p><pre>AWS Lambda</pre><pre>     ↓</pre><pre>Handler</pre><pre>     ↓</pre><pre>Your Application Logic</pre><p>For Node.js:</p><pre>export const handler = async (event, context) =&gt; {<br><br>};</pre><p>AWS passes information to your function.</p><p>Commonly:</p><pre>event<br><br>context</pre><h3>6. What Is event?</h3><p>The event object contains information about whatever triggered the function.</p><p>Its structure depends on the event source.</p><p>For API Gateway, it might contain:</p><pre>HTTP method</pre><pre>Path</pre><pre>Headers</pre><pre>Query parameters</pre><pre>Request body</pre><p>For S3:</p><pre>Bucket</pre><pre>Object key</pre><pre>Event type</pre><p>For SQS: <strong><em>Messages</em></strong></p><p>For DynamoDB Streams: <strong><em>Inserted/updated/deleted records</em></strong></p><p>So:</p><pre>EVENT SOURCE</pre><pre>determines</pre><pre>EVENT STRUCTURE</pre><h3>7. Example — S3 Event</h3><p>Imagine:</p><pre>User uploads invoice.pdf</pre><pre>↓</pre><pre>S3 Bucket</pre><pre>↓</pre><pre>Lambda</pre><p>The event contains information describing the S3 event.</p><p>Simplified concept:</p><pre>{<br>  &quot;Records&quot;: [<br>    {<br>      &quot;eventName&quot;: &quot;ObjectCreated:Put&quot;,<br>      &quot;s3&quot;: {<br>        &quot;bucket&quot;: {<br>          &quot;name&quot;: &quot;company-invoices&quot;<br>        },<br>        &quot;object&quot;: {<br>          &quot;key&quot;: &quot;invoice.pdf&quot;<br>        }<br>      }<br>    }<br>  ]<br>}</pre><p>Your Lambda can read:</p><pre>const bucket =<br>    event.Records[0].s3.bucket.name;</pre><pre>const key =<br>    event.Records[0].s3.object.key;</pre><p>Then process the object.</p><h3>8. What Is context?</h3><p>The context object contains information about the Lambda execution.</p><p>Depending on the runtime, you can access things such as:</p><pre>Function name</pre><pre>Function version</pre><pre>Memory allocation</pre><pre>Request ID</pre><pre>Remaining execution time</pre><p>Example:</p><pre>export const handler = async (event, context) =&gt; {</pre><pre>    console.log(context.awsRequestId);</pre><pre>    console.log(<br>        context.getRemainingTimeInMillis()<br>    );<br>};</pre><p>Useful when your function needs to know:</p><pre>&quot;How much execution time do I have left?&quot;</pre><h3>9. Lambda Execution Environment</h3><p>This is one of the most important Lambda concepts.</p><p>When Lambda runs your function, AWS provides an isolated Execution Environment.</p><p>Conceptually:</p><pre>Lambda Execution Environment</pre><pre>┌──────────────────────────────┐<br>│                              │<br>│ Runtime                      │<br>│                              │<br>│ Your Function Code           │<br>│                              │<br>│ Dependencies                 │<br>│                              │<br>│ Environment Variables        │<br>│                              │<br>│ /tmp Storage                 │<br>│                              │<br>└──────────────────────────────┘</pre><p>The environment provides the resources required to execute your function.</p><h3>10. Execution Environment Lifecycle</h3><p>At a high level, Lambda execution can be thought of in phases:</p><pre>INIT</pre><pre>↓</pre><pre>INVOKE</pre><pre>↓</pre><pre>possible reuse</pre><pre>↓</pre><pre>INVOKE</pre><pre>↓</pre><pre>possible reuse</pre><pre>↓</pre><pre>SHUTDOWN</pre><p>The distinction between:</p><pre>INIT</pre><pre>and</pre><pre>INVOKE</pre><p>is extremely important for performance.</p><h3>11. INIT Phase</h3><p>When Lambda creates a new execution environment, it needs to initialize it.</p><p>Conceptually:</p><pre>Create environment</pre><pre>↓</pre><pre>Start runtime</pre><pre>↓</pre><pre>Load function code</pre><pre>↓</pre><pre>Run initialization code</pre><pre>↓</pre><pre>Ready for invocation</pre><p>This initialization contributes to what developers commonly call, <strong><em>Cold Start</em></strong></p><h3>12. Cold Start</h3><p>Suppose nobody has invoked our function recently.</p><p>Request arrives:</p><pre>Request</pre><pre>↓</pre><pre>No ready execution environment</pre><pre>↓</pre><pre>Create environment</pre><pre>↓</pre><pre>Initialize runtime</pre><pre>↓</pre><pre>Load code</pre><pre>↓</pre><pre>Initialize dependencies</pre><pre>↓</pre><pre>Run handler</pre><p>The extra initialization latency is called, <strong><em>Cold Start</em></strong>.</p><h3>13. Warm Invocation</h3><p>After Lambda processes the request, AWS may keep that execution environment available.</p><p>Another request arrives.</p><p>Instead of creating everything again:</p><pre>Request</pre><pre>↓</pre><pre>Existing execution environment</pre><pre>↓</pre><pre>Run handler</pre><p>This is commonly called a <strong><em>Warm Invocation </em></strong>and the environment a <strong><em>Warm Execution Environment.</em></strong></p><h3>14. Cold vs Warm</h3><pre>COLD :</pre><pre>Create environment<br>      ↓<br>Initialize runtime<br>      ↓<br>Load code<br>      ↓<br>Run initialization<br>      ↓<br>Handler</pre><p>versus:</p><pre>WARM : </pre><pre>Existing environment<br>      ↓<br>Handler</pre><p>Therefore:</p><pre>Cold Invocation usually has additional latency.</pre><h3>15. Important: You Cannot Assume Warm Reuse</h3><p>This is critical.Developers sometimes think:</p><pre>&quot;My Lambda is warm now,<br>so it&#39;ll stay warm.&quot;</pre><p>Wrong assumption.</p><p>AWS can remove execution environments.</p><p>Therefore your application must remain correct even if every invocation effectively receives a new environment.</p><p>Never design correctness around:</p><pre>&quot;This variable will definitely<br>still exist next time.&quot;</pre><p>It might. It might not.</p><h3>16. Global Scope vs Handler Scope</h3><p>Consider:</p><pre>const database = createDatabaseConnection();</pre><pre>export const handler = async (event) =&gt; {</pre><pre>    const result =<br>        await database.query(...);</pre><pre>    return result;<br>};</pre><p>createDatabaseConnection() is outside the handler.</p><p>It can execute during initialization. If the environment is reused:</p><pre>Cold Start:</pre><pre>createDatabaseConnection()</pre><pre>↓</pre><pre>Handler</pre><pre>↓</pre><pre>Handler</pre><pre>↓</pre><pre>Handler</pre><p>instead of:</p><pre>Handler</pre><pre>create connection</pre><pre>↓</pre><pre>Handler</pre><pre>create connection</pre><pre>↓</pre><pre>Handler</pre><pre>create connection</pre><p>This can significantly improve performance.</p><h3>17. AWS Lambda Best Practice — Reuse Resources</h3><p>Objects that are expensive to initialize can often be initialized outside the handler.</p><p>Examples:</p><pre>AWS SDK clients</pre><pre>Database connections</pre><pre>HTTP clients</pre><pre>Configuration</pre><pre>Static resources</pre><p>Example:</p><pre>import { DynamoDBClient } from &quot;<a href="http://twitter.com/aws">@aws</a>-sdk/client-dynamodb&quot;;</pre><pre>const dynamodb = new DynamoDBClient({});</pre><pre>export const handler = async (event) =&gt; {</pre><pre>    // reuse client</pre><pre>};</pre><p>This is generally better than creating a new client inside every invocation.</p><h3>18. Why?</h3><p>Bad:</p><pre>export const handler = async () =&gt; {</pre><pre>    const client =<br>        new DynamoDBClient({});</pre><pre>};</pre><p>Every invocation constructs the client.</p><p>Better:</p><pre>const client =<br>    new DynamoDBClient({});</pre><pre>export const handler = async () =&gt; {</pre><pre>};</pre><p>Warm invocations may reuse it.</p><h3>19. But Don’t Store Critical State Globally</h3><p>Suppose:</p><pre>let balance = 100;</pre><pre>export const handler = async () =&gt; {</pre><pre>    balance -= 10;</pre><pre>};</pre><p>Do NOT assume subsequent requests see the same value.</p><p>Lambda can have:</p><pre>Environment A</pre><pre>Environment B</pre><pre>Environment C</pre><p>running simultaneously. Each has its own memory.</p><p>So Lambda execution environments are not your database.</p><p>Use:</p><pre>DynamoDB</pre><pre>RDS</pre><pre>S3</pre><pre>ElastiCache</pre><p>or another persistent/shared system for application state.</p><h3>20. Stateless Architecture</h3><p>Lambda functions should generally be designed as: <strong><em>Stateless</em></strong></p><p>Meaning:</p><pre>Invocation should not require previous invocation&#39;s local memory.</pre><p>Persistent state belongs outside Lambda.</p><p>Example:</p><pre>Lambda</pre><pre>↓</pre><pre>DynamoDB</pre><p>not:</p><pre>Lambda</pre><pre>↓</pre><pre>global JavaScript variable</pre><p>for critical business data.</p><h3>21. Cold Start Architecture</h3><p>Let’s visualize.</p><p>First request:</p><pre>Client<br>   │<br>   ▼<br>Lambda Service<br>   │<br>   ▼<br>No environment<br>   │<br>   ▼<br>Create Environment<br>   │<br>   ▼<br>Initialize Runtime<br>   │<br>   ▼<br>Load Code<br>   │<br>   ▼<br>Initialize Dependencies<br>   │<br>   ▼<br>Handler</pre><p>Later request:</p><pre>Client<br>   │<br>   ▼<br>Lambda Service<br>   │<br>   ▼<br>Existing Environment<br>   │<br>   ▼<br>Handler</pre><h3>22. What Affects Cold Start?</h3><p>Cold-start latency can be affected by factors such as:</p><pre>Runtime</pre><pre>Package/container characteristics</pre><pre>Initialization code</pre><pre>Dependencies</pre><pre>Networking configuration</pre><pre>Extensions</pre><pre>Memory/CPU resources</pre><pre>Application framework</pre><p>For example, if initialization does:</p><pre>Load enormous dependency</pre><pre>↓</pre><pre>Create database connection</pre><pre>↓</pre><pre>Fetch configuration</pre><pre>↓</pre><pre>Initialize giant framework</pre><p>startup may take longer.</p><h3>23. Reducing Cold Starts</h3><p>Common strategies include:</p><pre>Keep deployment package lean</pre><pre>Remove unused dependencies</pre><pre>Avoid unnecessary initialization</pre><pre>Reuse initialized resources</pre><pre>Allocate appropriate memory</pre><pre>Use Provisioned Concurrency when predictable low latency is required</pre><p>We’ll study Provisioned Concurrency deeply on Day 8.</p><h3>24. Provisioned Concurrency — Preview</h3><p>Normally:</p><pre>Request</pre><pre>↓</pre><pre>Maybe cold start</pre><p>With Provisioned Concurrency:</p><pre>AWS pre-initializes execution environments</pre><pre>↓</pre><pre>Request</pre><pre>↓</pre><pre>Ready environment</pre><p>This can reduce cold-start latency for the provisioned capacity.</p><p>But:</p><pre>Provisioned Concurrency costs money</pre><p>So it’s useful when latency requirements justify it.</p><h3>25. Lambda Memory</h3><p>When configuring Lambda, you choose memory allocation.</p><p>Example:</p><pre>128 MB</pre><pre>512 MB</pre><pre>1024 MB</pre><pre>2048 MB</pre><pre>4096 MB</pre><pre>...</pre><p>But memory configuration affects more than memory.</p><h3>26. Memory and CPU Are Related</h3><p>Lambda allocates CPU resources proportionally to configured memory.</p><p>Conceptually:</p><pre>More Memory</pre><pre>↓</pre><pre>More CPU allocation</pre><pre>↓</pre><pre>Potentially faster execution</pre><p>Therefore increasing memory can sometimes:</p><pre>increase cost per unit time</pre><pre>but</pre><pre>decrease execution duration</pre><p>and occasionally the function can become both:</p><pre>FASTER and cost-efficient</pre><p>depending on the workload.</p><h3>27. Example</h3><p>Suppose:</p><pre>512 MB, Duration = 4 seconds</pre><p>Increase to:</p><pre>1024 MB, Duration = 1.8 seconds</pre><p>Even though you’ve allocated more memory, execution is much faster.</p><p>Therefore Lambda optimization is not simply:</p><pre>&quot;Always choose minimum memory.&quot;</pre><p>That’s wrong.</p><p>You need to balance:</p><pre>Memory</pre><pre>CPU</pre><pre>Duration</pre><pre>Cost</pre><h3>28. CPU-Bound Functions</h3><p>Suppose your Lambda performs:</p><pre>Image processing</pre><pre>Compression</pre><pre>Encryption</pre><pre>Data transformation</pre><p>These can be CPU-intensive.</p><p>Increasing Lambda memory may provide more CPU and improve execution speed.</p><p>Exam scenario:</p><blockquote><em>Lambda has sufficient memory but computation is slow.</em></blockquote><p>Possible solution:</p><pre>Increase memory allocation</pre><p>because it also increases available CPU resources.</p><h3>29. Lambda Timeout</h3><p>Every Lambda function has a maximum execution duration configuration.</p><p>If your handler doesn’t complete before the configured timeout:</p><pre>Invocation</pre><pre>↓</pre><pre>Running</pre><pre>↓</pre><pre>Running</pre><pre>↓</pre><pre>TIMEOUT</pre><pre>↓</pre><pre>Execution terminated</pre><p>The function doesn’t get infinite execution time.</p><h3>30. Maximum Lambda Timeout</h3><p>The maximum Lambda execution timeout is <strong><em>15 minutes.</em></strong></p><p>This is worth memorizing.</p><pre>Lambda Maximum Execution = 15 minutes</pre><h3>31. Choosing Timeout</h3><p>Don’t blindly configure: <strong><em>900 seconds </em></strong>for every function.</p><p>Suppose an API request should finish in 2 seconds.</p><p>A 15-minute timeout can cause failed operations to consume resources unnecessarily.</p><p>Instead choose a timeout appropriate for the workload.</p><h3>32. Timeout and Downstream Services</h3><p>Suppose:</p><pre>API Gateway</pre><pre>↓</pre><pre>Lambda</pre><pre>↓</pre><pre>External API</pre><p>Lambda timeout: 30 seconds</p><p>But your HTTP client timeout is: 120 seconds</p><p>That’s pointless.</p><p>Lambda can terminate before the HTTP client gives up.</p><p>Timeouts should be designed across the whole request chain.</p><h3>33. context.getRemainingTimeInMillis()</h3><p>In Node.js:</p><pre>export const handler = async (event, context) =&gt; {</pre><pre>    const remaining =<br>        context.getRemainingTimeInMillis();</pre><pre>    console.log(<br>        `Remaining: ${remaining}ms`<br>    );<br>};</pre><p>This can help a function stop gracefully before Lambda terminates it.</p><p>Example:</p><pre>1000 records</pre><pre>↓</pre><pre>Processing</pre><pre>↓</pre><pre>Only 2 seconds remain</pre><pre>↓</pre><pre>Checkpoint / stop</pre><pre>↓</pre><pre>Continue later</pre><p>depending on architecture.</p><h3>34. Lambda /tmp Storage</h3><p>Lambda provides temporary local filesystem storage at:</p><pre>/tmp</pre><p>This is called: <strong><em>Ephemeral Storage</em></strong></p><p>Useful for:</p><pre>Temporary downloads</pre><pre>Image processing</pre><pre>Archive extraction</pre><pre>Intermediate files</pre><pre>ML model files</pre><pre>Temporary transformations</pre><h3>35. Example</h3><p>Suppose:</p><pre>S3 Image</pre><pre>↓</pre><pre>Lambda</pre><pre>↓</pre><pre>Download to /tmp</pre><pre>↓</pre><pre>Resize image</pre><pre>↓</pre><pre>Upload resized image to S3</pre><p>Architecture:</p><pre>Original Bucket</pre><pre>     │</pre><pre>     ▼</pre><pre>   Lambda</pre><pre>     │</pre><pre>     ▼</pre><pre>    /tmp</pre><pre>     │</pre><pre>     ▼</pre><pre>Image Processing</pre><pre>     │</pre><pre>     ▼</pre><pre>Resized Bucket</pre><h3>36. /tmp Is Not Durable Storage</h3><p>Do not treat /tmp like a database.</p><p>A reused environment may retain files temporarily.</p><p>But you cannot rely on that for durable state.</p><p>Think:</p><pre>/tmp = Temporary scratch space</pre><p>not:</p><pre>Persistent storage</pre><h3>37. Configurable Ephemeral Storage</h3><p>Lambda allows configuring ephemeral storage from: <strong><em>512 MB</em></strong> upto <strong><em>10,240 MB</em></strong> which is:</p><pre>10 GB</pre><p>Useful when processing larger temporary files.</p><p>Exam memory:</p><pre>/tmp : 512 MB default configurable up to 10 GB</pre><h3>38. Environment Variables</h3><p>Lambda supports environment variables.</p><p>Example:</p><pre>TABLE_NAME=Orders <br><br>ENVIRONMENT=production<br><br>LOG_LEVEL=info</pre><p>Node.js:</p><pre>const table = process.env.TABLE_NAME;</pre><p>This lets you separate:</p><pre>Code from Configuration</pre><h3>39. Why Environment Variables Matter</h3><p>Instead of:</p><pre>const table = &quot;production-orders-table&quot;;</pre><p>write:</p><pre>const table = process.env.TABLE_NAME;</pre><p>Now the same code can run in:</p><pre>Development</pre><pre>Staging</pre><pre>Production</pre><p>with different configuration.</p><h3>40. Example</h3><pre>DEV Lambda<br>TABLE_NAME=orders-dev</pre><pre>PROD Lambda<br>TABLE_NAME=orders-prod</pre><p>Same code.</p><p>Different environment configuration.</p><h3>41. Environment Variables and Secrets</h3><p>Should you put:</p><pre>DATABASE_PASSWORD=my-secret-password</pre><p>directly into ordinary environment configuration?</p><p>Be careful.</p><p>For sensitive application secrets, consider:</p><pre>AWS Secrets Manager<br><br>or<br><br>SSM Parameter Store</pre><p>depending on requirements.</p><p>Lambda environment variables can also be protected using encryption mechanisms, but secret-management services provide capabilities designed specifically for secret lifecycle and access.</p><h3>42. Lambda + Secrets Manager</h3><p>Architecture:</p><pre>Lambda</pre><pre>   │</pre><pre>   │ execution role<br>   ▼</pre><pre>Secrets Manager</pre><pre>   │</pre><pre>   ▼</pre><pre>Database Secret</pre><pre>   │</pre><pre>   ▼</pre><pre>Database</pre><p>Lambda role needs appropriate permission such as:</p><pre>secretsmanager:GetSecretValue</pre><p>and potentially KMS permissions depending on the encryption configuration.</p><h3>43. Don’t Fetch Secrets Every Time If Unnecessary</h3><p>Imagine:</p><pre>Invocation</pre><pre>↓</pre><pre>Secrets Manager</pre><pre>↓</pre><pre>Get secret</pre><pre>↓</pre><pre>Database</pre><p>on every request.</p><p>This adds:</p><pre>Latency</pre><pre>API calls</pre><pre>Cost</pre><p>Depending on security and rotation requirements, applications may cache secrets appropriately within the execution environment.</p><p>Again:</p><pre>Warm Environment can reuse initialized data</pre><p>but correctness must never depend on indefinite environment reuse.</p><h3>44. Lambda Execution Role</h3><p>Yesterday we learned this.</p><p>Lambda needs permission to access AWS services.</p><p>Example:</p><pre>Lambda</pre><pre>↓</pre><pre>DynamoDB</pre><p>The Lambda execution role needs:</p><pre>dynamodb:GetItem</pre><pre>dynamodb:PutItem</pre><h3>45. Execution Role Architecture</h3><pre>Lambda Function</pre><pre>      │ assumes<br>      ▼</pre><pre>Execution Role</pre><pre>      ├── DynamoDB<br>      ├── S3<br>      ├── SQS<br>      └── CloudWatch Logs</pre><p>The execution role answers:</p><blockquote><em>What can the Lambda function do?</em></blockquote><h3>46. Lambda Trust Policy</h3><p>The role must trust Lambda.</p><p>Conceptually:</p><pre>{<br>  &quot;Effect&quot;: &quot;Allow&quot;,<br>  &quot;Principal&quot;: {<br>    &quot;Service&quot;: &quot;lambda.amazonaws.com&quot;<br>  },<br>  &quot;Action&quot;: &quot;sts:AssumeRole&quot;<br>}</pre><p>Meaning:</p><pre>Lambda service can assume this role</pre><h3>47. Lambda Resource-Based Policy</h3><p>Now remember the opposite direction.</p><p>Execution role:</p><pre>Lambda</pre><pre>↓</pre><pre>DynamoDB</pre><p>Resource policy:</p><pre>S3</pre><pre>↓</pre><pre>Lambda</pre><p>If another service needs permission to invoke Lambda, Lambda’s resource-based policy may authorize that principal.</p><h3>48. Direction Trick</h3><p>Ask: <em>Who is calling whom?</em></p><pre>Lambda → S3<br><br>Lambda needs permission.<br>Execution Role.</pre><pre>S3 → Lambda<br><br>S3 needs permission to invoke Lambda.<br>Lambda Resource Policy.</pre><p>This one question solves many IAM exam scenarios.</p><h3>49. Lambda Logging</h3><p>By default, Lambda commonly integrates with: <strong><em>Amazon CloudWatch Logs</em></strong></p><p>Your code:</p><pre>console.log(&quot;Order created&quot;);</pre><p>can produce logs in CloudWatch Logs when the function has appropriate logging permissions.</p><p>Architecture:</p><pre>Lambda</pre><pre>↓</pre><pre>Execution Role</pre><pre>↓</pre><pre>CloudWatch Logs</pre><h3>50. Basic Logging Permissions</h3><p>Lambda commonly needs permissions involving CloudWatch Logs operations.</p><p>AWS provides the managed policy:</p><pre>AWSLambdaBasicExecutionRole</pre><p>for common basic logging permissions.</p><p>If your function runs but logs aren’t appearing, inspect the execution role.</p><h3>51. Lambda Invocation Models</h3><p>Lambda can be invoked in different ways.</p><p>Three major categories to understand are:</p><pre>Synchronous</pre><pre>Asynchronous</pre><pre>Event Source Mapping</pre><p>We’ll study them deeply tomorrow.</p><p>For now, understand the high-level distinction.</p><h3>52. Synchronous Invocation</h3><p>Caller waits for the response.</p><pre>Caller</pre><pre>↓</pre><pre>Lambda</pre><pre>↓</pre><pre>Execute</pre><pre>↓</pre><pre>Response</pre><pre>↓</pre><pre>Caller</pre><p>Examples can include:</p><pre>API Gateway</pre><pre>Application Load Balancer</pre><pre>Direct SDK invocation</pre><p>Conceptually:</p><pre>REQUEST</pre><pre>↓</pre><pre>WAIT</pre><pre>↓</pre><pre>RESPONSE</pre><h3>53. Asynchronous Invocation</h3><p>Caller sends the event and doesn’t wait for the function result in the same way.</p><p>Conceptually:</p><pre>Event Source</pre><pre>↓</pre><pre>Lambda service queues event</pre><pre>↓</pre><pre>Caller continues</pre><pre>↓</pre><pre>Lambda processes event</pre><p>Examples include event-driven integrations such as:</p><pre>S3 events<br>SNS<br>EventBridge</pre><p>depending on the integration.</p><p>Lambda provides retry/error-handling behavior for asynchronous invocation.</p><p>Tomorrow we’ll go deep into:</p><pre>Retries<br>Destinations<br>DLQs</pre><h3>54. Event Source Mapping</h3><p>Some event sources work differently.</p><p>Examples:</p><pre>SQS<br>DynamoDB Streams<br>Kinesis</pre><p>Lambda uses an:</p><h3>Event Source Mapping</h3><p>Conceptually:</p><pre>SQS Queue</pre><pre>      ▲<br>      │<br>Lambda polls<br>      │<br>      ▼</pre><pre>Event Source Mapping</pre><pre>      │</pre><pre>      ▼</pre><pre>Lambda Function</pre><p>This is different from S3 directly pushing an asynchronous event to Lambda.</p><p>Important.</p><p>We’ll spend significant time on this tomorrow.</p><h3>55. Push vs Poll</h3><p>Simplified mental model:</p><pre>S3</pre><pre>PUSH-style event<br>↓<br>Lambda</pre><p>while:</p><pre>SQS</pre><pre>Lambda polls<br>↑<br>Queue</pre><p>and:</p><pre>DynamoDB Streams</pre><pre>Lambda polls<br>↑<br>Stream</pre><p>Understanding this difference becomes crucial for retries and scaling.</p><h3>56. Lambda Deployment Package</h3><p>Your Lambda needs:</p><pre>Function Code</pre><pre>+</pre><pre>Dependencies</pre><p>Common deployment approaches include:</p><pre>.zip archive<br><br>Container image</pre><h3>57. ZIP Deployment</h3><p>Example:</p><pre>function.zip</pre><pre>├── index.js<br>├── package.json<br>├── node_modules/<br>└── application code</pre><p>Upload to Lambda.</p><p>For larger ZIP-based deployments, S3 can be involved in the deployment process.</p><h3>58. Container Image Lambda</h3><p>Lambda can also run functions packaged as container images.</p><p>Conceptually:</p><pre>Dockerfile</pre><pre>↓</pre><pre>Build Image</pre><pre>↓</pre><pre>Push to ECR</pre><pre>↓</pre><pre>Lambda</pre><p>This is useful when:</p><pre>Dependencies are complex</pre><pre>Container tooling already exists</pre><pre>Large application packages</pre><pre>Custom runtime requirements</pre><p>But Lambda container images still run under Lambda’s execution model.</p><p>It doesn’t suddenly become ECS.</p><h3>59. Lambda Runtime</h3><p>The runtime provides the language-specific execution environment.</p><p>AWS supports runtimes for languages such as:</p><pre>Node.js</pre><pre>Python</pre><pre>Java</pre><pre>.NET</pre><pre>Ruby</pre><p>and custom-runtime approaches are also possible.</p><p>For the exam, understand:</p><pre>Runtime =</pre><pre>Environment responsible for running your function code</pre><h3>60. Runtime Updates</h3><p>Managed runtimes evolve.</p><p>AWS can release runtime updates containing:</p><pre>Security patches</pre><pre>Bug fixes</pre><pre>Runtime changes</pre><p>This matters because your code should be tested against supported runtime versions.</p><p>Don’t assume:</p><pre>Node.js version X will exist forever.</pre><h3>61. Lambda Layers</h3><p>We’ll cover Layers more deeply later.</p><p>But conceptually:</p><pre>Function Code</pre><pre>+</pre><pre>Layer</pre><p>A layer can contain reusable content such as:</p><pre>Libraries</pre><pre>Dependencies</pre><pre>Custom runtimes</pre><pre>Shared code</pre><p>Architecture:</p><pre>             Shared Layer<br>             /    |    \<br>            /     |     \<br>           ▼      ▼      ▼<br><br>       Lambda A Lambda B Lambda C</pre><p>Useful when multiple functions share common dependencies.</p><h3>62. Lambda Versions</h3><p>When you modify $LATEST, you&#39;re modifying the mutable development version of the function.</p><p>You can publish:</p><pre>Version 1</pre><pre>Version 2</pre><pre>Version 3</pre><p>Published versions are immutable snapshots.</p><p>Conceptually:</p><pre>$LATEST<br>   │<br>   ▼<br>Publish<br>   │<br>   ▼<br>Version 1</pre><p>Then modify:</p><pre>$LATEST</pre><p>and publish:</p><pre>Version 2</pre><h3>63. Lambda Aliases</h3><p>An alias is a named pointer to a Lambda version.</p><p>Example:</p><pre>dev</pre><pre>staging</pre><pre>prod</pre><p>Architecture:</p><pre>prod</pre><pre>↓</pre><pre>Version 7</pre><p>Later:</p><pre>prod</pre><pre>↓</pre><pre>Version 8</pre><p>Applications can invoke:</p><pre>prod</pre><p>without needing to know the specific underlying version.</p><p>We’ll cover this deeply during deployment strategies.</p><h3>64. Lambda Function ARN</h3><p>Lambda resources use ARNs.</p><p>Conceptually:</p><pre>arn:aws:lambda:<br>REGION:<br>ACCOUNT_ID:<br>function:<br>FUNCTION_NAME</pre><p>Example shape:</p><pre>arn:aws:lambda:ap-south-1:123456789012:function:OrderProcessor</pre><p>Version or alias qualifiers can also be part of invocation/reference patterns.</p><h3>65. Lambda Pricing Mental Model</h3><p>At a high level, Lambda cost is based on factors including:</p><pre>Number of requests</pre><pre>+</pre><pre>Execution duration</pre><pre>+</pre><pre>Configured compute resources</pre><p>with additional pricing dimensions for some features.</p><p>This creates an interesting optimization problem.</p><p>Suppose:</p><pre>Low Memory<br>Duration = 5 sec</pre><p>versus:</p><pre>More Memory<br>Duration = 1 sec</pre><p>The second might be more efficient depending on the workload.</p><p>Never optimize Lambda by memory alone.</p><h3>66. Lambda vs EC2</h3><p>When should we use Lambda?</p><p>Good workloads often include:</p><pre>Event-driven processing</pre><pre>APIs</pre><pre>Automation</pre><pre>Short-running jobs</pre><pre>File processing</pre><pre>Queue consumers</pre><pre>Scheduled tasks</pre><p>EC2 may make more sense when you need things such as:</p><pre>Long-running processes</pre><pre>Full OS control</pre><pre>Special host configuration</pre><pre>Workloads unsuitable for Lambda limits</pre><h3>67. Lambda vs ECS/Fargate</h3><p>Suppose you have:</p><pre>Containerized service runs continuously</pre><p>ECS/Fargate may be more natural.</p><p>Suppose:</p><pre>Event happens <br><br>run code <br><br>finish</pre><p>Lambda may be a great fit.</p><p>Not every application should be converted to Lambda.</p><p>“Serverless” isn’t automatically better.</p><p>Architecture depends on workload.</p><h3>68. Lambda Maximum Execution Time</h3><p>Exam question:</p><blockquote><em>Application task takes 45 minutes.</em></blockquote><p>Can one Lambda invocation execute the whole task continuously?</p><p>No.</p><p>Remember:</p><pre>Lambda Maximum<br><br>15 minutes</pre><p>Possible alternatives could involve:</p><pre>Step Functions<br><br>ECS/Fargate<br><br>AWS Batch<br><br>EC2</pre><p>depending on the problem.</p><h3>69. Lambda and Step Functions</h3><p>Suppose a workflow contains:</p><pre>Validate Order</pre><pre>↓</pre><pre>Charge Payment</pre><pre>↓</pre><pre>Reserve Inventory</pre><pre>↓</pre><pre>Send Email</pre><p>You could write one giant Lambda.</p><p>But orchestration becomes messy.</p><p>Instead:</p><pre>Step Functions</pre><pre>↓</pre><pre>Lambda A</pre><pre>↓</pre><pre>Lambda B</pre><pre>↓</pre><pre>Lambda C</pre><p>Step Functions can orchestrate workflows.</p><p>We’ll cover this later.</p><h3>70. Lambda and API Gateway</h3><p>Classic serverless API:</p><pre>Client</pre><pre>↓</pre><pre>API Gateway</pre><pre>↓</pre><pre>Lambda</pre><pre>↓</pre><pre>DynamoDB</pre><p>Responsibilities:</p><pre>API Gateway<br>HTTP API surface<br>routing<br>authorization options<br>throttling capabilities</pre><pre>Lambda<br><br>business logic</pre><pre>DynamoDB<br><br>persistent data</pre><p>This architecture appears constantly in DVA-C02.</p><h3>71. Lambda + S3</h3><p>Common architecture:</p><pre>User</pre><pre>↓</pre><pre>S3</pre><pre>↓</pre><pre>ObjectCreated</pre><pre>↓</pre><pre>Lambda</pre><pre>↓</pre><pre>Process Object</pre><pre>↓</pre><pre>Output S3 Bucket</pre><p>Examples:</p><pre>Thumbnail generation</pre><pre>PDF processing</pre><pre>Virus scanning pipeline</pre><pre>Metadata extraction</pre><pre>ETL</pre><h3>72. Infinite Loop Danger</h3><p>Imagine:</p><pre>S3 Bucket</pre><pre>↓</pre><pre>Object uploaded</pre><pre>↓</pre><pre>Lambda</pre><pre>↓</pre><pre>Lambda writes processed object</pre><pre>↓</pre><pre>Same S3 Bucket</pre><pre>↓</pre><pre>Object uploaded event</pre><pre>↓</pre><pre>Lambda</pre><pre>↓</pre><pre>writes again</pre><pre>↓</pre><pre>Lambda</pre><pre>...</pre><p>Congratulations.</p><p>You’ve invented an AWS-powered money printer.</p><p>Unfortunately, it’s printing the bill.</p><p>Avoid recursive event loops.</p><p>Use:</p><pre>Separate input/output buckets</pre><pre>or</pre><pre>carefully designed prefixes/filters</pre><h3>73. Example Better Architecture</h3><pre>uploads/</pre><pre>↓</pre><pre>S3 Event</pre><pre>↓</pre><pre>Lambda</pre><pre>↓</pre><pre>processed/</pre><p>Configure the trigger only for:</p><pre>uploads/</pre><p>or use separate buckets:</p><pre>Raw Bucket</pre><pre>↓</pre><pre>Lambda</pre><pre>↓</pre><pre>Processed Bucket</pre><h3>74. Lambda + DynamoDB</h3><p>Typical architecture:</p><pre>API Gateway</pre><pre>↓</pre><pre>Lambda</pre><pre>↓</pre><pre>DynamoDB</pre><p>Lambda execution role:</p><pre>dynamodb:GetItem</pre><pre>dynamodb:PutItem</pre><pre>dynamodb:UpdateItem</pre><p>only as required.</p><p>Don’t attach:</p><pre>AdministratorAccess</pre><p>because it’s convenient.</p><p>Least privilege survives Day 6 too.</p><h3>75. Lambda + SQS</h3><p>Architecture:</p><pre>Producer</pre><pre>↓</pre><pre>SQS Queue</pre><pre>↓</pre><pre>Lambda</pre><pre>↓</pre><pre>Database</pre><p>This is extremely powerful because SQS decouples producers from consumers.</p><p>Instead of:</p><pre>Producer</pre><pre>↓</pre><pre>Lambda directly</pre><pre>↓</pre><pre>If Lambda overwhelmed:<br>problem</pre><p>we can have:</p><pre>Producer</pre><pre>↓</pre><pre>Queue</pre><pre>↓</pre><pre>Buffer</pre><pre>↓</pre><pre>Lambda consumers</pre><p>Tomorrow we’ll cover this deeply.</p><h3>76. Lambda + DynamoDB Streams</h3><p>Architecture:</p><pre>DynamoDB Table</pre><pre>↓</pre><pre>DynamoDB Stream</pre><pre>↓</pre><pre>Lambda</pre><pre>↓</pre><pre>Side Effect</pre><p>Examples:</p><pre>Send notification</pre><pre>Update search index</pre><pre>Audit change</pre><pre>Aggregate data</pre><p>Again:</p><pre>Lambda polls the stream<br>through event source mapping.</pre><h3>77. Lambda + EventBridge</h3><p>Architecture:</p><pre>Event</pre><pre>↓</pre><pre>EventBridge</pre><pre>↓</pre><pre>Rule</pre><pre>↓</pre><pre>Lambda</pre><p>Useful for:</p><pre>Application events</pre><pre>Scheduled events</pre><pre>AWS service events</pre><pre>Event-driven architectures</pre><p>Example:</p><pre>Every day at midnight</pre><pre>↓</pre><pre>EventBridge Scheduler/rule</pre><pre>↓</pre><pre>Lambda cleanup job</pre><p>depending on the scheduling service/pattern being used.</p><h3>78. Lambda Concurrency — Preview</h3><p>Suppose:</p><pre>100 requests arrive simultaneously.</pre><p>Lambda doesn’t necessarily execute them sequentially:</p><pre>Request 1<br>Request 2<br>Request 3<br>...<br>Request 100</pre><p>It can create multiple execution environments.</p><p>Conceptually:</p><pre>100 Requests</pre><pre>↓</pre><pre>Lambda</pre><pre>├── Environment 1<br>├── Environment 2<br>├── Environment 3<br>├── ...<br>└── Environment N</pre><p>This is: <strong>Concurrency, </strong>We’ll study it deeply on Day 8.</p><h3>79. Concurrency Explains Statelessness</h3><p>Suppose:</p><pre>Request A</pre><pre>↓</pre><pre>Environment 1</pre><p>while:</p><pre>Request B</pre><pre>↓</pre><pre>Environment 2</pre><p>A global variable in Environment 1 isn’t automatically shared with Environment 2.</p><p>Therefore:</p><pre>Global memory ≠ Shared application state</pre><p>Use external persistent systems.</p><h3>80. Reserved Concurrency — Preview</h3><p>Suppose account concurrency is shared by many functions.</p><p>One function suddenly receives enormous traffic.</p><p>Without controls:</p><pre>Function A consumes huge concurrency</pre><pre>↓</pre><pre>Function B struggles</pre><p>Reserved concurrency can help reserve and cap concurrency for a function.</p><p>We’ll cover the exact behavior on Day 8.</p><h3>81. Provisioned Concurrency — Preview Again</h3><p>Don’t confuse:</p><pre>Reserved Concurrency</pre><p>with:</p><pre>Provisioned Concurrency</pre><p>Quick mental model:</p><pre>RESERVED<br>Concurrency capacity boundary/reservation</pre><pre>PROVISIONED<br>Pre-initialized environments<br>for predictable low latency</pre><p>Very common exam distinction.</p><h3>82. Lambda Environment Reuse</h3><p>Suppose:</p><pre>let counter = 0;</pre><pre>export const handler = async () =&gt; {</pre><pre>    counter++;</pre><pre>    return counter;<br>};</pre><p>Invocation 1 might return:</p><pre>1</pre><p>Invocation 2 might return:</p><pre>2</pre><p>if the same environment is reused.</p><p>But invocation 3 might return:</p><pre>1</pre><p>because AWS used another execution environment.</p><p>Therefore:</p><pre>Never rely on this<br>for application correctness.</pre><h3>83. Lambda and Database Connections</h3><p>This is a real production concern.</p><p>Suppose Lambda scales:</p><pre>1 execution environment<br><br>↓<br><br>100<br><br>↓<br><br>1000</pre><p>Each environment creates database connections.</p><p>Traditional databases can become overwhelmed.</p><p>Architecture:</p><pre>Lambda Fleet</pre><pre>↓</pre><pre>Thousands of connections</pre><pre>↓</pre><pre>RDS</pre><pre>💥</pre><p>One AWS solution for relational databases is: <strong><em>Amazon RDS Proxy</em></strong></p><h3>84. RDS Proxy</h3><p>Conceptually:</p><pre>Lambda Functions</pre><pre>     │<br>     │ many connections<br>     ▼</pre><pre>   RDS Proxy</pre><pre>     │<br>     │ managed/poolable DB connectivity<br>     ▼</pre><pre>     RDS</pre><p>RDS Proxy can help manage database connections for serverless/highly scalable applications.</p><p>Remember this for later.</p><h3>85. Lambda Environment Variables vs Secrets Manager</h3><p>Exam comparison:</p><pre>Non-sensitive configuration → Environment Variables</pre><p>Examples:</p><pre>TABLE_NAME</pre><pre>ENVIRONMENT</pre><pre>LOG_LEVEL</pre><p>Sensitive secrets:</p><pre>Database password</pre><pre>API key</pre><pre>Credential</pre><p>Think:</p><pre>Secrets Manager depending on requirements.</pre><h3>86. Common Exam Scenario #1</h3><blockquote><em>Lambda needs more CPU.</em></blockquote><p>What configuration can help?</p><pre>Increase Lambda memory</pre><p>because CPU allocation increases with memory.</p><h3>87. Common Exam Scenario #2</h3><blockquote><em>Lambda occasionally experiences startup latency after periods of inactivity.</em></blockquote><p>What is happening?</p><pre>Cold Start</pre><h3>88. Common Exam Scenario #3</h3><blockquote><em>Application requires consistently low Lambda startup latency.</em></blockquote><p>Think:</p><pre>Provisioned Concurrency</pre><h3>89. Common Exam Scenario #4</h3><blockquote><em>Lambda repeatedly creates an SDK client inside the handler.</em></blockquote><p>Optimization?</p><pre>Initialize reusable SDK client<br>outside handler.</pre><p>This allows reuse across warm invocations.</p><h3>90. Common Exam Scenario #5</h3><blockquote><em>Lambda stores important application data in a global variable.</em></blockquote><p>Problem?</p><p>Execution environments are:</p><pre>temporary <br>isolated <br>not guaranteed to be reused</pre><p>Use external persistent storage.</p><h3>91. Common Exam Scenario #6</h3><blockquote><em>Lambda needs temporary disk storage to process a large archive.</em></blockquote><p>Use:</p><pre>/tmp</pre><p>and configure ephemeral storage as needed.</p><h3>92. Common Exam Scenario #7</h3><blockquote><em>A task takes 30 minutes.</em></blockquote><p>Can Lambda execute it in one invocation?</p><p>No.</p><pre>Maximum = 15 minutes</pre><p>Consider another architecture.</p><h3>93. Common Exam Scenario #8</h3><blockquote><em>Lambda can run but cannot write CloudWatch logs.</em></blockquote><p>Check:</p><pre>Execution Role</pre><p>for CloudWatch Logs permissions.</p><h3>94. Common Exam Scenario #9</h3><blockquote><em>Lambda must access DynamoDB.</em></blockquote><p>Use:</p><pre>Lambda Execution Role</pre><p>Not embedded access keys.</p><h3>95. Common Exam Scenario #10</h3><blockquote><em>S3 must invoke Lambda.</em></blockquote><p>Use:</p><pre>Lambda Resource-Based Policy</pre><p>Again:</p><pre>WHO calls WHOM?</pre><h3>96. Common Exam Scenario #11</h3><blockquote><em>Lambda processes S3 uploads but writes processed objects back to the same triggering path.</em></blockquote><p>Potential problem:</p><pre>Recursive invocation loop</pre><p>Fix using:</p><pre>Filters<br>Prefixes<br>Separate bucket/path</pre><h3>97. Common Exam Scenario #12</h3><blockquote><em>Lambda scales heavily and overwhelms an RDS database with connections.</em></blockquote><p>Think:</p><pre>RDS Proxy</pre><h3>🧠 Lambda Memory Map</h3><pre>AWS LAMBDA</pre><pre>├── Serverless Compute<br>│<br>├── Event Driven<br>│<br>├── Handler<br>│   ├── event<br>│   └── context<br>│<br>├── Execution Environment<br>│   ├── Runtime<br>│   ├── Code<br>│   ├── Dependencies<br>│   └── /tmp<br>│<br>├── Lifecycle<br>│   ├── Init<br>│   ├── Invoke<br>│   └── Shutdown<br>│<br>├── Cold Start<br>│<br>├── Warm Invocation<br>│<br>├── Memory<br>│   └── More memory → more CPU<br>│<br>├── Timeout<br>│   └── Max 15 minutes<br>│<br>├── Ephemeral Storage<br>│   ├── /tmp<br>│   └── Up to 10 GB<br>│<br>├── Configuration<br>│   └── Environment Variables<br>│<br>├── Security<br>│   ├── Execution Role<br>│   └── Resource Policy<br>│<br>├── Invocation<br>│   ├── Sync<br>│   ├── Async<br>│   └── Event Source Mapping<br>│<br>├── Deployment<br>│   ├── ZIP<br>│   └── Container Image<br>│<br>└── Scaling<br>    └── Concurrency</pre><h3>🔥 Lambda Cheat Sheet</h3><pre>+----+-------------------------+------------------------------------------+<br>| #  | Concept                 | Meaning                                  |<br>+----+-------------------------+------------------------------------------+<br>| 01 | Serverless              | AWS manages servers and infrastructure   |<br>| 02 | Event-Driven Compute    | Function runs when an event occurs       |<br>| 03 | Handler                 | Entry point of the Lambda function       |<br>| 04 | Event Trigger           | Event that starts Lambda execution       |<br>| 05 | Event Data              | Input passed to the Lambda function      |<br>| 06 | Context                 | Invocation and runtime information       |<br>| 07 | Runtime                 | Environment used to execute the function |<br>| 08 | Execution Environment   | Isolated environment for the function    |<br>| 09 | Cold Start              | New environment initialization           |<br>| 10 | Warm Invocation         | Reused execution environment             |<br>| 11 | Global Initialization   | Code outside handler, reusable           |<br>| 12 | Global State            | State outside handler; don&#39;t rely on it  |<br>| 13 | Memory                  | Allocated memory; also affects CPU       |<br>| 14 | Maximum Timeout         | Maximum execution time: 15 minutes       |<br>| 15 | /tmp                    | Ephemeral local storage                  |<br>| 16 | /tmp Maximum            | Maximum temporary storage: 10 GB         |<br>| 17 | Environment Variables  | Runtime configuration values              |<br>| 18 | Execution Role          | Lambda -&gt; AWS resource permissions       |<br>| 19 | Resource Policy         | Other principal -&gt; Lambda permissions    |<br>| 20 | CloudWatch Logs         | Lambda execution and application logs    |<br>| 21 | Synchronous             | Caller waits for the response            |<br>| 22 | Asynchronous            | Event is queued and processed later      |<br>| 23 | Event Source Mapping    | Lambda polls supported event sources     |<br>| 24 | ZIP Deployment          | Deploy function using a ZIP package      |<br>| 25 | Container Image         | Deploy function using container image    |<br>| 26 | Layers                  | Shared dependencies/code                 |<br>| 27 | Versions                | Immutable published snapshots            |<br>| 28 | Aliases                 | Named pointers to Lambda versions        |<br>| 29 | RDS Proxy               | Helps manage database connections        |<br>| 30 | Provisioned Concurrency | Pre-initialized Lambda environments      |<br>| 31 | Reserved Concurrency    | Controls/reserves function concurrency   |<br>+----+-------------------------+------------------------------------------+</pre><h3>⚠️ Exam Traps</h3><h3>Trap 1</h3><pre>Serverless means no servers.</pre><p>Wrong.</p><p>It means you don’t manage the underlying servers.</p><h3>Trap 2</h3><pre>Warm environment always stays alive.</pre><p>Wrong.</p><p>Reuse isn’t guaranteed.</p><h3>Trap 3</h3><pre>Global variables are persistent state.</pre><p>Wrong.</p><p>They’re environment-local and temporary.</p><h3>Trap 4</h3><pre>More Lambda memory only means more RAM.</pre><p>Wrong.</p><p>CPU allocation also increases with memory.</p><h3>Trap 5</h3><pre>Lambda can run indefinitely.</pre><p>Wrong.</p><p>Maximum:</p><pre>15 minutes</pre><h3>Trap 6</h3><pre>/tmp is persistent storage.</pre><p>Wrong.</p><p>It’s ephemeral scratch storage.</p><h3>Trap 7</h3><pre>Lambda needs DynamoDB → Resource Policy.</pre><p>Wrong.</p><p>Lambda execution role.</p><h3>Trap 8</h3><pre>S3 invokes Lambda → Execution Role.</pre><p>Wrong direction.</p><p>Lambda resource-based policy is relevant.</p><h3>Trap 9</h3><pre>Cold starts must always be solved<br>with Provisioned Concurrency.</pre><p>Wrong.</p><p>First understand whether cold starts are actually a business problem and optimize code/configuration appropriately.</p><h3>Trap 10</h3><pre>Lambda overwhelms RDS connections<br>→ increase Lambda concurrency.</pre><p>That can make the problem worse.</p><p>Think about connection management, including RDS Proxy.</p><h3>📝 Practice Questions</h3><h3>Question 1</h3><p>What is a Lambda execution environment?</p><p>An isolated environment AWS provides containing the runtime, function code, dependencies, temporary storage and other resources required to execute the function.</p><h3>Question 2</h3><p>What causes a cold start?</p><p>Lambda needs to create and initialize a new execution environment before processing an invocation.</p><h3>Question 3</h3><p>What’s a warm invocation?</p><p>An invocation that can use an already initialized execution environment.</p><h3>Question 4</h3><p>Should application state be stored in a Lambda global variable?</p><p>No.</p><p>Global data may be reused within the same warm environment, but execution environment reuse isn’t guaranteed and multiple environments may run simultaneously.</p><p>Use external persistent storage for critical state.</p><h3>Question 5</h3><p>Where should an AWS SDK client generally be initialized when practical?</p><p>Outside the handler so it can potentially be reused across warm invocations.</p><h3>Question 6</h3><p>A Lambda function needs additional CPU.</p><p>What can the developer change?</p><p>Increase configured memory, because Lambda allocates CPU proportionally with memory.</p><h3>Question 7</h3><p>What is the maximum Lambda execution timeout?</p><pre>15 minutes<br>=<br>900 seconds</pre><h3>Question 8</h3><p>Where can Lambda temporarily store files locally?</p><pre>/tmp</pre><h3>Question 9</h3><p>What is /tmp intended for?</p><p>Ephemeral scratch storage for temporary files and intermediate processing.</p><h3>Question 10</h3><p>Lambda needs access to DynamoDB.</p><p>What grants the permission?</p><p>Lambda execution role.</p><h3>Question 11</h3><p>S3 needs to invoke Lambda.</p><p>What permission mechanism is relevant?</p><p>Lambda resource-based policy.</p><h3>Question 12</h3><p>A Lambda processes uploaded images and stores transformed images in the same S3 location that triggers it.</p><p>What problem can occur?</p><p>Recursive invocations / an event loop.</p><p>Use event filters, prefixes or separate input/output locations.</p><h3>Question 13</h3><p>Lambda needs a database password.</p><p>What AWS service should you consider?</p><p>AWS Secrets Manager, depending on requirements.</p><h3>Question 14</h3><p>Hundreds of Lambda environments open connections to an RDS database and exhaust its connection capacity.</p><p>What service should you consider?</p><p>Amazon RDS Proxy.</p><h3>Question 15</h3><p>Which invocation style means the caller waits for Lambda’s response?</p><p>Synchronous invocation.</p><h3>Question 16</h3><p>Which model is commonly associated with SQS → Lambda?</p><p>Event source mapping.</p><p>Lambda polls the queue through the event source mapping.</p><h3>Question 17</h3><p>Which model is associated with DynamoDB Streams → Lambda?</p><p>Event source mapping.</p><h3>Question 18</h3><p>Why shouldn’t permanent AWS credentials be placed in Lambda environment variables?</p><p>Lambda should normally obtain temporary AWS credentials through its execution role.</p><h3>Question 19 — Exam Style</h3><p>A Lambda function experiences unpredictable initialization latency. The business requires consistently low latency for customer-facing requests.</p><p>What should the developer investigate?</p><p>Provisioned Concurrency.</p><p>It keeps configured Lambda execution environments initialized and ready for requests.</p><h3>Question 20 — Architecture</h3><p>Design a serverless image-processing system.</p><pre>User</pre><pre>↓</pre><pre>S3 Raw Images Bucket</pre><pre>↓</pre><pre>ObjectCreated Event</pre><pre>↓</pre><pre>Lambda Image Processor</pre><pre>↓</pre><pre>/tmp</pre><pre>↓</pre><pre>Resize / Transform</pre><pre>↓</pre><pre>S3 Processed Images Bucket</pre><p>Lambda execution role needs only the required permissions, such as:</p><pre>Raw bucket<br>→ GetObject</pre><pre>Processed bucket<br>→ PutObject</pre><pre>CloudWatch Logs<br>→ logging permissions</pre><p>This avoids recursive invocation and follows least privilege.</p><h3>🎯 2-Minute Day 6 Revision</h3><pre>LAMBDA<br>======</pre><pre>Serverless event-driven compute.<br></pre><pre>HANDLER<br>=======</pre><pre>Entry point.<br></pre><pre>EVENT<br>=====</pre><pre>Trigger information.<br></pre><pre>CONTEXT<br>=======</pre><pre>Invocation/runtime information.<br></pre><pre>EXECUTION ENVIRONMENT<br>=====================</pre><pre>Runtime + Code + Dependencies + /tmp<br></pre><pre>COLD START<br>==========</pre><pre>New environment initialization.<br></pre><pre>WARM INVOCATION<br>===============</pre><pre>Reuse initialized environment.<br></pre><pre>GLOBAL INITIALIZATION<br>=====================</pre><pre>Useful for reusable SDK clients,<br>DB connections, configuration.<br></pre><pre>GLOBAL STATE<br>============</pre><pre>Never rely on it for correctness.<br></pre><pre>MEMORY<br>======</pre><pre>More memory<br>→ More CPU<br></pre><pre>TIMEOUT<br>=======</pre><pre>Maximum 15 minutes.<br></pre><pre>/tmp<br>====</pre><pre>Ephemeral storage.</pre><pre>Default 512 MB.</pre><pre>Configurable up to 10 GB.<br></pre><pre>ENVIRONMENT VARIABLES<br>=====================</pre><pre>Configuration.<br></pre><pre>SECRETS<br>=======</pre><pre>Consider Secrets Manager.<br></pre><pre>LAMBDA → AWS<br>============</pre><pre>Execution Role.<br></pre><pre>AWS SERVICE → LAMBDA<br>====================</pre><pre>Resource-Based Policy.<br></pre><pre>SYNC<br>====</pre><pre>Caller waits.<br></pre><pre>ASYNC<br>=====</pre><pre>Event submitted for asynchronous processing.<br></pre><pre>SQS / DYNAMODB STREAMS / KINESIS<br>================================</pre><pre>Event Source Mapping.<br></pre><pre>LOW-LATENCY COLD START REQUIREMENT<br>==================================</pre><pre>Provisioned Concurrency.<br></pre><pre>TOO MANY RDS CONNECTIONS<br>========================</pre><pre>RDS Proxy.</pre><h3>🏆 The Most Important Lambda Diagram</h3><p>If you remember only one architecture from today, remember this:</p><pre>                     EVENT SOURCE</pre><pre>                         │</pre><pre>                         ▼</pre><pre>                 AWS Lambda Service</pre><pre>                         │</pre><pre>             ┌───────────┴───────────┐<br>             │                       │<br>             ▼                       ▼</pre><pre>       Existing Environment?       No Environment<br>             │                       │<br>             │                       ▼<br>             │                 Create Environment<br>             │                       │<br>             │                       ▼<br>             │                     INIT<br>             │                       │<br>             └───────────┬───────────┘<br>                         │<br>                         ▼</pre><pre>                       INVOKE</pre><pre>                         │<br>                         ▼</pre><pre>                       Handler</pre><pre>                    /      |      \<br>                   /       |       \<br>                  ▼        ▼        ▼</pre><pre>                 S3    DynamoDB    SQS</pre><pre>                         │<br>                         ▼</pre><pre>                 Execution Complete</pre><pre>                         │<br>                         ▼</pre><pre>             Environment may be reused</pre><p>That diagram explains:</p><pre>Cold Starts</pre><pre>Warm Starts</pre><pre>Global Initialization</pre><pre>SDK Client Reuse</pre><pre>/tmp Reuse</pre><pre>Stateless Design</pre><pre>Concurrency</pre><p>all at once.</p><h3>Day 6 Final Takeaway</h3><p>Don’t memorize Lambda as:</p><blockquote><em>Lambda runs code without servers.</em></blockquote><p>Understand it as:</p><pre>EVENT</pre><pre>↓</pre><pre>EXECUTION ENVIRONMENT</pre><pre>↓</pre><pre>INIT if required</pre><pre>↓</pre><pre>HANDLER</pre><pre>↓</pre><pre>AWS SERVICES through IAM role</pre><pre>↓</pre><pre>RESULT</pre><pre>↓</pre><pre>ENVIRONMENT MAY BE REUSED</pre><p>And remember the word:</p><h3>MAY.</h3><p>The environment <strong>may</strong> be reused.</p><p>That single word explains why:</p><pre>SDK clients outside handler<br>= GOOD</pre><pre>critical state outside handler<br>= REQUIRED</pre><h3>🚀 Day 7 Preview — Lambda Invocation, Events &amp; Failure Handling</h3><p>Tomorrow is where Lambda gets considerably more interesting.</p><p>We’ll answer:</p><blockquote><strong><em>What actually happens when a Lambda invocation fails?</em></strong></blockquote><p>Because the answer depends heavily on <strong>how the function was invoked</strong>.</p><p>The biggest thing we’ll build is a comparison that you should know almost instinctively:</p><pre>SYNCHRONOUS<br>vs<br>ASYNCHRONOUS<br>vs<br>EVENT SOURCE MAPPING</pre><p>because their retry and failure behavior is <strong>not the same</strong>.</p><p>That difference produces a lot of DVA-C02 questions.</p><p><strong>Day 6 taught us how Lambda runs.<br>Day 7 will teach us what happens when Lambda fails.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fb1430db88e4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Day 5 — IAM for Developers: AWS CLI, SDK Credentials, SigV4, Presigned URLs & Real Exam Scenarios]]></title>
            <link>https://hari27om.medium.com/day-5-iam-for-developers-aws-cli-sdk-credentials-sigv4-presigned-urls-real-exam-scenarios-93bfa6e1d564?source=rss-403dd53dc117------2</link>
            <guid isPermaLink="false">https://medium.com/p/93bfa6e1d564</guid>
            <dc:creator><![CDATA[Hari Om]]></dc:creator>
            <pubDate>Tue, 18 Aug 2026 12:57:23 GMT</pubDate>
            <atom:updated>2026-08-18T12:57:23.363Z</atom:updated>
            <content:encoded><![CDATA[<p>Over the previous three days, we built the IAM foundation.</p><pre>Day 2<br>IAM Fundamentals<br>│<br>├── Users<br>├── Groups<br>├── Authentication<br>├── Authorization<br>└── Least Privilege</pre><pre>Day 3<br>IAM Policies<br>│<br>├── Identity Policies<br>├── Resource Policies<br>├── Explicit Deny<br>├── Permissions Boundaries<br>└── SCPs</pre><pre>Day 4<br>IAM Roles<br>│<br>├── STS<br>├── Temporary Credentials<br>├── Execution Roles<br>├── Cross-Account Roles<br>├── External ID<br>└── PassRole</pre><p>Today we’re going to connect all of this to what developers actually do.</p><p>Because ultimately our application doesn’t “use IAM.”</p><p>Our application does something like:</p><pre>await dynamodb.send(new PutItemCommand(...));</pre><p>or:</p><pre>aws s3 cp invoice.pdf s3://company-invoices/</pre><p>And somehow AWS needs to determine:</p><pre>Who sent this?</pre><pre>↓</pre><pre>Can they perform this operation?</pre><pre>↓</pre><pre>Can they perform it on THIS resource?</pre><pre>↓</pre><pre>Should the request be allowed?</pre><p>Understanding that entire journey is today’s goal.</p><h3>Part 1 — AWS Is an API Platform</h3><p>Before discussing credentials, understand something fundamental:</p><blockquote><em>Almost everything you do with AWS ultimately becomes an API request.</em></blockquote><p>Suppose we create a Lambda function using the AWS Console.</p><p>You click:</p><pre>Create Function</pre><p>Behind the scenes, an AWS API operation is performed.</p><p>Likewise:</p><pre>aws lambda create-function ...</pre><p>calls an AWS API.</p><p>And:</p><pre>const command = new CreateFunctionCommand(...);<br><br>await lambda.send(command);</pre><p>also calls an AWS API.</p><p>Conceptually:</p><pre>AWS Console<br>      │<br>      │<br>AWS CLI<br>      │<br>      │<br>AWS SDK<br>      │<br>      ▼<br>  AWS APIs<br>      │<br>      ▼<br> AWS Services</pre><p>The interface changes.</p><p>The underlying authorization model doesn’t.</p><p>This is extremely useful for understanding IAM.</p><h3>Part 2 — What Happens During an AWS API Request?</h3><p>Suppose our Node.js application runs:</p><pre>await s3.send(<br>  new PutObjectCommand({<br>    Bucket: &quot;company-images&quot;,<br>    Key: &quot;cat.jpg&quot;,<br>    Body: image<br>  })<br>);</pre><p>The high-level process looks like:</p><pre>Application</pre><pre>   ↓</pre><pre>AWS SDK</pre><pre>    ↓</pre><pre>Find Credentials</pre><pre>    ↓</pre><pre>Build HTTP Request</pre><pre>    ↓</pre><pre>Sign Request</pre><pre>    ↓</pre><pre>Send Request to S3</pre><pre>    ↓</pre><pre>AWS Authenticates Caller</pre><pre>    ↓</pre><pre>AWS Evaluates Authorization</pre><pre>    ↓</pre><pre>ALLOW / DENY</pre><pre>    ↓</pre><pre>S3 Executes Request</pre><p>Every section of this flow can fail.</p><p>Understanding where it failed is a major AWS developer skill.</p><h3>Part 3 — Credentials</h3><p>AWS needs some way to identify the caller.</p><p>Common credential forms include:</p><h3>Long-lived IAM user credentials</h3><pre>Access Key ID<br>+<br>Secret Access Key</pre><p>and temporary credentials:</p><pre>Access Key ID<br>+<br>Secret Access Key<br>+<br>Session Token<br>+<br>Expiration</pre><p>The latter commonly comes from:</p><pre>STS<br>IAM Roles<br>Federation<br>AWS workloads</pre><h3>Part 4 — Access Key ID vs Secret Access Key</h3><p>An Access Key ID is somewhat analogous to a username.</p><p>Example shape:</p><pre>AKIA...</pre><p>It identifies a credential.</p><p>The Secret Access Key is the secret used when cryptographically signing requests.</p><p>You should protect it.</p><p>Do NOT:</p><pre>Commit it to GitHub</pre><pre>Put it in frontend JavaScript</pre><pre>Embed it in a mobile application</pre><pre>Log it</pre><pre>Send it over Slack</pre><pre>Hardcode it in Lambda</pre><h3>Part 5 — Session Token</h3><p>Temporary credentials have an additional component:</p><pre>Session Token</pre><p>So:</p><pre>Long-lived IAM user credentials<br>Access Key<br>Secret Key</pre><p>while temporary STS credentials involve:</p><pre>Access Key<br>Secret Key<br>Session Token<br>Expiration</pre><p>If you’re manually configuring temporary credentials and forget the session token, authentication will fail.</p><h3>Part 6 — AWS CLI Authentication</h3><p>Let’s say I install the AWS CLI.</p><p>A traditional setup command is:</p><pre>aws configure</pre><p>It asks for information such as:</p><pre>AWS Access Key ID:</pre><pre>AWS Secret Access Key:</pre><pre>Default region:</pre><pre>Default output format:</pre><p>The CLI can store configuration and credentials in files under the user’s AWS configuration directory.</p><p>On Linux/macOS this is normally:</p><pre>~/.aws/</pre><p>On Windows:</p><pre>%UserProfile%\.aws\</pre><p>Common files include:</p><pre>credentials<br><br>config</pre><h3>Part 7 — credentials File</h3><p>Conceptually:</p><pre>[default]<br>aws_access_key_id = ...<br>aws_secret_access_key = ...</pre><p>Important:</p><p>This is still sensitive information.</p><p>Never commit:</p><pre>.aws/credentials</pre><p>to source control.</p><h3>Part 8 — Config File</h3><p>Configuration commonly includes things such as:</p><pre>[default]<br>region = ap-south-1<br>output = json</pre><p>Credentials and configuration are related but aren’t exactly the same thing.</p><h3>Part 9 — AWS Profiles</h3><p>Developers often work with multiple environments.</p><p>Example:</p><pre>Personal AWS</pre><pre>Development AWS</pre><pre>Production AWS</pre><p>Using one set of credentials for everything would be messy.</p><p>AWS CLI supports:</p><h3>Named Profiles</h3><p>Example:</p><pre>aws configure --profile dev</pre><p>and:</p><pre>aws configure --profile production</pre><p>Then:</p><pre>aws s3 ls --profile dev</pre><p>or:</p><pre>aws s3 ls --profile production</pre><h3>Part 10 — Example Profile Setup</h3><p>Conceptually:</p><pre>[default]<br>aws_access_key_id = ...<br>aws_secret_access_key = ...</pre><pre>[dev]<br>aws_access_key_id = ...<br>aws_secret_access_key = ...</pre><pre>[production]<br>aws_access_key_id = ...<br>aws_secret_access_key = ...</pre><p>And configuration:</p><pre>[default]<br>region = ap-south-1</pre><pre>[profile dev]<br>region = ap-south-1</pre><pre>[profile production]<br>region = ap-south-1</pre><p>Notice the slightly different profile syntax used between the files.</p><h3>Part 11 — Check Which Identity You’re Using</h3><p>This command deserves to be memorized:</p><pre>aws sts get-caller-identity</pre><p>Typical output:</p><pre>{<br>  &quot;UserId&quot;: &quot;...&quot;,<br>  &quot;Account&quot;: &quot;123456789012&quot;,<br>  &quot;Arn&quot;: &quot;arn:aws:iam::123456789012:user/hari&quot;<br>}</pre><p>Using a profile:</p><pre>aws sts get-caller-identity --profile production</pre><p>Whenever something weird happens with AWS credentials:</p><h3>RUN THIS FIRST.</h3><p>I’ve lost count of how many “IAM problems” are actually:</p><blockquote><em>I’m authenticated to the wrong account.</em></blockquote><h3>Part 12 — Environment Variables</h3><p>AWS tooling can also use environment variables.</p><p>Common examples:</p><pre>AWS_ACCESS_KEY_ID</pre><pre>AWS_SECRET_ACCESS_KEY</pre><pre>AWS_SESSION_TOKEN</pre><pre>AWS_REGION</pre><pre>AWS_PROFILE</pre><p>Example on Linux/macOS:</p><pre>export AWS_PROFILE=dev</pre><p>Windows PowerShell:</p><pre>$env:AWS_PROFILE=&quot;dev&quot;</pre><p>Now commands can use that profile.</p><h3>Part 13 — Credential Provider Chain</h3><p>This is an important DVA-C02 concept.</p><p>Suppose we write:</p><pre>const s3 = new S3Client({<br>  region: &quot;ap-south-1&quot;<br>});</pre><p>Notice:</p><p>We haven’t supplied credentials.</p><p>Yet this can work.</p><p>How?</p><p>Because AWS SDKs implement mechanisms for locating credentials from supported sources.</p><p>This is commonly referred to as a:</p><h3>Credential Provider Chain</h3><p>Conceptually:</p><pre>Application</pre><pre>     ↓</pre><pre>AWS SDK</pre><pre>     ↓</pre><pre>Look for credentials</pre><pre>     │</pre><pre>     ├── Explicitly configured credentials<br>     │<br>     ├── Environment<br>     │<br>     ├── Shared configuration/credentials<br>     │<br>     ├── Identity Center / process providers<br>     │<br>     ├── Web identity<br>     │<br>     ├── ECS container credentials<br>     │<br>     └── EC2 instance credentials</pre><pre>     ↓</pre><pre>Credentials found</pre><pre>     ↓</pre><pre>Sign AWS Request</pre><p>Exact providers and precedence vary between SDK languages and versions.</p><p>For the exam, understand the pattern rather than memorizing every SDK’s precise provider ordering.</p><h3>Part 14 — Why Credential Provider Chains Matter</h3><p>Because we can write the same application:</p><pre>const client = new DynamoDBClient({<br>  region: &quot;ap-south-1&quot;<br>});</pre><p>and run it on:</p><pre>Application</pre><pre>EC2</pre><pre>ECS</pre><pre>Lambda</pre><pre>CI/CD</pre><p>without changing the application’s business logic to hardcode credentials.</p><p>Locally:</p><pre>SDK<br>↓<br>Developer credentials</pre><p>EC2:</p><pre>SDK<br>↓<br>Instance Role</pre><p>ECS:</p><pre>SDK<br>↓<br>Task Role</pre><p>Lambda:</p><pre>SDK<br>↓<br>Execution Role</pre><p>Beautiful.</p><h3>Part 15 — The Production Rule</h3><p>Whenever possible:</p><pre>DO NOT</pre><pre>put AWS credentials</pre><pre>inside application code.</pre><p>Instead:</p><pre>Application</pre><pre>↓</pre><pre>SDK Credential Provider</pre><pre>↓</pre><pre>IAM Role / Federated Identity</pre><pre>↓</pre><pre>Temporary Credentials</pre><p>This is both more secure and easier to operate.</p><h3>Part 16 — IAM Identity Center</h3><p>For workforce access, AWS recommends centralized access patterns rather than creating large numbers of long-lived IAM users.</p><p>AWS IAM Identity Center provides centralized workforce access across AWS accounts and applications.</p><p>Conceptually:</p><pre>Employee</pre><pre>↓</pre><pre>Corporate Identity</pre><pre>↓</pre><pre>IAM Identity Center</pre><pre>↓</pre><pre>AWS Account</pre><pre>↓</pre><pre>Permission Set</pre><pre>↓</pre><pre>Role Session</pre><p>This is particularly useful with:</p><pre>AWS Organizations<br>+<br>Multiple AWS Accounts</pre><h3>Part 17 — IAM Users vs Identity Center</h3><p>Traditional model:</p><pre>Account A<br>└── Hari IAM User</pre><pre>Account B<br>└── Hari IAM User</pre><pre>Account C<br>└── Hari IAM User</pre><p>Painful.</p><p>Modern centralized model:</p><pre>Hari</pre><pre>↓</pre><pre>Identity Center</pre><pre>├── Dev Account<br>├── Staging Account<br>└── Production Account</pre><p>Access is centralized.</p><h3>Part 18 — CLI With IAM Identity Center</h3><p>AWS CLI supports IAM Identity Center authentication.</p><p>You’ll encounter commands such as:</p><pre>aws configure sso</pre><p>and:</p><pre>aws sso login --profile company-dev</pre><p>Then:</p><pre>aws sts get-caller-identity --profile company-dev</pre><p>The key exam concept isn’t memorizing every command.</p><p>It’s understanding:</p><blockquote><em>Workforce users can obtain temporary AWS access through centralized/federated authentication rather than storing permanent IAM user access keys.</em></blockquote><h3>Part 19 — How AWS Knows a Request Is Really From You</h3><p>Here’s an interesting question.</p><p>Suppose your application sends:</p><pre>PUT /cat.jpg<br>Host: company-images.s3.amazonaws.com</pre><p>How does AWS know the request came from someone who possesses valid AWS credentials?</p><p>You shouldn’t simply send:</p><pre>SecretAccessKey: my-secret</pre><p>over the network.</p><p>Instead AWS requests are typically: <strong>Cryptographically Signed.</strong></p><p>AWS commonly uses: <strong>Signature Version 4</strong></p><p>also called: <strong>SigV4</strong></p><h3>Part 20 — AWS Signature Version 4</h3><p>SigV4 signs AWS API requests using credentials and request information.</p><p>Conceptually:</p><pre>HTTP Request</pre><pre>+</pre><pre>AWS Credentials</pre><pre>+</pre><pre>Timestamp</pre><pre>+</pre><pre>Region</pre><pre>+</pre><pre>Service</pre><pre>        ↓</pre><pre>Signature Version 4</pre><pre>        ↓</pre><pre>Signed Request</pre><pre>        ↓</pre><pre>AWS</pre><p>AWS can verify the signature and determine whether the request is authentic and hasn’t been improperly modified.</p><h3>Part 21 — Simplified SigV4 Flow</h3><p>The actual algorithm contains several cryptographic steps, but conceptually:</p><pre>Request</pre><pre>↓</pre><pre>Create Canonical Request</pre><pre>↓</pre><pre>Hash Request</pre><pre>↓</pre><pre>Create String to Sign</pre><pre>↓</pre><pre>Derive Signing Key</pre><pre>↓</pre><pre>Calculate Signature</pre><pre>↓</pre><pre>Attach Signature</pre><pre>↓</pre><pre>Send to AWS</pre><p>You generally do NOT implement this manually.</p><p>AWS SDKs and CLI handle it for you.</p><h3>Part 22 — Why SigV4 Matters for DVA-C02</h3><p>Suppose the exam says:</p><blockquote><em>A developer is directly calling an AWS API using custom HTTP requests.</em></blockquote><p>They may need to:</p><pre>Sign requests using AWS Signature Version 4</pre><p>But if using:</p><pre>AWS CLI</pre><pre>or</pre><pre>AWS SDK</pre><p>request signing is normally handled automatically.</p><p>Memory trick:</p><pre>AWS SDK</pre><pre>→ Signs for you.<br></pre><pre>Raw HTTP AWS API call</pre><pre>→ You may need to handle SigV4.</pre><h3>Part 23 — Request Signing vs Authorization</h3><p>These are different.</p><p>SigV4 helps AWS determine:</p><pre>Who signed the request?</pre><pre>Is the signature valid?</pre><p>IAM then determines:</p><pre>Is that principal allowed to perform this action?</pre><p>Think:</p><pre>SigV4</pre><pre>↓</pre><pre>Authentication / request integrity</pre><pre>↓</pre><pre>IAM Policies</pre><pre>↓</pre><pre>Authorization</pre><p>A perfectly signed request can still receive:</p><pre>AccessDenied</pre><p>because valid credentials don’t automatically mean sufficient permissions.</p><h3>Part 24 — Example Request Flow</h3><p>Our application executes:</p><pre>await dynamodb.send(<br>  new PutItemCommand({<br>    TableName: &quot;Orders&quot;,<br>    Item: ...<br>  })<br>);</pre><p>Flow:</p><pre>Node.js App</pre><pre>↓</pre><pre>AWS SDK</pre><pre>↓</pre><pre>Find Credentials</pre><pre>↓</pre><pre>Sign Request using SigV4</pre><pre>↓</pre><pre>Send Request</pre><pre>↓</pre><pre>AWS authenticates signature</pre><pre>↓</pre><pre>IAM evaluates</pre><pre>dynamodb:PutItem</pre><pre>↓</pre><pre>Resource:</pre><pre>Orders table</pre><pre>↓</pre><pre>Conditions</pre><pre>↓</pre><pre>Allow / Deny</pre><pre>↓</pre><pre>DynamoDB executes</pre><p>This is the complete developer mental model.</p><h3>Part 25 — Presigned URLs</h3><p>Now we get to an extremely useful S3 concept.</p><p>Suppose users need to upload profile pictures.</p><p>Architecture:</p><pre>Browser</pre><pre>↓</pre><pre>Backend</pre><pre>↓</pre><pre>S3</pre><p>One approach:</p><pre>Browser</pre><pre>↓</pre><pre>Upload image to Backend</pre><pre>↓</pre><pre>Backend receives 20 MB file</pre><pre>↓</pre><pre>Backend uploads to S3</pre><p>This wastes backend resources.</p><p>Can we allow the browser to upload directly to S3?</p><p>Yes.</p><p>But we definitely should NOT send AWS credentials to the browser.</p><p>Instead: <strong>Presigned URL.</strong></p><h3>Part 26 — Presigned URL Architecture</h3><pre>Browser</pre><pre>   │<br>   │ Request upload URL<br>   ▼</pre><pre>Backend</pre><pre>   │<br>   │ Generate presigned URL<br>   ▼</pre><pre>Browser</pre><pre>   │<br>   │ Direct upload<br>   ▼</pre><pre>Amazon S3</pre><p>The backend signs a temporary request.</p><p>The browser doesn’t receive your AWS secret key.</p><h3>Part 27 — How a Presigned URL Works</h3><p>Backend has permission:</p><pre>s3:PutObject</pre><p>Backend generates a URL containing signed request information.</p><p>Conceptually:</p><pre>https://bucket.s3.amazonaws.com/image.jpg<br>    ?X-Amz-Algorithm=...<br>    &amp;X-Amz-Credential=...<br>    &amp;X-Amz-Date=...<br>    &amp;X-Amz-Expires=...<br>    &amp;X-Amz-Signature=...</pre><p>The client can use the URL until it expires, subject to the permissions and restrictions under which it was generated.</p><h3>Part 28 — Presigned URL Does NOT Make Bucket Public</h3><p>Very important.</p><p>You do NOT need:</p><pre>Public S3 Bucket</pre><p>to use presigned URLs.</p><p>Instead:</p><pre>Private Bucket</pre><pre>+</pre><pre>Temporary Signed Request</pre><p>This is one reason they’re so useful.</p><h3>Part 29 — Download Architecture</h3><p>Same concept for downloads.</p><p>Instead of:</p><pre>User</pre><pre>↓</pre><pre>Backend</pre><pre>↓</pre><pre>Download 2 GB video</pre><pre>↓</pre><pre>Backend sends video</pre><pre>↓</pre><pre>User</pre><p>you can do:</p><pre>User</pre><pre>↓</pre><pre>Backend</pre><pre>↓</pre><pre>Authorization check</pre><pre>↓</pre><pre>Generate presigned GET URL</pre><pre>↓</pre><pre>User</pre><pre>↓</pre><pre>S3 Direct Download</pre><p>Much more scalable.</p><h3>Part 30 — JavaScript Presigned URL Example</h3><p>AWS SDK for JavaScript v3:</p><pre>import { S3Client, GetObjectCommand } from &quot;<a href="http://twitter.com/aws">@aws</a>-sdk/client-s3&quot;;<br>import { getSignedUrl } from &quot;<a href="http://twitter.com/aws">@aws</a>-sdk/s3-request-presigner&quot;;</pre><pre>const s3 = new S3Client({<br>  region: &quot;ap-south-1&quot;<br>});</pre><pre>async function createDownloadUrl(key) {</pre><pre>  const command = new GetObjectCommand({<br>    Bucket: &quot;private-documents&quot;,<br>    Key: key<br>  });</pre><pre>  const url = await getSignedUrl(<br>    s3,<br>    command,<br>    {<br>      expiresIn: 300<br>    }<br>  );</pre><pre>  return url;<br>}</pre><p>300 means: <strong>5 minutes</strong></p><p>The application doesn’t expose its AWS secret key to the client.</p><h3>Part 31 — Permission Behind Presigned URLs</h3><p>Important exam detail.</p><p>A presigned URL doesn’t magically create permission.</p><p>The credentials used to generate it must have permission for the underlying operation.</p><p>For example:</p><pre>Presigned GET</pre><pre>↓</pre><pre>Signer needs GetObject permission</pre><p>Presigned PUT:</p><pre>Signer needs PutObject permission</pre><p>The URL’s effective capabilities cannot exceed what the signing credentials permit.</p><h3>Part 32 — Presigned URL Exam Scenario</h3><p>Question: <em>Users must temporarily download private S3 objects without receiving AWS credentials.</em></p><p>Think immediately: <strong>S3 Presigned URL.</strong></p><p>Another scenario: <em>Browser must directly upload large files to private S3 bucket.</em></p><p>Again: <strong>Presigned URL.</strong></p><h3>Part 33 — Presigned URL vs CloudFront Signed URL</h3><p>Don’t confuse these.</p><p>Simplified mental model:</p><pre>S3 Presigned URL</pre><pre>→ Temporary direct S3 operation</pre><p>while:</p><pre>CloudFront Signed URL</pre><pre>→ Controlled access through CloudFront distribution</pre><p>We’ll revisit this when studying S3/CDN architectures.</p><p>For DVA-C02, S3 presigned URLs are particularly important.</p><h3>Part 34 — Credential Rotation</h3><p>Suppose an IAM user has an access key.</p><p>Over time:</p><pre>Key exists</pre><pre>↓</pre><pre>Key may leak</pre><pre>↓</pre><pre>Risk increases</pre><p>Long-lived credentials require lifecycle management.</p><p>Possible lifecycle:</p><pre>Create new key</pre><pre>↓</pre><pre>Update application</pre><pre>↓</pre><pre>Verify application</pre><pre>↓</pre><pre>Disable old key</pre><pre>↓</pre><pre>Delete old key</pre><p>This operational burden is another reason roles are superior for AWS workloads.</p><p>With roles:</p><pre>AWS</pre><pre>↓</pre><pre>Issues temporary credentials</pre><pre>↓</pre><pre>Credentials expire</pre><pre>↓</pre><pre>New credentials obtained automatically</pre><p>Less manual secret management.</p><h3>Part 35 — AccessDenied</h3><p>Now for the error every AWS developer eventually meets:</p><pre>AccessDenied</pre><p>or:</p><pre>AccessDeniedException</pre><p>A beginner reaction:</p><pre>Attach AdministratorAccess</pre><p>Please don’t.</p><p>That’s not debugging.</p><p>That’s turning off the security system because the door won’t open.</p><h3>Part 36 — How to Debug AccessDenied</h3><p>Use this algorithm.</p><h3>STEP 1 — Who am I?</h3><pre>aws sts get-caller-identity</pre><p>Determine:</p><pre>Account</pre><pre>User / Role</pre><pre>Assumed Role</pre><h3>STEP 2 — What API Operation Failed?</h3><p>Look at the error.</p><p>Example:</p><pre>not authorized to perform:</pre><pre>dynamodb:PutItem</pre><p>Now we know the exact action.</p><h3>STEP 3 — Which Resource?</h3><p>Example:</p><pre>arn:aws:dynamodb:ap-south-1:123456789012:table/Orders</pre><p>Check whether the policy’s Resource matches.</p><h3>STEP 4 — Is There an Allow?</h3><p>Search applicable permissions for:</p><pre>dynamodb:PutItem</pre><h3>STEP 5 — Is There an Explicit Deny?</h3><p>Remember Day 3:</p><pre>Explicit Deny</pre><pre>beats</pre><pre>Allow</pre><h3>STEP 6 — Check Permissions Boundary</h3><p>Maybe:</p><pre>Identity Policy</pre><pre>ALLOW PutItem</pre><p>but boundary doesn’t permit it.</p><p>Result:</p><pre>DENY</pre><h3>STEP 7 — Check SCP</h3><p>Maybe the AWS Organization blocks the requested operation.</p><h3>STEP 8 — Check Resource Policy</h3><p>For resources supporting resource-based policies, inspect those when relevant.</p><h3>STEP 9 — Check Conditions</h3><p>Maybe policy says:</p><pre>Allow only when</pre><pre>Environment = Production</pre><p>but your request doesn’t satisfy that condition.</p><h3>STEP 10 — Check KMS</h3><p>This one deserves special attention.</p><p>Sometimes the resource permission is correct but encryption introduces another authorization layer.</p><p>Example:</p><pre>S3 Object</pre><pre>↓</pre><pre>Encrypted with KMS key</pre><p>You might have:</p><pre>s3:GetObject</pre><p>but still fail because you don’t have the required KMS permissions/key-policy authorization.</p><p>This becomes an important DVA-C02 troubleshooting pattern.</p><h3>Part 37 — AccessDenied Decision Tree</h3><pre>ACCESS DENIED<br>     │<br>     ▼<br>Who am I?<br>     │<br>     ▼<br>Which API action?<br>     │<br>     ▼<br>Which resource ARN?<br>     │<br>     ▼<br>Identity Policy allows?<br>     │<br>     ▼<br>Resource Policy?<br>     │<br>     ▼<br>Explicit Deny?<br>     │<br>     ▼<br>Permissions Boundary?<br>     │<br>     ▼<br>SCP?<br>     │<br>     ▼<br>Session Policy?<br>     │<br>     ▼<br>Conditions?<br>     │<br>     ▼<br>KMS / dependent permissions?</pre><p>Keep this somewhere.</p><p>It’s useful outside the exam too.</p><h3>Part 38 — IAM Policy Simulator</h3><p>AWS provides tools for evaluating IAM policies.</p><p>The IAM Policy Simulator can help test whether policies would allow or deny particular actions under specified conditions.</p><p>Conceptually:</p><pre>Select identity</pre><pre>↓</pre><pre>Choose service</pre><pre>↓</pre><pre>Choose action</pre><pre>↓</pre><pre>Provide resource/context</pre><pre>↓</pre><pre>Simulate</pre><pre>↓</pre><pre>Allowed / Denied</pre><p>This can help debug complicated policies without actually performing the operation.</p><h3>Part 39 — IAM Access Analyzer</h3><p>Another important service/tool:</p><h3>IAM Access Analyzer</h3><p>It helps analyze resource access and identify resources shared outside your intended trust boundaries.</p><p>For example, it can help identify access involving:</p><pre>External AWS Accounts</pre><pre>Organizations</pre><pre>Public Access</pre><pre>External Principals</pre><p>depending on the supported resource and analysis type.</p><p>Think:</p><pre>&quot;Who outside my trust boundary can access this?&quot;</pre><p>→ IAM Access Analyzer.</p><h3>Part 40 — Access Analyzer vs Policy Simulator</h3><p>Do NOT confuse these.</p><pre>POLICY SIMULATOR</pre><pre>&quot;Would this action be allowed?&quot;</pre><p>vs</p><pre>ACCESS ANALYZER</pre><pre>&quot;Who can access this resource / what external access exists?&quot;</pre><p>Easy memory trick:</p><pre>SIMULATOR</pre><pre>simulate permissions<br></pre><pre>ANALYZER</pre><pre>analyze access</pre><h3>Part 41 — CloudTrail</h3><p>Now imagine something happened:</p><pre>S3 object deleted.</pre><pre>Who did it?</pre><p>IAM won’t answer that.</p><p>IAM answers:</p><pre>Can someone do this?</pre><p>For historical API activity, think: <strong>AWS CloudTrail.</strong></p><h3>Part 42 — CloudTrail Records API Activity</h3><p>Conceptually:</p><pre>User / Role</pre><pre>↓</pre><pre>AWS API Request</pre><pre>↓</pre><pre>CloudTrail</pre><pre>↓</pre><pre>Event History / Trails / Logs</pre><p>CloudTrail events can contain information such as:</p><pre>Who</pre><pre>What API</pre><pre>When</pre><pre>Source</pre><pre>Region</pre><pre>Resource information</pre><pre>Request parameters</pre><h3>Part 43 — CloudTrail Example</h3><p>Suppose:</p><pre>Production Lambda deleted.</pre><p>You want:</p><pre>Who called DeleteFunction?</pre><p>Think:</p><pre>CloudTrail</pre><p>Not:</p><pre>CloudWatch Metrics</pre><p>This distinction is exam-important.</p><h3>Part 44 — IAM vs CloudTrail</h3><pre>IAM : </pre><pre>&quot;ARE YOU ALLOWED?&quot;<br></pre><pre>CloudTrail : </pre><pre>&quot;WHAT API ACTIVITY HAPPENED?&quot;</pre><p>Excellent memory distinction.</p><h3>Part 45 — CloudTrail vs CloudWatch</h3><p>We’ll cover this deeply later, but start remembering:</p><pre>CloudTrail</pre><pre>API audit/activity</pre><pre>CloudWatch</pre><pre>Metrics<br>Logs<br>Alarms<br>Application/operational monitoring</pre><p>Question: <em>Who deleted an S3 bucket?</em></p><p>Think: <strong>CloudTrail</strong></p><p>Question: <em>Lambda error rate increased.</em></p><p>Think: <strong>CloudWatch</strong></p><h3>Part 46 — Resource-Based Policies Revisited</h3><p>Suppose:</p><pre>API Gateway</pre><pre>↓</pre><pre>Lambda</pre><p>API Gateway needs permission to invoke Lambda.</p><p>Lambda supports resource-based policies.</p><p>Conceptually:</p><pre>Lambda Resource Policy</pre><pre>ALLOW</pre><pre>apigateway.amazonaws.com</pre><pre>lambda:InvokeFunction</pre><p>Again:</p><pre>Incoming access to Lambda</pre><pre>→ Resource policy</pre><p>while:</p><pre>Lambda accessing DynamoDB</pre><pre>→ Execution role</pre><p>Direction matters.</p><h3>Part 47 — S3 Bucket Policies</h3><p>Suppose another AWS account needs access to your S3 bucket.</p><p>Instead of creating an IAM user inside your account, you may use a bucket policy.</p><p>Example concept:</p><pre>Account B Principal</pre><pre>↓</pre><pre>S3 Bucket Policy</pre><pre>↓</pre><pre>Allow GetObject</pre><p>Resource-based policies are powerful for cross-account resource sharing.</p><h3>Part 48 — KMS Changes the Game</h3><p>Imagine:</p><pre>Application</pre><pre>↓</pre><pre>S3</pre><pre>↓</pre><pre>KMS-encrypted object</pre><p>The application may need authorization involving both:</p><pre>S3</pre><p>and:</p><pre>KMS</pre><p>For example, reading encrypted data can involve permissions such as:</p><pre>s3:GetObject</pre><pre>kms:Decrypt</pre><p>depending on encryption mode and context.</p><p>Exam trap: <em>S3 permissions look correct but encrypted object access fails.</em></p><p>Check:</p><pre>KMS permissions / key policy</pre><h3>Part 49 — IAM Policy vs KMS Key Policy</h3><p>KMS has its own authorization model involving key policies.</p><p>This makes KMS scenarios more complicated than ordinary resource access.</p><p>We’ll cover KMS properly in the security section.</p><p>For now remember:</p><pre>Encrypted with customer-managed KMS key?</pre><pre>↓</pre><pre>Think about KMS authorization too.</pre><h3>Part 50 — Frontend Applications</h3><p>Suppose you’re building React:</p><pre>React</pre><pre>↓</pre><pre>S3</pre><p>Should React contain:</p><pre>const AWS_SECRET_ACCESS_KEY = &quot;...&quot;;</pre><p>Never.</p><p>Frontend JavaScript is sent to users.</p><p>Anything inside the frontend bundle should be considered observable.</p><p>Instead consider patterns like:</p><pre>React</pre><pre>↓</pre><pre>Backend API</pre><pre>↓</pre><pre>IAM Role</pre><pre>↓</pre><pre>AWS</pre><p>or:</p><pre>React</pre><pre>↓</pre><pre>Backend generates presigned URL</pre><pre>↓</pre><pre>S3</pre><p>or for suitable user-identity use cases:</p><pre>React</pre><pre>↓</pre><pre>Cognito / federation</pre><pre>↓</pre><pre>Temporary credentials</pre><pre>↓</pre><pre>AWS</pre><p>Never treat browser JavaScript as a safe place for permanent AWS credentials.</p><h3>Part 51 — Mobile Applications</h3><p>Same rule.</p><p>APK / IPA binaries can be inspected.</p><p>Don’t embed:</p><pre>IAM User Access Key</pre><pre>Secret Access Key</pre><p>Instead use:</p><pre>Federated identity</pre><pre>+</pre><pre>Temporary credentials</pre><p>or application APIs/presigned URLs depending on the architecture.</p><h3>Part 52 — Lambda Credentials</h3><p>Inside Lambda, don’t write:</p><pre>const client = new DynamoDBClient({<br>  credentials: {<br>    accessKeyId: process.env.AWS_KEY,<br>    secretAccessKey: process.env.AWS_SECRET<br>  }<br>});</pre><p>for ordinary AWS service access.</p><p>Instead:</p><pre>const client = new DynamoDBClient({});</pre><p>and let the SDK use the Lambda execution role credentials.</p><h3>Part 53 — EC2 Credentials</h3><p>Same principle.</p><p>Don’t:</p><pre>EC2</pre><pre>↓</pre><pre>credentials.json</pre><p>Use:</p><pre>EC2</pre><pre>↓</pre><pre>Instance Profile / Role</pre><pre>↓</pre><pre>Temporary Credentials</pre><h3>Part 54 — ECS Credentials</h3><p>Don’t put AWS keys into:</p><pre>Dockerfile</pre><pre>docker-compose.yml</pre><pre>Container environment variables</pre><p>for normal AWS workload identity.</p><p>Use:</p><pre>ECS Task Role</pre><p>for your application.</p><h3>Part 55 — CI/CD Credentials</h3><p>Modern CI/CD should also avoid permanent AWS access keys where possible.</p><p>Many CI systems support workload identity federation using OIDC.</p><p>Conceptually:</p><pre>CI/CD Platform</pre><pre>↓</pre><pre>OIDC Token</pre><pre>↓</pre><pre>AWS STS</pre><pre>↓</pre><pre>Assume Role</pre><pre>↓</pre><pre>Temporary Credentials</pre><pre>↓</pre><pre>Deploy</pre><p>This is much better than storing:</p><pre>AWS_ACCESS_KEY_ID<br><br>AWS_SECRET_ACCESS_KEY</pre><p>as permanent repository secrets.</p><h3>Part 56 — Why OIDC Is Better for CI/CD</h3><p>Traditional:</p><pre>GitHub / CI</pre><pre>↓</pre><pre>Stored AWS Access Key</pre><pre>↓</pre><pre>Long-lived secret</pre><p>Modern:</p><pre>CI</pre><pre>↓</pre><pre>OIDC identity</pre><pre>↓</pre><pre>STS</pre><pre>↓</pre><pre>Temporary Role Session</pre><pre>↓</pre><pre>AWS</pre><p>No permanent AWS secret needs to live in the repository’s CI secret store.</p><p>This pattern is increasingly important in real DevOps environments.</p><h3>Part 57 — Secrets vs Credentials</h3><p>These are related but not identical.</p><h3>AWS Workload Credentials</h3><p>Use:</p><pre>IAM Roles<br>STS<br>Temporary credentials</pre><h3>Application Secrets</h3><p>Examples:</p><pre>Database password</pre><pre>Stripe API key</pre><pre>OAuth client secret</pre><p>Use services such as:</p><pre>AWS Secrets Manager</pre><p>or, depending on requirements:</p><pre>SSM Parameter Store</pre><p>Don’t use Secrets Manager as an excuse to keep permanent AWS access keys when workload roles solve the problem better.</p><h3>Part 58 — DVA-C02 IAM Decision Tree</h3><p>Now let’s turn everything from Days 2–5 into exam instincts.</p><h3>Scenario</h3><pre>EC2 needs S3</pre><p>Answer:</p><pre>IAM Role / Instance Profile</pre><h3>Scenario</h3><pre>Lambda needs DynamoDB</pre><p>Answer:</p><pre>Lambda Execution Role</pre><h3>Scenario</h3><pre>ECS application needs S3</pre><p>Answer:</p><pre>ECS Task Role</pre><h3>Scenario</h3><pre>ECS needs to pull ECR image</pre><p>Answer:</p><pre>Task Execution Role</pre><h3>Scenario</h3><pre>S3 needs to invoke Lambda</pre><p>Answer:</p><pre>Lambda Resource-Based Policy</pre><h3>Scenario</h3><pre>Developer needs temporary access<br>to another account</pre><p>Answer:</p><pre>STS AssumeRole</pre><h3>Scenario</h3><pre>Third-party SaaS needs<br>cross-account access</pre><p>Answer:</p><pre>IAM Role<br>+<br>External ID</pre><h3>Scenario</h3><pre>Developer gives role to Lambda</pre><p>Answer:</p><pre>iam:PassRole</pre><h3>Scenario</h3><pre>Browser needs temporary access<br>to private S3 object</pre><p>Answer:</p><pre>Presigned URL</pre><h3>Scenario</h3><pre>Who deleted resource?</pre><p>Answer:</p><pre>CloudTrail</pre><h3>Scenario</h3><pre>Would this IAM action be allowed?</pre><p>Answer:</p><pre>IAM Policy Simulator</pre><h3>Scenario</h3><pre>Which resources have unintended<br>external access?</pre><p>Answer:</p><pre>IAM Access Analyzer</pre><h3>Scenario</h3><pre>Application has S3 access<br>but cannot decrypt object</pre><p>Think:</p><pre>KMS authorization</pre><h3>Scenario</h3><pre>Raw HTTP request to AWS API</pre><p>Think:</p><pre>Signature Version 4</pre><h3>Part 59 — Full IAM Mental Model</h3><p>Here’s the entire IAM system we’ve learned over four days.</p><pre>                        AWS REQUEST</pre><pre>                              │</pre><pre>                              ▼</pre><pre>                        AUTHENTICATION</pre><pre>                              │</pre><pre>                  ┌───────────┴───────────┐</pre><pre>                  ▼                       ▼</pre><pre>               IAM User                IAM Role<br>                                          │<br>                                          ▼<br>                                         STS<br>                                          │<br>                                          ▼<br>                                Temporary Credentials</pre><pre>                              │<br>                              ▼</pre><pre>                      Signed AWS Request</pre><pre>                              │<br>                              ▼</pre><pre>                      AUTHORIZATION</pre><pre>                              │</pre><pre>        ┌─────────────────────┼──────────────────────┐</pre><pre>        ▼                     ▼                      ▼</pre><pre> Identity Policy      Resource Policy         Session Policy</pre><pre>        │                     │                      │<br>        └─────────────────────┼──────────────────────┘<br>                              │<br>                              ▼</pre><pre>                  Permissions Boundary</pre><pre>                              │<br>                              ▼</pre><pre>                      Organization SCP</pre><pre>                              │<br>                              ▼</pre><pre>                       Conditions</pre><pre>                              │<br>                              ▼</pre><pre>                    Explicit Deny?</pre><pre>                      │            │<br>                     YES           NO<br>                      │            │<br>                      ▼            ▼<br>                    DENY        Required Allow?</pre><pre>                                   │<br>                              ┌────┴────┐<br>                              │         │<br>                             YES        NO<br>                              │         │<br>                              ▼         ▼<br>                            ALLOW      DENY</pre><p>The exact AWS policy evaluation rules have nuances depending on policy type and request context, but this diagram is an excellent exam mental model.</p><h3>Part 60 — The Developer’s IAM Debugging Checklist</h3><p>When something fails:</p><pre>1. WHO AM I?</pre><pre>aws sts get-caller-identity<br></pre><pre>2. WHAT ACTION FAILED?</pre><pre>Example:<br>s3:GetObject<br></pre><pre>3. WHAT RESOURCE?</pre><pre>Check ARN.<br></pre><pre>4. IDENTITY POLICY?</pre><pre>Is there Allow?<br></pre><pre>5. RESOURCE POLICY?</pre><pre>If applicable.<br></pre><pre>6. EXPLICIT DENY?</pre><pre>Always check.<br></pre><pre>7. PERMISSIONS BOUNDARY?</pre><pre>Could restrict.<br></pre><pre>8. SCP?</pre><pre>Organization may restrict.<br></pre><pre>9. SESSION POLICY?</pre><pre>Temporary session may be narrower.<br></pre><pre>10. CONDITIONS?</pre><pre>IP?<br>Tags?<br>MFA?<br>Region?<br></pre><pre>11. ENCRYPTION?</pre><pre>KMS permissions?<br></pre><pre>12. CLOUDTRAIL?</pre><pre>What actually happened?</pre><p>This is one of the most useful checklists from the entire IAM section.</p><h3>⚠️ Common Exam Traps</h3><h3>Trap 1 : <em>Application needs AWS access.</em></h3><p>Candidate chooses:</p><pre>IAM User + Access Key</pre><p>Usually wrong for AWS-hosted workloads.</p><p>Prefer:</p><pre>IAM Role</pre><h3>Trap 2 : <em>Lambda cannot access DynamoDB.</em></h3><p>Candidate modifies:</p><pre>Lambda Resource Policy</pre><p>Wrong direction.</p><p>Check:</p><pre>Lambda Execution Role</pre><h3>Trap 3 : <em>S3 cannot invoke Lambda.</em></h3><p>Candidate adds S3 permissions to Lambda execution role.</p><p>Wrong.</p><p>Think:</p><pre>Lambda Resource-Based Policy</pre><h3>Trap 4 : <em>Browser needs S3 download.</em></h3><p>Candidate makes bucket public.</p><p>Wrong.</p><p>Think:</p><pre>Presigned URL</pre><h3>Trap 5 : <em>Cross-account temporary access.</em></h3><p>Candidate creates IAM user in target account.</p><p>Usually not the best solution.</p><p>Think:</p><pre>AssumeRole</pre><h3>Trap 6 : <em>Third-party AWS access.</em></h3><p>Think:</p><pre>Role + External ID</pre><h3>Trap 7 : <em>Developer can create Lambda but can’t assign role.</em></h3><p>Think:</p><pre>iam:PassRole</pre><h3>Trap 8 : <em>API request is correctly signed but returns AccessDenied.</em></h3><p>Signature validity doesn’t mean authorization.</p><pre>Authenticated</pre><pre>≠</pre><pre>Authorized</pre><h3>Trap 9 : <em>Application can GetObject but encrypted file fails.</em></h3><p>Think:</p><pre>KMS</pre><h3>Trap 10 : <em>Need to know who deleted production resource.</em></h3><p>Don’t choose IAM Policy Simulator.</p><p>Choose:</p><pre>CloudTrail</pre><h3>🧠 Memory Tricks</h3><pre>IAM USER</pre><pre>Permanent identity</pre><pre><br>IAM ROLE</pre><pre>Temporary hat</pre><pre><br>STS</pre><pre>Temporary credential factory<br></pre><pre>POLICY</pre><pre>What can you do?<br></pre><pre>TRUST POLICY</pre><pre>Who can become the role?</pre><pre><br>EXECUTION ROLE</pre><pre>What can my AWS workload do?<br></pre><pre>PASSROLE</pre><pre>Give the role to a service.<br></pre><pre>ASSUMEROLE</pre><pre>Become/use the role.<br></pre><pre>SIGV4</pre><pre>Prove the AWS request is authentic.<br></pre><pre>PRESIGNED URL</pre><pre>Temporary signed access without giving AWS credentials.<br></pre><pre>CLOUDTRAIL</pre><pre>Who did what?<br></pre><pre>POLICY SIMULATOR</pre><pre>Would this be allowed?<br></pre><pre>ACCESS ANALYZER</pre><pre>Who has access?</pre><h3>🔥 IAM Master Cheat Sheet</h3><pre>+----------------------+---------------------------+------------------------------------------------------+<br>| CATEGORY             | CONCEPT                   | DESCRIPTION                                          |<br>+----------------------+---------------------------+------------------------------------------------------+<br>| 🔐 Core Concepts     | Authentication            | Who are you?                                         |<br>|                      | Authorization             | What can you do?                                     |<br>|                      | IAM User                  | Persistent identity                                  |<br>|                      | IAM Group                 | Collection of users                                  |<br>|                      | IAM Role                  | Assumable identity                                   |<br>|                      | IAM Policy                | Permission document                                  |<br>|                      | STS                       | Temporary credentials                               |<br>+----------------------+---------------------------+------------------------------------------------------+<br>| 📜 Policy Types      | Trust Policy              | Who can assume the role                              |<br>|                      | Permission Policy         | What the role can do                                 |<br>|                      | Explicit Deny             | Overrides ALL Allow statements                       |<br>|                      | Implicit Deny             | Default — deny unless explicitly allowed             |<br>|                      | Permissions Boundary      | Maximum permissions for an identity                  |<br>|                      | SCP (Service Control Pol.)| Organization‑level guardrail                         |<br>+----------------------+---------------------------+------------------------------------------------------+<br>| 🔄 Role Operations   | AssumeRole                | Obtain temporary session credentials                 |<br>|                      | PassRole                  | Pass a role to an AWS service                        |<br>+----------------------+---------------------------+------------------------------------------------------+<br>| ⚙️ Service Roles     | Lambda Execution Role     | Lambda → AWS services                                |<br>|                      | EC2 Role                  | EC2 instance → AWS services                          |<br>|                      | ECS Task Role             | Container app → AWS services                         |<br>|                      | Task Execution Role       | ECS infrastructure → AWS (pull images/logs)          |<br>+----------------------+---------------------------+------------------------------------------------------+<br>| 🛡️ Security &amp; Access | External ID               | Protects against confused‑deputy for third‑party    |<br>|                      | SigV4                     | Sign AWS API requests                                |<br>|                      | Presigned URL             | Temporarily grant S3 access via signed URL           |<br>|                      | KMS                       | Separate encryption/decryption authorization may apply|<br>+----------------------+---------------------------+------------------------------------------------------+<br>| 🔍 Monitor &amp; Validate| CloudTrail                | Audit all API activity                               |<br>|                      | Policy Simulator          | Test and simulate IAM policies                       |<br>|                      | Access Analyzer           | Analyze external and resource‑based access           |<br>+----------------------+---------------------------+------------------------------------------------------+</pre><h3>📝 Practice Questions</h3><h3>Question 1</h3><p>A Node.js application runs on EC2 and must upload images to S3.</p><p>The developer currently stores IAM access keys in environment variables.</p><p>What should be done?</p><p><strong>Answer </strong>: Attach an IAM role with appropriate S3 permissions to the EC2 instance and let the SDK obtain temporary credentials.</p><h3>Question 2</h3><p>A React application needs to allow users to upload images directly to a private S3 bucket for five minutes.</p><p>What should the backend generate?</p><p><strong>Answer : </strong>A presigned S3 upload URL.</p><h3>Question 3</h3><p>A user has valid AWS credentials but receives: <strong>AccessDeniedException</strong></p><p>Does this mean authentication failed?</p><p><strong>Answer</strong>: Not necessarily.</p><p>The caller may be successfully authenticated but not authorized to perform the requested operation.</p><h3>Question 4</h3><p>A developer directly constructs HTTP requests against an AWS API without using an SDK.</p><p>What mechanism is normally used to authenticate/sign AWS API requests?</p><p><strong>Answer </strong>: AWS Signature Version 4.</p><h3>Question 5</h3><p>A Lambda function needs dynamodb:PutItem.</p><p>Where should the permission normally be granted?</p><p><strong>Answer </strong>: The Lambda execution role.</p><h3>Question 6</h3><p>Amazon S3 must invoke a Lambda function.</p><p>Where should the invocation permission normally be configured?</p><p><strong>Answer </strong>: The Lambda function’s resource-based policy.</p><h3>Question 7</h3><p>A developer wants to determine which AWS identity their CLI credentials represent.</p><p>Which command?</p><pre>aws sts get-caller-identity</pre><h3>Question 8</h3><p>A company wants to determine whether an IAM user’s policies allow:</p><pre>s3:DeleteObject</pre><p>without actually deleting anything.</p><p>Which tool can help?</p><p><strong>Answer</strong>: IAM Policy Simulator.</p><h3>Question 9</h3><p>A security team wants to identify resources that are accessible from outside the organization’s intended trust boundary.</p><p>Which IAM capability should they investigate?</p><p><strong>Answer </strong>: IAM Access Analyzer.</p><h3>Question 10</h3><p>A production S3 bucket was deleted.</p><p>The security team needs to identify the API caller responsible.</p><p>Which AWS service?</p><p><strong>Answer </strong>: AWS CloudTrail.</p><h3>Question 11</h3><p>A Lambda role allows:</p><pre>s3:GetObject</pre><p>The object is encrypted using a customer-managed KMS key.</p><p>Lambda still receives an authorization error while reading/decrypting the data.</p><p>What should you investigate?</p><p><strong>Answer </strong>: KMS authorization, including required decrypt permission and the KMS key policy.</p><h3>Question 12</h3><p>A developer needs to create a Lambda function using an existing execution role.</p><p>They can call:</p><pre>lambda:CreateFunction</pre><p>but assigning the role fails.</p><p>What permission may be missing?</p><p><strong>Answer </strong>:</p><pre>iam:PassRole</pre><h3>Question 13</h3><p>A mobile application contains AWS access keys in its binary.</p><p>What’s wrong?</p><p><strong>Answer </strong>: Mobile application binaries can be inspected, exposing long-lived credentials.</p><p>Use federation/temporary credentials or an appropriate backend/presigned URL architecture instead.</p><h3>Question 14</h3><p>An ECS application needs to call DynamoDB.</p><p>Which role?</p><p><strong>Answer </strong>: ECS Task Role.</p><h3>Question 15</h3><p>ECS needs to pull the container image from ECR.</p><p>Which role?</p><p><strong>Answer </strong>: ECS Task Execution Role.</p><h3>Question 16</h3><p>A third-party SaaS platform needs cross-account access to thousands of customer AWS accounts.</p><p>Which additional IAM mechanism is especially relevant?</p><p><strong>Answer </strong>: External ID.</p><h3>Question 17</h3><p>What is the difference between CloudTrail and CloudWatch?</p><p><strong>Answer </strong>:</p><pre>CloudTrail<br>→ AWS API auditing/activity</pre><pre>CloudWatch<br>→ Metrics, logs, alarms and operational monitoring</pre><h3>Question 18 — Tricky</h3><p>A user has: <strong>Allow s3:* </strong>but another applicable policy contains: <strong>Deny s3:DeleteObject</strong></p><p>Can they delete objects?</p><p><strong>Answer </strong>: No. Explicit Deny wins.</p><h3>Question 19 — Tricky</h3><p>A permissions boundary allows: <strong>lambda:InvokeFunction</strong></p><p>but the user’s identity policies don’t grant it.</p><p>Can the user invoke Lambda because the boundary allows it?</p><p><strong>Answer </strong>: No, A permissions boundary doesn’t grant permissions.</p><h3>Question 20 — Architecture Question</h3><p>You are building:</p><pre>Browser<br>   ↓<br>API Gateway<br>   ↓<br>Lambda<br>   ↓<br>S3</pre><p>Users need temporary direct download access to private S3 files.</p><p>Design the permission flow.</p><p><strong>Answer </strong>:</p><pre>Browser</pre><pre>↓</pre><pre>API Gateway</pre><pre>↓</pre><pre>Lambda</pre><pre>↓</pre><pre>Lambda Execution Role<br>has appropriate s3:GetObject permission</pre><pre>↓</pre><pre>Lambda generates Presigned URL</pre><pre>↓</pre><pre>Browser receives URL</pre><pre>↓</pre><pre>Browser downloads directly from S3</pre><p>The S3 bucket can remain private.</p><p>The user never receives AWS access keys.</p><h3>🏆 IAM FINAL REVISION</h3><p>If I had only <strong>60 seconds</strong> before the exam, this is what I’d revise:</p><pre>AWS Workload needs AWS access?</pre><pre>→ IAM Role<br></pre><pre>Lambda → AWS?</pre><pre>→ Execution Role<br></pre><pre>EC2 → AWS?</pre><pre>→ Instance Role<br></pre><pre>ECS app → AWS?</pre><pre>→ Task Role<br></pre><pre>ECS infrastructure?</pre><pre>→ Task Execution Role<br></pre><pre>Another account?</pre><pre>→ AssumeRole<br></pre><pre>Third party?</pre><pre>→ AssumeRole + External ID<br></pre><pre>Give role to service?</pre><pre>→ PassRole<br></pre><pre>Temporary credentials?</pre><pre>→ STS<br></pre><pre>Browser → private S3 temporarily?</pre><pre>→ Presigned URL<br></pre><pre>Raw AWS API request?</pre><pre>→ SigV4<br></pre><pre>Who performed API action?</pre><pre>→ CloudTrail<br></pre><pre>Would permission work?</pre><pre>→ Policy Simulator<br></pre><pre>Who has external access?</pre><pre>→ Access Analyzer<br></pre><pre>Encrypted resource AccessDenied?</pre><pre>→ Check KMS<br></pre><pre>Explicit Deny?</pre><pre>→ DENY<br></pre><pre>No Allow?</pre><pre>→ DENY<br></pre><pre>Boundary?</pre><pre>→ Limits; doesn&#39;t grant<br></pre><pre>SCP?</pre><pre>→ Guardrail; doesn&#39;t simply grant</pre><p>If those associations become automatic, you’ve already solved a large portion of IAM-related DVA-C02 scenarios.</p><h3>🎯 Day 5 Key Takeaways</h3><p>The most important lesson from the entire IAM section is not:</p><blockquote><em>“Learn IAM policies.”</em></blockquote><p>It’s: <strong><em>Understand the identity behind every AWS API request.</em></strong></p><p>When your application calls:</p><pre>await s3.send(command);</pre><p>think about what’s really happening:</p><pre>Application</pre><pre>↓</pre><pre>Which credentials?</pre><pre>↓</pre><pre>Which identity?</pre><pre>↓</pre><pre>Signed how?</pre><pre>↓</pre><pre>Which API action?</pre><pre>↓</pre><pre>Which resource?</pre><pre>↓</pre><pre>Which policies?</pre><pre>↓</pre><pre>Any explicit Deny?</pre><pre>↓</pre><pre>Any boundary/SCP/session restriction?</pre><pre>↓</pre><pre>Any dependent permission such as KMS?</pre><pre>↓</pre><pre>ALLOW / DENY</pre><p>Once you think this way, IAM stops being mysterious.</p><p>And when you see:</p><pre>AccessDenied</pre><p>don’t panic.</p><p>Ask:</p><pre>WHO?</pre><pre>WHAT ACTION?</pre><pre>WHICH RESOURCE?</pre><pre>WHICH POLICY?</pre><pre>WHICH RESTRICTION?</pre><p>That is how AWS developers debug IAM.</p><h3>🏁 IAM SECTION COMPLETE</h3><p>We’ve now completed our core IAM block:</p><pre>DAY 2<br>IAM Fundamentals<br>      │<br>      ▼<br>Users, Groups, Authentication,<br>Authorization, Least Privilege<br></pre><pre>DAY 3<br>IAM Policies<br>      │<br>      ▼<br>Policy JSON, Resource Policies,<br>Explicit Deny, Boundaries, SCP<br></pre><pre>DAY 4<br>IAM Roles<br>      │<br>      ▼<br>STS, Temporary Credentials,<br>Execution Roles, Cross-Account,<br>External ID, PassRole<br></pre><pre>DAY 5<br>IAM for Developers<br>      │<br>      ▼<br>CLI, SDK, Credential Providers,<br>SigV4, Presigned URLs,<br>CloudTrail, Access Analyzer,<br>Troubleshooting</pre><p>Don’t expect to remember every detail immediately.</p><p>That’s normal.</p><p>From here onward, IAM will repeatedly appear inside every service we study.</p><p>When we learn Lambda:</p><pre>Execution Role</pre><p>When we learn S3:</p><pre>Bucket Policies<br>Presigned URLs</pre><p>When we learn DynamoDB:</p><pre>IAM permissions</pre><p>When we learn API Gateway:</p><pre>IAM authorization</pre><p>When we learn KMS:</p><pre>Key Policies</pre><p>When we learn ECS:</p><pre>Task Roles</pre><p>So IAM isn’t really finished.</p><p>We’ve simply learned the language required to understand everything that comes next.</p><h3>🚀 Day 6 Preview — AWS Lambda From First Principles</h3><p>Now we’re moving into one of the biggest services in the entire DVA-C02 exam:</p><h3>AWS Lambda.</h3><p>But we’re not going to start with: <em>“Lambda is serverless compute.”</em></p><p>We’re going to ask: <strong><em>What actually happens when AWS executes a Lambda function?</em></strong></p><p>We’ll cover:</p><pre>What Serverless Actually Means</pre><pre>Lambda Architecture</pre><pre>Execution Environment</pre><pre>Cold Starts</pre><pre>Warm Starts</pre><pre>Init Phase</pre><pre>Invoke Phase</pre><pre>Shutdown Phase</pre><pre>Handlers</pre><pre>Runtime</pre><pre>Memory</pre><pre>CPU Allocation</pre><pre>Timeout</pre><pre>Environment Variables</pre><pre>Execution Roles</pre><pre>Resource Policies</pre><pre>Synchronous Invocation</pre><pre>Asynchronous Invocation</pre><pre>Event Source Mappings</pre><pre>Retries</pre><pre>Dead Letter Queues</pre><pre>Destinations</pre><pre>Concurrency</pre><pre>Reserved Concurrency</pre><pre>Provisioned Concurrency</pre><pre>Versions</pre><pre>Aliases</pre><pre>Layers</pre><pre>/tmp Storage</pre><pre>Lambda Networking</pre><pre>Lambda + VPC</pre><pre>Lambda + S3</pre><pre>Lambda + SQS</pre><pre>Lambda + API Gateway</pre><pre>Lambda + DynamoDB Streams</pre><pre>CloudWatch Logging</pre><pre>X-Ray Tracing</pre><pre>Lambda Security</pre><pre>Performance Optimization</pre><pre>Cost Optimization</pre><pre>Real Production Architectures</pre><pre>DVA-C02 Exam Traps</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=93bfa6e1d564" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Day 4 — IAM Roles & AWS STS: Temporary Credentials, AssumeRole, Service Roles, and Cross-Account…]]></title>
            <link>https://hari27om.medium.com/day-4-iam-roles-aws-sts-temporary-credentials-assumerole-service-roles-and-cross-account-73d28e4b792a?source=rss-403dd53dc117------2</link>
            <guid isPermaLink="false">https://medium.com/p/73d28e4b792a</guid>
            <dc:creator><![CDATA[Hari Om]]></dc:creator>
            <pubDate>Fri, 31 Jul 2026 10:02:20 GMT</pubDate>
            <atom:updated>2026-07-31T10:02:20.623Z</atom:updated>
            <content:encoded><![CDATA[<h3>Day 4 — IAM Roles &amp; AWS STS: Temporary Credentials, AssumeRole, Service Roles, and Cross-Account Access</h3><p>Yesterday we learned how IAM policies answer:</p><blockquote><strong><em>What is this identity allowed to do?</em></strong></blockquote><p>Today we’re solving a different problem:</p><blockquote><strong><em>How can applications, AWS services, and users securely obtain those permissions without storing permanent credentials?</em></strong></blockquote><p>The answer is one of AWS’s most important security patterns:</p><h3>IAM Roles + AWS Security Token Service (STS)</h3><p>This chapter matters far beyond the exam.</p><p>If you’re building applications on AWS, you will constantly encounter:</p><ul><li>Lambda execution roles</li><li>EC2 instance roles</li><li>ECS task roles</li><li>Cross-account roles</li><li>sts:AssumeRole</li><li>Temporary security credentials</li><li>Trust policies</li><li>Service roles</li></ul><p>The fundamental rule we’ll build around is:</p><blockquote><strong><em>Applications running on AWS should generally use IAM roles and temporary credentials instead of hardcoded long-lived AWS access keys.</em></strong></blockquote><p>Let’s understand why.</p><h3>1. The Problem With Access Keys</h3><p>Suppose I’m building a Node.js backend running on EC2.</p><p>The application needs to upload files to S3.</p><p>A beginner might do this:</p><pre>const client = new S3Client({<br>    region: &quot;ap-south-1&quot;,<br>    credentials: {<br>        accessKeyId: &quot;AKIA...&quot;,<br>        secretAccessKey: &quot;...&quot;<br>    }<br>});</pre><p>It works.</p><p>And that’s exactly why it’s dangerous.</p><p>We’ve created:</p><pre>Application<br>     │<br>     ▼<br>Long-Lived Credentials<br>     │<br>     ▼<br>AWS</pre><p>Now imagine this code gets pushed to GitHub.</p><pre>git add .</pre><pre>git commit -m &quot;production ready&quot;</pre><pre>git push</pre><p>Congratulations.</p><p>Production is ready.</p><p>So are the credentials for whoever finds them.</p><h3>2. Why Long-Lived Credentials Are Dangerous</h3><p>An IAM user’s access credentials might remain valid until they’re rotated or disabled.</p><p>If stolen, an attacker could potentially continue using them.</p><p>You now have several problems:</p><pre>Credential leaked<br>       │<br>       ▼<br>Attacker gets AWS access<br>       │<br>       ▼<br>Credential remains usable<br>       │<br>       ▼<br>Manual rotation required<br>       │<br>       ▼<br>Application configuration changes</pre><p>AWS needed a better system.</p><p>What if credentials could be:</p><pre>Temporary</pre><pre>Automatically generated</pre><pre>Automatically rotated</pre><pre>Short-lived</pre><pre>Scoped to specific permissions</pre><p>That’s exactly what IAM Roles + STS provide.</p><h3>3. What Is an IAM Role?</h3><p>An IAM role is an AWS identity with permissions.</p><p>But unlike an IAM user, a role normally does not represent one permanent person and does not have standard long-lived credentials attached to it.</p><p>Instead:</p><pre>IAM Role</pre><pre>     ↓</pre><pre>Someone / Something</pre><pre>ASSUMES</pre><pre>the role</pre><pre>     ↓</pre><pre>Receives temporary credentials</pre><p>That “someone/something” could be:</p><pre>IAM User</pre><pre>Another IAM Role</pre><pre>AWS Service</pre><pre>Application</pre><pre>Another AWS Account</pre><pre>Federated User</pre><pre>External Identity Provider</pre><h3>4. User vs Role</h3><p>This distinction is fundamental.</p><p>IAM UserIAM RoleUsually represents a specific identityRepresents assumable permissionsCan have passwordNo normal console passwordCan have long-lived access keysUses temporary credentials when assumedPersistent identityAssumable identityCommon for legacy/direct IAM usersPreferred for workloads and temporary access</p><p>Think:</p><pre>USER</pre><pre>&quot;I am Hari.&quot;<br></pre><pre>ROLE</pre><pre>&quot;I am temporarily acting as ProductionDeployer.&quot;</pre><h3>5. Real-World Analogy</h3><p>Imagine you work at an airport.</p><p>Normally you’re:</p><pre>Hari<br>Software Engineer</pre><p>But during an emergency, you’re temporarily given:</p><pre>Emergency Operations Badge</pre><p>That badge allows:</p><pre>Enter Operations Room</pre><pre>Access Monitoring Systems</pre><pre>Perform Emergency Procedures</pre><p>After the emergency:</p><pre>Badge expires</pre><p>You haven’t permanently become an emergency administrator.</p><p>You temporarily assumed a privileged role.</p><p>That’s very similar to IAM roles.</p><h3>6. Roles Have Two Different Permission Questions</h3><p>This is where IAM Roles become interesting.</p><p>AWS needs to answer:</p><h3>Question 1</h3><blockquote><em>Who is allowed to assume this role?</em></blockquote><h3>Question 2</h3><blockquote><em>After assuming the role, what can they do?</em></blockquote><p>These are controlled separately.</p><pre>                   IAM ROLE</pre><pre>        ┌─────────────┴─────────────┐</pre><pre>        ▼                           ▼</pre><pre>Trust Policy                Permission Policy</pre><pre>WHO can assume             WHAT role can do<br>the role</pre><p>This distinction is extremely important.</p><h3>7. Trust Policy</h3><p>A role has a <strong>trust policy</strong>.</p><p>The trust policy specifies which principals are trusted to assume the role.</p><p>Example:</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;Principal&quot;: {<br>        &quot;Service&quot;: &quot;lambda.amazonaws.com&quot;<br>      },<br>      &quot;Action&quot;: &quot;sts:AssumeRole&quot;<br>    }<br>  ]<br>}</pre><p>Translate this into English:</p><pre>ALLOW</pre><pre>AWS Lambda</pre><pre>to</pre><pre>ASSUME THIS ROLE</pre><p>Notice:</p><pre>&quot;Principal&quot;: {<br>    &quot;Service&quot;: &quot;lambda.amazonaws.com&quot;<br>}</pre><p>This identifies who is trusted.</p><p>And:</p><pre>&quot;Action&quot;: &quot;sts:AssumeRole&quot;</pre><p>means the principal may assume the role.</p><h3>8. Permission Policy</h3><p>Now suppose the same role has this permission policy:</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;: &quot;s3:PutObject&quot;,<br>      &quot;Resource&quot;: &quot;arn:aws:s3:::company-images/*&quot;<br>    }<br>  ]<br>}</pre><p>That answers:</p><blockquote><em>What can the role do after being assumed?</em></blockquote><p>Answer:</p><pre>Upload objects</pre><pre>to</pre><pre>company-images</pre><p>So together:</p><pre>Trust Policy</pre><pre>Lambda can assume role</pre><pre>            +</pre><pre>Permission Policy</pre><pre>Role can upload to S3</pre><pre>            ↓</pre><pre>Lambda can upload to S3<br>while operating with the role</pre><h3>9. Trust vs Permissions — Memorize This</h3><pre>TRUST POLICY</pre><pre>WHO CAN BECOME ME?<br></pre><pre>PERMISSION POLICY</pre><pre>WHAT CAN I DO?</pre><p>This is one of the most useful IAM role memory tricks.</p><h3>10. What Is AWS STS?</h3><p>Now we need the service powering this system.</p><p><strong>AWS Security Token Service (STS)</strong></p><p>STS issues <strong>temporary security credentials</strong>.</p><p>Conceptually:</p><pre>Principal</pre><pre>     │<br>     │ AssumeRole<br>     ▼</pre><pre>AWS STS</pre><pre>     │<br>     ▼</pre><pre>Temporary Credentials</pre><pre>     │<br>     ▼</pre><pre>AWS Services</pre><p>STS is one of those services developers use constantly without necessarily realizing they’re using it.</p><h3>11. What Does STS Return?</h3><p>When a role is assumed, STS can return credentials containing:</p><pre>AccessKeyId</pre><pre>SecretAccessKey</pre><pre>SessionToken</pre><pre>Expiration</pre><p>Notice something new.</p><p>Normal long-lived IAM user credentials commonly involve:</p><pre>Access Key ID</pre><pre>Secret Access Key</pre><p>Temporary credentials also include:</p><pre>Session Token</pre><p>That session token matters.</p><h3>12. Temporary Credentials</h3><p>Conceptually:</p><pre>{<br>  &quot;AccessKeyId&quot;: &quot;ASIA...&quot;,<br>  &quot;SecretAccessKey&quot;: &quot;...&quot;,<br>  &quot;SessionToken&quot;: &quot;...&quot;,<br>  &quot;Expiration&quot;: &quot;...&quot;<br>}</pre><p>These credentials eventually expire.</p><p>That’s a huge security advantage.</p><h3>13. Long-Lived vs Temporary Credentials</h3><pre>IAM USER CREDENTIALS</pre><pre>Access Key<br>+<br>Secret Key</pre><pre>Potentially long-lived<br></pre><pre>IAM ROLE SESSION</pre><pre>Access Key<br>+<br>Secret Key<br>+<br>Session Token<br>+<br>Expiration</pre><pre>Temporary</pre><p>For workloads:</p><p><strong>Temporary credentials are strongly preferred.</strong></p><h3>14. AssumeRole Flow</h3><p>Let’s understand exactly what happens.</p><p>Suppose:</p><pre>Hari</pre><pre>wants to become</pre><pre>ProductionReadOnlyRole</pre><p>Flow:</p><pre>Hari</pre><pre>  │</pre><pre>  │ sts:AssumeRole</pre><pre>  ▼</pre><pre>AWS STS</pre><pre>  │</pre><pre>  │ Checks authorization + role trust</pre><pre>  ▼</pre><pre>ProductionReadOnlyRole</pre><pre>  │</pre><pre>  ▼</pre><pre>Temporary Credentials</pre><pre>  │</pre><pre>  ▼</pre><pre>Hari acts with role session permissions</pre><p>The important idea:</p><p>Hari isn’t modifying his original IAM identity.</p><p>He’s obtaining a temporary role session.</p><h3>15. AWS CLI AssumeRole Example</h3><p>You can manually assume a role:</p><pre>aws sts assume-role \<br>  --role-arn arn:aws:iam::123456789012:role/ProductionReadOnly \<br>  --role-session-name hari-production-session</pre><p>STS returns temporary credentials.</p><p>Conceptually:</p><pre>{<br>  &quot;Credentials&quot;: {<br>    &quot;AccessKeyId&quot;: &quot;ASIA...&quot;,<br>    &quot;SecretAccessKey&quot;: &quot;...&quot;,<br>    &quot;SessionToken&quot;: &quot;...&quot;,<br>    &quot;Expiration&quot;: &quot;...&quot;<br>  }<br>}</pre><p>You can then use those credentials for the duration of the session.</p><h3>16. Important: AssumeRole Requires Authorization</h3><p>Suppose Hari wants:</p><pre>ProductionAdminRole</pre><p>He cannot simply say:</p><pre>aws sts assume-role \<br>  --role-arn ...ProductionAdminRole</pre><p>and magically become an administrator.</p><p>AWS evaluates whether the assumption is permitted.</p><p>For cross-account access especially, think of two sides:</p><pre>CALLER SIDE</pre><pre>Is the caller allowed to call sts:AssumeRole?</pre><pre>            +</pre><pre>ROLE SIDE</pre><pre>Does the target role trust that caller/account?</pre><p>Both sides matter.</p><h3>17. IAM Roles for AWS Services</h3><p>Now we get to the most common DVA-C02 use case.</p><p>Suppose Lambda needs access to DynamoDB.</p><p>Bad architecture:</p><pre>Lambda</pre><pre>↓</pre><pre>Hardcoded Access Key</pre><pre>↓</pre><pre>DynamoDB</pre><p>Good architecture:</p><pre>Lambda</pre><pre>↓</pre><pre>Execution Role</pre><pre>↓</pre><pre>Temporary Credentials</pre><pre>↓</pre><pre>DynamoDB</pre><p>This role is called the <strong>Lambda Execution Role</strong></p><h3>18. Lambda Execution Role</h3><p>Imagine:</p><pre>Lambda Function<br>     │<br>     ▼<br>Execution Role<br>     │<br>     ├── dynamodb:GetItem<br>     ├── dynamodb:PutItem<br>     └── logs:PutLogEvents</pre><p>Lambda assumes the execution role.</p><p>The application code doesn’t need:</p><pre>AWS_ACCESS_KEY_ID</pre><pre>AWS_SECRET_ACCESS_KEY</pre><p>hardcoded.</p><p>AWS provides credentials to the runtime.</p><h3>19. Example Lambda Architecture</h3><pre>            API Gateway</pre><pre>                 │</pre><pre>                 ▼</pre><pre>               Lambda</pre><pre>                  │<br>                  │ assumes<br>                  ▼</pre><pre>          LambdaExecutionRole</pre><pre>             /          \</pre><pre>            ▼            ▼</pre><pre>       DynamoDB       CloudWatch</pre><p>Permission policy:</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;dynamodb:GetItem&quot;,<br>        &quot;dynamodb:PutItem&quot;<br>      ],<br>      &quot;Resource&quot;: &quot;arn:aws:dynamodb:ap-south-1:123456789012:table/Orders&quot;<br>    }<br>  ]<br>}</pre><p>Trust policy:</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;Principal&quot;: {<br>        &quot;Service&quot;: &quot;lambda.amazonaws.com&quot;<br>      },<br>      &quot;Action&quot;: &quot;sts:AssumeRole&quot;<br>    }<br>  ]<br>}</pre><p>Two completely different jobs.</p><h3>20. Execution Role vs Resource Policy</h3><p>This distinction causes many exam mistakes.</p><p>Suppose:</p><pre>Lambda<br>   │<br>   ▼<br>DynamoDB</pre><p>Question:</p><blockquote><em>How does Lambda get permission to access DynamoDB?</em></blockquote><p>Answer:</p><pre>Lambda Execution Role</pre><p>But suppose:</p><pre>S3<br> │<br> ▼<br>Lambda</pre><p>Question:</p><blockquote><em>How can S3 invoke Lambda?</em></blockquote><p>Now Lambda can use a:</p><pre>Resource-Based Policy</pre><p>allowing S3 to invoke it.</p><p>These are opposite directions.</p><h3>21. Direction Matters</h3><pre>Lambda → DynamoDB</pre><pre>WHO needs permission?</pre><pre>Lambda.</pre><pre>Use Lambda execution role permissions.</pre><p>But:</p><pre>S3 → Lambda</pre><pre>WHO is calling?</pre><pre>S3.</pre><pre>Lambda&#39;s resource-based policy can permit invocation.</pre><p>This distinction is very exam-worthy.</p><h3>22. EC2 Instance Roles</h3><p>Now imagine an application running on EC2.</p><p>It needs S3.</p><p>Bad:</p><pre>EC2</pre><pre>↓</pre><pre>.env</pre><pre>AWS_ACCESS_KEY_ID=...<br>AWS_SECRET_ACCESS_KEY=...</pre><pre>↓</pre><pre>S3</pre><p>Better:</p><pre>EC2 Instance</pre><pre>↓</pre><pre>IAM Role</pre><pre>↓</pre><pre>Temporary Credentials</pre><pre>↓</pre><pre>S3</pre><p>For EC2, the role is associated with instance through an : <strong>Instance Profile</strong></p><h3>23. Instance Profile</h3><p>This terminology can be confusing.</p><p>Conceptually:</p><pre>EC2 Instance</pre><pre>     │</pre><pre>     ▼</pre><pre>Instance Profile</pre><pre>     │</pre><pre>     ▼</pre><pre>IAM Role</pre><pre>     │</pre><pre>     ▼</pre><pre>Permissions</pre><p>The instance profile acts as the container through which an IAM role is associated with EC2.</p><p>In the console, AWS often hides some of this complexity.</p><p>But for CLI/API/CloudFormation work, you’ll encounter instance profiles.</p><h3>24. EC2 Credential Delivery</h3><p>How does code running inside EC2 obtain role credentials?</p><p>AWS exposes temporary credentials through the EC2 Instance Metadata Service.</p><p>Conceptually:</p><pre>Application</pre><pre>↓</pre><pre>AWS SDK Credential Provider Chain</pre><pre>↓</pre><pre>Instance Metadata Service</pre><pre>↓</pre><pre>Temporary Role Credentials</pre><pre>↓</pre><pre>AWS API</pre><p>The SDK can retrieve and refresh these credentials automatically.</p><p>You don’t manually rotate them.</p><h3>25. This Is Why SDK Code Can Be Simple</h3><p>Instead of:</p><pre>const s3 = new S3Client({<br>  credentials: {<br>    accessKeyId: &quot;...&quot;,<br>    secretAccessKey: &quot;...&quot;<br>  }<br>});</pre><p>you can often write:</p><pre>import { S3Client } from &quot;@aws-sdk/client-s3&quot;;<br><br>const s3 = new S3Client({<br>  region: &quot;ap-south-1&quot;<br>});</pre><p>The AWS SDK uses its credential provider chain to discover credentials.</p><p>Depending on the environment, that might come from:</p><pre>Environment variables</pre><pre>Shared AWS config/credentials</pre><pre>Web identity credentials</pre><pre>ECS task credentials</pre><pre>EC2 instance role credentials</pre><pre>Other supported providers</pre><p>The key point:</p><p><strong>Your application shouldn’t need to know the secret itself.</strong></p><h3>26. ECS Roles — Important Distinction</h3><p>With ECS, you’ll encounter two different roles.</p><pre>ECS Task Execution Role<br><br>vs<br><br>ECS Task Role</pre><p>These are NOT the same thing.</p><h3>27. ECS Task Execution Role</h3><p>Used by the ECS/Fargate infrastructure to perform actions required to start and operate the task.</p><p>For example:</p><pre>Pull container image from ECR</pre><pre>Send logs to CloudWatch</pre><pre>Retrieve certain startup secrets/configuration</pre><p>Think:</p><pre>AWS ECS infrastructure<br><br>needs permissions</pre><h3>28. ECS Task Role</h3><p>Used by:</p><pre>YOUR APPLICATION<br><br>inside the container</pre><p>Example:</p><pre>Node.js App<br><br>↓<br><br>DynamoDB</pre><p>Your app needs:</p><pre>dynamodb:GetItem</pre><p>That belongs in the: <strong>Task Role </strong>not the task execution role.</p><h3>29. ECS Memory Trick</h3><pre>EXECUTION ROLE</pre><pre>ECS needs it to RUN the task.<br></pre><pre>TASK ROLE</pre><pre>YOUR CODE needs it while RUNNING inside the task.</pre><p>This distinction is extremely useful for both the exam and real ECS deployments.</p><h3>30. Lambda vs EC2 vs ECS Roles</h3><p>WorkloadTypical RoleLambdaExecution RoleEC2Instance Role via Instance ProfileECS applicationTask RoleECS infrastructureTask Execution Role</p><p>Remember what is actually making the API call.</p><p>That’s usually the key to choosing the correct role.</p><h3>31. Cross-Account Access</h3><p>Now we’re getting into serious IAM territory.</p><p>Imagine a company has:</p><pre>AWS Account A<br>Development</pre><pre>AWS Account B<br>Production</pre><p>Developers normally work in Account A.</p><p>But occasionally they need read-only access to production resources.</p><p>Bad solution:</p><pre>Create duplicate IAM users in Production</pre><pre>↓</pre><pre>Create more passwords</pre><pre>↓</pre><pre>Create more access keys</pre><pre>↓</pre><pre>Manage more identities</pre><p>Better: <strong>Cross-Account Role</strong></p><h3>32. Cross-Account Architecture</h3><pre>ACCOUNT A</pre><pre>Developer<br>    │<br>    │<br>    │ AssumeRole<br>    │<br>    ▼</pre><pre>----------------------------</pre><pre>ACCOUNT B</pre><pre>ProductionReadOnlyRole<br>    │<br>    ▼<br>Production Resources</pre><p>The developer keeps their identity in Account A.</p><p>They temporarily assume a role in Account B.</p><h3>33. Cross-Account Trust Policy</h3><p>Account B’s role might trust Account A.</p><p>Simplified example:</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;Principal&quot;: {<br>        &quot;AWS&quot;: &quot;arn:aws:iam::111122223333:root&quot;<br>      },<br>      &quot;Action&quot;: &quot;sts:AssumeRole&quot;<br>    }<br>  ]<br>}</pre><p>Meaning:</p><pre>This role trusts principals from Account 111122223333,<br>subject to caller-side authorization and any conditions.</pre><p>Important:</p><p>Trusting the account does NOT automatically mean every identity gets access.</p><p>The caller still needs appropriate permission to assume the role.</p><h3>34. Caller Permission</h3><p>For example, the developer’s policy in Account A might contain:</p><pre>{<br>  &quot;Effect&quot;: &quot;Allow&quot;,<br>  &quot;Action&quot;: &quot;sts:AssumeRole&quot;,<br>  &quot;Resource&quot;: &quot;arn:aws:iam::444455556666:role/ProductionReadOnlyRole&quot;<br>}</pre><p>Now:</p><pre>Account A Developer</pre><pre>has permission</pre><pre>        ↓</pre><pre>sts:AssumeRole</pre><pre>        ↓</pre><pre>Account B role trusts Account A</pre><pre>        ↓</pre><pre>Role session created</pre><h3>35. Cross-Account Mental Model</h3><p>Think of a nightclub.</p><p>Your own security department says:</p><pre>&quot;You are allowed to visit Club B.&quot;</pre><p>That’s caller-side permission.</p><p>Club B says:</p><pre>&quot;We trust visitors matching these rules.&quot;</pre><p>That’s the trust policy.</p><p>You generally need both authorization relationships to line up.</p><h3>36. What Happens After AssumeRole?</h3><p>Suppose your original user has:</p><pre>S3<br>Lambda<br>DynamoDB</pre><p>You assume:</p><pre>ProductionReadOnlyRole</pre><p>which permits:</p><pre>CloudWatch Read</pre><pre>S3 Read</pre><p>Your role session acts according to the role session’s effective permissions.</p><p>It doesn’t simply combine all your original user permissions with the role.</p><p>Think:</p><pre>Original Identity</pre><pre>        ↓ AssumeRole</pre><pre>New temporary role session</pre><pre>        ↓</pre><pre>Role-based permissions</pre><h3>37. Why Cross-Account Roles Are Better</h3><p>Instead of:</p><pre>Account A User<br>Account B User<br>Account C User<br>Account D User</pre><p>you can have:</p><pre>Central Identity</pre><pre>      │</pre><pre>      ├── Assume Dev Role<br>      ├── Assume Staging Role<br>      └── Assume Production Role</pre><p>Much cleaner.</p><p>Much easier to audit.</p><p>Much easier to revoke.</p><h3>38. Role Sessions</h3><p>When you assume a role, AWS creates a role session.</p><p>Suppose the role is:</p><pre>ProductionReadOnly</pre><p>and Hari assumes it with:</p><pre>hari-session</pre><p>You’ll encounter assumed-role ARNs conceptually like:</p><pre>arn:aws:sts::123456789012:assumed-role/ProductionReadOnly/hari-session</pre><p>Notice:</p><pre>aws:sts</pre><pre>assumed-role</pre><p>This is not the same ARN format as the underlying IAM role:</p><pre>arn:aws:iam::123456789012:role/ProductionReadOnly</pre><p>This distinction matters in advanced policy debugging.</p><h3>39. Session Duration</h3><p>Temporary credentials don’t last forever.</p><p>Role sessions have a duration.</p><p>The role has a configured maximum session duration, and the requested session duration must fit applicable limits.</p><p>Different STS operations and scenarios can have different limits.</p><p>For exam purposes, remember the principle:</p><pre>Role credentials</pre><pre>=</pre><pre>TEMPORARY</pre><p>not permanent.</p><h3>40. Role Chaining</h3><p>Imagine:</p><pre>User</pre><pre>↓</pre><pre>Assumes Role A</pre><pre>↓</pre><pre>Role A assumes Role B</pre><p>This is called: <strong>Role Chaining</strong></p><p>Architecture:</p><pre>Hari</pre><pre>  ↓</pre><pre>DeveloperRole</pre><pre>  ↓</pre><pre>ProductionRole</pre><p>AWS imposes stricter duration behavior when one assumed role uses AssumeRole to assume another role.</p><p>For DVA-C02, understand:</p><blockquote><em>Role chaining means using one role session to assume another role.</em></blockquote><p>Don’t obsess over obscure limits unless your practice exams repeatedly target them.</p><h3>41. Session Policies</h3><p>Remember Day 3?</p><p>A role might allow:</p><pre>S3<br>DynamoDB<br>Lambda</pre><p>But when assuming it, we might want the specific session to use only <strong>S3</strong></p><p>STS supports session policies.</p><p>Conceptually:</p><pre>Role Permissions</pre><pre>{ S3, DynamoDB, Lambda }</pre><pre>             ∩</pre><pre>Session Policy</pre><pre>{ S3 }</pre><pre>             ↓</pre><pre>Session Effective Scope</pre><pre>{ S3 }</pre><p>Session policies restrict.</p><p>They don’t grant permissions beyond the role.</p><h3>42. Why Session Policies Are Useful</h3><p>Imagine one generic role:</p><pre>DataProcessor</pre><p>Role allows:</p><pre>Read S3<br>Write DynamoDB<br>Publish SNS</pre><p>For one specific session, perhaps only S3 access is required.</p><p>A session policy can narrow the session.</p><p>This follows: <strong>Least Privilege </strong>even within temporary sessions.</p><h3>43. External ID</h3><p>Now we’re entering an important cross-account scenario.</p><p>Suppose your company uses a third-party SaaS provider:</p><pre>MonitoringCompany</pre><p>They need access to your AWS account.</p><p>You create a role:</p><pre>ThirdPartyMonitoringRole</pre><p>and trust the provider’s AWS account.</p><p>But there’s a potential issue: <strong>Confused Deputy Problem</strong></p><h3>44. Confused Deputy Problem</h3><p>Imagine the SaaS company serves:</p><pre>Company A</pre><pre>Company B</pre><pre>Company C</pre><p>All customers configure roles that trust the SaaS provider.</p><p>An attacker/customer might try to trick the provider into accessing another customer’s role.</p><p>The provider is trusted — but is being “confused” into using its authority against the wrong customer’s resources.</p><p>That’s the confused deputy problem.</p><h3>45. External ID Helps</h3><p>AWS supports using an:</p><pre>ExternalId</pre><p>condition in the role’s trust policy.</p><p>Example:</p><pre>{<br>  &quot;Effect&quot;: &quot;Allow&quot;,<br>  &quot;Principal&quot;: {<br>    &quot;AWS&quot;: &quot;arn:aws:iam::999988887777:role/SaaSProviderRole&quot;<br>  },<br>  &quot;Action&quot;: &quot;sts:AssumeRole&quot;,<br>  &quot;Condition&quot;: {<br>    &quot;StringEquals&quot;: {<br>      &quot;sts:ExternalId&quot;: &quot;customer-abc-unique-id&quot;<br>    }<br>  }<br>}</pre><p>Now assuming the role requires the expected external ID.</p><h3>46. External ID Memory Trick</h3><pre>Third-party cross-account access?<br><br>Think:<br>EXTERNAL ID</pre><p>Especially when the question mentions:</p><pre>Third-party company</pre><pre>SaaS provider</pre><pre>Multiple customers</pre><pre>Confused deputy</pre><p>External ID should immediately come to mind.</p><h3>47. External ID Is Not a Password</h3><p>Important nuance.</p><p>External IDs should not be treated as secret credentials.</p><p>They’re primarily used to help ensure the third party is assuming the intended customer’s role.</p><p>The third-party provider should generally generate and manage unique external IDs for customers.</p><h3>48. Web Identity Federation</h3><p>Suppose you’re building a mobile application.</p><p>Users sign in with an identity provider.</p><p>Your mobile app needs temporary AWS access.</p><p>Should you put this inside the APK?</p><pre>AWS_ACCESS_KEY_ID</pre><pre>AWS_SECRET_ACCESS_KEY</pre><p>Absolutely not.</p><p>Those credentials could be extracted.</p><p>Instead, AWS supports temporary credentials based on federated identities.</p><h3>49. Federation Concept</h3><pre>User</pre><pre>↓</pre><pre>Identity Provider</pre><pre>↓</pre><pre>Authenticated Identity</pre><pre>↓</pre><pre>AWS Federation / STS</pre><pre>↓</pre><pre>Temporary AWS Credentials</pre><pre>↓</pre><pre>AWS Resources</pre><p>The user doesn’t need a permanent IAM user.</p><h3>50. Common Identity Providers</h3><p>Depending on the architecture, federation can involve:</p><pre>OpenID Connect (OIDC)</pre><pre>SAML</pre><pre>Corporate identity providers</pre><pre>Amazon Cognito</pre><pre>IAM Identity Center</pre><p>For application-development exam scenarios, Cognito and web identity federation are particularly important.</p><p>We’ll cover Cognito separately.</p><h3>51. AssumeRoleWithWebIdentity</h3><p>STS supports scenarios where web identity tokens can be exchanged for temporary AWS credentials.</p><p>Conceptually:</p><pre>Application</pre><pre>↓</pre><pre>OIDC Identity Provider</pre><pre>↓</pre><pre>Identity Token</pre><pre>↓</pre><pre>STS</pre><pre>↓</pre><pre>Temporary AWS Credentials</pre><p>This is important for modern workloads as well.</p><h3>52. Kubernetes / EKS Connection</h3><p>Even though EKS isn’t the center of DVA-C02, understanding the pattern helps.</p><p>A Kubernetes workload shouldn’t share the EC2 node’s giant permission set.</p><p>Instead, workloads can obtain AWS permissions associated with their workload identity.</p><p>Conceptually:</p><pre>Pod</pre><pre>↓</pre><pre>Workload Identity</pre><pre>↓</pre><pre>STS / AWS credential mechanism</pre><pre>↓</pre><pre>Temporary credentials</pre><pre>↓</pre><pre>S3 / DynamoDB / etc.</pre><p>Again the same AWS philosophy:</p><pre>NO hardcoded credentials</pre><pre>USE workload identity</pre><pre>USE temporary credentials</pre><h3>53. Service-Linked Roles</h3><p>You’ll also encounter: Service-Linked Roles</p><p>These are IAM roles linked directly to specific AWS services.</p><p>They’re predefined by the service and include permissions that the service needs to perform actions on your behalf.</p><p>Examples might involve services that need to:</p><pre>Manage infrastructure</pre><pre>Create resources</pre><pre>Configure networking</pre><pre>Write logs</pre><p>The important distinction:</p><pre>SERVICE ROLE</pre><pre>Role you configure/use for a service.<br></pre><pre>SERVICE-LINKED ROLE</pre><pre>Special role tied directly to an AWS service.</pre><h3>54. PassRole — Extremely Important</h3><p>Now for a DVA-C02 concept that causes plenty of confusion:</p><pre>iam:PassRole</pre><p>Suppose Hari creates a Lambda function.</p><p>He tells AWS:</p><pre>Create Lambda and give it:</pre><pre>LambdaExecutionRole</pre><p>Hari isn’t assuming that role himself.</p><p>He’s telling Lambda:</p><blockquote><em>Use this role.</em></blockquote><p>AWS needs to verify Hari is allowed to pass that role to Lambda.</p><p>That’s:</p><pre>iam:PassRole</pre><h3>55. PassRole Architecture</h3><pre>Developer</pre><pre>   │ Create Lambda<br>   │ and assign Role X<br>   ▼</pre><pre>AWS Lambda</pre><pre>   │<br>   ▼</pre><pre>Role X</pre><p>Developer needs relevant permissions such as:</p><pre>lambda:CreateFunction</pre><p>and:</p><pre>iam:PassRole</pre><p>for the role being assigned.</p><h3>56. Why PassRole Exists</h3><p>Imagine there were no iam:PassRole protection.</p><p>A developer with permission to create Lambda functions could say:</p><pre>Create Lambda</pre><pre>↓</pre><pre>Attach Administrator Role</pre><pre>↓</pre><pre>Invoke Lambda</pre><pre>↓</pre><pre>Perform admin operations</pre><p>That would enable privilege escalation.</p><p>iam:PassRole helps control which roles users can delegate to AWS services.</p><h3>57. AssumeRole vs PassRole</h3><p>This is an excellent exam comparison.</p><p>AssumeRolePassRoleCaller becomes/uses a role sessionCaller gives a role to an AWS serviceUses STSIAM authorization check during delegationTemporary credentials returned to caller/sessionCaller doesn’t receive role credentialssts:AssumeRoleiam:PassRole</p><p>Memory trick:</p><pre>AssumeRole</pre><pre>&quot;I want to BE this role.&quot;<br></pre><pre>PassRole</pre><pre>&quot;I want THIS SERVICE to USE this role.&quot;</pre><p>Excellent exam rule.</p><h3>58. Real Scenario: Creating Lambda</h3><p>Suppose:</p><pre>Developer</pre><p>needs to create:</p><pre>OrderProcessor Lambda</pre><p>using:</p><pre>OrderProcessorExecutionRole</pre><p>Developer needs permission to:</p><pre>lambda:CreateFunction</pre><p>and permission to pass the execution role:</p><pre>iam:PassRole</pre><p>Then Lambda itself must be trusted by that execution role:</p><pre>lambda.amazonaws.com</pre><pre>↓</pre><pre>sts:AssumeRole</pre><p>Notice the chain:</p><pre>Developer</pre><pre>│<br>│ iam:PassRole<br>▼</pre><pre>Execution Role</pre><pre>▲<br>│ sts:AssumeRole<br>│</pre><pre>Lambda Service</pre><p>Two different permissions solving two different problems.</p><h3>59. Real Production Architecture</h3><p>Imagine we’re building:</p><pre>E-Commerce API</pre><p>Architecture:</p><pre>Client<br>                      │<br>                      ▼<br>                 API Gateway<br>                      │<br>                      ▼<br>                   Lambda<br>                      │<br>              Execution Role<br>                 /         \<br>                ▼           ▼<br>          DynamoDB         S3<br>              │<br>              ▼<br>          EventBridge</pre><p>Lambda execution role might allow:</p><pre>dynamodb:GetItem<br>dynamodb:PutItem</pre><pre>s3:PutObject</pre><pre>events:PutEvents</pre><p>That’s it.</p><p>It should NOT automatically have:</p><pre>iam:*</pre><pre>ec2:*</pre><pre>s3:*</pre><pre>dynamodb:*</pre><p>Least privilege still applies.</p><h3>60. CloudWatch Logging Example</h3><p>Lambda commonly needs to write logs.</p><p>Its execution role therefore needs permissions for CloudWatch Logs.</p><p>You’ll commonly see AWS-managed permissions such as those provided by:</p><pre>AWSLambdaBasicExecutionRole</pre><p>which allow Lambda to write logs.</p><p>The conceptual architecture:</p><pre>Lambda</pre><pre>↓</pre><pre>Execution Role</pre><pre>↓</pre><pre>CloudWatch Logs</pre><p>If logging permissions are missing:</p><pre>Function might execute</pre><pre>but</pre><pre>logs cannot be written properly</pre><p>This is a useful troubleshooting scenario.</p><h3>61. AWS CLI — Create a Role</h3><p>First create a trust policy:</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;Principal&quot;: {<br>        &quot;Service&quot;: &quot;lambda.amazonaws.com&quot;<br>      },<br>      &quot;Action&quot;: &quot;sts:AssumeRole&quot;<br>    }<br>  ]<br>}</pre><p>Save as:</p><pre>trust-policy.json</pre><p>Create role:</p><pre>aws iam create-role \<br>  --role-name OrderProcessorRole \<br>  --assume-role-policy-document file://trust-policy.json</pre><h3>62. Attach Permission Policy</h3><p>For example:</p><pre>aws iam attach-role-policy \<br>  --role-name OrderProcessorRole \<br>  --policy-arn arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole</pre><p>Now:</p><pre>Trust Policy</pre><pre>Lambda can assume<br></pre><pre>Permission Policy</pre><pre>Role can write logs</pre><p>Again:</p><p>Two different jobs.</p><h3>63. Inspect Role</h3><pre>aws iam get-role \<br>  --role-name OrderProcessorRole</pre><p>List attached policies:</p><pre>aws iam list-attached-role-policies \<br>  --role-name OrderProcessorRole</pre><h3>64. AWS SDK — AssumeRole</h3><p>Node.js example using AWS SDK v3:</p><pre>import {<br>  STSClient,<br>  AssumeRoleCommand<br>} from &quot;@aws-sdk/client-sts&quot;;</pre><pre>const sts = new STSClient({<br>  region: &quot;ap-south-1&quot;<br>});</pre><pre>async function assumeProductionRole() {<br>  const response = await sts.send(<br>    new AssumeRoleCommand({<br>      RoleArn:<br>        &quot;arn:aws:iam::123456789012:role/ProductionReadOnly&quot;,<br>      RoleSessionName: &quot;developer-session&quot;<br>    })<br>  );</pre><pre>  return response.Credentials;<br>}</pre><pre>assumeProductionRole()<br>  .then((credentials) =&gt; {<br>    console.log(<br>      &quot;Temporary credentials expire at:&quot;,<br>      credentials?.Expiration<br>    );<br>  })<br>  .catch(console.error);</pre><p>In production, avoid logging credential values themselves.</p><h3>65. AWS SDK Credential Provider Chain</h3><p>This deserves special attention as a developer.</p><p>When you create:</p><pre>const client = new S3Client({<br>  region: &quot;ap-south-1&quot;<br>});</pre><p>you haven’t explicitly provided credentials.</p><p>So how does the SDK authenticate?</p><p>It searches supported credential sources according to its credential provider behavior.</p><p>Possible sources can include:</p><pre>Explicit configuration</pre><pre>Environment variables</pre><pre>Shared credentials/config files</pre><pre>IAM Identity Center credentials</pre><pre>Web identity credentials</pre><pre>ECS container credentials</pre><pre>EC2 instance metadata credentials</pre><p>The exact order varies by SDK/language/version.</p><p>For the exam, understand the core idea:</p><blockquote><em>AWS SDKs can automatically obtain credentials from the workload environment, allowing applications to use IAM roles without hardcoded secrets.</em></blockquote><h3>66. Local Development vs Production</h3><p>Local machine:</p><pre>Developer Laptop</pre><pre>↓</pre><pre>AWS CLI / Identity Center / local credentials</pre><pre>↓</pre><pre>AWS SDK</pre><p>Production EC2:</p><pre>EC2</pre><pre>↓</pre><pre>Instance Role</pre><pre>↓</pre><pre>Temporary Credentials</pre><p>Lambda:</p><pre>Lambda</pre><pre>↓</pre><pre>Execution Role</pre><pre>↓</pre><pre>Temporary Credentials</pre><p>ECS:</p><pre>Container</pre><pre>↓</pre><pre>Task Role</pre><pre>↓</pre><pre>Temporary Credentials</pre><p>Same application code.</p><p>Different credential source.</p><p>That’s a very powerful design.</p><h3>67. Never Put Credentials in Git</h3><p>Bad:</p><pre>const credentials = {<br>  accessKeyId: &quot;AKIA...&quot;,<br>  secretAccessKey: &quot;...&quot;<br>};</pre><p>Also bad:</p><pre>config.js<br>credentials.json<br>production-secrets.txt</pre><p>And dangerous:</p><pre>.env</pre><p>if accidentally committed.</p><p>For AWS workloads:</p><pre>IAM Role<br>+<br>Temporary Credentials</pre><p>is usually the right answer.</p><h3>68. What About Secrets Manager?</h3><p>Important distinction.</p><p>You may think:</p><blockquote><em>Why not store AWS access keys inside Secrets Manager?</em></blockquote><p>That’s better than hardcoding them, but for AWS workload authentication it’s usually solving the wrong problem.</p><p>Instead of:</p><pre>Application</pre><pre>↓</pre><pre>Secrets Manager</pre><pre>↓</pre><pre>Retrieve AWS Access Key</pre><pre>↓</pre><pre>Use AWS</pre><p>prefer:</p><pre>Application</pre><pre>↓</pre><pre>IAM Role</pre><pre>↓</pre><pre>Temporary Credentials</pre><pre>↓</pre><pre>AWS</pre><p>Secrets Manager is excellent for things like:</p><pre>Database passwords</pre><pre>Third-party API keys</pre><pre>Application secrets</pre><p>But AWS-to-AWS workload authentication should generally use IAM roles.</p><h3>69. IAM Role vs Secrets Manager</h3><pre>Need AWS permissions?</pre><pre>IAM ROLE<br></pre><pre>Need database password?</pre><pre>SECRETS MANAGER<br></pre><pre>Need third-party Stripe/API secret?</pre><pre>SECRETS MANAGER<br></pre><pre>Need Lambda to access S3?</pre><pre>IAM ROLE</pre><p>This distinction can eliminate several exam distractors.</p><h3>70. Temporary Credentials vs Access Keys</h3><pre>┌────────────────────────────┬──────────────────────────┬──────────────────────────┐<br>│ Feature                    │ IAM User Access Keys     │ Role Credentials         │<br>├────────────────────────────┼──────────────────────────┼──────────────────────────┤<br>│ Long-lived                 │ Usually                  │ ❌                       │<br>│ Automatically expire       │ ❌                       │ ✅                       │<br>│ Session token              │ ❌ normally              │ ✅                       │<br>│ Rotation managed           │ Manual / separately      │ Typically automatic      │<br>│ automatically              │                          │                          │<br>│ Good for AWS workloads     │ Usually avoid            │ ✅                       │<br>│ Risk if leaked             │ Higher persistence       │ Limited lifetime         │<br>└────────────────────────────┴──────────────────────────┴──────────────────────────┘</pre><h3>71. Common Exam Scenario #1</h3><p>An application runs on EC2 and needs access to S3.</p><p>AWS asks:</p><blockquote><em>What is the MOST secure solution?</em></blockquote><p>Options might include:</p><p>A. Hardcode credentials.</p><p>B. Store credentials in source code environment configuration.</p><p>C. Create an IAM user and copy keys to EC2.</p><p>D. Attach an IAM role to the EC2 instance.</p><p>Answer:</p><h3>D</h3><p>Use an IAM role.</p><h3>72. Common Exam Scenario #2</h3><p>Lambda needs DynamoDB access.</p><p>Answer:</p><pre>Add required DynamoDB permissions</pre><pre>to</pre><pre>Lambda Execution Role</pre><p>Not:</p><pre>Create IAM user</pre><pre>Generate access keys</pre><pre>Store them inside Lambda</pre><h3>73. Common Exam Scenario #3</h3><p>S3 needs to invoke Lambda.</p><p>Don’t modify Lambda’s execution role expecting it to solve incoming invocation.</p><p>Instead:</p><pre>Lambda Resource-Based Policy</pre><pre>allows</pre><pre>S3</pre><pre>lambda:InvokeFunction</pre><p>Direction matters.</p><h3>74. Common Exam Scenario #4</h3><p>Developer needs temporary access to another AWS account.</p><p>Think:</p><pre>Cross-Account IAM Role</pre><pre>+</pre><pre>STS AssumeRole</pre><p>Not duplicate IAM users.</p><h3>75. Common Exam Scenario #5</h3><p>Third-party SaaS needs access to your AWS account.</p><p>Think:</p><pre>Cross-Account Role</pre><pre>+</pre><pre>External ID</pre><p>especially when confused-deputy protection is mentioned.</p><h3>76. Common Exam Scenario #6</h3><p>Developer needs to assign an existing IAM role to a new Lambda function.</p><p>Think:</p><pre>iam:PassRole</pre><p>Not:</p><pre>sts:AssumeRole</pre><p>The developer isn’t becoming the execution role.</p><p>They’re passing it to Lambda.</p><h3>77. Common Exam Scenario #7</h3><p>ECS application needs DynamoDB.</p><p>Use:</p><pre>ECS Task Role</pre><p>not:</p><pre>Task Execution Role</pre><p>Task execution role is for ECS infrastructure activities.</p><h3>78. Troubleshooting AccessDenied With Roles</h3><p>Suppose Lambda gets:</p><pre>AccessDeniedException:<br>User is not authorized to perform dynamodb:PutItem</pre><p>Debug:</p><pre>1. Identify Lambda execution role.</pre><pre>2. Inspect role permission policies.</pre><pre>3. Check dynamodb:PutItem.</pre><pre>4. Check table ARN.</pre><pre>5. Check Conditions.</pre><pre>6. Check explicit Deny.</pre><pre>7. Check permissions boundary.</pre><pre>8. Check organization SCP.</pre><pre>9. Check resource-specific controls where relevant.</pre><p>Don’t immediately attach:</p><pre>AdministratorAccess</pre><p>That’s debugging with a chainsaw.</p><h3>79. Trust Policy Troubleshooting</h3><p>Suppose you see:</p><pre>AccessDenied:<br>not authorized to perform sts:AssumeRole</pre><p>Now investigate:</p><pre>Does caller have permission to assume?</pre><pre>Does role trust caller?</pre><pre>Do trust-policy conditions match?</pre><pre>Is an SCP blocking STS?</pre><pre>Is a permissions boundary involved?</pre><pre>Is the role ARN correct?</pre><p>Remember:</p><pre>Permission Policy problem</pre><pre>≠</pre><pre>Trust Policy problem</pre><h3>80. CloudTrail and AssumeRole</h3><p>Role assumptions can be recorded through AWS CloudTrail.</p><p>That means security teams can investigate:</p><pre>Who assumed role?</pre><pre>When?</pre><pre>From where?</pre><pre>Which role?</pre><pre>What happened afterward?</pre><p>Temporary credentials don’t mean anonymous credentials.</p><p>Role sessions remain auditable.</p><h3>81. Source Identity</h3><p>In more advanced environments, AWS supports mechanisms such as source identity to help administrators trace role sessions back to the original identity.</p><p>Conceptually:</p><pre>Original User</pre><pre>↓</pre><pre>Assume Role</pre><pre>↓</pre><pre>Assume Another Role</pre><pre>↓</pre><pre>Perform Action</pre><p>Without good session attribution, investigation can become difficult.</p><p>AWS provides features to improve traceability across role assumptions.</p><p>For DVA-C02, simply understand that assumed roles remain traceable and auditable.</p><h3>82. Role Tags and Session Tags</h3><p>IAM roles and STS sessions can also use tags.</p><p>Example:</p><pre>Department = Engineering</pre><pre>Environment = Production</pre><pre>Project = Payments</pre><p>Policies can evaluate these attributes.</p><p>This enables: <strong>ABAC (</strong>Attribute-Based Access Control).</p><p>Example concept:</p><pre>Developer</pre><pre>Project = Payments</pre><pre>↓</pre><pre>Can access resources where</pre><pre>Project = Payments</pre><p>This becomes useful at scale because you don’t need separate policies for every resource.</p><h3>83. RBAC vs ABAC</h3><p>Traditional role-based model:</p><pre>DeveloperRole</pre><pre>↓</pre><pre>PaymentsPolicy</pre><p>ABAC-style model:</p><pre>Principal Tag</pre><pre>Project = Payments</pre><pre>        ↓</pre><pre>Resource Tag</pre><pre>Project = Payments</pre><pre>        ↓</pre><pre>ALLOW</pre><p>For DVA-C02, know that IAM Conditions and tags can implement attribute-based permissions.</p><h3>84. Production Architecture — Full Example</h3><p>Imagine we’re building a payment platform.</p><pre>                        Internet</pre><pre>                            │</pre><pre>                            ▼</pre><pre>                       API Gateway</pre><pre>                            │</pre><pre>                            ▼</pre><pre>                      PaymentLambda</pre><pre>                            │</pre><pre>                     Execution Role</pre><pre>                    /       |       \</pre><pre>                   /        |        \</pre><pre>                  ▼         ▼         ▼</pre><pre>             DynamoDB      SQS     Secrets Manager</pre><pre>                             │</pre><pre>                             ▼</pre><pre>                      Worker Lambda</pre><pre>                             │</pre><pre>                      Execution Role</pre><pre>                             │</pre><pre>                             ▼</pre><pre>                        External API</pre><p>Notice:</p><p>No AWS access keys.</p><p>Each Lambda gets its own role.</p><p>Payment Lambda might have:</p><pre>dynamodb:PutItem</pre><pre>sqs:SendMessage</pre><pre>secretsmanager:GetSecretValue</pre><p>Worker Lambda might have completely different permissions.</p><p>That’s least privilege at the workload level.</p><h3>85. Bad Architecture</h3><pre>All Lambdas</pre><pre>↓</pre><pre>One Shared Admin Role</pre><pre>↓</pre><pre>Everything</pre><p>Easy? Yes.</p><p>Secure? No.</p><p>One compromised Lambda now potentially exposes the entire AWS environment.</p><h3>86. Better Architecture</h3><pre>PaymentLambda<br>     ↓<br>PaymentRole<br>     ↓<br>PaymentsTable<br></pre><pre>ImageLambda<br>     ↓<br>ImageRole<br>     ↓<br>ImagesBucket<br></pre><pre>EmailLambda<br>     ↓<br>EmailRole<br>     ↓<br>SNS</pre><p>Each workload gets only what it needs.</p><h3>87. DVA-C02 Decision Tree</h3><p>When you see:</p><pre>&quot;Application running on EC2 needs AWS access&quot;</pre><p>Think:</p><pre>EC2 IAM Role</pre><p>When you see:</p><pre>&quot;Lambda needs AWS access&quot;</pre><p>Think:</p><pre>Lambda Execution Role</pre><p>When you see:</p><pre>&quot;Application inside ECS needs AWS access&quot;</pre><p>Think:</p><pre>ECS Task Role</pre><p>When you see:</p><pre>&quot;ECS needs ECR/logging permissions&quot;</pre><p>Think:</p><pre>Task Execution Role</pre><p>When you see:</p><pre>&quot;Temporary cross-account access&quot;</pre><p>Think:</p><pre>STS AssumeRole</pre><p>When you see:</p><pre>&quot;Third-party SaaS cross-account access&quot;</pre><p>Think:</p><pre>External ID</pre><p>When you see:</p><pre>&quot;Give role to AWS service&quot;</pre><p>Think:</p><pre>iam:PassRole</pre><p>When you see:</p><pre>&quot;Who may assume role?&quot;</pre><p>Think:</p><pre>Trust Policy</pre><p>When you see:</p><pre>&quot;What can assumed role do?&quot;</pre><p>Think:</p><pre>Permission Policy</pre><h3>88. The Most Important Diagram From Day 4</h3><p>Remember this architecture:</p><pre>                  PRINCIPAL</pre><pre>                     │</pre><pre>                     │ sts:AssumeRole</pre><pre>                     ▼</pre><pre>                  AWS STS</pre><pre>                     │</pre><pre>                     ▼</pre><pre>              Temporary Credentials</pre><pre>        AccessKeyId<br>        SecretAccessKey<br>        SessionToken<br>        Expiration</pre><pre>                     │</pre><pre>                     ▼</pre><pre>                 ROLE SESSION</pre><pre>                     │</pre><pre>                     ▼</pre><pre>               AWS RESOURCES</pre><p>And before STS creates that session:</p><pre>WHO CAN ASSUME?</pre><pre>↓</pre><pre>Trust / caller authorization<br></pre><pre>WHAT CAN ROLE DO?</pre><pre>↓</pre><pre>Permission Policies</pre><p>That’s the heart of IAM roles.</p><h3>89. IAM User vs IAM Role vs Policy</h3><p>Don’t mix these concepts.</p><pre>USER</pre><pre>Persistent identity<br></pre><pre>ROLE</pre><pre>Assumable identity<br></pre><pre>POLICY</pre><pre>Permissions document<br></pre><pre>STS</pre><pre>Issues temporary credentials</pre><p>One-line memory model:</p><pre>USER = WHO YOU ARE</pre><pre>ROLE = WHO YOU CAN TEMPORARILY BECOME</pre><pre>POLICY = WHAT YOU CAN DO</pre><pre>STS = TEMPORARY CREDENTIAL MACHINE</pre><h3>90. AssumeRole vs PassRole vs Execution Role</h3><p>This is worth revising repeatedly.</p><pre>AssumeRole:</pre><pre>Developer → Role</pre><pre>&quot;I become/use this role session.&quot;<br></pre><pre>PassRole: </pre><pre>Developer → AWS Service → Role</pre><pre>&quot;Give this role to that service.&quot;</pre><pre>Execution Role:</pre><pre>Lambda → Role → AWS resources</pre><pre>&quot;This is what Lambda may do while executing.&quot;</pre><h3>🧠 Memory Tricks</h3><h3>IAM Role</h3><pre>Temporary Hat</pre><pre>Put it on.</pre><pre>Get permissions.</pre><pre>Take it off / session expires.</pre><h3>STS</h3><pre>Security Token Service</pre><pre>=</pre><pre>Temporary Credential Factory</pre><h3>Trust Policy</h3><pre>WHO CAN ENTER?</pre><h3>Permission Policy</h3><pre>WHAT CAN THEY DO AFTER ENTERING?</pre><h3>AssumeRole</h3><pre>I USE/BECOME THE ROLE.</pre><h3>PassRole</h3><pre>I GIVE THE ROLE TO A SERVICE.</pre><h3>External ID</h3><pre>Third Party?</pre><pre>Confused Deputy?</pre><pre>Think External ID.</pre><h3>ECS</h3><pre>Task Role</pre><pre>= App permissions<br></pre><pre>Task Execution Role</pre><pre>= ECS infrastructure permissions</pre><h3>⚠️ Exam Traps</h3><h3>Trap 1</h3><p>Application running on EC2 needs S3.</p><p>Don’t choose:</p><pre>IAM User + Access Keys</pre><p>Choose:</p><pre>IAM Role</pre><h3>Trap 2</h3><p>Lambda can’t access DynamoDB.</p><p>Don’t change Lambda resource-based policy.</p><p>Check:</p><pre>Execution Role</pre><h3>Trap 3</h3><p>S3 can’t invoke Lambda.</p><p>Don’t modify execution-role DynamoDB/S3 permissions expecting them to fix incoming invocation.</p><p>Check:</p><pre>Lambda Resource-Based Policy</pre><h3>Trap 4</h3><p>User needs to become another role.</p><pre>sts:AssumeRole</pre><h3>Trap 5</h3><p>User needs Lambda to use a role.</p><pre>iam:PassRole</pre><h3>Trap 6</h3><p>Permissions boundary says Lambda allowed.</p><p>Identity policy doesn’t allow Lambda.</p><p>Result:</p><pre>DENIED</pre><p>Boundaries don’t grant.</p><h3>Trap 7</h3><p>Role trusts Account A.</p><p>Therefore everyone in Account A can assume it?</p><p>Not automatically.</p><p>Caller-side authorization still matters.</p><h3>Trap 8</h3><p>Need AWS credentials inside Lambda.</p><p>Don’t store AWS keys in Secrets Manager as the default solution.</p><p>Use:</p><pre>Execution Role</pre><h3>🔥 2-Minute Revision Cheat Sheet</h3><pre>IAM ROLE<br>========</pre><pre>Assumable AWS identity.</pre><pre>No normal long-lived credentials.</pre><pre>Used with temporary credentials.<br></pre><pre>STS<br>===</pre><pre>Security Token Service</pre><pre>Issues:</pre><pre>AccessKeyId<br>SecretAccessKey<br>SessionToken<br>Expiration<br></pre><pre>TRUST POLICY<br>============</pre><pre>WHO can assume role?<br></pre><pre>PERMISSION POLICY<br>=================</pre><pre>WHAT can role do?<br></pre><pre>LAMBDA<br>======</pre><pre>Execution Role<br></pre><pre>EC2<br>===</pre><pre>IAM Role<br>+<br>Instance Profile<br></pre><pre>ECS<br>===</pre><pre>Task Role<br>→ Application permissions</pre><pre>Task Execution Role<br>→ ECS infrastructure permissions<br></pre><pre>CROSS ACCOUNT<br>=============</pre><pre>Account A</pre><pre>↓</pre><pre>sts:AssumeRole</pre><pre>↓</pre><pre>Role in Account B<br></pre><pre>THIRD PARTY<br>===========</pre><pre>Cross-account role</pre><pre>+</pre><pre>External ID<br></pre><pre>ASSUME ROLE<br>===========</pre><pre>&quot;I want to use/be this role.&quot;<br></pre><pre>PASS ROLE<br>=========</pre><pre>&quot;I want AWS service to use this role.&quot;<br></pre><pre>BEST PRACTICE<br>=============</pre><pre>Temporary credentials</pre><pre>&gt;</pre><pre>Long-lived access keys<br></pre><pre>NEVER DEFAULT TO<br>================</pre><pre>Hardcoded AWS credentials</pre><h3>📝 Practice Questions</h3><h3>Question 1</h3><p>An application running on EC2 needs to upload objects to S3.</p><p>What is the most secure approach?</p><p>A. Hardcode access keys.</p><p>B. Store IAM user credentials in .env.</p><p>C. Attach an IAM role to EC2 with s3:PutObject.</p><p>D. Store IAM user credentials in S3.</p><h3>Answer : <strong>C</strong></h3><p>Use an IAM role associated with the EC2 instance.</p><p>The application can obtain temporary credentials automatically.</p><h3>Question 2</h3><p>A Lambda function needs to write records into DynamoDB.</p><p>Where should permission be granted?</p><p>A. Lambda resource-based policy.</p><p>B. Lambda execution role.</p><p>C. API Gateway execution role.</p><p>D. IAM user.</p><h3>Answer : <strong>B — Lambda Execution Role</strong></h3><p>The Lambda function is making the DynamoDB API call.</p><h3>Question 3</h3><p>S3 must invoke Lambda after an object upload.</p><p>Where should permission allowing the invocation exist?</p><h3>Answer</h3><p>Lambda’s resource-based policy can allow the S3 service to invoke the function.</p><p>Remember direction:</p><pre>S3 → Lambda</pre><h3>Question 4</h3><p>A developer needs temporary read-only access to a production AWS account.</p><p>Best solution?</p><p>A. Create another IAM user.</p><p>B. Share root credentials.</p><p>C. Create cross-account IAM role and use STS.</p><p>D. Copy production access keys.</p><h3>Answer :<strong>C</strong></h3><p>Cross-account role + STS.</p><h3>Question 5</h3><p>A third-party monitoring company needs access to your AWS account and manages thousands of customers.</p><p>What IAM mechanism helps protect against the confused deputy problem?</p><h3>Answer : <strong>External ID</strong></h3><h3>Question 6</h3><p>A developer creates a Lambda function and assigns an execution role.</p><p>Which additional IAM permission may the developer need for assigning that role?</p><h3>Answer</h3><pre>iam:PassRole</pre><h3>Question 7</h3><p>What’s the difference between:</p><pre>sts:AssumeRole</pre><p>and:</p><pre>iam:PassRole</pre><h3>Answer</h3><p>AssumeRole means the caller obtains a temporary role session.</p><p>PassRole means the caller delegates a role to an AWS service.</p><h3>Question 8</h3><p>An application inside an ECS task needs DynamoDB access.</p><p>Which role should contain DynamoDB permissions?</p><p>A. Task Execution Role.</p><p>B. Task Role.</p><h3>Answer: <strong>B — Task Role</strong></h3><p>The application itself needs DynamoDB.</p><h3>Question 9</h3><p>ECS Fargate needs to pull an image from ECR.</p><p>Which role is relevant?</p><h3>Answer : <strong>Task Execution Role</strong></h3><p>The ECS infrastructure needs the permission to start the task.</p><h3>Question 10</h3><p>What four pieces of information should you associate with temporary STS credentials?</p><h3>Answer</h3><pre>Access Key ID</pre><pre>Secret Access Key</pre><pre>Session Token</pre><pre>Expiration</pre><h3>Question 11</h3><p>What does a role’s trust policy control?</p><h3>Answer</h3><p>Who or what is allowed to assume the role.</p><h3>Question 12</h3><p>What does a role’s permission policy control?</p><h3>Answer</h3><p>What actions the assumed role can perform against AWS resources.</p><h3>Question 13 — Harder</h3><p>An IAM user has administrator permissions.</p><p>The user assumes a role that only allows:</p><pre>s3:GetObject</pre><p>Can the resulting role session create EC2 instances simply because the original user was an administrator?</p><h3>Answer : No.</h3><p>After assuming the role, requests made using the role session are evaluated against the role session’s effective permissions.</p><p>The user’s original administrator permissions aren’t simply merged into the role.</p><h3>Question 14 — Exam Style</h3><p>A developer stores AWS credentials inside Lambda environment variables so that Lambda can access DynamoDB.</p><p>The security team wants to eliminate long-lived credentials with the least operational overhead.</p><p>What should be done?</p><h3>Answer</h3><p>Create/configure a Lambda execution role with the required DynamoDB permissions and remove the hardcoded credentials.</p><p>Lambda obtains temporary credentials for its execution role automatically.</p><h3>Question 15 — Tricky</h3><p>A developer can create Lambda functions but receives an authorization error when specifying an existing execution role.</p><p>The role itself correctly trusts Lambda.</p><p>What permission might the developer be missing?</p><h3>Answer</h3><pre>iam:PassRole</pre><p>The developer isn’t trying to assume the role.</p><p>They’re attempting to pass it to Lambda.</p><h3>🎯 Day 4 Key Takeaways</h3><p>The most important idea from today is:</p><blockquote><strong><em>Don’t give applications permanent AWS credentials when AWS can give them temporary credentials through a role.</em></strong></blockquote><p>IAM roles solve the problem of securely delegating AWS permissions.</p><p>The four concepts you absolutely need to distinguish are:</p><pre>IAM Role<br>↓<br>Assumable identity<br></pre><pre>Trust Policy<br>↓<br>Who can assume it?<br></pre><pre>Permission Policy<br>↓<br>What can it do?<br></pre><pre>STS<br>↓<br>Issues temporary credentials</pre><p>For AWS workloads:</p><pre>Lambda<br>→ Execution Role<br></pre><pre>EC2<br>→ Instance Role<br></pre><pre>ECS Application<br>→ Task Role<br></pre><pre>ECS Infrastructure<br>→ Task Execution Role</pre><p>For humans/accounts:</p><pre>Cross-account access<br>→ AssumeRole<br></pre><pre>Third-party access<br>→ Role + External ID<br></pre><pre>Give role to AWS service<br>→ PassRole</pre><p>And perhaps the most useful security principle from the entire IAM section:</p><pre>Hardcoded credentials</pre><pre>        ❌</pre><pre>Long-lived credentials</pre><pre>        ↓</pre><pre>Avoid where possible<br></pre><pre>IAM Role</pre><pre>        +</pre><pre>Temporary Credentials</pre><pre>        +</pre><pre>Least Privilege</pre><pre>        ✅</pre><p>Once this becomes your default mental model, many AWS security questions stop being difficult.</p><h3>🚀 Day 5 Preview — IAM for Developers &amp; Real DVA-C02 Scenarios</h3><p>We now understand:</p><pre>Day 2<br>Identity fundamentals</pre><pre>↓</pre><pre>Day 3<br>Policy evaluation</pre><pre>↓</pre><pre>Day 4<br>Roles + STS</pre><p>Day 5 will combine everything.</p><p>We’ll cover:</p><pre>AWS CLI authentication</pre><pre>AWS SDK credential provider chains</pre><pre>AWS CLI profiles</pre><pre>Named profiles</pre><pre>Environment variables</pre><pre>IAM Identity Center concepts</pre><pre>Credential precedence</pre><pre>AWS Signature Version 4</pre><pre>How AWS API requests are signed</pre><pre>Presigned URLs</pre><pre>Temporary credentials</pre><pre>Credential rotation</pre><pre>Secrets vs credentials</pre><pre>AccessDenied debugging</pre><pre>CloudTrail for IAM debugging</pre><pre>Policy Simulator concepts</pre><pre>IAM Access Analyzer</pre><pre>Cross-account troubleshooting</pre><pre>Lambda permission debugging</pre><pre>EC2 permission debugging</pre><pre>ECS permission debugging</pre><pre>Common DVA-C02 IAM scenarios</pre><pre>30+ IAM exam questions</pre><p>Most importantly, we’ll build a complete:</p><h3>“Which IAM Solution Should I Choose?” Decision Tree</h3><p>so that when the exam says:</p><blockquote><em>EC2 application needs S3…</em></blockquote><p>you immediately think:</p><pre>Instance Role</pre><p>When it says:</p><blockquote><em>Lambda needs DynamoDB…</em></blockquote><p>you immediately think:</p><pre>Execution Role</pre><p>When it says:</p><blockquote><em>Another AWS account…</em></blockquote><p>you immediately think:</p><pre>AssumeRole</pre><p>And whjen it says:</p><blockquote><em>Temporary credentials…</em></blockquote><p>you immediately think:</p><pre>STS</pre><p>Day 5 will turn the IAM concepts from Days 2–4 into <strong>exam-solving instincts</strong>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=73d28e4b792a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Day 3 — IAM Policies Deep Dive: How AWS Actually Decides “Allow” or “Deny”]]></title>
            <link>https://hari27om.medium.com/day-3-iam-policies-deep-dive-how-aws-actually-decides-allow-or-deny-27eeff4a27b1?source=rss-403dd53dc117------2</link>
            <guid isPermaLink="false">https://medium.com/p/27eeff4a27b1</guid>
            <dc:creator><![CDATA[Hari Om]]></dc:creator>
            <pubDate>Wed, 29 Jul 2026 09:30:28 GMT</pubDate>
            <atom:updated>2026-07-29T09:30:28.664Z</atom:updated>
            <content:encoded><![CDATA[<p>In Day 2, We learned the fundamentals of AWS Identity and Access Management:</p><ul><li>Users</li><li>Groups</li><li>Authentication</li><li>Authorization</li><li>Root user</li><li>MFA</li><li>Least privilege</li></ul><p>But there was one major question left unanswered:</p><blockquote><em>How does AWS actually decide what an authenticated identity can do?</em></blockquote><p>The answer is:</p><p><strong>IAM Policies.</strong></p><p>Today we’re going deep into them.</p><p>By the end of this chapter, the goal isn’t simply to know what an IAM policy is.</p><p>The goal is to look at a policy like this:</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;: &quot;s3:GetObject&quot;,<br>      &quot;Resource&quot;: &quot;arn:aws:s3:::company-documents/*&quot;<br>    }<br>  ]<br>}</pre><p>and immediately understand:</p><blockquote><em>“This allows reading objects from the </em><em>company-documents S3 bucket, but doesn&#39;t allow uploading, deleting, or managing the bucket itself.&quot;</em></blockquote><p>That ability is extremely important for the DVA-C02 exam.</p><h3>1. What Is an IAM Policy?</h3><p>An IAM policy is a JSON document that defines permissions.</p><p>In simple terms:</p><pre>IAM Policy</pre><pre>  ↓</pre><pre>Defines</pre><pre>WHO / WHAT</pre><pre>can perform</pre><pre>WHICH ACTION</pre><pre>on</pre><pre>WHICH RESOURCE</pre><pre>under</pre><pre>WHICH CONDITIONS</pre><p>For identity-based policies, the identity the policy is attached to provides the “who.”</p><p>For resource-based policies, the policy can explicitly contain a Principal.</p><p>We’ll get to that distinction later.</p><h3>2. IAM Is Fundamentally an API Authorization System</h3><p>This is one of the most useful mental models for developers.</p><p>When you click this in the AWS Console:</p><pre>Delete Object</pre><p>AWS isn’t performing some magical console operation.</p><p>Behind the scenes, an AWS API operation is being requested.</p><p>Similarly:</p><pre>aws s3 rm s3://production/file.pdf</pre><p>eventually results in an API request against Amazon S3.</p><p>And code like:</p><pre>await s3.send(<br>    new DeleteObjectCommand({<br>        Bucket: &quot;production&quot;,<br>        Key: &quot;file.pdf&quot;<br>    })<br>);</pre><p>also results in an AWS API request.</p><p>Different interfaces:</p><pre>AWS Console<br>AWS CLI<br>AWS SDK<br>REST/API<br>CloudFormation<br>Terraform</pre><p>but eventually AWS needs to authorize API operations.</p><p>That means IAM permissions frequently look like:</p><pre>s3:GetObject</pre><pre>s3:PutObject</pre><pre>s3:DeleteObject</pre><pre>lambda:InvokeFunction</pre><pre>dynamodb:GetItem</pre><pre>dynamodb:PutItem</pre><pre>secretsmanager:GetSecretValue</pre><p>Understanding this makes IAM much easier.</p><h3>3. The Basic Structure of an IAM Policy</h3><p>Consider:</p><pre>{<br>  &quot;Version&quot;: &quot;2012-10-17&quot;,<br>  &quot;Statement&quot;: [<br>    {<br>      &quot;Sid&quot;: &quot;ReadProductionFiles&quot;,<br>      &quot;Effect&quot;: &quot;Allow&quot;,<br>      &quot;Action&quot;: [<br>        &quot;s3:GetObject&quot;<br>      ],<br>      &quot;Resource&quot;: &quot;arn:aws:s3:::production-files/*&quot;<br>    }<br>  ]<br>}</pre><p>Let’s break it apart.</p><pre>Policy<br>│<br>├── Version<br>│<br>└── Statement<br>     │<br>     ├── Sid<br>     ├── Effect<br>     ├── Action<br>     ├── Resource<br>     └── Condition (optional)</pre><p>These elements form the foundation of IAM authorization.</p><h3>4. Version</h3><p>You’ll commonly see:</p><pre>&quot;Version&quot;: &quot;2012-10-17&quot;</pre><p>A beginner might assume:</p><blockquote><em>“This policy was created in 2012.”</em></blockquote><p>No.</p><p>This is the <strong>policy language version</strong>.</p><p>It does NOT represent:</p><ul><li>Policy creation date</li><li>Policy update date</li><li>AWS account creation date</li></ul><p>For modern IAM policies, you’ll normally see:</p><pre>2012-10-17</pre><p>Note : Do not waste time interpreting this as a date associated with the policy itself.</p><h3>5. Statement</h3><p>The real permissions live inside:</p><pre>&quot;Statement&quot;: []</pre><p>A policy can contain one or multiple statements.</p><p>Example:</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;: &quot;s3:GetObject&quot;,<br>      &quot;Resource&quot;: &quot;arn:aws:s3:::my-bucket/*&quot;<br>    },<br>    {<br>      &quot;Effect&quot;: &quot;Allow&quot;,<br>      &quot;Action&quot;: &quot;sqs:SendMessage&quot;,<br>      &quot;Resource&quot;: &quot;arn:aws:sqs:ap-south-1:123456789012:orders&quot;<br>    }<br>  ]<br>}</pre><p>Conceptually:</p><pre>Statement 1<br>    ↓<br>Read objects from S3</pre><pre>Statement 2<br>    ↓<br>Send messages to SQS</pre><h3>6. Sid — Statement ID</h3><p>You may see:</p><pre>&quot;Sid&quot;: &quot;AllowReadFromS3&quot;</pre><p>Sid means:</p><p><strong>Statement ID</strong></p><p>It gives a statement a human-readable identifier.</p><p>Example:</p><pre>{<br>  &quot;Sid&quot;: &quot;AllowUploadImages&quot;,<br>  &quot;Effect&quot;: &quot;Allow&quot;,<br>  &quot;Action&quot;: &quot;s3:PutObject&quot;,<br>  &quot;Resource&quot;: &quot;arn:aws:s3:::images/*&quot;<br>}</pre><p>Sid does not itself grant permission.</p><p>It’s mainly useful for identifying and managing statements.</p><h3>7. Effect</h3><p>This is one of the most important fields.</p><p>There are two possibilities:</p><pre>Allow</pre><pre>Deny</pre><p>Example:</p><pre>&quot;Effect&quot;: &quot;Allow&quot;</pre><p>means:</p><blockquote><em>This statement can grant permission.</em></blockquote><p>While:</p><pre>&quot;Effect&quot;: &quot;Deny&quot;</pre><p>means:</p><blockquote><em>This statement explicitly denies permission.</em></blockquote><p>We’ll soon see why <strong>Deny is extremely powerful</strong>.</p><h3>8. Action</h3><p>Action specifies the AWS API operation affected by the statement.</p><p>Example:</p><pre>&quot;Action&quot;: &quot;s3:GetObject&quot;</pre><p>Break it apart:</p><pre>s3 : GetObject<br>│       │<br>│       └── API operation<br>│<br>└────────── AWS service</pre><p>More examples:</p><pre>lambda:InvokeFunction</pre><pre>dynamodb:GetItem</pre><pre>dynamodb:PutItem</pre><pre>sqs:SendMessage</pre><pre>sns:Publish</pre><pre>secretsmanager:GetSecretValue</pre><p>This naming convention appears everywhere.</p><h3>9. Multiple Actions</h3><p>Instead of one:</p><pre>&quot;Action&quot;: &quot;s3:GetObject&quot;</pre><p>we can specify several:</p><pre>&quot;Action&quot;: [<br>  &quot;s3:GetObject&quot;,<br>  &quot;s3:PutObject&quot;,<br>  &quot;s3:DeleteObject&quot;<br>]</pre><p>That identity could potentially:</p><pre>READ<br>WRITE<br>DELETE</pre><p>objects, subject to the rest of the statement and other applicable policies.</p><h3>10. Wildcards in Actions</h3><p>Here’s where things become dangerous.</p><pre>&quot;Action&quot;: &quot;s3:*&quot;</pre><p>means essentially:</p><pre>All applicable S3 actions</pre><p>Similarly:</p><pre>&quot;Action&quot;: &quot;*&quot;</pre><p>is extremely broad.</p><p>Combined with:</p><pre>&quot;Resource&quot;: &quot;*&quot;</pre><p>you can create enormous permissions.</p><p>Example:</p><pre>{<br>  &quot;Effect&quot;: &quot;Allow&quot;,<br>  &quot;Action&quot;: &quot;*&quot;,<br>  &quot;Resource&quot;: &quot;*&quot;<br>}</pre><p>Conceptually:</p><pre>Allow</pre><pre>EVERY ACTION</pre><pre>on</pre><pre>EVERY RESOURCE</pre><p>This is administrator-style permission.</p><h3>11. Principle of Least Privilege Appears Again</h3><p>Suppose our application only downloads invoices.</p><p>Bad:</p><pre>{<br>  &quot;Effect&quot;: &quot;Allow&quot;,<br>  &quot;Action&quot;: &quot;s3:*&quot;,<br>  &quot;Resource&quot;: &quot;*&quot;<br>}</pre><p>Much better:</p><pre>{<br>  &quot;Effect&quot;: &quot;Allow&quot;,<br>  &quot;Action&quot;: &quot;s3:GetObject&quot;,<br>  &quot;Resource&quot;: &quot;arn:aws:s3:::company-invoices/*&quot;<br>}</pre><p>The second policy says:</p><pre>Can read objects</pre><pre>ONLY</pre><pre>from company-invoices</pre><p>This drastically reduces the blast radius if the credentials are compromised.</p><h3>12. Resource</h3><p>The Resource field answers:</p><blockquote><em>Which AWS resource does this statement apply to?</em></blockquote><p>AWS normally identifies resources using an:</p><p><strong>ARN — Amazon Resource Name</strong></p><p>Example:</p><pre>arn:aws:s3:::company-invoices/*</pre><h3>13. Understanding ARN</h3><p>You’ll encounter ARNs constantly.</p><p>A generalized ARN structure is:</p><pre>arn:partition:service:region:account-id:resource</pre><p>Example:</p><pre>arn:aws:lambda:ap-south-1:123456789012:function:processOrder</pre><p>Breakdown:</p><pre>arn<br>│<br>├── aws<br>│<br>├── lambda<br>│<br>├── ap-south-1<br>│<br>├── 123456789012<br>│<br>└── function:processOrder</pre><p>Meaning:</p><pre>Partition → aws</pre><pre>Service → Lambda</pre><pre>Region → ap-south-1</pre><pre>Account → 123456789012</pre><pre>Resource → processOrder function</pre><h3>14. S3 ARNs Look Slightly Different</h3><p>Example:</p><pre>arn:aws:s3:::production-files</pre><p>Notice:</p><pre>No region</pre><pre>No account ID</pre><p>S3 has its own ARN formats.</p><p>Bucket:</p><pre>arn:aws:s3:::production-files</pre><p>Objects inside bucket:</p><pre>arn:aws:s3:::production-files/*</pre><p>That distinction is extremely important.</p><h3>15. Bucket vs Object Permissions</h3><p>Consider:</p><pre>{<br>  &quot;Effect&quot;: &quot;Allow&quot;,<br>  &quot;Action&quot;: &quot;s3:GetObject&quot;,<br>  &quot;Resource&quot;: &quot;arn:aws:s3:::production-files/*&quot;<br>}</pre><p>This applies to:</p><pre>production-files/a.pdf</pre><pre>production-files/image.jpg</pre><pre>production-files/folder/file.txt</pre><p>because GetObject works against objects.</p><p>But listing a bucket uses:</p><pre>s3:ListBucket</pre><p>and the relevant bucket resource is:</p><pre>arn:aws:s3:::production-files</pre><p>not:</p><pre>arn:aws:s3:::production-files/*</pre><p>This is a classic source of IAM bugs.</p><h3>16. Practical S3 Policy</h3><p>Suppose an application needs to:</p><ol><li>List files.</li><li>Download files.</li></ol><p>A policy could look like:</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;: &quot;s3:ListBucket&quot;,<br>      &quot;Resource&quot;: &quot;arn:aws:s3:::production-files&quot;<br>    },<br>    {<br>      &quot;Effect&quot;: &quot;Allow&quot;,<br>      &quot;Action&quot;: &quot;s3:GetObject&quot;,<br>      &quot;Resource&quot;: &quot;arn:aws:s3:::production-files/*&quot;<br>    }<br>  ]<br>}</pre><p>Notice the difference.</p><pre>ListBucket<br>     ↓<br>Bucket ARN<br><br>arn:aws:s3:::production-files</pre><pre>GetObject<br>     ↓<br>Object ARN</pre><pre>arn:aws:s3:::production-files/*</pre><p>Remember this.</p><p>It comes up repeatedly when working with S3 permissions.</p><h3>17. Resource Wildcards</h3><p>You can use:</p><pre>&quot;Resource&quot;: &quot;*&quot;</pre><p>meaning all applicable resources.</p><p>But again:</p><p><strong>Least privilege.</strong></p><p>Instead of:</p><pre>&quot;Resource&quot;: &quot;*&quot;</pre><p>prefer something like:</p><pre>&quot;Resource&quot;: &quot;arn:aws:s3:::production-files/*&quot;</pre><p>when the service/action supports resource-level restrictions.</p><p>Some AWS actions cannot be restricted to individual resources and therefore require &quot;Resource&quot;: &quot;*&quot;. So don&#39;t automatically assume every wildcard is bad; understand whether the particular action supports resource-level permissions.</p><h3>18. Condition</h3><p>Now IAM becomes powerful.</p><p>Suppose we want:</p><pre>Allow access to S3</pre><p>but only:</p><pre>when request comes from a particular network</pre><p>or:</p><pre>when MFA is present</pre><p>or:</p><pre>when resource has a specific tag</pre><p>That’s what Condition does.</p><h3>19. Condition Example</h3><p>Example:</p><pre>{<br>  &quot;Effect&quot;: &quot;Allow&quot;,<br>  &quot;Action&quot;: &quot;s3:GetObject&quot;,<br>  &quot;Resource&quot;: &quot;arn:aws:s3:::company-data/*&quot;,<br>  &quot;Condition&quot;: {<br>    &quot;IpAddress&quot;: {<br>      &quot;aws:SourceIp&quot;: &quot;203.0.113.0/24&quot;<br>    }<br>  }<br>}</pre><p>Conceptually:</p><pre>ALLOW</pre><pre>s3:GetObject</pre><pre>ON</pre><pre>company-data/*</pre><pre>ONLY IF</pre><pre>Source IP matches 203.0.113.0/24</pre><p>Now permissions aren’t simply:</p><pre>WHO + ACTION + RESOURCE</pre><p>They’re:</p><pre>WHO<br>+<br>ACTION<br>+<br>RESOURCE<br>+<br>CONTEXT</pre><h3>20. Conditions Are Extremely Powerful</h3><p>Conditions can evaluate information such as:</p><pre>Source IP</pre><pre>MFA status</pre><pre>Request time</pre><pre>Principal ARN</pre><pre>Resource tags</pre><pre>Principal tags</pre><pre>Requested region</pre><pre>Transport security</pre><pre>AWS service making the request</pre><p>For example, organizations can build policies based on tags.</p><p>Imagine:</p><pre>Developer tag:<br><br>Department = Development</pre><pre>Resource:<br><br>Department = Development</pre><p>A condition could allow access when attributes match.</p><p>This moves toward attribute-based access control.</p><h3>21. Principal</h3><p>Now we need another important policy element:</p><pre>&quot;Principal&quot;</pre><p>Principal answers:</p><blockquote><em>Who is this resource policy talking about?</em></blockquote><p>For example:</p><pre>&quot;Principal&quot;: {<br>  &quot;AWS&quot;: &quot;arn:aws:iam::123456789012:role/MyRole&quot;<br>}</pre><p>or an AWS service:</p><pre>&quot;Principal&quot;: {<br>  &quot;Service&quot;: &quot;lambda.amazonaws.com&quot;<br>}</pre><p>However, there is a critical distinction:</p><p><strong>Principal is generally used in resource-based policies and role trust policies, not ordinary identity-based IAM policies.</strong></p><p>Why?</p><p>Because if a policy is attached directly to:</p><pre>IAM User Hari</pre><p>AWS already knows the principal.</p><h3>22. Identity-Based Policies</h3><p>An identity-based policy is attached to an identity.</p><p>That identity can be:</p><pre>IAM User</pre><pre>IAM Group</pre><pre>IAM Role</pre><p>Architecture:</p><pre>IAM User<br>    │<br>    │<br>    ▼<br>IAM Policy<br>    │<br>    │<br>    ▼<br>Permissions</pre><p>Example:</p><pre>Hari</pre><pre>↓</pre><pre>S3ReadPolicy</pre><pre>↓</pre><pre>Can read S3</pre><p>The policy answers:</p><blockquote><em>What can Hari do?</em></blockquote><h3>23. Resource-Based Policies</h3><p>Instead of attaching the policy to an identity, we attach it directly to a resource.</p><p>Example:</p><pre>S3 Bucket</pre><pre>↓</pre><pre>Bucket Policy</pre><p>Other important examples include:</p><pre>S3 Bucket Policies</pre><pre>SQS Queue Policies</pre><pre>SNS Topic Policies</pre><pre>KMS Key Policies</pre><pre>Lambda Resource-Based Policies</pre><p>The policy effectively answers:</p><blockquote><em>Who can access this resource?</em></blockquote><h3>24. Identity Policy vs Resource Policy</h3><p>Think about a house.</p><p>Identity policy:</p><pre>Hari&#39;s ID card says:</pre><pre>Hari may enter Building A.</pre><p>Resource policy:</p><pre>Building A&#39;s entrance says:</pre><pre>Hari may enter.</pre><p>Different direction.</p><h3>25. Visual Comparison</h3><pre>IDENTITY-BASED POLICY</pre><pre>User / Role<br>    │<br>    ▼<br>Policy<br>    │<br>    ▼<br>Resource<br></pre><pre>RESOURCE-BASED POLICY</pre><pre>Resource<br>    │<br>    ▼<br>Policy<br>    │<br>    ▼<br>Principal</pre><h3>26. Example: S3 Bucket Policy</h3><p>Imagine another AWS account needs access to our bucket.</p><p>A simplified bucket policy might look like:</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;Principal&quot;: {<br>        &quot;AWS&quot;: &quot;arn:aws:iam::111122223333:role/AnalyticsRole&quot;<br>      },<br>      &quot;Action&quot;: &quot;s3:GetObject&quot;,<br>      &quot;Resource&quot;: &quot;arn:aws:s3:::analytics-data/*&quot;<br>    }<br>  ]<br>}</pre><p>Meaning:</p><pre>AnalyticsRole</pre><pre>from another account</pre><pre>can</pre><pre>GetObject</pre><pre>from</pre><pre>analytics-data</pre><p>Resource policies become especially important for cross-account access.</p><h3>27. Managed Policies vs Inline Policies</h3><p>Another important IAM concept.</p><p>There are three categories worth understanding:</p><pre>AWS Managed Policy</pre><pre>Customer Managed Policy</pre><pre>Inline Policy</pre><h3>28. AWS Managed Policy</h3><p>Created and maintained by AWS.</p><p>Examples include policies such as:</p><pre>ReadOnlyAccess</pre><pre>AdministratorAccess</pre><p>Architecture:</p><pre>AWS</pre><pre>↓</pre><pre>Creates Policy</pre><pre>↓</pre><pre>You Attach Policy</pre><pre>↓</pre><pre>User / Group / Role</pre><p>Advantages:</p><ul><li>Easy to use</li><li>Maintained by AWS</li><li>Convenient for common scenarios</li></ul><p>Disadvantage:</p><ul><li>Often broader than your application’s exact needs</li><li>You cannot modify the AWS-managed policy itself</li></ul><h3>29. Customer Managed Policy</h3><p>Created and maintained by you.</p><p>Example:</p><pre>ProductionInvoiceReader</pre><p>Policy:</p><pre>{<br>  &quot;Effect&quot;: &quot;Allow&quot;,<br>  &quot;Action&quot;: [<br>    &quot;s3:GetObject&quot;<br>  ],<br>  &quot;Resource&quot;: [<br>    &quot;arn:aws:s3:::production-invoices/*&quot;<br>  ]<br>}</pre><p>This gives much more precise control.</p><p>And unlike inline policies, a customer managed policy can be reused.</p><pre>ProductionInvoiceReader<br>        │<br>   ┌────┼────┐<br>   │    │    │<br>   ▼    ▼    ▼<br><br>RoleA RoleB UserA</pre><h3>30. Inline Policy</h3><p>An inline policy is embedded directly inside one identity.</p><pre>IAM Role</pre><pre>↓</pre><pre>Inline Policy</pre><p>It has a strict one-to-one relationship with that identity.</p><p>Conceptually:</p><pre>RoleA<br>  │<br>  └── SpecialPolicy</pre><p>Delete the identity and the inline policy goes with it.</p><p>AWS generally recommends managed policies when permissions need to be reused across multiple identities.</p><h3>31. Managed vs Inline</h3><pre>Feature                     AWS Managed    Customer Managed    Inline<br>──────────────────────────────────────────────────────────────────────<br>Created by                  AWS            You                 You<br>Editable by you             ❌             ✅                  ✅<br>Reusable                    ✅             ✅                  ❌<br>Separate policy entity      ✅             ✅                  ❌<br>One-to-one relationship     ❌             ❌                  ✅<br>Precise custom permissions  Sometimes      ✅                  ✅</pre><p>For most custom reusable application permissions:</p><p><strong>Customer managed policies are usually preferable.</strong></p><h3>32. Now the Most Important Part</h3><p>Everything until now was preparation.</p><p>We need to understand:</p><h3>IAM POLICY EVALUATION</h3><p>This is one of the most important IAM concepts for the exam.</p><h3>33. IAM Starts With DENY</h3><p>Imagine a brand-new IAM user:</p><pre>Hari</pre><p>No policies attached.</p><p>Can Hari read S3?</p><pre>NO</pre><p>Can Hari create Lambda?</p><pre>NO</pre><p>Can Hari start EC2?</p><pre>NO</pre><p>Why?</p><p>Because AWS follows: <strong>Default Deny</strong></p><p>Another term you’ll hear is: <strong>Implicit Deny</strong></p><p>Nothing needs to explicitly say:</p><pre>&quot;Deny&quot;</pre><p>No applicable permission means:</p><pre>DENIED</pre><h3>34. Implicit Deny</h3><p>Imagine:</p><pre>Hari</pre><pre>↓</pre><pre>No Policy</pre><pre>↓</pre><pre>s3:GetObject</pre><p>Result:</p><pre>DENIED</pre><p>Why?</p><p>No policy explicitly allowed it.</p><p>That’s: <strong>Implicit Deny</strong></p><h3>35. Explicit Allow</h3><p>Now attach:</p><pre>{<br>  &quot;Effect&quot;: &quot;Allow&quot;,<br>  &quot;Action&quot;: &quot;s3:GetObject&quot;,<br>  &quot;Resource&quot;: &quot;*&quot;<br>}</pre><p>Result:</p><pre>s3:GetObject</pre><pre>↓</pre><pre>Explicit Allow</pre><pre>↓</pre><pre>ALLOWED</pre><p>Assuming no other applicable control blocks it.</p><h3>36. Explicit Deny</h3><p>Now suppose another applicable policy contains:</p><pre>{<br>  &quot;Effect&quot;: &quot;Deny&quot;,<br>  &quot;Action&quot;: &quot;s3:GetObject&quot;,<br>  &quot;Resource&quot;: &quot;*&quot;<br>}</pre><p>Now we have:</p><pre>Policy A</pre><pre>ALLOW s3:GetObject<br></pre><pre>Policy B</pre><pre>DENY s3:GetObject</pre><p>What happens? <strong>DENIED</strong></p><p>Why?</p><p>Because: <strong>Explicit Deny beats Explicit Allow.</strong></p><p>This is one of the most important sentences in IAM.</p><p>Memorize it.</p><h3>37. IAM Permission Priority</h3><p>A useful simplified model:</p><pre>1. Explicit DENY</pre><pre>        beats</pre><pre>2. Explicit ALLOW</pre><pre>        beats</pre><pre>3. Implicit DENY</pre><p>Another way:</p><pre>Explicit Deny<br>      ↓<br>   strongest</pre><pre>Explicit Allow<br>      ↓</pre><pre>Implicit Deny<br>      ↓<br>    default</pre><h3>38. Exam Scenario</h3><p>User has:</p><pre>Policy A</pre><pre>Allow:<br>s3:*</pre><p>Another applicable policy says:</p><pre>Policy B</pre><pre>Deny:<br>s3:DeleteObject</pre><p>Can the user:</p><pre>s3:GetObject?</pre><p>Yes.</p><p>Can the user:</p><pre>s3:PutObject?</pre><p>Yes.</p><p>Can the user:</p><pre>s3:DeleteObject?</pre><p>NO.</p><p>Because the explicit Deny wins for DeleteObject.</p><h3>39. Very Important: Policies Combine</h3><p>Users often receive permissions from several sources.</p><p>Example:</p><pre>Hari<br> │<br> ├── Direct Policy<br> │<br> ├── Developer Group<br> │<br> └── Monitoring Group</pre><p>Imagine:</p><pre>Direct Policy<br>→ S3 Read</pre><pre>Developer Group<br>→ Lambda Deploy</pre><pre>Monitoring Group<br>→ CloudWatch Read</pre><p>Effective permissions may include all of these allows, subject to boundaries, organization controls, explicit denies, and other applicable policy types.</p><h3>40. Policy Evaluation Mental Model</h3><p>When AWS receives a request:</p><pre>Request</pre><pre>↓</pre><pre>Authenticate Principal</pre><pre>↓</pre><pre>Build Request Context</pre><pre>↓</pre><pre>Find Applicable Policies</pre><pre>↓</pre><pre>Any applicable Explicit Deny?<br>     │<br>     ├── YES → DENY<br>     │<br>     └── NO<br>          ↓<br>Does evaluation produce required Allow?<br>     │<br>     ├── YES → ALLOW<br>     │<br>     └── NO → DENY</pre><p>This simplified flow will solve many exam questions.</p><p>The full AWS policy evaluation system has additional layers that we’ll discuss shortly.</p><h3>41. Example: Multiple Policies</h3><p>Policy A:</p><pre>{<br>  &quot;Effect&quot;: &quot;Allow&quot;,<br>  &quot;Action&quot;: &quot;s3:*&quot;,<br>  &quot;Resource&quot;: &quot;*&quot;<br>}</pre><p>Policy B:</p><pre>{<br>  &quot;Effect&quot;: &quot;Deny&quot;,<br>  &quot;Action&quot;: &quot;s3:DeleteObject&quot;,<br>  &quot;Resource&quot;: &quot;*&quot;<br>}</pre><p>Question:</p><p>Can user upload?</p><pre>YES</pre><p>Can user download?</p><pre>YES</pre><p>Can user delete?</p><pre>NO</pre><h3>42. Another Example</h3><p>Policy A:</p><pre>Allow:</pre><pre>s3:GetObject</pre><p>Policy B:</p><pre>Allow:</pre><pre>dynamodb:GetItem</pre><p>Effective allowed permissions include:</p><pre>s3:GetObject</pre><pre>+</pre><pre>dynamodb:GetItem</pre><p>Again, assuming no other applicable restriction blocks them.</p><h3>43. Permissions Boundaries</h3><p>Now we’re entering more advanced IAM.</p><p>Suppose you’re running a large company.</p><p>You allow developers to create IAM roles.</p><p>Danger:</p><pre>Developer</pre><pre>↓</pre><pre>Creates Role</pre><pre>↓</pre><pre>AdministratorAccess</pre><pre>↓</pre><pre>Privilege Escalation</pre><p>That’s bad.</p><p>We need a way to say:</p><blockquote><em>You can create permissions, but they can never exceed this maximum.</em></blockquote><p>That’s where: <strong>Permissions Boundaries </strong>come in.</p><h3>44. Think of Boundary as a Ceiling</h3><p>Imagine:</p><pre>Identity Policy:</pre><pre>Allows<br>S3<br>Lambda<br>DynamoDB<br>EC2<br></pre><pre>Permissions Boundary:</pre><pre>Allows maximum<br>S3<br>Lambda</pre><p>Effective permissions:</p><pre>S3<br>Lambda</pre><p>NOT:</p><pre>DynamoDB<br>EC2</pre><p>because the boundary limits the maximum.</p><h3>45. Critical Boundary Rule</h3><p>A permissions boundary:</p><p><strong>does NOT grant permissions by itself.</strong></p><p>This is extremely important.</p><p>Suppose:</p><pre>Identity Policy</pre><pre>Allows:<br>S3</pre><pre>Boundary<br><br>Allows:<br>S3<br>Lambda<br>DynamoDB</pre><p>Effective:</p><pre>S3</pre><p>Not:</p><pre>S3 + Lambda + DynamoDB</pre><p>The identity policy still has to grant the permission.</p><h3>46. Think in Sets</h3><p>Identity policy:</p><pre>{ S3, Lambda, DynamoDB }</pre><p>Boundary:</p><pre>{ S3, Lambda }</pre><p>Effective:</p><pre>INTERSECTION</pre><p>Therefore:</p><pre>{ S3, Lambda }</pre><p>This idea of intersections becomes important when organizations use SCPs too.</p><h3>47. Service Control Policies — SCPs</h3><p>Large organizations often have many AWS accounts.</p><p>Example:</p><pre>AWS Organization<br>├── Production Account<br>├── Development Account<br>├── Security Account<br>└── Testing Account</pre><p>AWS Organizations can apply:</p><p><strong>Service Control Policies (SCPs)</strong></p><p>These establish permission guardrails for accounts or organizational units.</p><p>Example:</p><pre>Organization rule:</pre><pre>Developers must NEVER use certain regions.</pre><p>An SCP can restrict those actions across affected member accounts.</p><h3>48. SCP Does NOT Normally Grant Permissions</h3><p>This is another classic exam trap.</p><p>Suppose SCP allows:</p><pre>S3<br>Lambda<br>DynamoDB</pre><p>Does the developer automatically have those permissions?</p><p>NO.</p><p>IAM still needs to grant them.</p><p>Think:</p><pre>IAM Policy<br>      ↓<br>What identity is granted<br><br><br>SCP<br>      ↓<br>Organization-level guardrail</pre><p>Effective access must survive all applicable layers.</p><h3>49. Policy Evaluation with SCP</h3><p>Simplified:</p><pre>Identity Policy</pre><pre>ALLOW Lambda</pre><pre>        +</pre><pre>SCP<br></pre><pre>ALLOW Lambda</pre><pre>        ↓</pre><pre>Lambda may be allowed</pre><p>But:</p><pre>Identity Policy</pre><pre>ALLOW EC2</pre><pre>        +</pre><pre>SCP</pre><pre>doesn&#39;t permit / explicitly denies required EC2 action</pre><pre>        ↓</pre><pre>DENIED</pre><h3>50. The Full Mental Model</h3><p>Think of authorization like several security gates.</p><pre>REQUEST<br>   │<br>   ▼<br>Identity permissions<br>   │<br>   ▼<br>Permissions Boundary<br>   │<br>   ▼<br>Organizations controls<br>   │<br>   ▼<br>Resource policy / other applicable controls<br>   │<br>   ▼<br>Final Authorization</pre><p>The exact AWS evaluation rules vary by policy type and request context, so don’t treat this picture as literal evaluation order.</p><p>The key idea is:</p><p><strong>Your effective permission is constrained by every applicable authorization layer.</strong></p><p>And:</p><p><strong>Applicable explicit Deny remains dominant.</strong></p><h3>51. Session Policies</h3><p>When using temporary credentials through STS, permissions can also be restricted with:</p><pre>Session Policies</pre><p>Example:</p><pre>IAM Role permissions</pre><pre>S3<br>Lambda<br>DynamoDB</pre><pre>        ↓</pre><pre>Assume Role with Session Policy</pre><pre>Only S3</pre><pre>        ↓</pre><pre>Session can only use allowed intersection</pre><p>We’ll explore this properly when we study STS.</p><p>For now remember:</p><blockquote><em>Session policies can restrict a session; they don’t expand it beyond the role’s permissions.</em></blockquote><h3>52. NotAction</h3><p>You may encounter:</p><pre>&quot;NotAction&quot;</pre><p>Instead of saying:</p><pre>These actions</pre><p>it describes:</p><pre>Everything applicable EXCEPT these actions</pre><p>Example:</p><pre>{<br>  &quot;Effect&quot;: &quot;Allow&quot;,<br>  &quot;NotAction&quot;: &quot;iam:*&quot;,<br>  &quot;Resource&quot;: &quot;*&quot;<br>}</pre><p>Conceptually:</p><pre>Allow applicable actions</pre><pre>EXCEPT</pre><pre>IAM actions</pre><p>Be extremely careful with NotAction, especially with Allow, because it can grant much broader permissions than expected.</p><h3>53. NotResource</h3><p>Similarly:</p><pre>&quot;NotResource&quot;</pre><p>means:</p><pre>Resources except those specified</pre><p>This is powerful but easier to misconfigure.</p><p>For the exam, focus primarily on understanding what the inversion means rather than memorizing obscure combinations.</p><h3>54. Important JSON Rule</h3><p>You cannot combine:</p><pre>Action</pre><pre>and</pre><pre>NotAction</pre><p>inside the same statement.</p><p>Likewise:</p><pre>Resource</pre><pre>and</pre><pre>NotResource</pre><p>are mutually exclusive.</p><p>And:</p><pre>Principal</pre><pre>and</pre><pre>NotPrincipal</pre><p>are mutually exclusive.</p><h3>55. Real Production Example</h3><p>Imagine our application architecture:</p><pre>User<br> │<br> ▼<br>API Gateway<br> │<br> ▼<br>Lambda<br> │<br> ├──────────────► DynamoDB<br> │<br> └──────────────► S3</pre><p>Our Lambda needs:</p><pre>Read/write DynamoDB</pre><pre>Upload invoices to S3</pre><p>It does NOT need:</p><pre>Delete S3 bucket</pre><pre>Create EC2</pre><pre>Modify IAM</pre><pre>Delete DynamoDB table</pre><p>A permission policy might look roughly like:</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;dynamodb:GetItem&quot;,<br>        &quot;dynamodb:PutItem&quot;,<br>        &quot;dynamodb:UpdateItem&quot;<br>      ],<br>      &quot;Resource&quot;: &quot;arn:aws:dynamodb:ap-south-1:123456789012:table/Orders&quot;<br>    },<br>    {<br>      &quot;Effect&quot;: &quot;Allow&quot;,<br>      &quot;Action&quot;: [<br>        &quot;s3:PutObject&quot;<br>      ],<br>      &quot;Resource&quot;: &quot;arn:aws:s3:::company-invoices/*&quot;<br>    }<br>  ]<br>}</pre><p>This is much better than:</p><pre>{<br>  &quot;Effect&quot;: &quot;Allow&quot;,<br>  &quot;Action&quot;: &quot;*&quot;,<br>  &quot;Resource&quot;: &quot;*&quot;<br>}</pre><h3>56. Why Least Privilege Matters in Production</h3><p>Imagine someone discovers a vulnerability allowing them to make your Lambda perform unauthorized operations.</p><p>If Lambda has:</p><pre>AdministratorAccess</pre><p>the attacker potentially gains a massive blast radius.</p><p>But if Lambda can only:</p><pre>dynamodb:GetItem<br>dynamodb:PutItem<br>s3:PutObject</pre><p>against specific resources, the damage is much more constrained.</p><p>IAM is therefore not simply:</p><blockquote><em>AWS configuration.</em></blockquote><p>It is part of your application’s security architecture.</p><h3>57. AWS CLI — Create a Customer Managed Policy</h3><p>Suppose we create:</p><pre>s3-read-policy.json</pre><p>with:</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;: &quot;s3:GetObject&quot;,<br>      &quot;Resource&quot;: &quot;arn:aws:s3:::company-files/*&quot;<br>    }<br>  ]<br>}</pre><p>Create it:</p><pre>aws iam create-policy \<br>  --policy-name CompanyFilesReadOnly \<br>  --policy-document file://s3-read-policy.json</pre><p>Then attach it to a user:</p><pre>aws iam attach-user-policy \<br>  --user-name hari \<br>  --policy-arn arn:aws:iam::123456789012:policy/CompanyFilesReadOnly</pre><h3>58. List Attached Policies</h3><pre>aws iam list-attached-user-policies \<br>  --user-name hari</pre><p>For roles:</p><pre>aws iam list-attached-role-policies \<br>  --role-name MyLambdaRole</pre><h3>59. SDK Example — JavaScript</h3><p>Using AWS SDK for JavaScript v3:</p><pre>import {<br>  IAMClient,<br>  ListAttachedRolePoliciesCommand,<br>} from &quot;<a href="http://twitter.com/aws">@aws</a>-sdk/client-iam&quot;;</pre><pre>const client = new IAMClient({<br>  region: &quot;ap-south-1&quot;,<br>});</pre><pre>async function listPolicies(roleName) {<br>  try {<br>    const response = await client.send(<br>      new ListAttachedRolePoliciesCommand({<br>        RoleName: roleName,<br>      })<br>    );</pre><pre>    for (const policy of response.AttachedPolicies ?? []) {<br>      console.log(policy.PolicyName, policy.PolicyArn);<br>    }<br>  } catch (error) {<br>    console.error(&quot;Unable to list policies:&quot;, error);<br>    throw error;<br>  }<br>}</pre><pre>listPolicies(&quot;MyLambdaRole&quot;);</pre><p>The interesting part isn’t the JavaScript.</p><p>It’s what authorizes this API call.</p><p>The credentials used by this SDK need permission such as:</p><pre>iam:ListAttachedRolePolicies</pre><p>This illustrates the deeper idea:</p><blockquote><em>Every AWS SDK call eventually becomes an API request that IAM must authorize.</em></blockquote><h3>60. Debugging AccessDenied</h3><p>Sooner or later, every AWS developer meets:</p><pre>AccessDenied</pre><p>Welcome to AWS development.</p><p>Instead of randomly attaching AdministratorAccess, debug systematically.</p><p>Ask:</p><pre>1. Who am I?</pre><pre>2. Which API action am I attempting?</pre><pre>3. Which resource ARN am I accessing?</pre><pre>4. Does an identity policy allow it?</pre><pre>5. Does a resource policy matter?</pre><pre>6. Is there an explicit Deny?</pre><pre>7. Is a permissions boundary restricting me?</pre><pre>8. Is an SCP restricting me?</pre><pre>9. Is a session policy restricting me?</pre><pre>10. Does a Condition fail?</pre><p>That checklist solves a huge percentage of IAM problems.</p><h3>61. Useful CLI Debugging Command</h3><p>When you’re unsure which identity your CLI is using:</p><pre>aws sts get-caller-identity</pre><p>This returns information such as:</p><pre>{<br>  &quot;UserId&quot;: &quot;...&quot;,<br>  &quot;Account&quot;: &quot;123456789012&quot;,<br>  &quot;Arn&quot;: &quot;arn:aws:iam::123456789012:user/hari&quot;<br>}</pre><p>This command is incredibly useful.</p><p>Before debugging IAM permissions:</p><pre>FIRST:</pre><pre>aws sts get-caller-identity</pre><p>Know who AWS thinks you are.</p><h3>62. Common IAM Policy Mistakes</h3><h3>Mistake 1</h3><p>Using:</p><pre>&quot;Action&quot;: &quot;*&quot;,<br>&quot;Resource&quot;: &quot;*&quot;</pre><p>because it’s easier.</p><p>It works.</p><p>It is also often terrible security.</p><h3>Mistake 2</h3><p>Wrong S3 ARN.</p><p>Using:</p><pre>arn:aws:s3:::bucket</pre><p>for:</p><pre>s3:GetObject</pre><p>when the object resource normally needs:</p><pre>arn:aws:s3:::bucket/*</pre><h3>Mistake 3</h3><p>Thinking Allow always wins.</p><p>Wrong.</p><pre>Explicit Deny</pre><p>wins over applicable Allow.</p><h3>Mistake 4</h3><p>Thinking a permissions boundary grants permissions.</p><p>It doesn’t.</p><p>It limits the maximum permissions available through identity-based policies.</p><h3>Mistake 5</h3><p>Thinking SCP automatically grants access.</p><p>It doesn’t.</p><p>It establishes organization-level permission guardrails.</p><h3>Mistake 6</h3><p>Using AWS managed policies everywhere.</p><p>They’re convenient but can be broader than necessary.</p><p>Production applications often benefit from tightly scoped customer-managed policies.</p><h3>63. DVA-C02 Exam Traps</h3><h3>Trap #1 — Explicit Deny</h3><pre>User:<br><br>Allow S3*</pre><pre>Bucket policy:<br><br>Deny DeleteObject</pre><p>Question:</p><p>Can user delete?</p><p>Answer:</p><pre>NO</pre><p>Explicit Deny wins.</p><h3>Trap #2 — Missing Allow</h3><pre>No policy says:<br><br>Allow</pre><p>Question:</p><p>Can user perform action?</p><p>Answer: NO</p><p>Implicit deny.</p><h3>Trap #3 — Permissions Boundary</h3><pre>Identity:<br><br>Allow S3 + Lambda</pre><pre>Boundary only permits:<br><br>S3</pre><p>Effective identity permissions cannot use Lambda through that identity policy.</p><h3>Trap #4 — SCP</h3><pre>IAM says:<br><br>Allow EC2</pre><p>Organization guardrail prevents the requested EC2 action.</p><pre>Result:<br><br>DENIED</pre><h3>Trap #5 — S3 Bucket vs Object</h3><pre>s3:ListBucket  → bucket ARN</pre><p>while:</p><pre>s3:GetObject   → object ARN</pre><p>Do not confuse them.</p><h3>64. IAM Policy Reading Algorithm</h3><p>Whenever the exam shows a policy, don’t panic.</p><p>Read it in this order:</p><pre>STEP 1<br>Effect?<br>Allow / Deny<br><br>STEP 2<br>Action?<br>What API operation?<br><br>STEP 3<br>Resource?<br>Which exact resource?<br><br>STEP 4<br>Condition?<br>Under what circumstances?<br><br>STEP 5<br>Principal?<br>If applicable, who?<br><br>STEP 6<br>Other policies?<br>Any explicit Deny or limiting policy?</pre><p>You can mentally translate:</p><pre>{<br>  &quot;Effect&quot;: &quot;Allow&quot;,<br>  &quot;Action&quot;: &quot;s3:GetObject&quot;,<br>  &quot;Resource&quot;: &quot;arn:aws:s3:::invoices/*&quot;<br>}</pre><p>into:</p><pre>ALLOW</pre><pre>READING OBJECTS</pre><pre>FROM</pre><pre>INVOICES BUCKET</pre><p>Don’t read JSON.</p><p>Translate it into English.</p><h3>65. Comparison Cheat Sheet</h3><pre>┌──────────────────────┬──────────────────────────────────────────────┐<br>│ Concept              │ Meaning                                      │<br>├──────────────────────┼──────────────────────────────────────────────┤<br>│ Identity Policy      │ Attached to user/group/role                  │<br>│ Resource Policy      │ Attached to resource                         │<br>│ AWS Managed          │ Created/managed by AWS                       │<br>│ Customer Managed     │ Created/managed by you                       │<br>│ Inline               │ Embedded into one identity                   │<br>│ Permissions Boundary │ Maximum permissions for identity             │<br>│ SCP                  │ Organization-level guardrail                 │<br>│ Session Policy       │ Restricts temporary session                  │<br>│ Explicit Allow       │ Grants permission when evaluation permits    │<br>│ Implicit Deny        │ Default                                      │<br>│ Explicit Deny        │ Overrides Allow                              │<br>└──────────────────────┴──────────────────────────────────────────────┘</pre><h3>66. The IAM Equation</h3><p>For exam revision, keep this mental model:</p><pre>DEFAULT = DENY</pre><pre>ALLOW + No blocking control = ALLOW<br></pre><pre>ALLOW + EXPLICIT DENY = DENY</pre><p>And for limiting controls:</p><pre>Identity permissions</pre><pre>∩</pre><pre>Permissions Boundary</pre><pre>∩</pre><pre>Organization controls</pre><pre>∩</pre><pre>Session restrictions where applicable</pre><pre>=</pre><pre>Effective capability</pre><p>Resource-based policies add another dimension, so the real AWS evaluation logic is more nuanced than this equation.</p><p>But this mental model is excellent for exam questions.</p><h3>🧠 Memory Tricks</h3><h3>Authentication</h3><pre>&quot;I know WHO you are.&quot;</pre><h3>Authorization</h3><pre>&quot;I know WHAT you can do.&quot;</pre><h3>Action</h3><pre>WHAT?</pre><h3>Resource</h3><pre>WHERE?</pre><h3>Condition</h3><pre>WHEN / UNDER WHAT CONDITIONS?</pre><h3>Principal</h3><pre>WHO?</pre><h3>Explicit Deny</h3><p>Think:</p><pre>DENY = Emergency Brake</pre><p>Once an applicable explicit Deny is hit, an Allow does not override it.</p><h3>⚡ 2-Minute Revision Sheet</h3><p>Before the exam, remember:</p><pre>IAM Policy = JSON permissions document<br></pre><pre>Core elements:</pre><pre>Version<br>Statement<br>Effect<br>Action<br>Resource<br>Condition<br>Principal<br></pre><pre>Effect:</pre><pre>Allow<br>Deny<br></pre><pre>Default:</pre><pre>Implicit Deny<br></pre><pre>Strongest:</pre><pre>Explicit Deny<br></pre><pre>Identity Policy:</pre><pre>Attached to<br>User / Group / Role<br></pre><pre>Resource Policy:</pre><pre>Attached to<br>Resource<br></pre><pre>Managed Policy:</pre><pre>Reusable<br></pre><pre>Inline Policy:</pre><pre>One identity<br></pre><pre>Permissions Boundary:</pre><pre>Maximum permission ceiling<br>Does NOT grant permission<br></pre><pre>SCP:</pre><pre>Organization guardrail<br>Does NOT normally grant permission<br></pre><pre>S3:</pre><pre>ListBucket<br>→ bucket ARN</pre><pre>GetObject<br>→ object ARN</pre><h3>📝 Practice Questions</h3><h3>Question 1</h3><p>A developer has this policy:</p><pre>{<br>  &quot;Effect&quot;: &quot;Allow&quot;,<br>  &quot;Action&quot;: &quot;s3:*&quot;,<br>  &quot;Resource&quot;: &quot;*&quot;<br>}</pre><p>Another applicable policy contains:</p><pre>{<br>  &quot;Effect&quot;: &quot;Deny&quot;,<br>  &quot;Action&quot;: &quot;s3:DeleteObject&quot;,<br>  &quot;Resource&quot;: &quot;*&quot;<br>}</pre><p>Can the developer delete objects? Answer : No.</p><p>The explicit Deny overrides the Allow.</p><h3>Question 2</h3><p>An IAM user has no policies attached.</p><p>Can the user invoke Lambda? Answer : No.</p><p>AWS permissions are implicitly denied unless an applicable policy grants access.</p><h3>Question 3</h3><p>A Lambda function only needs to read objects from:</p><pre>company-images</pre><p>Which policy follows least privilege better?</p><p>A:</p><pre>s3:*<br>Resource *</pre><p>B:</p><pre>s3:GetObject<br>Resource company-images/*</pre><p>Answer : B.</p><p>It grants only the required API action against the required resource.</p><h3>Question 4</h3><p>A user has:</p><pre>IAM Policy:<br>Allow S3<br>Allow Lambda<br>Allow DynamoDB</pre><pre>Permissions Boundary allows:<br>S3<br>Lambda</pre><p>Which of those services can the identity-based permissions effectively authorize?</p><p>Answer :</p><p>S3 and Lambda.</p><p>DynamoDB exceeds the boundary.</p><h3>Question 5</h3><p>A permissions boundary contains:</p><pre>Allow S3</pre><p>but the user’s identity policies don’t grant S3.</p><p>Can the user access S3 because of the boundary?</p><p>Answer : No.</p><p>Permissions boundaries don’t grant permissions.</p><p>They limit permissions.</p><h3>Question 6</h3><p>Which policy type has a strict one-to-one relationship with an IAM identity?</p><p>Answer : Inline policy.</p><h3>Question 7</h3><p>Which policy type would normally be best when the same custom permission should be attached to 20 roles?</p><p>Answer : Customer managed policy.</p><p>It’s reusable and centrally managed.</p><h3>Question 8</h3><p>What should you run first when debugging which AWS identity your CLI is using?</p><pre>aws sts get-caller-identity</pre><p>This tells you the identity and account associated with the current credentials.</p><h3>🎯 Key Takeaways</h3><p>IAM policies aren’t random JSON.</p><p>They’re structured authorization rules.</p><pre>Think:</pre><pre>WHO</pre><pre>can perform</pre><pre>WHAT ACTION</pre><pre>on</pre><pre>WHICH RESOURCE</pre><pre>under</pre><pre>WHICH CONDITIONS</pre><p>The single most important rule from today’s chapter is:</p><blockquote><strong><em>Explicit Deny overrides Allow.</em></strong></blockquote><p>The second most important:</p><blockquote><strong><em>Everything starts implicitly denied.</em></strong></blockquote><p>The third:</p><blockquote><strong><em>Permissions boundaries and SCPs constrain permissions; they don’t simply hand permissions to users.</em></strong></blockquote><p>And the practical developer lesson:</p><blockquote><em>Never solve </em><em>AccessDenied by blindly attaching </em><em>AdministratorAccess.</em></blockquote><p>Find the API operation.</p><p>Find the principal.</p><p>Find the resource.</p><p>Inspect the applicable policies.</p><p>Find the missing Allow or blocking Deny.</p><p>That’s how IAM becomes understandable instead of mysterious.</p><h3>Day 4 Preview — IAM Roles &amp; AWS STS</h3><p>Today we answered:</p><blockquote><strong><em>What are you allowed to do?</em></strong></blockquote><p>Tomorrow we’re going to answer a much more interesting question:</p><blockquote><strong><em>How can an application securely access AWS without storing an access key and secret key?</em></strong></blockquote><p>That’s where <strong>IAM Roles and AWS Security Token Service (STS)</strong> enter the picture.</p><p>We’ll cover:</p><pre>IAM Roles</pre><pre>Role Trust Policies</pre><pre>Permission Policies</pre><pre>AssumeRole</pre><pre>AWS STS</pre><pre>Temporary Credentials</pre><pre>EC2 Instance Roles</pre><pre>Lambda Execution Roles</pre><pre>ECS Task Roles</pre><pre>Cross-Account Access</pre><pre>Service Roles</pre><pre>Role Chaining</pre><pre>Session Duration</pre><pre>External ID</pre><pre>Web Identity Federation</pre><p>Most importantly, we’ll understand why this:</p><pre>Application<br>   ↓<br>Hardcoded AWS keys<br>   ↓<br>AWS</pre><p>is bad architecture…</p><p>and why AWS wants:</p><pre>Application<br>   ↓<br>IAM Role<br>   ↓<br>Temporary STS Credentials<br>   ↓<br>AWS</pre><p>instead.</p><p>That concept is central to secure AWS development and shows up repeatedly in DVA-C02 scenarios.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=27eeff4a27b1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Day 2 — AWS IAM Fundamentals: The Security Gatekeeper of AWS]]></title>
            <link>https://hari27om.medium.com/day-2-aws-iam-fundamentals-the-security-gatekeeper-of-aws-06bf92887da8?source=rss-403dd53dc117------2</link>
            <guid isPermaLink="false">https://medium.com/p/06bf92887da8</guid>
            <dc:creator><![CDATA[Hari Om]]></dc:creator>
            <pubDate>Tue, 28 Jul 2026 07:47:45 GMT</pubDate>
            <atom:updated>2026-07-28T07:47:45.537Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>“Before AWS checks what you want to do, it first checks who you are.”</blockquote><h3>Introduction</h3><p>Imagine you’re entering a corporate office.</p><p>Before you can access the meeting room, cafeteria, server room, or CEO’s office, security asks:</p><blockquote><strong><em>Who are you?</em></strong></blockquote><p>After confirming your identity, security asks another question:</p><blockquote><strong><em>What are you allowed to access?</em></strong></blockquote><p>AWS works exactly the same way.</p><p>Every single API request that reaches AWS first goes through a security checkpoint.</p><p>That checkpoint is <strong>IAM (Identity and Access Management).</strong></p><p>Whether you are:</p><ul><li>Uploading an image to S3</li><li>Launching an EC2 instance</li><li>Invoking Lambda</li><li>Reading DynamoDB</li><li>Creating CloudFormation stacks</li></ul><p>AWS performs one check before anything else.</p><p>Is this request allowed?</p><p>If yes…</p><p>The service executes.</p><p>If no…</p><p>AWS immediately rejects the request.</p><p>That is IAM.</p><h3>Why Does IAM Exist?</h3><p>Imagine AWS without IAM.</p><p>Anyone who knows your account ID could:</p><ul><li>Delete your S3 bucket</li><li>Launch 500 EC2 instances</li><li>Read your database</li><li>Download secrets</li><li>Delete Lambda functions</li></ul><p>That would obviously be disastrous.</p><p>AWS therefore needed a centralized authorization system.</p><p>Instead of every AWS service implementing its own authentication and authorization, AWS created <strong>IAM</strong>.</p><p>Today every AWS service depends on IAM.</p><p>Think of IAM as the operating system’s security layer.</p><pre>                 AWS Account</pre><pre>        +-----------------------------+<br>        |                             |<br>        |            IAM              |<br>        |                             |<br>        +--------------+--------------+<br>                       |<br>      -----------------------------------------<br>      |        |        |        |            |<br>     S3     Lambda    EC2    DynamoDB    CloudFormation</pre><p>Notice something?</p><p>IAM sits <strong>above every AWS service</strong>.</p><h3>What Exactly is IAM?</h3><p>AWS defines IAM as an identity service.</p><p>That’s technically correct.</p><p>But as developers, it’s easier to think of it differently.</p><p>IAM answers only two questions.</p><pre>WHO are you?</pre><pre>WHAT are you allowed to do?</pre><p>Everything else is built on these two questions.</p><h3>Authentication vs Authorization</h3><p>This is one of AWS’s favorite exam topics.</p><p>Many candidates confuse these terms.</p><p>Let’s separate them forever.</p><h3>Authentication</h3><p>Authentication answers:</p><pre>Who are you?</pre><p>Example</p><pre>Username: John</pre><pre>Password: ********</pre><p>AWS verifies your identity.</p><p>Authentication is complete.</p><h3>Authorization</h3><p>Authorization asks something different.</p><pre>Now that I know who you are...</pre><pre>What can you do?</pre><p>Example :</p><pre>Can create Lambda?</pre><pre>YES</pre><pre>Can delete DynamoDB?</pre><pre>NO</pre><pre>Can read S3?</pre><pre>YES</pre><p>Authentication happens first.</p><p>Authorization happens second.</p><p>Never confuse these two.</p><h3>Real World Analogy</h3><p>Think about a hotel.</p><p>Authentication</p><pre>Reception checks your identity.</pre><pre>You are Hari.</pre><pre>Welcome.</pre><p>Authorization</p><pre>Can access Room 204</pre><pre>YES</pre><pre>Can enter Kitchen?</pre><pre>NO</pre><pre>Can access Manager Office?</pre><pre>NO</pre><p>AWS works identically.</p><h3>IAM Components</h3><p>IAM has five fundamental building blocks.</p><pre>IAM</pre><pre>├── Users</pre><pre>├── Groups</pre><pre>├── Roles</pre><pre>├── Policies</pre><pre>└── Identity Providers</pre><p>Today’s focus is on the first two. We’ll tackle Policies and Roles in dedicated chapters.</p><h3>IAM Users</h3><p>An IAM User represents <strong>one identity</strong> inside an AWS account.</p><p>Examples:</p><pre>Alice</pre><pre>Bob</pre><pre>BackendApp</pre><pre>Intern01</pre><p>Each user has unique credentials.</p><p>A user can have:</p><ul><li>Password (AWS Console)</li><li>Access Key ID</li><li>Secret Access Key</li><li>Both</li><li>Neither</li></ul><h3>Example</h3><p>Suppose a company has:</p><pre>CEO</pre><pre>HR</pre><pre>Developer</pre><pre>Intern</pre><p>AWS might represent them like this.</p><pre>IAM</pre><pre>+-- CEO</pre><pre>+-- HR</pre><pre>+-- Developer</pre><pre>+-- Intern</pre><p>Every person has a different permission set.</p><h3>Root User vs IAM User</h3><p>This is probably the most asked IAM question.</p><h3>Root User</h3><p>Created automatically.</p><pre>AWS Account Created</pre><pre>↓</pre><pre>Root User Exists</pre><p>Characteristics</p><ul><li>Unlimited permissions</li><li>Can delete account</li><li>Can close billing</li><li>Can modify everything</li><li>Cannot be restricted by IAM policies</li></ul><p>Never use the root account for day-to-day work.</p><h3>IAM User</h3><p>Created by administrators.</p><p>Example</p><pre>Dev</pre><pre>↓</pre><pre>Limited permissions</pre><pre>↓</pre><pre>Can deploy Lambda</pre><pre>↓</pre><pre>Cannot delete billing</pre><p>This is what developers should use.</p><h3>Why AWS Says “Don’t Use Root”</h3><p>Imagine developing software.</p><p>Every deployment uses:</p><pre>Administrator</pre><pre>Full Access</pre><pre>Unlimited Power</pre><p>One accidental command.</p><pre>aws s3 rm s3://production --force</pre><p>Production gone.</p><p>Instead…</p><p>Create an IAM User with only the permissions required.</p><h3>Principle of Least Privilege</h3><p>One sentence.</p><p>Remember it forever.</p><blockquote><strong><em>Give only the permissions required — nothing more.</em></strong></blockquote><p>Example</p><p>Developer only needs Lambda.</p><p>Bad : AdministratorAccess</p><p>Good :</p><pre>Lamba</pre><pre>CloudWatch Logs</pre><pre>S3 Read</pre><pre>Nothing Else</pre><p>AWS loves asking scenario questions where the correct answer is the most restrictive permission that still accomplishes the task.</p><h3>IAM Groups</h3><p>Imagine hiring 500 developers.</p><p>Would you assign permissions individually?</p><p>No.</p><p>Instead:</p><pre>Developers</pre><pre>↓</pre><pre>One Group</pre><pre>↓</pre><pre>Shared Permissions</pre><p>Now every developer inherits those permissions.</p><p>Example :</p><pre>IAM</pre><pre>|</pre><pre>+-- Developers</pre><pre>|      |</pre><pre>|      +-- Hari</pre><pre>|      +-- Alice</pre><pre>|      +-- Bob</pre><pre>+-- HR</pre><pre>|      |</pre><pre>|      +-- John</pre><pre>|      +-- Sarah</pre><p>Groups simplify permission management.</p><h3>Users vs Groups</h3><p>UserGroupIndividual identityCollection of usersHas credentialsNo credentialsCan sign inCannot sign inGets permissions directly or via groupsUsed to assign common permissions</p><h3>Can One User Join Multiple Groups?</h3><p>Yes.</p><p>Example:</p><pre>Hari</pre><pre>↓</pre><pre>Developer Group</pre><pre>↓</pre><pre>Security Group</pre><pre>↓</pre><pre>CloudFormation Group</pre><p>Permissions from all attached groups are combined.</p><p>This is common in large organizations.</p><h3>What Happens When You Make an AWS API Call?</h3><p>This is the part many courses skip — but understanding it helps everything else click.</p><p>Imagine you run:</p><pre>aws s3 ls</pre><p>Here’s what happens:</p><pre>Developer</pre><pre>↓</pre><pre>AWS CLI</pre><pre>↓</pre><pre>Access Key + Secret Key</pre><pre>↓</pre><pre>AWS signs the request</pre><pre>↓</pre><pre>AWS IAM authenticates the caller</pre><pre>↓</pre><pre>AWS evaluates permissions</pre><pre>↓</pre><pre>Allowed?</pre><pre>↓</pre><pre>YES</pre><pre>↓</pre><pre>Amazon S3</pre><pre>↓</pre><pre>Returns bucket list</pre><p>Every request follows this general flow. Services don’t decide permissions on their own; they rely on IAM.</p><h3>Credentials</h3><p>IAM users can authenticate using different credential types depending on how they interact with AWS.</p><p>CredentialPurposeUsername + PasswordAWS Management ConsoleAccess Key ID + Secret Access KeyCLI and SDKsMFA DeviceAdditional security layer</p><p>As a developer, you’ll most often use access keys with the AWS CLI or SDKs during development, but in production, applications should typically use IAM Roles instead of long-lived access keys (covered later in the series).</p><h3>Multi-Factor Authentication (MFA)</h3><p>Passwords can be stolen.</p><p>MFA adds another verification factor.</p><pre>Password</pre><pre>+</pre><pre>Authenticator App</pre><pre>↓</pre><pre>Access Granted</pre><p>Even if someone knows your password, they still need the second factor.</p><p><strong>Exam Tip:</strong> Enable MFA for the root user and for privileged IAM users.</p><h3>Real-World Scenario</h3><p>Imagine you’re building an e-commerce platform.</p><p>Your team has:</p><ul><li>12 Backend Developers</li><li>8 Frontend Developers</li><li>3 DevOps Engineers</li><li>2 Security Engineers</li></ul><p>A sensible IAM design might look like:</p><pre>AWS Account</pre><pre>|</pre><pre>+-- Backend Developers Group</pre><pre>|</pre><pre>+-- Frontend Developers Group</pre><pre>|</pre><pre>+-- DevOps Group</pre><pre>|</pre><pre>+-- Security Group</pre><p>Each group receives only the permissions required for its responsibilities.</p><h3>AWS CLI Example</h3><p>Create a user:</p><pre>aws iam create-user --user-name hari</pre><p>List users:</p><pre>aws iam list-users</pre><p>Create a group:</p><pre>aws iam create-group --group-name Developers</pre><p>Add a user to the group:</p><pre>aws iam add-user-to-group \<br>    --group-name Developers \<br>    --user-name hari</pre><h3>AWS SDK Example (Python — Boto3)</h3><pre>import boto3</pre><pre>iam = boto3.client(&quot;iam&quot;)</pre><pre>response = iam.list_users()</pre><pre>for user in response[&quot;Users&quot;]:<br>    print(user[&quot;UserName&quot;])</pre><p>This is a common administrative operation that lists IAM users. Your application code should avoid embedding long-lived credentials; instead, use IAM Roles where possible.</p><h3>Best Practices</h3><p>✅ Never use the root user for daily work.</p><p>✅ Enable MFA on the root account.</p><p>✅ Follow the Principle of Least Privilege.</p><p>✅ Use groups to manage permissions for teams.</p><p>✅ Prefer IAM Roles over long-lived access keys for applications and AWS services.</p><h3>Common Mistakes</h3><p>❌ Giving every developer AdministratorAccess.</p><p>❌ Sharing the root account.</p><p>❌ Hardcoding access keys in source code.</p><p>❌ Creating a new permission set for every user instead of using groups.</p><p>❌ Leaving unused access keys active indefinitely.</p><h3>AWS Exam Traps</h3><p><strong>Trap 1:</strong> Root user vs IAM user.</p><p>If a question asks about routine administration or development, the answer is almost never the root user.</p><p><strong>Trap 2:</strong> Least Privilege.</p><p>When several options work, AWS usually expects the one granting the minimum necessary permissions.</p><p><strong>Trap 3:</strong> Groups vs Roles.</p><p>Groups organize users. Roles provide temporary permissions and can be assumed by users, services, or external identities. We’ll explore roles in depth later.</p><h3>Key Takeaways</h3><ul><li>Every AWS request is authenticated and authorized through IAM.</li><li>IAM is the security foundation that every AWS service relies on.</li><li>Authentication answers <strong>who you are</strong>; authorization answers <strong>what you can do</strong>.</li><li>Use IAM users instead of the root account for everyday work.</li><li>Organize users with groups to simplify permission management.</li><li>Apply the Principle of Least Privilege consistently.</li><li>Think of IAM as the security checkpoint every AWS API request must pass before reaching its destination.</li></ul><h3>Tomorrow’s Chapter</h3><p><strong>Day 3 — IAM Policies Deep Dive</strong></p><p>We’ll go beyond “attach a policy” and answer questions like:</p><ul><li>What is an IAM Policy internally?</li><li>How does AWS evaluate policy statements?</li><li>What do Effect, Action, Resource, and Condition actually mean?</li><li>Managed Policies vs Customer Managed Policies vs Inline Policies</li><li>Identity-based vs Resource-based Policies</li><li>Explicit Deny vs Implicit Deny (one of the most important exam concepts)</li><li>Reading and writing IAM policy JSON like a developer</li><li>Common DVA-C02 exam traps around policy evaluation</li></ul><p>By the end of Day 3, you’ll be able to read almost any IAM policy and predict whether an AWS request will be allowed or denied — a skill that’s invaluable for both the exam and real-world AWS development.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=06bf92887da8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[30 Days to AWS Developer Associate (DVA-C02) ]]></title>
            <link>https://hari27om.medium.com/30-days-to-aws-developer-associate-dva-c02-0f96774d64d8?source=rss-403dd53dc117------2</link>
            <guid isPermaLink="false">https://medium.com/p/0f96774d64d8</guid>
            <dc:creator><![CDATA[Hari Om]]></dc:creator>
            <pubDate>Tue, 28 Jul 2026 07:04:29 GMT</pubDate>
            <atom:updated>2026-07-28T07:24:12.248Z</atom:updated>
            <content:encoded><![CDATA[<h3>Day 1 — Understanding the Exam, AWS Fundamentals, and Building the Right Mindset</h3><blockquote>“Before learning AWS services, learn how AWS wants you to think.”</blockquote><h3>Introduction</h3><p>I recently started preparing for the <strong>AWS Certified Developer — Associate (DVA-C02)</strong> exam. Instead of silently reading documentation and hoping I remember everything, I’ve decided to document my journey publicly.</p><p>Over the next <strong>30 days</strong>, I’ll publish one article every day covering a specific topic from the exam guide. My goal isn’t just to pass the certification — it’s to truly understand how modern cloud applications are built.</p><p>If you’re preparing for the exam or are simply curious about AWS development, I hope these notes help you too.</p><p>Let’s begin with the most overlooked topic…</p><p><strong>Understanding what this exam is actually testing.</strong></p><h3>What is the AWS Developer Associate Exam?</h3><p>Many developers assume this certification is about memorizing AWS services.</p><p>It isn’t.</p><p>The exam evaluates whether you can build, deploy, secure, troubleshoot, and optimize applications that run on AWS.</p><p>Think of yourself as a backend developer building production software.</p><p>Every question asks something like:</p><blockquote><em>“Given this application requirement, which AWS service or architecture would you choose?”</em></blockquote><p>Notice that it doesn’t ask for definitions.</p><p>It tests engineering decisions.</p><h3>What Makes This Exam Different?</h3><p>The Developer Associate certification focuses on one simple question:</p><blockquote><strong><em>Can you build cloud-native applications on AWS?</em></strong></blockquote><p>Unlike the Solutions Architect certification, which focuses on designing infrastructure, the Developer Associate exam focuses on the developer’s day-to-day workflow.</p><p>That includes:</p><ul><li>Writing application code</li><li>Integrating AWS SDKs</li><li>Authenticating users</li><li>Deploying applications</li><li>Processing events</li><li>Debugging production issues</li><li>Monitoring applications</li><li>Managing secrets</li><li>Working with serverless architectures</li></ul><p>As developers, these are problems we solve every day.</p><p>AWS simply provides managed services to solve them more efficiently.</p><h3>The Biggest Mistake Beginners Make</h3><p>When people start learning AWS, they usually memorize service definitions.</p><p>For example:</p><blockquote><em>Lambda runs code.</em></blockquote><blockquote><em>S3 stores files.</em></blockquote><blockquote><em>DynamoDB is NoSQL.</em></blockquote><p>While these definitions are technically correct, they’re almost useless during the exam.</p><p>AWS doesn’t ask:</p><blockquote><em>“What is Lambda?”</em></blockquote><p>Instead, it asks:</p><blockquote><em>You need to execute backend code only when requests arrive, automatically scale to thousands of users, avoid managing servers, and pay only for execution time.</em></blockquote><p>Which AWS service should you choose?</p><p>Now the answer becomes obvious.</p><p><strong>Lambda.</strong></p><p>AWS exams test problem-solving, not memorization.</p><h3>Think in Problems, Not Services</h3><p>This is probably the biggest mindset shift you’ll make.</p><p>Instead of learning:</p><pre>Lambda<br>Definition: Runs code.</pre><p>Think like this:</p><pre>Problem</pre><pre>↓</pre><pre>Need backend execution</pre><pre>↓</pre><pre>Don&#39;t want servers</pre><pre>↓</pre><pre>Need automatic scaling</pre><pre>↓</pre><pre>Pay per request</pre><pre>↓</pre><pre>AWS Lambda</pre><p>Every AWS service exists because it solves a particular engineering problem.</p><p>Learn the problem first.</p><p>The service becomes obvious.</p><h3>The AWS Philosophy</h3><p>As I started reading AWS documentation, I noticed a recurring pattern.</p><p>AWS consistently encourages developers to choose managed services whenever possible.</p><p>Consider a simple example.</p><p>Suppose you need to process uploaded images.</p><p>A traditional approach might look like this:</p><pre>EC2 Server</pre><pre>↓</pre><pre>Python Script</pre><pre>↓</pre><pre>Resize Image</pre><pre>↓</pre><pre>Store Output</pre><p>On AWS, the preferred architecture is very different.</p><pre>Amazon S3</pre><pre>↓</pre><pre>Event Notification</pre><pre>↓</pre><pre>AWS Lambda</pre><pre>↓</pre><pre>Resize Image</pre><pre>↓</pre><pre>Amazon S3</pre><p>Notice what’s missing.</p><p>No server.</p><p>No operating system.</p><p>No manual scaling.</p><p>No infrastructure maintenance.</p><p>AWS wants developers to focus on business logic rather than infrastructure.</p><h3>Event-Driven Thinking</h3><p>One of the most important concepts for this certification is <strong>event-driven architecture</strong>.</p><p>Instead of applications constantly polling for changes, AWS services react to events.</p><p>Imagine a customer uploads an image.</p><pre>User uploads image</pre><pre>↓</pre><pre>Amazon S3 receives file</pre><pre>↓</pre><pre>S3 triggers Lambda</pre><pre>↓</pre><pre>Lambda processes image</pre><pre>↓</pre><pre>Store resized image</pre><pre>↓</pre><pre>Notify users</pre><p>Nobody manually starts the process.</p><p>Everything happens automatically.</p><p>This idea appears throughout the certification.</p><p>Once you understand event-driven systems, many AWS services suddenly make sense.</p><h3>The Core Serverless Architecture</h3><p>If I had to summarize the Developer Associate exam in one diagram, it would probably look like this:</p><pre>Client</pre><pre>↓</pre><pre>Amazon API Gateway</pre><pre>↓</pre><pre>AWS Lambda</pre><pre>↓</pre><pre>Amazon DynamoDB</pre><p>This architecture appears everywhere.</p><p>Sometimes SQS is inserted between services.</p><p>Sometimes EventBridge starts the workflow.</p><p>Sometimes Step Functions coordinate multiple Lambda functions.</p><p>But the overall philosophy remains the same.</p><p>Build small, scalable, event-driven systems using managed services.</p><h3>Learn Services by Asking Four Questions</h3><p>From today onward, every AWS service I study will answer these four questions.</p><h3>1. Why does this service exist?</h3><p>What engineering problem is AWS trying to solve?</p><h3>2. When should I use it?</h3><p>Which real-world scenarios make this service the best choice?</p><h3>3. When should I avoid it?</h3><p>Every service has limitations.</p><p>Understanding when <em>not</em> to use a service is just as important.</p><h3>4. Which services work well with it?</h3><p>AWS services rarely work in isolation.</p><p>Lambda integrates with API Gateway.</p><p>S3 integrates with Lambda.</p><p>CloudWatch monitors almost everything.</p><p>Learning integrations is far more valuable than memorizing isolated features.</p><h3>The 80/20 Rule for This Exam</h3><p>AWS has hundreds of services.</p><p>Fortunately, you don’t need to master all of them.</p><p>A relatively small group of services appears repeatedly throughout the certification.</p><p>These include:</p><ul><li>IAM</li><li>Lambda</li><li>API Gateway</li><li>DynamoDB</li><li>Amazon S3</li><li>CloudWatch</li><li>CloudFormation</li><li>AWS SAM</li><li>Amazon SNS</li><li>Amazon SQS</li><li>Amazon EventBridge</li><li>AWS Step Functions</li><li>Amazon ECS</li><li>AWS Fargate</li><li>Amazon ECR</li><li>Amazon Cognito</li><li>AWS Secrets Manager</li><li>AWS Systems Manager Parameter Store</li><li>AWS CodePipeline</li><li>AWS X-Ray</li></ul><p>Master these services and you’ll cover the majority of scenarios you’ll encounter during preparation.</p><h3>Revision Notes</h3><p>Before moving to Day 2, here’s everything I want to remember.</p><p>✅ This is a developer-focused certification.</p><p>✅ Questions are scenario-based, not definition-based.</p><p>✅ Think in terms of engineering problems.</p><p>✅ AWS prefers managed services over self-managed infrastructure.</p><p>✅ Event-driven architecture is a recurring theme.</p><p>✅ Serverless architectures appear frequently.</p><p>✅ Learn why a service exists before learning its features.</p><h3>What’s Next?</h3><p>In <strong>Day 2</strong>, we’ll dive into <strong>AWS Identity and Access Management (IAM)</strong> — arguably the most important service in AWS.</p><p>We’ll explore users, groups, roles, policies, temporary credentials, least privilege, cross-account access, IAM Identity Center, and the exam traps that catch many candidates.</p><p>Understanding IAM is foundational because almost every AWS service interacts with it.</p><p>See you in Day 2. 👋</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0f96774d64d8" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>