<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Pranav Ghoderao on Medium]]></title>
        <description><![CDATA[Stories by Pranav Ghoderao on Medium]]></description>
        <link>https://medium.com/@pranavghoderao?source=rss-fa9e6f84e862------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Yy76hCbCG7JngBDmmYPWbg.jpeg</url>
            <title>Stories by Pranav Ghoderao on Medium</title>
            <link>https://medium.com/@pranavghoderao?source=rss-fa9e6f84e862------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 01:01:14 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@pranavghoderao/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Setting Up OIDC Authentication for Azure DevOps (ADO) with AWS]]></title>
            <link>https://medium.com/@pranavghoderao/setting-up-oidc-authentication-for-azure-devops-ado-with-aws-7a2679566fec?source=rss-fa9e6f84e862------2</link>
            <guid isPermaLink="false">https://medium.com/p/7a2679566fec</guid>
            <category><![CDATA[azure-devops]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[aws-oidc]]></category>
            <category><![CDATA[ci-cd-pipeline]]></category>
            <dc:creator><![CDATA[Pranav Ghoderao]]></dc:creator>
            <pubDate>Mon, 30 Dec 2024 10:37:15 GMT</pubDate>
            <atom:updated>2024-12-30T11:09:52.199Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*0KuPBPNlQbhSGTaX1Hpygg.jpeg" /></figure><h3>Introduction</h3><blockquote>Integrating Azure DevOps (ADO) pipelines with AWS services is a common requirement for many organizations. Traditionally, AWS access keys were used to authenticate tasks in ADO pipelines, which introduced the burden of securely managing and rotating credentials. OpenID Connect (OIDC) simplifies this process by allowing Azure DevOps pipelines to assume AWS roles without requiring static credentials.</blockquote><blockquote>In this blog, we’ll walk through the complete process of setting up OIDC authentication between Azure DevOps and AWS to securely call AWS services in your pipelines.</blockquote><h3>Key Benefits of OIDC Authentication</h3><ul><li><strong><em>Eliminates static credentials-</em></strong> No need to manage AWS access keys manually.</li><li><strong><em>Secure by design-</em></strong> Short-lived tokens minimize security risks.</li><li><strong><em>Streamlined setup-</em></strong> OIDC tokens directly federate Azure DevOps pipelines into AWS.</li></ul><h3>Prerequisites</h3><p>Before starting, ensure you have the following-</p><ol><li>An <strong><em>AWS account</em></strong> with sufficient permissions to create IAM roles and policies.</li><li>An <strong><em>Azure DevOps organization</em></strong> with access to manage pipelines.</li><li>Basic understanding of<strong><em> AWS IAM roles</em></strong> and <strong><em>Azure DevOps pipeline configurations</em></strong>.</li><li>Install the <strong><em>AWS Toolkit</em></strong> for Azure DevOps.</li></ol><ul><li>Install the toolkit from the <a href="https://marketplace.visualstudio.com/items?itemName=AmazonWebServices.aws-vsts-tools"><strong><em>Azure DevOps Marketplace</em></strong></a><strong><em>.</em></strong></li><li><strong><em>Note-</em></strong> The toolkit is scoped at the organization level.</li></ul><p>5. Obtain your <strong><em>Azure DevOps Organization Number</em></strong></p><ul><li><em>Navigate to </em><strong><em>Organization Settings → Microsoft Entra → Download</em></strong><em> to get an Excel sheet.</em></li><li><em>The ADO organization number will be listed in the file.</em></li></ul><h3>Step 1: Create an ADO Service Connection</h3><ul><li>Navigate to <strong><em>Project Settings → Service connections → New service connection</em></strong><em>.</em></li><li>Select the <strong><em>AWS</em></strong> connection type.</li><li>Provide the <strong><em>Role ARN </em></strong>(you’ll get this later from AWS).</li><li>Check the <strong><em>Use OIDC</em></strong> option.</li><li>Save the connection.</li></ul><h3>Step 2: Create an OIDC Identity Provider in AWS</h3><ul><li>Log in to the <strong><em>AWS Management Console</em></strong> with <strong><em>Administrator Access.</em></strong></li><li>Navigate to <strong>IAM → Identity Providers → Add Provider</strong>.</li><li>Select the <strong><em>OpenID Connect </em></strong>option and fill in:</li><li><strong><em>Provider URL-</em></strong> https://vstoken.dev.azure.com/&lt;ADO-ORG-Number&gt;</li><li><strong><em>Audience- </em></strong>api://AzureADTokenExchange</li><li>Click <strong><em>Add Provider</em></strong> to save.</li></ul><h3>Step 3: Assign a Role to the OIDC Provider</h3><h4><strong>Steps to Create and Assign a Role</strong></h4><ul><li>In AWS, select the newly created Identity Provider and click <strong>Assign Role</strong>.</li><li>Select <strong><em>Create a new role</em></strong>.</li><li>Choose the permissions required for your pipeline (apply least privilege).</li><li>Name the role (e.g., ado-oidc-role) and create it.</li><li>Copy the <strong><em>ARN </em></strong>of the newly created role (you’ll need it later).</li></ul><h4><strong>Update the Trust Policy</strong></h4><p>Edit the trust relationship of the role to include the following-</p><pre>{<br>  &quot;Effect&quot;: &quot;Allow&quot;,<br>  &quot;Principal&quot;: {<br>    &quot;Federated&quot;: &quot;arn:aws:iam::&lt;AWS_ACCOUNT_ID&gt;:oidc-provider/vstoken.dev.azure.com/&lt;ADO-ORG-Number&gt;&quot;<br>  },<br>  &quot;Action&quot;: &quot;sts:AssumeRoleWithWebIdentity&quot;,<br>  &quot;Condition&quot;: {<br>    &quot;StringEquals&quot;: {<br>      &quot;vstoken.dev.azure.com/&lt;ADO-ORG-Number&gt;:aud&quot;: &quot;api://AzureADTokenExchange&quot;,<br>      &quot;vstoken.dev.azure.com/&lt;ADO-ORG-Number&gt;:sub&quot;: &quot;sc://&lt;ADO-Org-Name&gt;/&lt;ADO-Project-Name&gt;/&lt;ADO-ServiceConnection-Name&gt;&quot;<br>    }<br>  }<br>}</pre><h3>Step 4: Update the ADO Service Connection</h3><ul><li>Navigate back to the ADO service connection created earlier.</li><li>Enter the <strong><em>AWS Role ARN</em></strong> (copied from the IAM role).</li><li>Check the <strong><em>Use OIDC </em></strong>option.</li><li>Save the service connection (e.g., ado-oidc-ado).</li></ul><h3>Step 5: Configure the Pipeline</h3><p>Below is an example of an Azure DevOps pipeline using the OIDC-based AWS credentials-</p><pre>trigger: none<br><br>pool:<br>  vmImage: &#39;ubuntu-latest&#39;             # Default agents<br><br>jobs:<br>- job: AWS_OIDC_Test<br>  steps:<br>  - task: AWSCLI@1<br>    inputs:<br>      awsCredentials: &#39;aws-oidc-ado&#39;  # Name of the ADO service connection<br>      regionName: &#39;us-east-1&#39;<br>      awsCommand: &#39;s3&#39;<br>      awsSubCommand: &#39;ls&#39;</pre><h3>Testing the Pipeline</h3><ul><li>Run the pipeline and ensure it can assume the AWS role using OIDC tokens.</li><li>Verify the pipeline executes the AWS CLI commands successfully (e.g., listing S3 buckets).</li><li>Check <strong><em>AWS CloudTrail</em></strong> logs to confirm the role assumption.</li></ul><h3>Tips and Troubleshooting</h3><ul><li><strong><em>Access Denied</em>-</strong> Ensure the IAM role has the correct permissions and the trust relationship is configured accurately.</li><li><strong><em>Invalid Audience-</em></strong> Verify that the audience in the trust policy matches api://AzureADTokenExchange.</li><li><strong><em>Pipeline Fails to Authenticate-</em></strong> Ensure the sub value in the trust policy matches your ADO organization, project, and service connection name.</li></ul><h3>Conclusion</h3><blockquote>By configuring OIDC authentication between Azure DevOps and AWS, you’ve taken a significant step toward improving the security and simplicity of your CI/CD workflows. OIDC eliminates the need for static credentials, enabling a seamless, token-based authentication mechanism.</blockquote><blockquote>Explore more possibilities like using OIDC for other CI/CD platforms or further enhancing pipeline security with least-privilege permissions.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7a2679566fec" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Streamlining Azurerm Provider v3.0.0+ Upgrade with Terraform Import Utility]]></title>
            <link>https://medium.com/@pranavghoderao/streamlining-azurerm-provider-v3-0-0-upgrade-with-terraform-import-utility-70935d637d40?source=rss-fa9e6f84e862------2</link>
            <guid isPermaLink="false">https://medium.com/p/70935d637d40</guid>
            <category><![CDATA[terraform-provider]]></category>
            <category><![CDATA[azurerm]]></category>
            <category><![CDATA[terraform]]></category>
            <category><![CDATA[module-upgrade]]></category>
            <category><![CDATA[terraform-import]]></category>
            <dc:creator><![CDATA[Pranav Ghoderao]]></dc:creator>
            <pubDate>Wed, 16 Aug 2023 16:04:27 GMT</pubDate>
            <atom:updated>2023-08-16T16:04:27.780Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wwdBR51nIEulxpjLevSBtQ.png" /></figure><h3><strong>Introduction</strong></h3><blockquote>As cloud infrastructure evolves rapidly, so do the tools that manage it. One such tool is Terraform, an infrastructure as code (IaC) solution that enables seamless provisioning and management of cloud resources. With the release of Terraform “Azurerm” provider versions 3.0.0 and above, some provider resources have changed their names and attributes. This presents a challenge when upgrading existing infrastructure that relies on these resources.</blockquote><h3><strong>The Challenge of Upgrading to Provider Version 3.0.0+</strong></h3><blockquote>Upgrading infrastructure code to harness the latest Terraform provider versions is crucial to stay aligned with evolving best practices and features. However, this transition is not without hurdles. With the introduction of the new “3. x. x” version update, substantial changes have been made to the names of resources and their associated attributes within the “Azurerm” module. Detailed insights into these changes can be found in the upgrade guide provided at -</blockquote><blockquote><a href="https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/guides/3.0-upgrade-guide">https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/guides/3.0-upgrade-guide</a>.</blockquote><h3><strong>Why is a streamlined upgrade process so crucial? Let’s break it down:</strong></h3><blockquote><strong><em>1. No Looking Back:</em></strong> As we make the shift from the “2. x.x” version to the new and shiny “3. x.x ”version of the “Azurerm” provider, we face non-backward compatibility. This means that modules built using the “2. x.x” version might not fit seamlessly into the new version’s framework. This misalignment can lead to potential disruptions.</blockquote><blockquote><strong>2. Harmonizing Old and New:</strong> Consider a scenario: you have modules that utilize the older “Azurerm” provider version to establish existing resources, and you also want to introduce new modules using the updated provider version to create new resources. However, initiating Terraform with providers of different versions is a challenge. This mismatch can lead to complications as you try to manage these distinct provider versions under one roof.</blockquote><blockquote><strong>3. Simplifying the Complicated: </strong>Manually hunting down and updating resource references, names, and attributes can feel like a marathon. Imagine scrolling through lines of code, making tweaks to every instance that needs modification. In larger projects, this endeavor becomes even more formidable, consuming valuable time and increasing the risk of errors.</blockquote><h3><strong>Introducing the Algorithm for Terraform Import Utility</strong></h3><blockquote>This utility automatically generates import blocks based on your existing state file, enabling a seamless transition to the new module version. All you have to do is follow the guide — add these import blocks to your existing code and update it to work with the fancy new modules that support the new provider version.</blockquote><p><strong>Here’s a detailed breakdown of the algorithm</strong></p><p><strong><em>Step 1: </em></strong><em>Reading the Terraform State</em></p><pre>Function readState(pathread):<br>       Open the state file at &#39;path&#39;<br>       Load JSON content from the file into the &#39;state&#39; dictionary<br>       Close the file<br>       Return &#39;state&#39;</pre><blockquote><strong>Explanation: </strong>This step involves creating a function that reads the Terraform state file from the provided path. The state file contains information about your existing infrastructure. The function opens the file, loads its contents as JSON into a dictionary called ‘state’, and then returns this dictionary for further processing.</blockquote><p><strong><em>Step 2:</em></strong><em> Resource Identification</em></p><pre>Function getPivot(state):<br>       Initialize empty &#39;pivotList&#39;<br>       Initialize &#39;index&#39; to 0<br><br>       Extract the &#39;resources&#39; list from the &#39;state&#39;<br><br>       For each resource in &#39;resources&#39;:<br>           If a resource has a module, add its module name to &#39;modList&#39;; else add &quot;NA&quot;<br><br>       While &#39;index&#39; &lt; length of &#39;modList&#39;:<br>           Set &#39;start_position&#39; to &#39;index&#39;<br>           Set &#39;val&#39; to &#39;modList[index]&#39;<br><br>           While &#39;index&#39; &lt; length of &#39;modList&#39; and &#39;modList[index]&#39; equals &#39;val&#39;:<br>               Increment &#39;index&#39; by 1<br>           Set &#39;end_position&#39; to &#39;index&#39; + 1<br><br>           Append tuple (val, start_position, end_position) to &#39;pivotList&#39;<br><br>       Return &#39;resources&#39;, &#39;pivotList&#39;</pre><blockquote><strong>Explanation: </strong>This step involves identifying and organizing resources based on their modules. The function ‘getPivot’ takes the ‘state’ dictionary as input and extracts the ‘resources’ list. For each resource, it determines whether it belongs to a module or not and creates a list ‘modList’ of module names. The function then groups resources based on modules by creating a ‘pivotList’ containing tuples representing the module name, start position, and end position of each group.</blockquote><p><strong><em>Step 3:</em></strong><em> Generating Import Blocks</em></p><pre>Function genRawImport(resources, pivotList):<br>      Initialize an empty list &#39;importList&#39;<br><br>      Create a mapping &#39;holder&#39; to handle changed/modified resource names<br><br>      For each &#39;pivot&#39; in &#39;pivotList&#39;:<br>          Set &#39;modName&#39; to the module name from &#39;pivot&#39;<br><br>          Loop from start position to end position - 1:<br>              Get the &#39;resource&#39; at the current &#39;index&#39; from &#39;resources&#39;<br><br>              Check if the &#39;resource&#39; is managed and not a null_resource:<br>                  For each &#39;instance&#39; in &#39;resource[&#39;instances&#39;]&#39;:<br>                      Set &#39;id&#39; to the &#39;id&#39; attribute of &#39;instance[&#39;attributes&#39;]&#39;<br>                      Set &#39;resource_type&#39; to the type of the current &#39;resource&#39;<br><br>                      Check if &#39;resource_type&#39; exists in &#39;holder&#39;:<br>                          If &#39;resource_type&#39; is &quot;azurerm_virtual_machine&quot;:<br>                              Extract &#39;os_type&#39; from &#39;instance[&#39;attributes&#39;][&#39;storage_os_disk&#39;][0][&#39;os_type&#39;]&#39;<br>                              Construct &#39;to&#39; using &#39;modName&#39;, &#39;holder[resource_type][os_type]&#39;, &#39;resource[&#39;name&#39;]&#39;, and &#39;instance[&#39;index_key&#39;]&#39; if present<br>                          Else:<br>                              If &#39;instance&#39; has &#39;index_key&#39;:<br>                                  Construct &#39;to&#39; using &#39;modName&#39;, &#39;holder[resource_type]&#39;, &#39;resource[&#39;name&#39;]&#39;, and &#39;instance[&#39;index_key&#39;]&#39;<br>                              Else:<br>                                  Construct &#39;to&#39; using &#39;modName&#39;, &#39;holder[resource_type]&#39;, and &#39;resource[&#39;name&#39;]&#39;<br>                      Else:<br>                          If &#39;instance&#39; has &#39;index_key&#39;:<br>                              Construct &#39;to&#39; using &#39;modName&#39;, &#39;resource_type&#39;, &#39;resource[&#39;name&#39;]&#39;, and &#39;instance[&#39;index_key&#39;]&#39;<br>                          Else:<br>                              Construct &#39;to&#39; using &#39;modName&#39;, &#39;resource_type&#39;, and &#39;resource[&#39;name&#39;]&#39;<br><br>                      Remove &quot;NA&quot; prefix from &#39;to&#39; if present<br>                      Append [to, id] to &#39;importList&#39;<br><br>      Return &#39;importList&#39;</pre><blockquote><strong>Explanation: </strong>This algorithm outlines the process of generating an import list to facilitate the migration of Azurerm provider resources in Terraform configurations. The function ‘genRawImport’ takes ‘resources’ and ‘pivotList’ as inputs. It iterates through the ‘pivotList’, extracting module names and resource indices. For each resource instance, it constructs the ‘to’ value for the import block based on the resource’s type, module, and attributes. The ‘holder’ mapping assists in handling changed resource names. The resulting ‘importList’ contains pairs of ‘to’ and ‘id’, forming the import blocks required for the migration.</blockquote><p><strong><em>Step 4:</em></strong><em> Output and Usage Instructions</em></p><pre> Function getImportBlock(importList):<br>       Initialize empty &#39;result&#39;<br><br>       For each element [to, id] in &#39;importList&#39;:<br>           Construct import block string with format &#39;to&#39; and &#39;id&#39; values<br>           Append the block to &#39;result&#39;<br><br>       Return &#39;result&#39;</pre><blockquote><strong>Explanation:</strong> This step involves formatting and outputting the generated import blocks. The function ‘getImportBlock’ takes ‘importList’ as input and constructs strings for each element in the list. These strings represent import blocks with formatted ‘to’ and ‘id’ values. The strings are then appended to the ‘result’ string, which contains the complete set of import blocks that can be directly integrated into your Terraform configuration files.</blockquote><h3><strong>Conclusion</strong></h3><blockquote>Upgrading to the new Azurerm provider version 3.0.0+ doesn’t have to be a complex and error-prone process. The Terraform Import Utility simplifies the transition by automatically generating import blocks based on your existing infrastructure. By following the outlined steps, you can seamlessly integrate these import blocks into your code and work with the new modules that support the updated provider version. Embrace the power of streamlined upgrades and stay on the cutting edge of cloud infrastructure management with Terraform.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=70935d637d40" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>