<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>IAM Roles on Digi Hunch</title><link>https://www.digihunch.com/tag/iam-roles/</link><description>Recent content in IAM Roles on Digi Hunch</description><generator>Hugo -- gohugo.io</generator><language>en-US</language><lastBuildDate>Tue, 08 Apr 2025 14:14:15 -0400</lastBuildDate><atom:link href="https://www.digihunch.com/tag/iam-roles/index.xml" rel="self" type="application/rss+xml"/><item><title>IAM Roles for any workload</title><link>https://www.digihunch.com/2024/07/iam-roles-for-any-workload/</link><pubDate>Sun, 14 Jul 2024 23:53:49 -0400</pubDate><guid>https://www.digihunch.com/2024/07/iam-roles-for-any-workload/</guid><description>&lt;img src="https://www.digihunch.com/wp-content/uploads/2025/04/feature-iam-role-anywhere.webp" alt="Featured image of post IAM Roles for any workload" /&gt;&lt;h2 class="wp-block-heading"&gt;Background&lt;/h2&gt;&#10;&lt;p class="wp-block-paragraph"&gt;A few month back a client of mine wanted to use GitLab pipeline to deploy infrastructure on AWS with Terraform. The key question is how to authenticate the Terraform process running in the pipeline to AWS with temporary credential. Having &lt;a href="https://www.digihunch.com/2023/01/github-action-gotchas/"&gt;worked it out on GitHub&lt;/a&gt;, my proposal at time was to &lt;a href="https://docs.gitlab.com/ee/ci/cloud_services/aws/"&gt;add OIDC provider&lt;/a&gt; to represent the GitLab runner. &lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;After a few months, they told me that they are self-hosting their GitLab instance. The idea above was based on exposing an identity provider document on the public Internet, which the client is unable to do. &lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;Now, I have an idea: IAM Roles Anywhere.&lt;/p&gt;&#10;&lt;h2 class="wp-block-heading"&gt;IAM Role Introduction&lt;/h2&gt;&#10;&lt;p class="wp-block-paragraph"&gt;Many 101 tutorials asks beginners to create standalone IAM users (or group) with IAM policies directly attached. For programatic access they also include creating a pair of access key and secret access key and pass them along to an external application. The keys are long term credentials, and worse, never expires. The leakage of these long-term credentials had been such a headache that AWS strongly discourage the use of long term credentials. You can feel the discouragement when trying to create an access key through the web console, or by the banners on top of the &lt;a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_access-keys.html"&gt;documentation page&lt;/a&gt; about how to do so. &lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;The recommendation is use temporary security credentials. In the context of AWS that means IAM roles. The users must assume an IAM role by issuing an API call, and the Security Token Service (STS) grants temporary credential in response.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;&lt;svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="351px" viewBox="-0.5 -0.5 351 122" style="max-width:100%;max-height:122px;"&gt;&lt;defs&gt;&lt;/defs&gt;&lt;g&gt;&lt;g data-cell-id="0"&gt;&lt;g data-cell-id="1"&gt;&lt;g data-cell-id="VRZMaZhQ_cbes_kdLvWi-8"&gt;&lt;g&gt;&lt;rect x="0" y="0" width="350" height="120" fill="rgb(255, 255, 255)" stroke="rgb(0, 0, 0)" pointer-events="all"&gt;&lt;/rect&gt;&lt;/g&gt;&lt;/g&gt;&lt;g data-cell-id="VRZMaZhQ_cbes_kdLvWi-1"&gt;&lt;g&gt;&lt;path d="M 320 76.55 C 320 78.52 318.4 80 316.39 80 L 275.69 80 C 273.24 80 272 78.23 272 76.73 L 272 23.42 C 272 21.21 273.91 20 275.64 20 L 316.61 20 C 318.37 20 320 21.41 320 23.36 Z" fill="#759c3e" stroke="none" pointer-events="all"&gt;&lt;/path&gt;&lt;path d="M 295.89 56.07 C 287 56.07 278.95 49.27 278.95 39.5 C 278.95 30.98 286.32 23.48 296.19 23.48 C 304.93 23.48 313.05 30.44 313.05 39.71 C 313.05 48.35 305.84 56.07 295.89 56.07 Z" fill="#4f4f4f" stroke="none" pointer-events="all"&gt;&lt;/path&gt;&lt;path d="M 290.59 67.19 L 289.18 67.19 C 289.18 66.44 288.94 65.57 287.89 65.1 C 287.29 64.88 286.32 64.7 285.21 65.03 C 284.66 65.21 284.16 65.6 284.03 66.33 C 283.83 67.41 284.66 67.82 285.47 68.06 C 287.2 68.52 287.94 68.57 288.78 68.88 C 289.71 69.2 290.7 69.74 291 70.92 C 291.25 72.24 290.73 73.18 290.02 73.74 C 289.29 74.34 288.02 74.8 286.34 74.74 C 284.99 74.68 283.8 74.23 283.11 73.54 C 282.51 72.94 282.12 72.18 282.12 71.01 L 283.51 71.01 C 283.56 72.22 284.17 72.91 285.07 73.32 C 286.09 73.71 287.44 73.72 288.38 73.32 C 288.99 73.06 289.55 72.54 289.54 71.68 C 289.52 70.86 288.97 70.36 287.76 70.05 C 286.65 69.75 285.55 69.68 284.52 69.32 C 283.44 68.93 282.23 68.21 282.53 66.33 C 282.71 65.16 283.64 64.33 285.11 63.98 C 286.46 63.7 287.91 63.83 288.89 64.34 C 289.87 64.87 290.54 65.81 290.59 67.19 Z M 300.45 65.04 L 296.82 65.04 L 296.82 74.38 L 295.34 74.38 L 295.34 65.04 L 291.64 65.04 L 291.64 63.82 L 300.45 63.82 Z M 309.41 67.19 L 308 67.19 C 308 66.44 307.76 65.55 306.71 65.07 C 306.12 64.85 305.15 64.67 304.03 65.01 C 303.48 65.19 302.98 65.57 302.85 66.3 C 302.65 67.4 303.48 67.8 304.3 68.04 C 306.02 68.51 306.75 68.54 307.61 68.85 C 308.53 69.17 309.52 69.71 309.8 70.89 C 310.07 72.22 309.55 73.15 308.85 73.72 C 308.11 74.31 306.84 74.77 305.16 74.71 C 303.81 74.67 302.62 74.2 301.93 73.51 C 301.33 72.93 300.94 72.18 300.94 71.01 L 302.34 71.01 C 302.38 72.22 303 72.88 303.89 73.29 C 304.91 73.69 306.26 73.71 307.2 73.3 C 307.81 73.05 308.38 72.52 308.36 71.65 C 308.35 70.84 307.78 70.35 306.59 70.03 C 305.47 69.72 304.38 69.65 303.34 69.29 C 302.26 68.91 301.05 68.18 301.35 66.32 C 301.54 65.13 302.46 64.31 303.94 63.95 C 305.29 63.67 306.73 63.82 307.7 64.33 C 308.69 64.85 309.36 65.81 309.41 67.19 Z M 298.93 42.57 L 298.93 29.55 L 295.42 29.55 L 295.42 39.21 L 288.94 39.21 L 288.94 42.57 Z M 295.95 52.7 C 288.61 52.7 282.46 46.9 282.46 39.65 C 282.46 32.29 288.96 26.83 296.13 26.83 C 303.15 26.83 309.52 32.51 309.52 39.77 C 309.52 47.09 303.15 52.7 295.95 52.7 Z" fill="#ffffff" stroke="none" pointer-events="all"&gt;&lt;/path&gt;&lt;/g&gt;&lt;/g&gt;&lt;g data-cell-id="VRZMaZhQ_cbes_kdLvWi-2"&gt;&lt;g&gt;&lt;path d="M 56.16 79.58 L 48.37 75.17 L 43 78.24 L 30 70.84 L 30 56.08 L 37.43 51.83 L 37.43 32.71 L 59.71 20 L 82 32.69 L 82 58.05 L 64.07 68.25 L 64.07 75.04 Z" fill="#444444" stroke="none" pointer-events="all"&gt;&lt;/path&gt;&lt;path d="M 59.71 44.44 L 79.65 33.11 L 59.79 21.87 L 39.94 33.11 Z M 42.35 63.72 L 31.21 57.4 L 31.21 70.11 L 42.35 76.5 Z M 42.92 62.75 L 54.06 56.35 L 42.92 50.03 L 31.78 56.35 Z M 54.7 62.3 L 54.7 57.48 L 43.56 63.79 L 43.56 76.5 L 48.17 73.87 L 48.17 65.98 Z M 58.9 63.12 L 58.9 45.9 L 39.04 34.57 L 39.04 50.92 L 42.99 48.66 L 55.91 56.02 L 55.91 61.62 L 56.08 61.54 Z M 64.06 66.51 L 80.46 57.16 L 80.46 34.49 L 60.6 45.82 L 60.6 64.07 L 64.06 66.03 Z M 55.92 69.87 L 62.05 66.39 L 55.99 62.9 L 49.93 66.39 Z M 55.51 77.8 L 55.51 70.84 L 49.37 67.35 L 49.37 74.32 Z M 56.63 77.8 L 62.78 74.32 L 62.78 67.35 L 56.63 70.84 Z" fill="#ffffff" stroke="none" pointer-events="all"&gt;&lt;/path&gt;&lt;/g&gt;&lt;g&gt;&lt;g transform="translate(-0.5 -0.5)"&gt;&lt;switch&gt;&lt;foreignObject pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility" style="overflow: visible; text-align: left;"&gt;&lt;div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe flex-start; justify-content: unsafe center; width: 1px; height: 1px; padding-top: 87px; margin-left: 56px;"&gt;&lt;div data-drawio-colors="color: rgb(0, 0, 0); " style="box-sizing: border-box; font-size: 0px; text-align: center;"&gt;&lt;div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; pointer-events: all; white-space: nowrap;"&gt;CLI&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/foreignObject&gt;&lt;text x="56" y="99" fill="rgb(0, 0, 0)" font-family="&amp;quot;Helvetica&amp;quot;" font-size="12px" text-anchor="middle"&gt;CLI&lt;/text&gt;&lt;/switch&gt;&lt;/g&gt;&lt;/g&gt;&lt;/g&gt;&lt;g data-cell-id="VRZMaZhQ_cbes_kdLvWi-4"&gt;&lt;g&gt;&lt;path d="M 82 32.81 L 263.63 32.99" fill="none" stroke="rgb(0, 0, 0)" stroke-miterlimit="10" pointer-events="stroke"&gt;&lt;/path&gt;&lt;path d="M 268.88 33 L 261.88 36.49 L 263.63 32.99 L 261.89 29.49 Z" fill="rgb(0, 0, 0)" stroke="rgb(0, 0, 0)" stroke-miterlimit="10" pointer-events="all"&gt;&lt;/path&gt;&lt;/g&gt;&lt;g data-cell-id="VRZMaZhQ_cbes_kdLvWi-6"&gt;&lt;g&gt;&lt;g transform="translate(-0.5 -0.5)"&gt;&lt;switch&gt;&lt;foreignObject pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility" style="overflow: visible; text-align: left;"&gt;&lt;div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 1px; height: 1px; padding-top: 20px; margin-left: 163px;"&gt;&lt;div data-drawio-colors="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); " style="box-sizing: border-box; font-size: 0px; text-align: center;"&gt;&lt;div style="display: inline-block; font-size: 11px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; pointer-events: all; background-color: rgb(255, 255, 255); white-space: nowrap;"&gt;Request: AssumeRole*&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/foreignObject&gt;&lt;text x="163" y="23" fill="rgb(0, 0, 0)" font-family="&amp;quot;Helvetica&amp;quot;" font-size="11px" text-anchor="middle"&gt;Request: AssumeRole*&lt;/text&gt;&lt;/switch&gt;&lt;/g&gt;&lt;/g&gt;&lt;/g&gt;&lt;/g&gt;&lt;g data-cell-id="VRZMaZhQ_cbes_kdLvWi-5"&gt;&lt;g&gt;&lt;path d="M 270 60 L 88.37 57.91" fill="none" stroke="rgb(0, 0, 0)" stroke-miterlimit="10" pointer-events="stroke"&gt;&lt;/path&gt;&lt;path d="M 83.12 57.85 L 90.16 54.43 L 88.37 57.91 L 90.08 61.43 Z" fill="rgb(0, 0, 0)" stroke="rgb(0, 0, 0)" stroke-miterlimit="10" pointer-events="all"&gt;&lt;/path&gt;&lt;/g&gt;&lt;g data-cell-id="VRZMaZhQ_cbes_kdLvWi-7"&gt;&lt;g&gt;&lt;g transform="translate(-0.5 -0.5)"&gt;&lt;switch&gt;&lt;foreignObject pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility" style="overflow: visible; text-align: left;"&gt;&lt;div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe flex-start; width: 1px; height: 1px; padding-top: 90px; margin-left: 122px;"&gt;&lt;div data-drawio-colors="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); " style="box-sizing: border-box; font-size: 0px; text-align: left;"&gt;&lt;div style="display: inline-block; font-size: 11px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; pointer-events: all; background-color: rgb(255, 255, 255); white-space: nowrap;"&gt;Response:&lt;div&gt;&amp;#8211; AccessKeyId&lt;/div&gt;&lt;div&gt;&amp;#8211; SecretAccessKey&lt;/div&gt;&lt;div&gt;&amp;#8211; SessionToken&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/foreignObject&gt;&lt;text x="122" y="94" fill="rgb(0, 0, 0)" font-family="&amp;quot;Helvetica&amp;quot;" font-size="11px"&gt;Response:&amp;#8230;&lt;/text&gt;&lt;/switch&gt;&lt;/g&gt;&lt;/g&gt;&lt;/g&gt;&lt;/g&gt;&lt;/g&gt;&lt;/g&gt;&lt;/g&gt;&lt;switch&gt;&lt;g requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"&gt;&lt;/g&gt;&lt;a transform="translate(0,-5)" xlink:href="https://www.drawio.com/doc/faq/svg-export-text-problems" target="_blank" rel="noopener"&gt;&lt;text text-anchor="middle" font-size="10px" x="50%" y="100%"&gt;Text is not SVG &amp;#8211; cannot display&lt;/text&gt;&lt;/a&gt;&lt;/switch&gt;&lt;/svg&gt;&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;This diagram has several variations. For example, the request can be AssumeRole, AssumeRoleWithSAML and AssumeRoleWithWebIdentity, depending on whether and how the user info is federated with external identity store. The returned response, a triplet of three values, makes the temporary credential that we should use in any secure environment. They must be renewed before expiry. This model works not only for human identity (e.g. SAML integration, OIDC integration, cross-account access) but also for workload identity (e.g. EC2 instance profile, Lambda execution role, ECS task role, etc). &lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;Another good example is &lt;a href="https://www.digihunch.com/2024/01/workload-identity-on-kubernetes-2-of-2-eks-and-rosa-on-aws/"&gt;IAM Role for Service Account (IRSA)&lt;/a&gt;, where a web identity represents a Kuberentes Service Account to gain role credential using the AssumeRoleWithWebIdentity API. In this post however, I&amp;#8217;d like to explore more about the IAM role for EC2 instance profile.&lt;/p&gt;&#10;&lt;h2 class="wp-block-heading"&gt;The IMDS service &lt;/h2&gt;&#10;&lt;p class="wp-block-paragraph"&gt;For EC2 instance, we all know that we can associate an IAM role as the instance profile and grant the process using AWS SDK running on the instance with permissions associated with the IAM role. At a lower level, this relies on the IMDS (Instance Metadata Service) running on the instance.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;If an EC2 instance&amp;#8217;s profile points to an IAM role, a process running on the instance using AWS SDK will also need to get the triplet from the STS. It is summarized in this diagram:&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;&lt;svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="531px" viewBox="-0.5 -0.5 531 141" style="max-width:100%;max-height:141px;"&gt;&lt;defs&gt;&lt;/defs&gt;&lt;g&gt;&lt;g data-cell-id="0"&gt;&lt;g data-cell-id="1"&gt;&lt;g data-cell-id="mtzehsWG86ey03g9Zuuk-1"&gt;&lt;g&gt;&lt;rect x="0" y="0" width="530" height="140" fill="rgb(255, 255, 255)" stroke="rgb(0, 0, 0)" pointer-events="all"&gt;&lt;/rect&gt;&lt;/g&gt;&lt;/g&gt;&lt;g data-cell-id="mtzehsWG86ey03g9Zuuk-2"&gt;&lt;g&gt;&lt;rect x="10" y="10" width="330" height="100" fill="#d5e8d4" stroke="#82b366" pointer-events="all"&gt;&lt;/rect&gt;&lt;/g&gt;&lt;/g&gt;&lt;g data-cell-id="mtzehsWG86ey03g9Zuuk-3"&gt;&lt;g&gt;&lt;path d="M 518 101.55 C 518 103.52 516.4 105 514.39 105 L 473.69 105 C 471.24 105 470 103.23 470 101.73 L 470 48.42 C 470 46.21 471.91 45 473.64 45 L 514.61 45 C 516.37 45 518 46.41 518 48.36 Z" fill="#759c3e" stroke="none" pointer-events="all"&gt;&lt;/path&gt;&lt;path d="M 493.89 81.07 C 485 81.07 476.95 74.27 476.95 64.5 C 476.95 55.98 484.32 48.48 494.19 48.48 C 502.93 48.48 511.05 55.44 511.05 64.71 C 511.05 73.35 503.84 81.07 493.89 81.07 Z" fill="#4f4f4f" stroke="none" pointer-events="all"&gt;&lt;/path&gt;&lt;path d="M 488.59 92.19 L 487.18 92.19 C 487.18 91.44 486.94 90.57 485.89 90.1 C 485.29 89.88 484.32 89.7 483.21 90.03 C 482.66 90.21 482.16 90.6 482.03 91.33 C 481.83 92.41 482.66 92.82 483.47 93.06 C 485.2 93.52 485.94 93.57 486.78 93.88 C 487.71 94.2 488.7 94.74 489 95.92 C 489.25 97.24 488.73 98.18 488.02 98.74 C 487.29 99.34 486.02 99.8 484.34 99.74 C 482.99 99.68 481.8 99.23 481.11 98.54 C 480.51 97.94 480.12 97.18 480.12 96.01 L 481.51 96.01 C 481.56 97.22 482.17 97.91 483.07 98.32 C 484.09 98.71 485.44 98.72 486.38 98.32 C 486.99 98.06 487.55 97.54 487.54 96.68 C 487.52 95.86 486.97 95.36 485.76 95.05 C 484.65 94.75 483.55 94.68 482.52 94.32 C 481.44 93.93 480.23 93.21 480.53 91.33 C 480.71 90.16 481.64 89.33 483.11 88.98 C 484.46 88.7 485.91 88.83 486.89 89.34 C 487.87 89.87 488.54 90.81 488.59 92.19 Z M 498.45 90.04 L 494.82 90.04 L 494.82 99.38 L 493.34 99.38 L 493.34 90.04 L 489.64 90.04 L 489.64 88.82 L 498.45 88.82 Z M 507.41 92.19 L 506 92.19 C 506 91.44 505.76 90.55 504.71 90.07 C 504.12 89.85 503.15 89.67 502.03 90.01 C 501.48 90.19 500.98 90.57 500.85 91.3 C 500.65 92.4 501.48 92.8 502.3 93.04 C 504.02 93.51 504.75 93.54 505.61 93.85 C 506.53 94.17 507.52 94.71 507.8 95.89 C 508.07 97.22 507.55 98.15 506.85 98.72 C 506.11 99.31 504.84 99.77 503.16 99.71 C 501.81 99.67 500.62 99.2 499.93 98.51 C 499.33 97.93 498.94 97.18 498.94 96.01 L 500.34 96.01 C 500.38 97.22 501 97.88 501.89 98.29 C 502.91 98.69 504.26 98.71 505.2 98.3 C 505.81 98.05 506.38 97.52 506.36 96.65 C 506.35 95.84 505.78 95.35 504.59 95.03 C 503.47 94.72 502.38 94.65 501.34 94.29 C 500.26 93.91 499.05 93.18 499.35 91.32 C 499.54 90.13 500.46 89.31 501.94 88.95 C 503.29 88.67 504.73 88.82 505.7 89.33 C 506.69 89.85 507.36 90.81 507.41 92.19 Z M 496.93 67.57 L 496.93 54.55 L 493.42 54.55 L 493.42 64.21 L 486.94 64.21 L 486.94 67.57 Z M 493.95 77.7 C 486.61 77.7 480.46 71.9 480.46 64.65 C 480.46 57.29 486.96 51.83 494.13 51.83 C 501.15 51.83 507.52 57.51 507.52 64.77 C 507.52 72.09 501.15 77.7 493.95 77.7 Z" fill="#ffffff" stroke="none" pointer-events="all"&gt;&lt;/path&gt;&lt;/g&gt;&lt;/g&gt;&lt;g data-cell-id="mtzehsWG86ey03g9Zuuk-4"&gt;&lt;g&gt;&lt;rect x="212.5" y="60" width="105" height="35" rx="5.25" ry="5.25" fill="#ffe6cc" stroke="#d79b00" pointer-events="all"&gt;&lt;/rect&gt;&lt;/g&gt;&lt;g&gt;&lt;g transform="translate(-0.5 -0.5)"&gt;&lt;switch&gt;&lt;foreignObject pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility" style="overflow: visible; text-align: left;"&gt;&lt;div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 103px; height: 1px; padding-top: 78px; margin-left: 214px;"&gt;&lt;div data-drawio-colors="color: rgb(0, 0, 0); " style="box-sizing: border-box; font-size: 0px; text-align: center;"&gt;&lt;div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; pointer-events: all; white-space: normal; overflow-wrap: normal;"&gt;IMDS v2&lt;div&gt;169.254.169.254&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/foreignObject&gt;&lt;text x="265" y="81" fill="rgb(0, 0, 0)" font-family="&amp;quot;Helvetica&amp;quot;" font-size="12px" text-anchor="middle"&gt;IMDS v2&amp;#8230;&lt;/text&gt;&lt;/switch&gt;&lt;/g&gt;&lt;/g&gt;&lt;/g&gt;&lt;g data-cell-id="mtzehsWG86ey03g9Zuuk-5"&gt;&lt;g&gt;&lt;rect x="30" y="62.5" width="120" height="30" fill="#dae8fc" stroke="#6c8ebf" pointer-events="all"&gt;&lt;/rect&gt;&lt;/g&gt;&lt;g&gt;&lt;g transform="translate(-0.5 -0.5)"&gt;&lt;switch&gt;&lt;foreignObject pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility" style="overflow: visible; text-align: left;"&gt;&lt;div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 118px; height: 1px; padding-top: 78px; margin-left: 31px;"&gt;&lt;div data-drawio-colors="color: rgb(0, 0, 0); " style="box-sizing: border-box; font-size: 0px; text-align: center;"&gt;&lt;div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; pointer-events: all; white-space: normal; overflow-wrap: normal;"&gt;AWS SDK&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/foreignObject&gt;&lt;text x="90" y="81" fill="rgb(0, 0, 0)" font-family="&amp;quot;Helvetica&amp;quot;" font-size="12px" text-anchor="middle"&gt;AWS SDK&lt;/text&gt;&lt;/switch&gt;&lt;/g&gt;&lt;/g&gt;&lt;/g&gt;&lt;g data-cell-id="mtzehsWG86ey03g9Zuuk-6"&gt;&lt;g&gt;&lt;path d="M 149.88 74.26 L 206.76 75.35" fill="none" stroke="rgb(0, 0, 0)" stroke-miterlimit="10" pointer-events="stroke"&gt;&lt;/path&gt;&lt;path d="M 212.01 75.45 L 204.95 78.81 L 206.76 75.35 L 205.08 71.82 Z" fill="rgb(0, 0, 0)" stroke="rgb(0, 0, 0)" stroke-miterlimit="10" pointer-events="all"&gt;&lt;/path&gt;&lt;/g&gt;&lt;/g&gt;&lt;g data-cell-id="mtzehsWG86ey03g9Zuuk-7"&gt;&lt;g&gt;&lt;path d="M 211.87 84.5 L 156.37 84.95" fill="none" stroke="rgb(0, 0, 0)" stroke-miterlimit="10" pointer-events="stroke"&gt;&lt;/path&gt;&lt;path d="M 151.12 84.99 L 158.09 81.43 L 156.37 84.95 L 158.15 88.43 Z" fill="rgb(0, 0, 0)" stroke="rgb(0, 0, 0)" stroke-miterlimit="10" pointer-events="all"&gt;&lt;/path&gt;&lt;/g&gt;&lt;/g&gt;&lt;g data-cell-id="mtzehsWG86ey03g9Zuuk-8"&gt;&lt;g&gt;&lt;path d="M 317.29 70.78 L 463.63 70.03" fill="none" stroke="rgb(0, 0, 0)" stroke-miterlimit="10" pointer-events="stroke"&gt;&lt;/path&gt;&lt;path d="M 468.88 70.01 L 461.9 73.54 L 463.63 70.03 L 461.86 66.54 Z" fill="rgb(0, 0, 0)" stroke="rgb(0, 0, 0)" stroke-miterlimit="10" pointer-events="all"&gt;&lt;/path&gt;&lt;/g&gt;&lt;g data-cell-id="mtzehsWG86ey03g9Zuuk-9"&gt;&lt;g&gt;&lt;g transform="translate(-0.5 -0.5)"&gt;&lt;switch&gt;&lt;foreignObject pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility" style="overflow: visible; text-align: left;"&gt;&lt;div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 1px; height: 1px; padding-top: 58px; margin-left: 398px;"&gt;&lt;div data-drawio-colors="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); " style="box-sizing: border-box; font-size: 0px; text-align: center;"&gt;&lt;div style="display: inline-block; font-size: 11px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; pointer-events: all; background-color: rgb(255, 255, 255); white-space: nowrap;"&gt;Request: AssumeRole&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/foreignObject&gt;&lt;text x="398" y="61" fill="rgb(0, 0, 0)" font-family="&amp;quot;Helvetica&amp;quot;" font-size="11px" text-anchor="middle"&gt;Request: AssumeRole&lt;/text&gt;&lt;/switch&gt;&lt;/g&gt;&lt;/g&gt;&lt;/g&gt;&lt;/g&gt;&lt;g data-cell-id="mtzehsWG86ey03g9Zuuk-10"&gt;&lt;g&gt;&lt;path d="M 470 80 L 322.29 81.53" fill="none" stroke="rgb(0, 0, 0)" stroke-miterlimit="10" pointer-events="stroke"&gt;&lt;/path&gt;&lt;path d="M 317.04 81.58 L 324.01 78.01 L 322.29 81.53 L 324.08 85.01 Z" fill="rgb(0, 0, 0)" stroke="rgb(0, 0, 0)" stroke-miterlimit="10" pointer-events="all"&gt;&lt;/path&gt;&lt;/g&gt;&lt;g data-cell-id="mtzehsWG86ey03g9Zuuk-11"&gt;&lt;g&gt;&lt;g transform="translate(-0.5 -0.5)"&gt;&lt;switch&gt;&lt;foreignObject pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility" style="overflow: visible; text-align: left;"&gt;&lt;div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe flex-start; width: 1px; height: 1px; padding-top: 112px; margin-left: 352px;"&gt;&lt;div data-drawio-colors="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); " style="box-sizing: border-box; font-size: 0px; text-align: left;"&gt;&lt;div style="display: inline-block; font-size: 11px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; pointer-events: all; background-color: rgb(255, 255, 255); white-space: nowrap;"&gt;Response:&lt;div&gt;&amp;#8211; AccessKeyId&lt;/div&gt;&lt;div&gt;&amp;#8211; SecretAccessKey&lt;/div&gt;&lt;div&gt;&amp;#8211; SessionToken&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/foreignObject&gt;&lt;text x="352" y="115" fill="rgb(0, 0, 0)" font-family="&amp;quot;Helvetica&amp;quot;" font-size="11px"&gt;Response:&amp;#8230;&lt;/text&gt;&lt;/switch&gt;&lt;/g&gt;&lt;/g&gt;&lt;/g&gt;&lt;/g&gt;&lt;g data-cell-id="mtzehsWG86ey03g9Zuuk-12"&gt;&lt;g&gt;&lt;rect x="30" y="25" width="120" height="37.5" fill="rgb(255, 255, 255)" stroke="rgb(0, 0, 0)" pointer-events="all"&gt;&lt;/rect&gt;&lt;path d="M 42 25 L 42 62.5 M 138 25 L 138 62.5" fill="none" stroke="rgb(0, 0, 0)" stroke-miterlimit="10" pointer-events="all"&gt;&lt;/path&gt;&lt;/g&gt;&lt;g&gt;&lt;g transform="translate(-0.5 -0.5)"&gt;&lt;switch&gt;&lt;foreignObject pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility" style="overflow: visible; text-align: left;"&gt;&lt;div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 94px; height: 1px; padding-top: 44px; margin-left: 43px;"&gt;&lt;div data-drawio-colors="color: rgb(0, 0, 0); " style="box-sizing: border-box; font-size: 0px; text-align: center;"&gt;&lt;div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; pointer-events: all; white-space: normal; overflow-wrap: normal;"&gt;Application&lt;div&gt;Process&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/foreignObject&gt;&lt;text x="90" y="47" fill="rgb(0, 0, 0)" font-family="&amp;quot;Helvetica&amp;quot;" font-size="12px" text-anchor="middle"&gt;Application&amp;#8230;&lt;/text&gt;&lt;/switch&gt;&lt;/g&gt;&lt;/g&gt;&lt;/g&gt;&lt;g data-cell-id="mtzehsWG86ey03g9Zuuk-13"&gt;&lt;g&gt;&lt;path d="M 180 20 L 210 20 L 210 50 L 180 50 Z" fill="#ed7100" stroke="none" pointer-events="all"&gt;&lt;/path&gt;&lt;path d="M 189.43 40.57 L 200.14 40.57 L 200.14 29.86 L 189.43 29.86 Z M 201 29.86 L 202.71 29.86 L 202.71 30.71 L 201 30.71 L 201 32.43 L 202.71 32.43 L 202.71 33.29 L 201 33.29 L 201 34.57 L 202.71 34.57 L 202.71 35.43 L 201 35.43 L 201 37.14 L 202.71 37.14 L 202.71 38 L 201 38 L 201 39.71 L 202.71 39.71 L 202.71 40.57 L 201 40.57 L 201 40.63 C 201 41.07 200.64 41.43 200.2 41.43 L 200.14 41.43 L 200.14 43.14 L 199.29 43.14 L 199.29 41.43 L 197.57 41.43 L 197.57 43.14 L 196.71 43.14 L 196.71 41.43 L 195.43 41.43 L 195.43 43.14 L 194.57 43.14 L 194.57 41.43 L 192.86 41.43 L 192.86 43.14 L 192 43.14 L 192 41.43 L 190.29 41.43 L 190.29 43.14 L 189.43 43.14 L 189.43 41.43 L 189.37 41.43 C 188.93 41.43 188.57 41.07 188.57 40.63 L 188.57 40.57 L 187.29 40.57 L 187.29 39.71 L 188.57 39.71 L 188.57 38 L 187.29 38 L 187.29 37.14 L 188.57 37.14 L 188.57 35.43 L 187.29 35.43 L 187.29 34.57 L 188.57 34.57 L 188.57 33.29 L 187.29 33.29 L 187.29 32.43 L 188.57 32.43 L 188.57 30.71 L 187.29 30.71 L 187.29 29.86 L 188.57 29.86 L 188.57 29.8 C 188.57 29.36 188.93 29 189.37 29 L 189.43 29 L 189.43 27.29 L 190.29 27.29 L 190.29 29 L 192 29 L 192 27.29 L 192.86 27.29 L 192.86 29 L 194.57 29 L 194.57 27.29 L 195.43 27.29 L 195.43 29 L 196.71 29 L 196.71 27.29 L 197.57 27.29 L 197.57 29 L 199.29 29 L 199.29 27.29 L 200.14 27.29 L 200.14 29 L 200.2 29 C 200.64 29 201 29.36 201 29.8 Z M 195.43 46.09 C 195.43 46.12 195.4 46.14 195.38 46.14 L 183.91 46.14 C 183.88 46.14 183.86 46.12 183.86 46.09 L 183.86 34.62 C 183.86 34.6 183.88 34.57 183.91 34.57 L 186.43 34.57 L 186.43 33.71 L 183.91 33.71 C 183.41 33.71 183 34.12 183 34.62 L 183 46.09 C 183 46.59 183.41 47 183.91 47 L 195.38 47 C 195.88 47 196.29 46.59 196.29 46.09 L 196.29 44 L 195.43 44 Z M 207 23.91 L 207 35.38 C 207 35.88 206.59 36.29 206.09 36.29 L 203.57 36.29 L 203.57 35.43 L 206.09 35.43 C 206.12 35.43 206.14 35.4 206.14 35.38 L 206.14 23.91 C 206.14 23.88 206.12 23.86 206.09 23.86 L 194.62 23.86 C 194.6 23.86 194.57 23.88 194.57 23.91 L 194.57 26.43 L 193.71 26.43 L 193.71 23.91 C 193.71 23.41 194.12 23 194.62 23 L 206.09 23 C 206.59 23 207 23.41 207 23.91 Z" fill="#ffffff" stroke="none" pointer-events="all"&gt;&lt;/path&gt;&lt;/g&gt;&lt;g&gt;&lt;g transform="translate(-0.5 -0.5)"&gt;&lt;switch&gt;&lt;foreignObject pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility" style="overflow: visible; text-align: left;"&gt;&lt;div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe flex-start; width: 1px; height: 1px; padding-top: 35px; margin-left: 212px;"&gt;&lt;div data-drawio-colors="color: #232F3E; " style="box-sizing: border-box; font-size: 0px; text-align: left;"&gt;&lt;div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(35, 47, 62); line-height: 1.2; pointer-events: all; white-space: nowrap;"&gt;&lt;div&gt;&lt;span style="background-color: initial;"&gt;EC2 Instance&lt;/span&gt;&lt;br&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/foreignObject&gt;&lt;text x="212" y="39" fill="#232F3E" font-family="&amp;quot;Helvetica&amp;quot;" font-size="12px"&gt;EC2 I&amp;#8230;&lt;/text&gt;&lt;/switch&gt;&lt;/g&gt;&lt;/g&gt;&lt;/g&gt;&lt;/g&gt;&lt;/g&gt;&lt;/g&gt;&lt;switch&gt;&lt;g requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"&gt;&lt;/g&gt;&lt;a transform="translate(0,-5)" xlink:href="https://www.drawio.com/doc/faq/svg-export-text-problems" target="_blank" rel="noopener"&gt;&lt;text text-anchor="middle" font-size="10px" x="50%" y="100%"&gt;Text is not SVG &amp;#8211; cannot display&lt;/text&gt;&lt;/a&gt;&lt;/switch&gt;&lt;/svg&gt;&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;The IMDS is a service available on one of the link-local IP address (169.254.169.254) on the EC2 instance. Requests made to this IP address are not routed elsewhere. The Instance Metadata Service (IMDS) is a means for the cloud service provider&amp;#8217;s virtualization layer to share information with the processes on the operating system of a virtual machine. It responds with information related to the instance itself, such as the subnets, IAM role, instance ID, AMI ID, security group. The instance metadata also includes user data script for cloud init process to consume, and most relevantly, the role credential for the instance. This also requires that the IMDS service to have connectivity to the STS endpoint, either via interface endpoint or over the Internet. The AssumeRole calls are logged in CloudTrail.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;All major cloud vendors (AWS, Azure and GCP) uses the IMDS mechanism, and this mechanism obviously draws the attention of bad actors. I find some good articles on this &lt;a href="https://www.sans.org/blog/cloud-instance-metadata-services-imds-/"&gt;here&lt;/a&gt; and &lt;a href="https://www.tenable.com/blog/secure-your-aws-ec2-instance-metadata-service-imds"&gt;here&lt;/a&gt;.&lt;/p&gt;&#10;&lt;h2 class="wp-block-heading"&gt;IAM Role for EC2 Workload&lt;/h2&gt;&#10;&lt;p class="wp-block-paragraph"&gt;For EC2 instances at AWS, the initial IMDS v1 was introduced in 2012 and allows a GET method to fetch instance metadata. The IMDS v1 is subject to attacks such as SSRF (Server-side request forgery). In 2019 AWS introduced IMDS v2 which tackles those &lt;a href="https://aws.amazon.com/blogs/security/defense-in-depth-open-firewalls-reverse-proxies-ssrf-vulnerabilities-ec2-instance-metadata-service/"&gt;vulnerabilities&lt;/a&gt;. As of date, the recommendation is to use IMDSv2. Here is an example of how to fetch instance metadata, including the credential:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# Grab a token&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;TOKEN&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;`&lt;/span&gt;curl -X PUT &lt;span style="color:#e6db74"&gt;&amp;#34;http://169.254.169.254/latest/api/token&amp;#34;&lt;/span&gt; -H &lt;span style="color:#e6db74"&gt;&amp;#34;X-aws-ec2-metadata-token-ttl-seconds: 21600&amp;#34;&lt;/span&gt;&lt;span style="color:#e6db74"&gt;`&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# Get top-level instance metadata information&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;curl http://169.254.169.254/latest/meta-data/profile -H &lt;span style="color:#e6db74"&gt;&amp;#34;X-aws-ec2-metadata-token: &lt;/span&gt;$TOKEN&lt;span style="color:#e6db74"&gt;&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# Get the name of the role&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;curl -H &lt;span style="color:#e6db74"&gt;&amp;#34;X-aws-ec2-metadata-token: &lt;/span&gt;$TOKEN&lt;span style="color:#e6db74"&gt;&amp;#34;&lt;/span&gt; http://169.254.169.254/latest/meta-data/iam/security-credentials&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# Get the credential for the role session&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;curl -H &lt;span style="color:#e6db74"&gt;&amp;#34;X-aws-ec2-metadata-token: &lt;/span&gt;$TOKEN&lt;span style="color:#e6db74"&gt;&amp;#34;&lt;/span&gt; http://169.254.169.254/latest/meta-data/iam/security-credentials/InstanceProfileRoleName&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p class="wp-block-paragraph"&gt;These commands emulate how the SDK library fetches the credentials to assume the instance profile role. You can also find similar commands on the &lt;a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/iam-roles-for-amazon-ec2.html#instance-metadata-security-credentials"&gt;documentation&lt;/a&gt;. However, there isn&amp;#8217;t much details about how the instance metadata service interacts with the STS service, except a general statement:&lt;/p&gt;&#10;&lt;blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow"&gt;&#10;&lt;p class="wp-block-paragraph"&gt;&lt;/p&gt;&#10;&lt;cite&gt;These security credentials are temporary and we rotate them automatically. We make new credentials available at least five minutes before the expiration of the old credentials.&lt;/cite&gt;&lt;/blockquote&gt;&#10;&lt;p class="wp-block-paragraph"&gt;When creating a new EC2 instance, make sure that the instance metadata option has http_endpoint enabled, to enable the IMDS service. Also set http_tokens to required, which would run IMDSv2 exclusively. With that setup, the application does not have to mana to use an &lt;a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/use-a-supported-sdk-version-for-imdsv2.html"&gt;SDK version&lt;/a&gt; that supports IMDSv2. Another metadata option is http_put_response_hop_limit, with default of 1. This limits the number of hops in the metadata request. If the process runs from a Docker container with bridge networking mode, set it to 2 or the process cannot even secure a token.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;&lt;svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="581px" viewBox="-0.5 -0.5 581 161" style="max-width:100%;max-height:161px;"&gt;&lt;defs&gt;&lt;/defs&gt;&lt;g&gt;&lt;g data-cell-id="0"&gt;&lt;g data-cell-id="1"&gt;&lt;g data-cell-id="rtsicqcqSDVIAgyO7OKc-1"&gt;&lt;g&gt;&lt;rect x="0" y="0" width="580" height="160" fill="rgb(255, 255, 255)" stroke="rgb(0, 0, 0)" pointer-events="all"&gt;&lt;/rect&gt;&lt;/g&gt;&lt;/g&gt;&lt;g data-cell-id="rtsicqcqSDVIAgyO7OKc-2"&gt;&lt;g&gt;&lt;rect x="10" y="10" width="360" height="138.75" fill="#d5e8d4" stroke="#82b366" pointer-events="all"&gt;&lt;/rect&gt;&lt;/g&gt;&lt;/g&gt;&lt;g data-cell-id="rtsicqcqSDVIAgyO7OKc-14"&gt;&lt;g&gt;&lt;rect x="20" y="20" width="190" height="110" rx="16.5" ry="16.5" fill="#fff2cc" stroke="#d6b656" pointer-events="all"&gt;&lt;/rect&gt;&lt;/g&gt;&lt;/g&gt;&lt;g data-cell-id="rtsicqcqSDVIAgyO7OKc-3"&gt;&lt;g&gt;&lt;path d="M 565.5 114.05 C 565.5 116.02 563.9 117.5 561.89 117.5 L 521.19 117.5 C 518.74 117.5 517.5 115.73 517.5 114.23 L 517.5 60.92 C 517.5 58.71 519.41 57.5 521.14 57.5 L 562.11 57.5 C 563.87 57.5 565.5 58.91 565.5 60.86 Z" fill="#759c3e" stroke="none" pointer-events="all"&gt;&lt;/path&gt;&lt;path d="M 541.39 93.57 C 532.5 93.57 524.45 86.77 524.45 77 C 524.45 68.48 531.82 60.98 541.69 60.98 C 550.43 60.98 558.55 67.94 558.55 77.21 C 558.55 85.85 551.34 93.57 541.39 93.57 Z" fill="#4f4f4f" stroke="none" pointer-events="all"&gt;&lt;/path&gt;&lt;path d="M 536.09 104.69 L 534.68 104.69 C 534.68 103.94 534.44 103.07 533.39 102.6 C 532.79 102.38 531.82 102.2 530.71 102.53 C 530.16 102.71 529.66 103.1 529.53 103.83 C 529.33 104.91 530.16 105.32 530.97 105.56 C 532.7 106.02 533.44 106.07 534.28 106.38 C 535.21 106.7 536.2 107.24 536.5 108.42 C 536.75 109.74 536.23 110.68 535.52 111.24 C 534.79 111.84 533.52 112.3 531.84 112.24 C 530.49 112.18 529.3 111.73 528.61 111.04 C 528.01 110.44 527.62 109.68 527.62 108.51 L 529.01 108.51 C 529.06 109.72 529.67 110.41 530.57 110.82 C 531.59 111.21 532.94 111.22 533.88 110.82 C 534.49 110.56 535.05 110.04 535.04 109.18 C 535.02 108.36 534.47 107.86 533.26 107.55 C 532.15 107.25 531.05 107.18 530.02 106.82 C 528.94 106.43 527.73 105.71 528.03 103.83 C 528.21 102.66 529.14 101.83 530.61 101.48 C 531.96 101.2 533.41 101.33 534.39 101.84 C 535.37 102.37 536.04 103.31 536.09 104.69 Z M 545.95 102.54 L 542.32 102.54 L 542.32 111.88 L 540.84 111.88 L 540.84 102.54 L 537.14 102.54 L 537.14 101.32 L 545.95 101.32 Z M 554.91 104.69 L 553.5 104.69 C 553.5 103.94 553.26 103.05 552.21 102.57 C 551.62 102.35 550.65 102.17 549.53 102.51 C 548.98 102.69 548.48 103.07 548.35 103.8 C 548.15 104.9 548.98 105.3 549.8 105.54 C 551.52 106.01 552.25 106.04 553.11 106.35 C 554.03 106.67 555.02 107.21 555.3 108.39 C 555.57 109.72 555.05 110.65 554.35 111.22 C 553.61 111.81 552.34 112.27 550.66 112.21 C 549.31 112.17 548.12 111.7 547.43 111.01 C 546.83 110.43 546.44 109.68 546.44 108.51 L 547.84 108.51 C 547.88 109.72 548.5 110.38 549.39 110.79 C 550.41 111.19 551.76 111.21 552.7 110.8 C 553.31 110.55 553.88 110.02 553.86 109.15 C 553.85 108.34 553.28 107.85 552.09 107.53 C 550.97 107.22 549.88 107.15 548.84 106.79 C 547.76 106.41 546.55 105.68 546.85 103.82 C 547.04 102.63 547.96 101.81 549.44 101.45 C 550.79 101.17 552.23 101.32 553.2 101.83 C 554.19 102.35 554.86 103.31 554.91 104.69 Z M 544.43 80.07 L 544.43 67.05 L 540.92 67.05 L 540.92 76.71 L 534.44 76.71 L 534.44 80.07 Z M 541.45 90.2 C 534.11 90.2 527.96 84.4 527.96 77.15 C 527.96 69.79 534.46 64.33 541.63 64.33 C 548.65 64.33 555.02 70.01 555.02 77.27 C 555.02 84.59 548.65 90.2 541.45 90.2 Z" fill="#ffffff" stroke="none" pointer-events="all"&gt;&lt;/path&gt;&lt;/g&gt;&lt;/g&gt;&lt;g data-cell-id="rtsicqcqSDVIAgyO7OKc-4"&gt;&lt;g&gt;&lt;rect x="260" y="72.5" width="105" height="35" rx="5.25" ry="5.25" fill="#ffe6cc" stroke="#d79b00" pointer-events="all"&gt;&lt;/rect&gt;&lt;/g&gt;&lt;g&gt;&lt;g transform="translate(-0.5 -0.5)"&gt;&lt;switch&gt;&lt;foreignObject pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility" style="overflow: visible; text-align: left;"&gt;&lt;div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 103px; height: 1px; padding-top: 90px; margin-left: 261px;"&gt;&lt;div data-drawio-colors="color: rgb(0, 0, 0); " style="box-sizing: border-box; font-size: 0px; text-align: center;"&gt;&lt;div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; pointer-events: all; white-space: normal; overflow-wrap: normal;"&gt;IMDS v2&lt;div&gt;169.254.169.254&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/foreignObject&gt;&lt;text x="313" y="94" fill="rgb(0, 0, 0)" font-family="&amp;quot;Helvetica&amp;quot;" font-size="12px" text-anchor="middle"&gt;IMDS v2&amp;#8230;&lt;/text&gt;&lt;/switch&gt;&lt;/g&gt;&lt;/g&gt;&lt;/g&gt;&lt;g data-cell-id="rtsicqcqSDVIAgyO7OKc-5"&gt;&lt;g&gt;&lt;rect x="30" y="87.5" width="120" height="30" fill="#dae8fc" stroke="#6c8ebf" pointer-events="all"&gt;&lt;/rect&gt;&lt;/g&gt;&lt;g&gt;&lt;g transform="translate(-0.5 -0.5)"&gt;&lt;switch&gt;&lt;foreignObject pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility" style="overflow: visible; text-align: left;"&gt;&lt;div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 118px; height: 1px; padding-top: 103px; margin-left: 31px;"&gt;&lt;div data-drawio-colors="color: rgb(0, 0, 0); " style="box-sizing: border-box; font-size: 0px; text-align: center;"&gt;&lt;div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; pointer-events: all; white-space: normal; overflow-wrap: normal;"&gt;AWS SDK&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/foreignObject&gt;&lt;text x="90" y="106" fill="rgb(0, 0, 0)" font-family="&amp;quot;Helvetica&amp;quot;" font-size="12px" text-anchor="middle"&gt;AWS SDK&lt;/text&gt;&lt;/switch&gt;&lt;/g&gt;&lt;/g&gt;&lt;/g&gt;&lt;g data-cell-id="rtsicqcqSDVIAgyO7OKc-8"&gt;&lt;g&gt;&lt;path d="M 364.79 83.28 L 511.13 82.53" fill="none" stroke="rgb(0, 0, 0)" stroke-miterlimit="10" pointer-events="stroke"&gt;&lt;/path&gt;&lt;path d="M 516.38 82.51 L 509.4 86.04 L 511.13 82.53 L 509.36 79.04 Z" fill="rgb(0, 0, 0)" stroke="rgb(0, 0, 0)" stroke-miterlimit="10" pointer-events="all"&gt;&lt;/path&gt;&lt;/g&gt;&lt;g data-cell-id="rtsicqcqSDVIAgyO7OKc-9"&gt;&lt;g&gt;&lt;g transform="translate(-0.5 -0.5)"&gt;&lt;switch&gt;&lt;foreignObject pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility" style="overflow: visible; text-align: left;"&gt;&lt;div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 1px; height: 1px; padding-top: 71px; margin-left: 445px;"&gt;&lt;div data-drawio-colors="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); " style="box-sizing: border-box; font-size: 0px; text-align: center;"&gt;&lt;div style="display: inline-block; font-size: 11px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; pointer-events: all; background-color: rgb(255, 255, 255); white-space: nowrap;"&gt;Request: AssumeRole&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/foreignObject&gt;&lt;text x="445" y="74" fill="rgb(0, 0, 0)" font-family="&amp;quot;Helvetica&amp;quot;" font-size="11px" text-anchor="middle"&gt;Request: AssumeRole&lt;/text&gt;&lt;/switch&gt;&lt;/g&gt;&lt;/g&gt;&lt;/g&gt;&lt;/g&gt;&lt;g data-cell-id="rtsicqcqSDVIAgyO7OKc-10"&gt;&lt;g&gt;&lt;path d="M 517.5 92.5 L 369.79 94.03" fill="none" stroke="rgb(0, 0, 0)" stroke-miterlimit="10" pointer-events="stroke"&gt;&lt;/path&gt;&lt;path d="M 364.54 94.08 L 371.51 90.51 L 369.79 94.03 L 371.58 97.51 Z" fill="rgb(0, 0, 0)" stroke="rgb(0, 0, 0)" stroke-miterlimit="10" pointer-events="all"&gt;&lt;/path&gt;&lt;/g&gt;&lt;g data-cell-id="rtsicqcqSDVIAgyO7OKc-11"&gt;&lt;g&gt;&lt;g transform="translate(-0.5 -0.5)"&gt;&lt;switch&gt;&lt;foreignObject pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility" style="overflow: visible; text-align: left;"&gt;&lt;div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe flex-start; width: 1px; height: 1px; padding-top: 124px; margin-left: 400px;"&gt;&lt;div data-drawio-colors="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); " style="box-sizing: border-box; font-size: 0px; text-align: left;"&gt;&lt;div style="display: inline-block; font-size: 11px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; pointer-events: all; background-color: rgb(255, 255, 255); white-space: nowrap;"&gt;Response:&lt;div&gt;&amp;#8211; AccessKeyId&lt;/div&gt;&lt;div&gt;&amp;#8211; SecretAccessKey&lt;/div&gt;&lt;div&gt;&amp;#8211; SessionToken&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/foreignObject&gt;&lt;text x="400" y="128" fill="rgb(0, 0, 0)" font-family="&amp;quot;Helvetica&amp;quot;" font-size="11px"&gt;Response:&amp;#8230;&lt;/text&gt;&lt;/switch&gt;&lt;/g&gt;&lt;/g&gt;&lt;/g&gt;&lt;/g&gt;&lt;g data-cell-id="rtsicqcqSDVIAgyO7OKc-12"&gt;&lt;g&gt;&lt;rect x="30" y="50" width="120" height="37.5" fill="rgb(255, 255, 255)" stroke="rgb(0, 0, 0)" pointer-events="all"&gt;&lt;/rect&gt;&lt;path d="M 42 50 L 42 87.5 M 138 50 L 138 87.5" fill="none" stroke="rgb(0, 0, 0)" stroke-miterlimit="10" pointer-events="all"&gt;&lt;/path&gt;&lt;/g&gt;&lt;g&gt;&lt;g transform="translate(-0.5 -0.5)"&gt;&lt;switch&gt;&lt;foreignObject pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility" style="overflow: visible; text-align: left;"&gt;&lt;div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 94px; height: 1px; padding-top: 69px; margin-left: 43px;"&gt;&lt;div data-drawio-colors="color: rgb(0, 0, 0); " style="box-sizing: border-box; font-size: 0px; text-align: center;"&gt;&lt;div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; pointer-events: all; white-space: normal; overflow-wrap: normal;"&gt;Application&lt;div&gt;Process&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/foreignObject&gt;&lt;text x="90" y="72" fill="rgb(0, 0, 0)" font-family="&amp;quot;Helvetica&amp;quot;" font-size="12px" text-anchor="middle"&gt;Application&amp;#8230;&lt;/text&gt;&lt;/switch&gt;&lt;/g&gt;&lt;/g&gt;&lt;/g&gt;&lt;g data-cell-id="rtsicqcqSDVIAgyO7OKc-13"&gt;&lt;g&gt;&lt;path d="M 240 20 L 270 20 L 270 50 L 240 50 Z" fill="#ed7100" stroke="none" pointer-events="all"&gt;&lt;/path&gt;&lt;path d="M 249.43 40.57 L 260.14 40.57 L 260.14 29.86 L 249.43 29.86 Z M 261 29.86 L 262.71 29.86 L 262.71 30.71 L 261 30.71 L 261 32.43 L 262.71 32.43 L 262.71 33.29 L 261 33.29 L 261 34.57 L 262.71 34.57 L 262.71 35.43 L 261 35.43 L 261 37.14 L 262.71 37.14 L 262.71 38 L 261 38 L 261 39.71 L 262.71 39.71 L 262.71 40.57 L 261 40.57 L 261 40.63 C 261 41.07 260.64 41.43 260.2 41.43 L 260.14 41.43 L 260.14 43.14 L 259.29 43.14 L 259.29 41.43 L 257.57 41.43 L 257.57 43.14 L 256.71 43.14 L 256.71 41.43 L 255.43 41.43 L 255.43 43.14 L 254.57 43.14 L 254.57 41.43 L 252.86 41.43 L 252.86 43.14 L 252 43.14 L 252 41.43 L 250.29 41.43 L 250.29 43.14 L 249.43 43.14 L 249.43 41.43 L 249.37 41.43 C 248.93 41.43 248.57 41.07 248.57 40.63 L 248.57 40.57 L 247.29 40.57 L 247.29 39.71 L 248.57 39.71 L 248.57 38 L 247.29 38 L 247.29 37.14 L 248.57 37.14 L 248.57 35.43 L 247.29 35.43 L 247.29 34.57 L 248.57 34.57 L 248.57 33.29 L 247.29 33.29 L 247.29 32.43 L 248.57 32.43 L 248.57 30.71 L 247.29 30.71 L 247.29 29.86 L 248.57 29.86 L 248.57 29.8 C 248.57 29.36 248.93 29 249.37 29 L 249.43 29 L 249.43 27.29 L 250.29 27.29 L 250.29 29 L 252 29 L 252 27.29 L 252.86 27.29 L 252.86 29 L 254.57 29 L 254.57 27.29 L 255.43 27.29 L 255.43 29 L 256.71 29 L 256.71 27.29 L 257.57 27.29 L 257.57 29 L 259.29 29 L 259.29 27.29 L 260.14 27.29 L 260.14 29 L 260.2 29 C 260.64 29 261 29.36 261 29.8 Z M 255.43 46.09 C 255.43 46.12 255.4 46.14 255.38 46.14 L 243.91 46.14 C 243.88 46.14 243.86 46.12 243.86 46.09 L 243.86 34.62 C 243.86 34.6 243.88 34.57 243.91 34.57 L 246.43 34.57 L 246.43 33.71 L 243.91 33.71 C 243.41 33.71 243 34.12 243 34.62 L 243 46.09 C 243 46.59 243.41 47 243.91 47 L 255.38 47 C 255.88 47 256.29 46.59 256.29 46.09 L 256.29 44 L 255.43 44 Z M 267 23.91 L 267 35.38 C 267 35.88 266.59 36.29 266.09 36.29 L 263.57 36.29 L 263.57 35.43 L 266.09 35.43 C 266.12 35.43 266.14 35.4 266.14 35.38 L 266.14 23.91 C 266.14 23.88 266.12 23.86 266.09 23.86 L 254.62 23.86 C 254.6 23.86 254.57 23.88 254.57 23.91 L 254.57 26.43 L 253.71 26.43 L 253.71 23.91 C 253.71 23.41 254.12 23 254.62 23 L 266.09 23 C 266.59 23 267 23.41 267 23.91 Z" fill="#ffffff" stroke="none" pointer-events="all"&gt;&lt;/path&gt;&lt;/g&gt;&lt;g&gt;&lt;g transform="translate(-0.5 -0.5)"&gt;&lt;switch&gt;&lt;foreignObject pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility" style="overflow: visible; text-align: left;"&gt;&lt;div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe flex-start; width: 1px; height: 1px; padding-top: 35px; margin-left: 272px;"&gt;&lt;div data-drawio-colors="color: #232F3E; " style="box-sizing: border-box; font-size: 0px; text-align: left;"&gt;&lt;div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(35, 47, 62); line-height: 1.2; pointer-events: all; white-space: nowrap;"&gt;&lt;div&gt;&lt;span style="background-color: initial;"&gt;EC2 Instance&lt;/span&gt;&lt;br&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/foreignObject&gt;&lt;text x="272" y="39" fill="#232F3E" font-family="&amp;quot;Helvetica&amp;quot;" font-size="12px"&gt;EC2 I&amp;#8230;&lt;/text&gt;&lt;/switch&gt;&lt;/g&gt;&lt;/g&gt;&lt;/g&gt;&lt;g data-cell-id="rtsicqcqSDVIAgyO7OKc-23"&gt;&lt;g&gt;&lt;path d="M 150 110 Q 160 170 171.64 113.74" fill="none" stroke="rgb(0, 0, 0)" stroke-miterlimit="10" pointer-events="stroke"&gt;&lt;/path&gt;&lt;path d="M 172.7 108.59 L 174.71 116.16 L 171.64 113.74 L 167.86 114.74 Z" fill="rgb(0, 0, 0)" stroke="rgb(0, 0, 0)" stroke-miterlimit="10" pointer-events="all"&gt;&lt;/path&gt;&lt;/g&gt;&lt;/g&gt;&lt;g data-cell-id="rtsicqcqSDVIAgyO7OKc-24"&gt;&lt;g&gt;&lt;path d="M 238.45 107.5 Q 260 170 287.49 105.85" fill="none" stroke="rgb(0, 0, 0)" stroke-miterlimit="10" pointer-events="stroke"&gt;&lt;/path&gt;&lt;path d="M 289.56 101.03 L 290.02 108.84 L 287.49 105.85 L 283.59 106.08 Z" fill="rgb(0, 0, 0)" stroke="rgb(0, 0, 0)" stroke-miterlimit="10" pointer-events="all"&gt;&lt;/path&gt;&lt;/g&gt;&lt;/g&gt;&lt;g data-cell-id="rtsicqcqSDVIAgyO7OKc-26"&gt;&lt;g&gt;&lt;rect x="180" y="87.5" width="50" height="22.5" fill="#75dfff" stroke="rgb(0, 0, 0)" pointer-events="all"&gt;&lt;/rect&gt;&lt;/g&gt;&lt;g&gt;&lt;g transform="translate(-0.5 -0.5)"&gt;&lt;switch&gt;&lt;foreignObject pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility" style="overflow: visible; text-align: left;"&gt;&lt;div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe flex-end; justify-content: unsafe center; width: 48px; height: 1px; padding-top: 85px; margin-left: 181px;"&gt;&lt;div data-drawio-colors="color: rgb(0, 0, 0); " style="box-sizing: border-box; font-size: 0px; text-align: center;"&gt;&lt;div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; pointer-events: all; white-space: normal; overflow-wrap: normal;"&gt;Bridge&lt;div&gt;Network&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/foreignObject&gt;&lt;text x="205" y="85" fill="rgb(0, 0, 0)" font-family="&amp;quot;Helvetica&amp;quot;" font-size="12px" text-anchor="middle"&gt;Bridge&amp;#8230;&lt;/text&gt;&lt;/switch&gt;&lt;/g&gt;&lt;/g&gt;&lt;/g&gt;&lt;g data-cell-id="rtsicqcqSDVIAgyO7OKc-22"&gt;&lt;g&gt;&lt;rect x="220" y="87.5" width="30" height="20" fill="none" stroke="none" pointer-events="all"&gt;&lt;/rect&gt;&lt;path d="M 225.13 105.54 L 225.13 100.05 L 235.79 100.05 L 235.79 102.79 L 241.32 102.79 L 241.32 103.58 L 247.24 103.58 L 247.24 101.23 L 241.32 101.23 L 241.32 102.01 L 236.58 102.01 L 236.58 98.09 L 244.08 98.09 L 244.08 98.87 L 248.82 98.87 L 248.82 96.52 L 244.08 96.52 L 244.08 97.3 L 235.79 97.3 L 235.79 99.26 L 225.13 99.26 L 225.13 96.13 L 232.63 96.13 L 232.63 93.38 L 236.58 93.38 L 236.58 94.56 L 242.5 94.56 L 242.5 91.42 L 236.58 91.42 L 236.58 92.6 L 231.84 92.6 L 231.84 95.34 L 225.13 95.34 L 225.13 89.85 L 250 89.85 L 250 105.54 L 239.74 105.54 L 239.74 107.5 L 238.95 107.5 L 238.95 105.54 L 238.16 105.54 L 238.16 107.5 L 237.37 107.5 L 237.37 105.54 L 236.58 105.54 L 236.58 107.5 L 235.79 107.5 L 235.79 105.54 L 235 105.54 L 235 107.5 L 234.21 107.5 L 234.21 105.54 L 233.42 105.54 L 233.42 107.5 L 232.63 107.5 L 232.63 105.54 L 231.84 105.54 L 231.84 107.5 L 231.05 107.5 L 231.05 105.54 L 230.26 105.54 L 230.26 107.5 L 229.47 107.5 L 229.47 105.54 L 228.68 105.54 L 228.68 107.5 L 227.89 107.5 L 227.89 105.54 Z M 222.76 107.5 L 222.76 88.68 L 220 88.68 L 220 87.5 L 223.95 87.5 L 223.95 107.5 Z" fill="#505050" stroke="none" pointer-events="all"&gt;&lt;/path&gt;&lt;/g&gt;&lt;/g&gt;&lt;g data-cell-id="rtsicqcqSDVIAgyO7OKc-16"&gt;&lt;g&gt;&lt;rect x="160" y="87.5" width="30" height="20" fill="none" stroke="none" pointer-events="all"&gt;&lt;/rect&gt;&lt;path d="M 165.13 105.54 L 165.13 100.05 L 175.79 100.05 L 175.79 102.79 L 181.32 102.79 L 181.32 103.58 L 187.24 103.58 L 187.24 101.23 L 181.32 101.23 L 181.32 102.01 L 176.58 102.01 L 176.58 98.09 L 184.08 98.09 L 184.08 98.87 L 188.82 98.87 L 188.82 96.52 L 184.08 96.52 L 184.08 97.3 L 175.79 97.3 L 175.79 99.26 L 165.13 99.26 L 165.13 96.13 L 172.63 96.13 L 172.63 93.38 L 176.58 93.38 L 176.58 94.56 L 182.5 94.56 L 182.5 91.42 L 176.58 91.42 L 176.58 92.6 L 171.84 92.6 L 171.84 95.34 L 165.13 95.34 L 165.13 89.85 L 190 89.85 L 190 105.54 L 179.74 105.54 L 179.74 107.5 L 178.95 107.5 L 178.95 105.54 L 178.16 105.54 L 178.16 107.5 L 177.37 107.5 L 177.37 105.54 L 176.58 105.54 L 176.58 107.5 L 175.79 107.5 L 175.79 105.54 L 175 105.54 L 175 107.5 L 174.21 107.5 L 174.21 105.54 L 173.42 105.54 L 173.42 107.5 L 172.63 107.5 L 172.63 105.54 L 171.84 105.54 L 171.84 107.5 L 171.05 107.5 L 171.05 105.54 L 170.26 105.54 L 170.26 107.5 L 169.47 107.5 L 169.47 105.54 L 168.68 105.54 L 168.68 107.5 L 167.89 107.5 L 167.89 105.54 Z M 162.76 107.5 L 162.76 88.68 L 160 88.68 L 160 87.5 L 163.95 87.5 L 163.95 107.5 Z" fill="#505050" stroke="none" pointer-events="all"&gt;&lt;/path&gt;&lt;/g&gt;&lt;/g&gt;&lt;g data-cell-id="rtsicqcqSDVIAgyO7OKc-28"&gt;&lt;g&gt;&lt;rect x="30" y="20" width="110" height="30" fill="none" stroke="none" pointer-events="all"&gt;&lt;/rect&gt;&lt;/g&gt;&lt;g&gt;&lt;g transform="translate(-0.5 -0.5)"&gt;&lt;switch&gt;&lt;foreignObject pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility" style="overflow: visible; text-align: left;"&gt;&lt;div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 108px; height: 1px; padding-top: 35px; margin-left: 31px;"&gt;&lt;div data-drawio-colors="color: rgb(0, 0, 0); " style="box-sizing: border-box; font-size: 0px; text-align: center;"&gt;&lt;div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; pointer-events: all; white-space: normal; overflow-wrap: normal;"&gt;Docker Daemon&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/foreignObject&gt;&lt;text x="85" y="39" fill="rgb(0, 0, 0)" font-family="&amp;quot;Helvetica&amp;quot;" font-size="12px" text-anchor="middle"&gt;Docker Daemon&lt;/text&gt;&lt;/switch&gt;&lt;/g&gt;&lt;/g&gt;&lt;/g&gt;&lt;/g&gt;&lt;/g&gt;&lt;/g&gt;&lt;switch&gt;&lt;g requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"&gt;&lt;/g&gt;&lt;a transform="translate(0,-5)" xlink:href="https://www.drawio.com/doc/faq/svg-export-text-problems" target="_blank" rel="noopener"&gt;&lt;text text-anchor="middle" font-size="10px" x="50%" y="100%"&gt;Text is not SVG &amp;#8211; cannot display&lt;/text&gt;&lt;/a&gt;&lt;/switch&gt;&lt;/svg&gt;&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;The diagram above illustrates this scenario with two hops.&lt;/p&gt;&#10;&lt;h2 class="wp-block-heading"&gt;IAM Role Anywhere Concept&lt;/h2&gt;&#10;&lt;p class="wp-block-paragraph"&gt;As this point, we know that the process of workload assuming an IAM role, is essentially using SDK to gain role credentials from instance metadata. In addition to using SDK and instance metadata, AWS also supports using X.509 certificate to gain role credentials. As a result, workload no longer needs AWS SDK, and it doesn&amp;#8217;t rely on instance metadata from an EC2 instance. This mechanism is known as IAM Role Anywhere, and it greatly expands the use cases for IAM Role. &lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;To make this work, we first have to provide a certificate authority (CA) to AWS as a trust anchor. It can be any X.509 CA including AWS Private CA. The IAM Roles Anywhere will allow any end-entity endorsed by this trust anchor, to assume an IAM role as specified. We also need to create a profile, in which we can add IAM policies directly, or link to an IAM roles with a trust policy for service principal &lt;code&gt;rolesanywhere.amazonaws.com&lt;/code&gt;. &lt;/p&gt;&#10;&lt;figure class="wp-block-image size-full"&gt;&lt;img loading="lazy" decoding="async" width="691" height="283" src="https://www.digihunch.com/wp-content/uploads/2024/07/iam-role-anywhere-diagram.webp" alt="" class="wp-image-12989" srcset="https://www.digihunch.com/wp-content/uploads/2024/07/iam-role-anywhere-diagram.webp 691w, https://www.digihunch.com/wp-content/uploads/2024/07/iam-role-anywhere-diagram-300x123.webp 300w" sizes="auto, (max-width: 691px) 100vw, 691px" /&gt;&lt;/figure&gt;&#10;&lt;p class="wp-block-paragraph"&gt;To gain role credential, the requestor must provide both the private key, and its end-entity certificate. The certificate proofs the endorsement of the CA as Role&amp;#8217;s trust anchor specifies. The private key proofs the requestor&amp;#8217;s identity. The requestor uses the &lt;a href="https://docs.aws.amazon.com/rolesanywhere/latest/userguide/credential-helper.html"&gt;aws_signing_helper&lt;/a&gt; utility to request role credentials. &lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;The utility is compatible with the &lt;code&gt;credential_process&lt;/code&gt; feature in AWS config, which passes the returned role credentials to the AWS config profile for AWS CLI or SDK running on external virtual machine.&lt;/p&gt;&#10;&lt;h2 class="wp-block-heading"&gt;IAM Role Anywhere Lab&lt;/h2&gt;&#10;&lt;p class="wp-block-paragraph"&gt;Let&amp;#8217;s tweak the three commands from this &lt;a href="https://www.digihunch.com/2021/08/creating-tls-certificate-kubernetes/"&gt;old post&lt;/a&gt; of mine to create the test materials: a self-signed CA and a certificate signed by the CA:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;openssl req -x509 -sha256 -newkey rsa:4096 -keyout ca.key -out ca.crt -days &lt;span style="color:#ae81ff"&gt;356&lt;/span&gt; -nodes -subj &lt;span style="color:#e6db74"&gt;&amp;#39;/CN=Health Certificate Authority&amp;#39;&lt;/span&gt; -addext basicConstraints&lt;span style="color:#f92672"&gt;=&lt;/span&gt;critical,CA:TRUE,pathlen:1 -addext keyUsage&lt;span style="color:#f92672"&gt;=&lt;/span&gt;keyCertSign&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cat &amp;gt; ext.cnf &lt;span style="color:#e6db74"&gt;&amp;lt;&amp;lt;EOF&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#e6db74"&gt;[v3_leaf]&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#e6db74"&gt;keyUsage = digitalSignature&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#e6db74"&gt;basicConstraints=CA:false&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#e6db74"&gt;EOF&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;openssl req -new -newkey rsa:4096 -keyout server.key -out server.csr -nodes -subj &lt;span style="color:#e6db74"&gt;&amp;#39;/CN=*.digihunch.com&amp;#39;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;openssl x509 -req -sha256 -days &lt;span style="color:#ae81ff"&gt;365&lt;/span&gt; -in server.csr -CA ca.crt -CAkey ca.key -set_serial &lt;span style="color:#ae81ff"&gt;01&lt;/span&gt; -out server.crt -extfile ext.cnf -extensions v3_leaf&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p class="wp-block-paragraph"&gt;I tweak them to add the &lt;a href="https://www.digihunch.com/2024/02/public-key-infrastructure-1-of-3-basics/"&gt;X.509 extensions&lt;/a&gt; to meet the &lt;a href="https://docs.aws.amazon.com/rolesanywhere/latest/userguide/trust-model.html"&gt;requirement&lt;/a&gt; for signature validation. We need the following files from the output.&lt;/p&gt;&#10;&lt;ul class="wp-block-list"&gt;&#10;&lt;li&gt;ca.crt -&amp;gt; the certificate of the CA. We provide this file as the trust anchor&lt;/li&gt;&#10;&lt;li&gt;server.crt -&amp;gt; the certificate of the server, we need it as the end-entity certificate&lt;/li&gt;&#10;&lt;li&gt;server.key -&amp;gt; we need to present this file to proof identity of the requestor&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p class="wp-block-paragraph"&gt;First, we go to AWS console and create a new trust anchor. Copy the content of ca.crt as the certificate. Then we can create a profile with an IAM role, with the trust policy looking like &lt;a href="https://docs.aws.amazon.com/rolesanywhere/latest/userguide/trust-model.html"&gt;this&lt;/a&gt; example. Then we can request the role credential with one command:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;aws_signing_helper credential-process --certificate server.crt --private-key server.key --trust-anchor-arn $TRUST_ANCHOR_ARN --profile-arn $PROFILE_ARN --role-arn $ROLE_ARN&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p class="wp-block-paragraph"&gt;Moreover, if the workload supports AWS SDK or can use CLI but not an EC2 instance, we can bake this in the AWS profile on the external machine:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;[profile myprofile]&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;output = json&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;credential_process = aws_signing_helper credential-process --certificate /path/server.crt --private-key /path/server.key --trust-anchor-arn $TRUST_ANCHOR_ARN --profile-arn $PROFILE_ARN --role-arn $ROLE_ARN&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p class="wp-block-paragraph"&gt;We can even configure this in any &lt;a href="https://aws.amazon.com/blogs/security/enable-external-pipeline-deployments-to-aws-cloud-by-using-iam-roles-anywhere/"&gt;pipeline&lt;/a&gt; as code to allow deployment from a non-AWS pipeline. &lt;/p&gt;&#10;&lt;h2 class="wp-block-heading"&gt;Summary&lt;/h2&gt;&#10;&lt;p class="wp-block-paragraph"&gt;In summary, apart from native AWS services, an IAM role can trust the following types of principals:&lt;/p&gt;&#10;&lt;ul class="wp-block-list"&gt;&#10;&lt;li&gt;Native IAM identity such as an IAM user or an IAM group&lt;/li&gt;&#10;&lt;li&gt;Authenticated identity from SAML identity provider that IAM is configured to trust&lt;/li&gt;&#10;&lt;li&gt;Authenticated identity from OIDC identity provider that IAM is configured to trust&lt;/li&gt;&#10;&lt;li&gt;Validated identity endorsed by a Certificate Authority that IAM designate as a trust anchor&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p class="wp-block-paragraph"&gt;The first type is rarely used because few organizations uses AWS IAM as their identity store. Most organizations have their identity store with federation capability via SAML. On the other hand, a lot of modern applications adopts identity stores with OIDC compliance. Now with IAM Role Anywhere, any entity with X.509 identity can also assume an IAM role. It works with any CI/CD pipeline, whether it is self-hosted. Also, it is now more important to keep the keys safe. &lt;/p&gt;&#10;&lt;nav class="wp-post-navigation" aria-label="Post navigation"&gt;&#10;&lt;a rel="prev" href="https://www.digihunch.com/2024/05/managing-ec2-instances-across-aws-accounts-ssm/"&gt;&lt;span class="wp-post-navigation-label"&gt;Previous Post&lt;/span&gt;&lt;strong class="wp-post-navigation-title"&gt;Managing EC2 instances across accounts with Ansible&lt;/strong&gt;&lt;/a&gt;&#10;&lt;a rel="next" href="https://www.digihunch.com/2024/08/test-open-id-connect-flows-locally/"&gt;&lt;span class="wp-post-navigation-label"&gt;Next Post&lt;/span&gt;&lt;strong class="wp-post-navigation-title"&gt;Test Open ID Connect Flows Locally&lt;/strong&gt;&lt;/a&gt;&#10;&lt;/nav&gt;&#10;</description></item><item><title>Landing Zone in Azure – Introduction</title><link>https://www.digihunch.com/2023/03/landing-zone-in-azure/</link><pubDate>Sat, 25 Mar 2023 01:30:00 -0400</pubDate><guid>https://www.digihunch.com/2023/03/landing-zone-in-azure/</guid><description>&lt;img src="https://www.digihunch.com/wp-content/uploads/2025/04/feature-az-lz.webp" alt="Featured image of post Landing Zone in Azure – Introduction" /&gt;&lt;p class="wp-block-paragraph"&gt;I recently renewed my associate administrator certification, and feel it&amp;#8217;s a good opportunity to brush up on Azure landing zone. &lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;The lame part of this is the semantics. I found many similar terms across cloud service provider (CSPs). In the context of Azure, it makes sense to clarify the terms again for Cloud Adoption Framework (CAF) and Cloud Operating Models.&lt;/p&gt;&#10;&lt;h2 class="wp-block-heading" id="h-cloud-adoption-framework-caf"&gt;Cloud Adoption Framework (CAF)&lt;/h2&gt;&#10;&lt;p class="wp-block-paragraph"&gt;Similar to AWS Cloud Adoption Framework (CAF), Azure also has the concept of CAF and it means the same thing. This part may feel lofty, but it&amp;#8217;s in fact foundational. To get started on the cloud there are thousand ways to configure the foundation (right or wrong). The adopter needs CAF to navigate through the offerings and define what they can achieve. &lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;The &lt;a href="https://learn.microsoft.com/en-us/azure/cloud-adoption-framework/"&gt;CAF&lt;/a&gt; documentation is good although length. The most &amp;#8220;beefy&amp;#8221; part is &lt;a href="https://learn.microsoft.com/en-us/azure/cloud-adoption-framework/ready/"&gt;Ready&lt;/a&gt; section. &lt;/p&gt;&#10;&lt;h2 class="wp-block-heading"&gt;Cloud Operating Models&lt;/h2&gt;&#10;&lt;p class="wp-block-paragraph"&gt;Every cloud company has some narrative about cloud operating model. For example, Here&amp;#8217;s &lt;a href="https://developer.hashicorp.com/well-architected-framework/com/cloud-operating-model"&gt;Hashicorp&amp;#8217;s&lt;/a&gt; definition, and here&amp;#8217;s &lt;a href="https://docs.aws.amazon.com/whitepapers/latest/building-cloud-operating-model/building-cloud-operating-model.html"&gt;AWS&lt;/a&gt;&amp;#8216; white paper on it. In the context of Azure, the CAF document gives some guidance on developing your own operating model in alignment with the CAF. In addition, it also gives a few example cloud operating models:&lt;/p&gt;&#10;&lt;ul class="wp-block-list"&gt;&#10;&lt;li&gt;Decentralized operations&lt;/li&gt;&#10;&lt;li&gt;Centralized operations&lt;/li&gt;&#10;&lt;li&gt;Enterprise operations&lt;/li&gt;&#10;&lt;li&gt;Distributed operations&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p class="wp-block-paragraph"&gt;There is a &lt;a href="https://learn.microsoft.com/en-us/azure/cloud-adoption-framework/operating-model/compare#priorities-or-scope"&gt;comparison table&lt;/a&gt; that highlights their differences as well as an &lt;a href="https://learn.microsoft.com/en-us/azure/cloud-adoption-framework/operating-model/compare#accountability-alignment"&gt;accountability chart&lt;/a&gt; proposing team divisions. Another &lt;a href="https://learn.microsoft.com/en-us/azure/cloud-adoption-framework/operating-model/compare#accelerate-operating-model-implementation-in-azure"&gt;insightful table&lt;/a&gt; is the one that list out implementation starting point and typical path of iterations for each operating model. The table also suggests that Azure Landing Zone includes two implementation options: starting small and CAF enterprise-scale.&lt;/p&gt;&#10;&lt;h2 class="wp-block-heading"&gt;Landing Zone at High Level&lt;/h2&gt;&#10;&lt;p class="wp-block-paragraph"&gt;Followed by Cloud Operating Model is the design and implementation of Azure Landing Zone. There are currently eight design areas:&lt;/p&gt;&#10;&lt;ul class="wp-block-list"&gt;&#10;&lt;li&gt;Billing and Active Directory tenant: including Azure AD tenant&lt;/li&gt;&#10;&lt;li&gt;Identity and Access Management: including hybrid identity&lt;/li&gt;&#10;&lt;li&gt;Network Topology and Connectivity&lt;/li&gt;&#10;&lt;li&gt;Resource Organization: different levels of resource containers&lt;/li&gt;&#10;&lt;li&gt;Security&lt;/li&gt;&#10;&lt;li&gt;Management&lt;/li&gt;&#10;&lt;li&gt;Governance&lt;/li&gt;&#10;&lt;li&gt;Platform automation and DevOps&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p class="wp-block-paragraph"&gt;Out of the many design areas, I fell short off IAM and Network so I&amp;#8217;ll try to discuss them in more details below in the next section. As for resource organization, apart from Resource Group and Subscription, it is also important to understand management group.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;Most cloud engineers work with subscription and resource group. That is where a lot are going on. For enterprises however, Azure has to address the requirement for the capability of top-down enforcement. Management Group provides a governance scope above subscriptions, provided that all subscriptions trust a single Azure AD account. Management groups may form a hierarchy of up to six levels to help you configure policies and access, so that the all the subscriptions under each management group have unified policy and access configuration. At the very top is root management group. Any assignment of user access or policy on the root management group applies to all resources within the directory. Because of this, all customers should evaluate the need to have items defined on this scope.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;We can apply policy guardrails (e.g Azure Policy) at management group level so that the policies are effect across subscriptions. Azure Policy can also address operational compliance considerations by &lt;a href="https://learn.microsoft.com/en-us/azure/cloud-adoption-framework/ready/landing-zone/design-area/management-operational-compliance#monitor-for-configuration-drift"&gt;monitoring configuration drift&lt;/a&gt;.&lt;/p&gt;&#10;&lt;h2 class="wp-block-heading"&gt;Identity and Access Management&lt;/h2&gt;&#10;&lt;p class="wp-block-paragraph"&gt;First, we really need to distinguish &lt;strong&gt;AD DS on Windows Server&lt;/strong&gt;, &lt;strong&gt;Azure AD&lt;/strong&gt; and &lt;strong&gt;Azure AD DS&lt;/strong&gt;. In an &lt;a href="https://www.digihunch.com/2020/02/everything-about-the-domain/"&gt;old post&lt;/a&gt;, I discussed what is a Windows domain, the key role of a domain controller (to manage user identity, as well computer identity), and the fact that Active Directory is a complete redesign of Windows Domain system since Windows 2000. So we can start with AD DS on Windows Server:&lt;/p&gt;&#10;&lt;ul class="wp-block-list"&gt;&#10;&lt;li&gt;&lt;strong&gt;AD DS on Windows Server&lt;/strong&gt;: In the good old days, some common network administrative activities were to configure Active Directory (including the X.500 compatible database, the OUs, domains and forests) on Windows Servers, joining computers to the company&amp;#8217;s domain, configure group policy, configure LDAP and Kerberos, upgrading Domain controllers, etc. Over the years, Microsoft moved these activities to the cloud and offer them as a managed service, known as Azure AD DS.&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Azure Active Directory Domain Service (Azure AD DS)&lt;/strong&gt;: allows you to use managed domain services (e.g. Windows Domain Join, group policy, LDAP, Kerberos authentication) without having to deploy, manage or patch domain controllers. It is a SaaS offering to manage your domain controllers in the cloud, with a pay-as-you-go model. The counterpart in AWS is &amp;#8220;AWS Directory Service&amp;#8221; which lets you run Microsoft Active Directory (AD) as an AWS managed service.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p class="wp-block-paragraph"&gt;In summary, both AD DS on Windows Server (self-hosted) and Azure AD DS (managed service) are identity stores that operates on Windows domains. Even though the latter is a managed service, it supports LDAP or Kerberos as integration protocol for third party applications (usually on-premis) to use. Both LDAP and Kerberos came around prior to the cloud era and they are not optimized for cloud connectivity. For example, insecure bind (on port 389) in &lt;a href="https://www.digihunch.com/2020/03/lightweight-directory-access-protocol-ldap/"&gt;LDAP&lt;/a&gt; is still prevalent. &lt;a href="https://www.digihunch.com/2020/03/ntlm-and-kerberos/"&gt;Kerberos&lt;/a&gt; is fairly complex to configure. However, they are not phased out right away because of their established presence as well as the domain&amp;#8217;s awareness to authenticate devices. &lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;Many organizations have to keep their domain service and when they move to cloud so they still have to use Active Directory as identity store. For this, Azure has Azure AD connect. On the AWS side, there is also an &lt;a href="https://docs.aws.amazon.com/directoryservice/latest/admin-guide/directory_ad_connector.html"&gt;AD connector&lt;/a&gt; tool to allow on-prem users to log into AWS applications and services. With AD connector you can also join EC2 instance to existing AD domain. &lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;Now let&amp;#8217;s examine Azure AD.&lt;/p&gt;&#10;&lt;ul class="wp-block-list"&gt;&#10;&lt;li&gt;Azure AD: is an IAM solution. It contains an identity store (with users and groups in a flat directory structure) but more importantly it integrates with external identity stores (including Domain Service, self-hosted or SaaS managed), which gives it hybrid-identity capability. A company can even sync their own on-prem identity store to Azure AD using Azure AD Connect. As an IAM solution, Azure AD also allows a company to tie their identity store to applications using modern protocols such as SAML and OAuth. Azure AD treats applications as objects, and they can represents either Microsoft Applications (Office 365, Dynamics 365, Azure) or third-party ones (Slack, Salesforce) as long as they use the supported protocol for SSO. The closest AWS counterpart of Azure AD is Amazon Cognito (arguably), even though their capabilities are not identical in every aspect.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p class="wp-block-paragraph"&gt;Compared to Domain Service, Azure AD alone doesn&amp;#8217;t have the concept of domain. Therefore you cannot join a server or PC to a domain and configure group policy. Azure AD&amp;#8217;s native identity store is a flat directory structure without OUs or forests. Azure AD is NOT a replacement of domain service, either self-hosted or managed.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;Now coming back to the Azure landing zone literature, the &lt;a href="https://learn.microsoft.com/en-us/azure/cloud-adoption-framework/ready/landing-zone/design-area/identity-access-active-directory-hybrid-identity"&gt;document&lt;/a&gt; lays out the key decision to make about identity:&lt;/p&gt;&#10;&lt;blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow"&gt;&#10;&lt;p class="wp-block-paragraph"&gt;A critical design decision for enterprise organizations adopting Azure is whether to extend current on-premises identity domains into Azure or to create new identity domains.&lt;/p&gt;&#10;&lt;cite&gt;Azure Active Directory (Azure AD) and hybrid identity&lt;/cite&gt;&lt;/blockquote&gt;&#10;&lt;p class="wp-block-paragraph"&gt;The document even includes a comprehensive &lt;a href="https://learn.microsoft.com/en-us/azure/cloud-adoption-framework/decision-guides/identity/"&gt;identity decision guide&lt;/a&gt;. After this decision, we&amp;#8217;ll know what identity store to use. Then we can address the problem of platform access vs workload access. In other words, IAM of management traffic vs business traffic, which opens up topics such as RBAC, service principle and managed identities.&lt;/p&gt;&#10;&lt;h2 class="wp-block-heading"&gt;Networking&lt;/h2&gt;&#10;&lt;p class="wp-block-paragraph"&gt;Back in 2017, Azure published a &lt;a href="https://learn.microsoft.com/en-us/azure/architecture/networking/architecture/hub-spoke"&gt;white paper&lt;/a&gt; about V-Net and it focuses on mesh network and hub-and-spoke. Back then Azure customers run multiple lines of business (LOB) on different V-Nets. The V-Net peering feature allows early cloud adopters to organize all their V-Nets in a mesh topology, ensuring all peers have access to all other peers, or a hub-and-spoke topology to aggregate shared resources in hubs so they can be shared by the spokes in the network.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;When setting up a landing zone, network topology is a big decision. In the landing zone document today, clients need to consider the followings: &lt;/p&gt;&#10;&lt;ul class="wp-block-list"&gt;&#10;&lt;li&gt;Traditional Azure networking topologies, including:&#10;&lt;ul class="wp-block-list"&gt;&#10;&lt;li&gt;large flat V-Net&lt;/li&gt;&#10;&lt;li&gt;multiple V-Nets connected with multiple Azure ExpressRoute circuits/connections&lt;/li&gt;&#10;&lt;li&gt;hub-and-spoke &lt;/li&gt;&#10;&lt;li&gt;full mesh&lt;/li&gt;&#10;&lt;li&gt;hybrid&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;Microsoft managed networking topology (on top of Virtual WAN)&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p class="wp-block-paragraph"&gt;From the 2017 white paper, most organizations at that time solve their need for network isolation and connectivity by creating a mesh architecture among various V-Nets. All nodes in the network are interconnected so network traffic is fast and can be easily redirected. However, mesh topology has significant disadvantages because it requires too many connections as the footprint expands, making it very costly to operate and quick to reach limit of number of peering links. It is not scalable. The white paper is to advocate the use of hub-and-spoke topology, which I will discuss in the next section.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;It is worth-noting that, today (Jan 2023) one can create both topologies with &lt;a href="https://learn.microsoft.com/en-us/azure/virtual-network-manager/"&gt;Azure Virtual Network Manager&lt;/a&gt;. It is currently a preview service but I can foresee it will eventually get integrated with landing zone.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;No matter which topology, another issue to address is &lt;a href="https://learn.microsoft.com/en-us/azure/architecture/reference-architectures/hybrid-networking/#hub-spoke-network-topology"&gt;connectivity to on-prem network&lt;/a&gt;, and to Azure &lt;a href="https://learn.microsoft.com/en-us/azure/cloud-adoption-framework/ready/azure-best-practices/connectivity-to-azure-paas-services"&gt;PaaS services&lt;/a&gt;. If the traffic is light, we can use VPN gateway to configure IPSec tunnel that goes over public internet encrypted. It is simple to configure with a good aggregate bandwidth. This connection requires a VPN device on premise as well. A faster alternative is Azure &lt;a href="https://learn.microsoft.com/en-us/azure/expressroute/"&gt;ExpressRoute&lt;/a&gt;, which runs a private connection with a third-party connectivity provider. &lt;a href="https://learn.microsoft.com/en-us/azure/architecture/reference-architectures/hybrid-networking/#azure-expressroute-connection"&gt;ExpressRoute&lt;/a&gt; is more complex and expensive to set up, but it supports much higher bandwidth with direct access and better SLA. In reality, many clients configures ExpressRoute with VPN failover for connectivity to on-prem network. For &lt;a href="https://learn.microsoft.com/en-us/azure/cloud-adoption-framework/ready/azure-best-practices/connectivity-to-azure-paas-services"&gt;connectivity to PaaS services&lt;/a&gt;, options are service endpoint and private link endpoint.&lt;/p&gt;&#10;&lt;h2 class="wp-block-heading"&gt;Hub-and-spoke topology&lt;/h2&gt;&#10;&lt;p class="wp-block-paragraph"&gt;In the &lt;a href="https://learn.microsoft.com/en-us/azure/cloud-adoption-framework/ready/azure-best-practices/traditional-azure-networking-topology"&gt;traditional topologies&lt;/a&gt;, &lt;a href="https://learn.microsoft.com/en-us/azure/cloud-adoption-framework/ready/azure-best-practices/hub-spoke-network-topology"&gt;hub-and-spoke&lt;/a&gt; network topology is popular as the hub network provides a central point of management. Also it overcomes &lt;a href="https://learn.microsoft.com/en-us/azure/azure-resource-manager/management/azure-subscription-service-limits#networking-limits"&gt;subscription limits&lt;/a&gt; and institutes a separation of concerns. The Azure documentation recommends &lt;a href="https://learn.microsoft.com/en-us/azure/architecture/reference-architectures/hybrid-networking/hub-spoke?tabs=cli"&gt;hub-and-spoke architecture &lt;/a&gt;for larger cloud adoption efforts. If the footprint is even massive, we can even extend the model to a cluster of hubs and spokes. &lt;/p&gt;&#10;&lt;div class="wp-block-image"&gt;&#10;&lt;figure class="aligncenter size-full"&gt;&lt;img loading="lazy" decoding="async" width="677" height="452" src="https://www.digihunch.com/wp-content/uploads/2023/03/azure-hub-spoke.webp" alt="" class="wp-image-12907" srcset="https://www.digihunch.com/wp-content/uploads/2023/03/azure-hub-spoke.webp 677w, https://www.digihunch.com/wp-content/uploads/2023/03/azure-hub-spoke-300x200.webp 300w, https://www.digihunch.com/wp-content/uploads/2023/03/azure-hub-spoke-410x275.webp 410w" sizes="auto, (max-width: 677px) 100vw, 677px" /&gt;&lt;figcaption class="wp-element-caption"&gt;A cluster of multiple hub-and-spoke&lt;/figcaption&gt;&lt;/figure&gt;&#10;&lt;/div&gt;&#10;&lt;p class="wp-block-paragraph"&gt;We can connect multiple hubs using:&lt;/p&gt;&#10;&lt;ul class="wp-block-list"&gt;&#10;&lt;li&gt;V-Net peering&lt;/li&gt;&#10;&lt;li&gt;Azure ExpressRoute&lt;/li&gt;&#10;&lt;li&gt;Azure Virtual WAN&lt;/li&gt;&#10;&lt;li&gt;Site-to-site VPN&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p class="wp-block-paragraph"&gt;Within a single hub-and-spoke model, the Hub V-Net hosts shared services and acts as central point of connectivity (to many spoke V-Nets). Often in the Hub V-Net are Azure Bastion, Azure Firewall and VPN Gateway or ExpressRoute gateway. The spoke V-Nets (in same or different subscriptions) isolates and manage workloads in prod, non-prod, etc. Since a single V-Net cannot traverse subscription boundaries, you have to use V-Net peering (preferred), ExpressRoute circuit, or VPN Gateways. V-Net peering works across regions, and across Azure AD tenants. It is low-latency but isn&amp;#8217;t transitive.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;In some cases we also configure &lt;a href="https://learn.microsoft.com/en-us/azure/cloud-adoption-framework/ready/azure-best-practices/perimeter-networks"&gt;perimeter networks&lt;/a&gt; (aka DMZs) in the hub-and-spoke architecture, to handle external traffic. Perimeter networks host services such as External Load balancer, &lt;a href="https://learn.microsoft.com/en-us/azure/firewall/overview"&gt;Azure Firewall&lt;/a&gt;, Azure Application Firewall &lt;a href="https://learn.microsoft.com/en-us/azure/web-application-firewall/ag/ag-overview"&gt;on Azure Application Gateway&lt;/a&gt; or &lt;a href="https://learn.microsoft.com/en-us/azure/web-application-firewall/afds/afds-overview"&gt;on Azure FrontDoor&lt;/a&gt;) , &lt;a href="https://learn.microsoft.com/en-us/azure/architecture/reference-architectures/dmz/nva-ha"&gt;network virtual appliances&lt;/a&gt; (&lt;a href="https://learn.microsoft.com/en-us/azure/cloud-adoption-framework/ready/azure-best-practices/perimeter-networks#network-virtual-appliances"&gt;NVAs&lt;/a&gt;), IDS, IPS, and other security appliances. Incoming packets flow through the security appliances before reaching back-end servers. Internet-bound packets from workloads must also flow through security appliances in the perimeter network before they can leave the network. The document gives an &lt;a href="https://learn.microsoft.com/en-us/azure/cloud-adoption-framework/ready/azure-best-practices/perimeter-networks#perimeter-network-topology"&gt;example&lt;/a&gt; of a DMZ hub V-Net with two perimeter networks.&lt;/p&gt;&#10;&lt;h2 class="wp-block-heading"&gt;Virtual WANs&lt;/h2&gt;&#10;&lt;p class="wp-block-paragraph"&gt;&lt;a href="https://www.techtarget.com/searchnetworking/definition/WAN-wide-area-network"&gt;This&lt;/a&gt; page discusses what is WAN and SD-WAN. WAN connects multiple LANs in different geographic areas and is common with companies with multiple offices in different regions. WAN infrastructure may be privately owned or leased as a service from a third-party service provider (hybrid WAN). Companies may use IPSec VPN, SSL VPN or direct connection to build their WANs. Software-defined WAN (SD-WAN) leverages virtualization technologies, network overlays, on-site SD-WAN devices and software platforms to build hybrid WANs.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;&lt;a href="https://learn.microsoft.com/en-us/azure/virtual-wan/virtual-wan-about"&gt;Azure Virtual WAN&lt;/a&gt; (similar to &lt;a href="https://aws.amazon.com/blogs/networking-and-content-delivery/introducing-aws-cloud-wan-preview/"&gt;AWS cloud WAN&lt;/a&gt;) is a managed service to build a virtual WAN with a single operational interface that brings many networking, security and routing functionalities together. It simplifies end-to-end network connectivity (within Azure, between Azure and on-prem) by creating a hub-and-spoke architecture. &lt;/p&gt;&#10;&lt;div class="wp-block-image"&gt;&#10;&lt;figure class="aligncenter size-full"&gt;&lt;img loading="lazy" decoding="async" width="1024" height="608" src="https://www.digihunch.com/wp-content/uploads/2023/03/azure-virtual-wan.webp" alt="" class="wp-image-12908" srcset="https://www.digihunch.com/wp-content/uploads/2023/03/azure-virtual-wan.webp 1024w, https://www.digihunch.com/wp-content/uploads/2023/03/azure-virtual-wan-300x178.webp 300w, https://www.digihunch.com/wp-content/uploads/2023/03/azure-virtual-wan-768x456.webp 768w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /&gt;&lt;figcaption class="wp-element-caption"&gt;Virtual WAN&lt;/figcaption&gt;&lt;/figure&gt;&#10;&lt;/div&gt;&#10;&lt;p class="wp-block-paragraph"&gt;Virtual WAN is essentially an integrated connectivity solutions (in hub and spoke), with a &lt;a href="https://learn.microsoft.com/en-us/azure/virtual-wan/virtual-wan-global-transit-network-architecture"&gt;global transit network architecture&lt;/a&gt;. The configurations, including spoke setup) is automated and troubleshooting is more intuitive. Global transit network configures multiple virtual WAN hubs with hub-to-hub connectivity, which ultimately enables any-to-any connectivity, with different paths discussed &lt;a href="https://learn.microsoft.com/en-us/azure/virtual-wan/virtual-wan-global-transit-network-architecture#anytoany"&gt;here&lt;/a&gt;.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;The landing zone document &lt;a href="https://learn.microsoft.com/en-us/azure/cloud-adoption-framework/ready/azure-best-practices/virtual-wan-network-topology#virtual-wan-network-design-recommendations"&gt;recommends&lt;/a&gt; Virtual WAN for new large or global network deployments in Azure where you need global transit connectivity across Azure regions and on-premises locations.&lt;/p&gt;&#10;&lt;h2 class="wp-block-heading"&gt;Summary&lt;/h2&gt;&#10;&lt;p class="wp-block-paragraph"&gt;Landing Zone configuration involves many components and there is no way to discuss everything thoroughly. In this post I put down my notes reading Azure landing zone documentation. Overall, working on landing zones requires learning a variety of services by the CSP.&lt;/p&gt;&#10;&lt;nav class="wp-post-navigation" aria-label="Post navigation"&gt;&#10;&lt;a rel="prev" href="https://www.digihunch.com/2023/03/a-taste-of-iot-device-tracking/"&gt;&lt;span class="wp-post-navigation-label"&gt;Previous Post&lt;/span&gt;&lt;strong class="wp-post-navigation-title"&gt;A taste of IoT device tracking&lt;/strong&gt;&lt;/a&gt;&#10;&lt;a rel="next" href="https://www.digihunch.com/2023/04/kubernetes-multiple-cpu-architecture-container-image/"&gt;&lt;span class="wp-post-navigation-label"&gt;Next Post&lt;/span&gt;&lt;strong class="wp-post-navigation-title"&gt;Kubernetes with Multiple CPU Architectures 1 of 2 – Container Image&lt;/strong&gt;&lt;/a&gt;&#10;&lt;/nav&gt;&#10;</description></item><item><title>AWS CDK example in Python – provision Kubernetes Nodes</title><link>https://www.digihunch.com/2020/12/instance-initialization-with-aws-cdk-in-python/</link><pubDate>Thu, 03 Dec 2020 21:14:00 -0400</pubDate><guid>https://www.digihunch.com/2020/12/instance-initialization-with-aws-cdk-in-python/</guid><description>&lt;p class="wp-block-paragraph"&gt;There are two mechanisms to initialize instances in AWS. Cloud init and CloudFormation Init. Both are widely used and we discuss each of them in this posting. Then we will give an example of using AWS CDK in Python.&lt;/p&gt;&#10;&lt;h3 class="wp-block-heading" id="h-cloud-init"&gt;Cloud-Init&lt;/h3&gt;&#10;&lt;p class="wp-block-paragraph"&gt;Cloud-Init is a service originally built for Ubuntu, as a bootstrapping utility to customize a Linux VM as it boots for the first time. It has evolved to be an industry standard multi-distribution method for cross-platform (public or private) cloud instance initialization, or even bare-metal installation. In &lt;a href="https://cloudbase-init.readthedocs.io/en/latest/intro.html" class="rank-math-link"&gt;cloud-init&lt;/a&gt; you can install packages and write files, or configure users and security. Because cloud-init is called during the initial boot process, there are no additional steps or required agents to apply your configuration. &lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;Cloud-Init uses UserData, which is part of instance metadata. With AWS, you can pass two types of user data to&lt;a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/user-data.html#user-data-shell-scripts" class="rank-math-link"&gt; Amazon EC2&lt;/a&gt;: shell scripts and cloud-init directives.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;The cloud-config files are text files encoded in base64, with more details covered in the documentation &lt;a href="https://cloudinit.readthedocs.io/en/latest/topics/format.html#cloud-config-data" class="rank-math-link"&gt;here&lt;/a&gt;. cloud-init also works across distributions. For example, you don&amp;#8217;t use apt-get install or yum install to install a package. Instead you can define a list of packages to install. cloud-init automatically uses the native package management tool for the distro you select.&lt;/p&gt;&#10;&lt;h3 class="wp-block-heading" id="h-cloudformation-init"&gt;CloudFormation Init&lt;/h3&gt;&#10;&lt;p class="wp-block-paragraph"&gt;The cloudformation init mechanism does not only initialize instance, it also provides a mechanism for the resource being created to communicate with other resources. It allows an instance to emit signal to a different resource (via cfn-signal). It can also monitor changes to external resource and invoke local action (using cfn-hup with hooks). CloudFormation Init requires several components to work together:&lt;/p&gt;&#10;&lt;ul class="wp-block-list"&gt;&#10;&lt;li&gt;The cloudformation resource should have metadata. The metadata must have a key &lt;a href="https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-init.html" class="rank-math-link"&gt;AWS::CloudFormation::Init&lt;/a&gt; in which configsets are declared.&lt;/li&gt;&#10;&lt;li&gt;The UserData must use helper script (&lt;a href="https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/cfn-init.html" class="rank-math-link"&gt;cfn-init&lt;/a&gt;) to invoke configuration jobs&lt;/li&gt;&#10;&lt;li&gt;The UserData can use helper script (&lt;a href="https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/cfn-signal.html" class="rank-math-link"&gt;cfn-signal&lt;/a&gt;) to signal with a CreationPolicy or WaitCondition (of the same or different resource), so you can synchronize other resources in the stack when the prerequisite resource or application is ready.&lt;/li&gt;&#10;&lt;li&gt;The &lt;a href="https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/cfn-hup.html" class="rank-math-link"&gt;cfn-hup&lt;/a&gt; service on the instance can be configured, to check for updates to metadata and execute custom hooks when changes are detected.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;h3 class="wp-block-heading" id="h-comparison"&gt;Comparison&lt;/h3&gt;&#10;&lt;p class="wp-block-paragraph"&gt;While there are overlaps between the functionalities of Cloud Init and CloudFormation Init, the major difference is the latter support extended features (signal, update, etc); whereas the former is vendor neutral. The table below summarized some the differences:&lt;/p&gt;&#10;&lt;figure class="wp-block-table is-style-stripes"&gt;&lt;table class="has-background" style="background-color:#e9fbe5"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;strong&gt;Cloud Init&lt;/strong&gt;&lt;/td&gt;&lt;td&gt;&lt;strong&gt;CloudFormation Init&lt;/strong&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Works on&lt;/td&gt;&lt;td&gt;Linux OS distribution&lt;/td&gt;&lt;td&gt;CloudFormation resource, in combination with cfn &lt;a href="https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/cfn-helper-scripts-reference.html" class="rank-math-link"&gt;helper scripts&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Usecase&lt;/td&gt;&lt;td&gt;Initialization only&lt;/td&gt;&lt;td&gt;Both initialization and resource update&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Trigger&lt;/td&gt;&lt;td&gt;cloud-init systemd service&lt;/td&gt;&lt;td&gt;Initial: from UserData&lt;br&gt;Update: by cfn hook&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Adoption&lt;/td&gt;&lt;td&gt;Multiple cloud vendors and bare-metal system&lt;/td&gt;&lt;td&gt;AWS cloud instances&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Action Playbook&lt;/td&gt;&lt;td&gt;/var/lib/cloud/&lt;br&gt;Instance Metadata -&amp;gt; User Data, encoded in base 64&lt;/td&gt;&lt;td&gt;CloudFormation Resource -&amp;gt; Metadata section -&amp;gt; AWS::CloudFormation::Init -&amp;gt; configSets and configs&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Log file and stdout&lt;/td&gt;&lt;td&gt;/var/log/cloud-init.log&lt;br&gt;/var/log/cloud-init-output.log&lt;/td&gt;&lt;td&gt;/var/log/cfn-init.log&lt;br&gt;/var/log/cfn-init-cmd.log&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;figcaption class="wp-element-caption"&gt;Comparison between cloud-init and cfn-init&lt;/figcaption&gt;&lt;/figure&gt;&#10;&lt;h3 class="wp-block-heading" id="h-aws-cloud-development-toolkit-cdk"&gt;AWS Cloud Development Toolkit (CDK)&lt;/h3&gt;&#10;&lt;p class="wp-block-paragraph"&gt;Traditionally, AWS CloudFormation uses &lt;a href="https://aws.amazon.com/cloudformation/resources/templates/" class="rank-math-link"&gt;template &lt;/a&gt;in YAML or JSON for resource declaration. As the size of system grows, the amount of resource involved grows quickly and the size of such declaration file may grow beyond manageable.&lt;a href="https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-nested-stacks.html" class="rank-math-link"&gt; Nested stacks&lt;/a&gt; and &lt;a href="https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-stack-exports.html" class="rank-math-link"&gt;export of output&lt;/a&gt; are mechanisms designed to combat the template sprawling, but to a very limited extent. Two reasons it is hard to control template size are:&lt;/p&gt;&#10;&lt;ul class="wp-block-list"&gt;&#10;&lt;li&gt;In declarative statements, each line carries very small piece of information. Without flow controls such as if-else, loops, object oriented structure, the level of code reusability is very low;&lt;/li&gt;&#10;&lt;li&gt;Some auxiliary resources (such as AWS::EC2::VPCGatewayAttachment) must be declared explicitly, even though they are insignificant to the stack functionality&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p class="wp-block-paragraph"&gt;To address these challenges, AWS introduced &lt;a class="rank-math-link" href="https://aws.amazon.com/cdk/"&gt;AWS CDK&lt;/a&gt; (cloud development tookkit), which supports multiple languages (JavaScript, TypeScript, Python, Java, and C#). The CDK was natively developed in TypeScript, which is supposed to be the preferred development language. A &lt;a class="rank-math-link" href="https://docs.aws.amazon.com/cdk/latest/guide/getting_started.html"&gt;tutorial &lt;/a&gt;is provided here, with detailed API documentation &lt;a class="rank-math-link" href="https://docs.aws.amazon.com/cdk/api/latest/docs/aws-construct-library.html"&gt;here&lt;/a&gt;.&lt;/p&gt;&#10;&lt;div class="wp-block-image"&gt;&#10;&lt;figure class="aligncenter size-large is-resized"&gt;&lt;img loading="lazy" decoding="async" src="https://www.digihunch.com/wp-content/uploads/2022/04/image-1.png" alt="" class="wp-image-4962" width="621" height="242"/&gt;&lt;/figure&gt;&#10;&lt;/div&gt;&#10;&lt;p class="wp-block-paragraph"&gt;To &lt;a href="https://docs.aws.amazon.com/cdk/latest/guide/work-with-cdk-python.html" class="rank-math-link"&gt;install &lt;/a&gt;aws cdk and create a hello world project, follow &lt;a href="https://docs.aws.amazon.com/cdk/latest/guide/hello_world.html" class="rank-math-link"&gt;this &lt;/a&gt;example.&lt;/p&gt;&#10;&lt;h3 class="wp-block-heading" id="h-an-example-in-python"&gt;An Example in Python&lt;/h3&gt;&#10;&lt;p class="wp-block-paragraph"&gt;I have created an example for AWS CDK in Python. The purpose is to create some EC2 instance to complete a lab for Kubernetes (without using managed EKS service). The example provisions the followings:&lt;/p&gt;&#10;&lt;ul class="wp-block-list"&gt;&#10;&lt;li&gt;VPC, a public and private subnets, Internet and NAT gateways;&lt;/li&gt;&#10;&lt;li&gt;Relevant security groups and permissions&lt;/li&gt;&#10;&lt;li&gt;Bastion host, public instances in public subnet&lt;/li&gt;&#10;&lt;li&gt;Private instances in private subnet, with public route through NAT gateway&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p class="wp-block-paragraph"&gt;The private instances forms a cluster for Kubernetes lab. We will use &lt;a href="https://kubernetes.io/docs/setup/production-environment/tools/kubespray/" class="rank-math-link"&gt;kubespray &lt;/a&gt;to initialize these instances. During the bootstraping, we download &lt;a href="https://github.com/kubernetes-sigs/kubespray" class="rank-math-link"&gt;kubespray&lt;/a&gt;, install ansible, etc.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;Here is the code &lt;a href="https://github.com/digihunch/kubelab/tree/main/kube-cdk"&gt;repo&lt;/a&gt; for this example. With CloudFormation only, the single template could go well beyond 1000 lines. With CDK, the code are organized into several different python files, each representing a stack. The stacks can be stood up with command:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cdk deploy vpc-stack&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cdk deploy security-stack&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cdk deploy bastion-stack&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cdk deploy private-stack&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p class="wp-block-paragraph"&gt;Although the &lt;a href="https://docs.aws.amazon.com/cdk/api/latest/python/index.html" class="rank-math-link"&gt;documentation &lt;/a&gt;in Python is available, there are generally not a lot of examples built out on the Internet. The &lt;a href="https://pypi.org/" class="rank-math-link"&gt;pypi &lt;/a&gt;site provides some Python specific examples for each module (e.g. &lt;a href="https://pypi.org/project/aws-cdk.core/" class="rank-math-link"&gt;core &lt;/a&gt;and &lt;a href="https://pypi.org/project/aws-cdk.aws-ec2/" class="rank-math-link"&gt;aws-ec2&lt;/a&gt;). Given these libraries are available for only 2 years (since 2018), many advocates TypeScript as the language. However, I have implemented some CloudFormation init, used helper script, and UserData in this example, without running into any language specific issues.It should be noted that the EC2 instance by default will call cfn-init. So there is no need to explicitly run cfn-signal or cfn-init from user data in python code (&lt;a href="https://github.com/digihunch/kubelab/blob/main/kube-cdk/kube_cdk/bastion_stack.py" class="rank-math-link"&gt;example&lt;/a&gt;). This can be verified in file /var/lib/cloud/instances/&amp;lt;instance-id&amp;gt;/user-data.txt which automatically includes the following lines:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# fingerprint: e1b32ead13878deb&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;(&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; set +e&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; /opt/aws/bin/cfn-init -v --region us-east-1 --stack bastion-stack --resource bastionhost5F466975da9934ba490de456 -c config_set_1,config_set_2&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; /opt/aws/bin/cfn-signal -e $? --region us-east-1 --stack bastion-stack --resource bastionhost5F466975da9934ba490de456&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; cat /var/log/cfn-init.log &amp;gt;&amp;amp;&lt;span style="color:#ae81ff"&gt;2&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;)&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p class="wp-block-paragraph"&gt;In addition to Python, AWS CDK also supports other languages. In the &lt;a href="https://www.digihunch.com/2020/12/instance-initialization-with-aws-cdk-in-python/"&gt;next&lt;/a&gt; post, we will discuss use of CDK in Typescript.&lt;/p&gt;&#10;&lt;nav class="wp-post-navigation" aria-label="Post navigation"&gt;&#10;&lt;a rel="prev" href="https://www.digihunch.com/2020/11/ipvs-iptables-and-kube-proxy/"&gt;&lt;span class="wp-post-navigation-label"&gt;Previous Post&lt;/span&gt;&lt;strong class="wp-post-navigation-title"&gt;IPVS, iptables and kube-proxy&lt;/strong&gt;&lt;/a&gt;&#10;&lt;a rel="next" href="https://www.digihunch.com/2020/12/high-performance-computing-cluster/"&gt;&lt;span class="wp-post-navigation-label"&gt;Next Post&lt;/span&gt;&lt;strong class="wp-post-navigation-title"&gt;High Performance Computing&lt;/strong&gt;&lt;/a&gt;&#10;&lt;/nav&gt;&#10;</description></item></channel></rss>