<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>InfrastructureAsCode on NASAN</title><link>https://nasan.ch/tags/infrastructureascode/</link><description>Recent content in InfrastructureAsCode on NASAN</description><generator>Hugo</generator><language>en</language><lastBuildDate>Tue, 26 Sep 2023 06:10:21 +0100</lastBuildDate><atom:link href="https://nasan.ch/tags/infrastructureascode/index.xml" rel="self" type="application/rss+xml"/><item><title>(2/2) How to use Terraform from local Machine additionally to Azure DevOps Pipeline (2 Part Series)</title><link>https://nasan.ch/posts/2023-09-27-terraform-locally/</link><pubDate>Tue, 26 Sep 2023 06:10:21 +0100</pubDate><guid>https://nasan.ch/posts/2023-09-27-terraform-locally/</guid><description>&lt;p&gt;In the latest blog post &lt;a href="https://nasan.ch/posts/2023-09-23-azuredevopsterraform/" target="_blank" rel="noopener noreffer"&gt;(1/2) Setting up Azure workload identity federation with Terraform in Azure DevOps pipelines (2 Part Series)&lt;/a&gt; we learned how to setup Azure DevOps using Workload Identiy Federation&lt;/p&gt;
&lt;p&gt;Because we are using a managed identity and not a service principal with a secret that has a certain lifetime, we are not directly able to run terraform from locally.&lt;/p&gt;
&lt;p&gt;But what about using a service principal for local activities whose secret will expire after a few hours instead of months?&lt;br&gt;
This wasn&amp;rsquo;t practical when using a service principal in the service connection. Typically, the secret had a longer lifetime, so it didn&amp;rsquo;t need to be renewed every time within the service connection.&lt;/p&gt;</description></item><item><title>(1/2) Setting up Azure workload identity federation with Terraform in Azure DevOps pipelines (2 Part Series)</title><link>https://nasan.ch/posts/2023-09-23-azuredevopsterraform/</link><pubDate>Sat, 23 Sep 2023 06:10:21 +0100</pubDate><guid>https://nasan.ch/posts/2023-09-23-azuredevopsterraform/</guid><description>&lt;p&gt;I was curious about how to set up Azure DevOps to utilize Terraform for deploying Azure resources with &lt;strong&gt;workload identity federation&lt;/strong&gt; instead of relying on a &lt;strong&gt;service principal&lt;/strong&gt; with secrets. In this blog post, I will demonstrate how I set up this configuration.&lt;/p&gt;
&lt;p&gt;To learn more about workload identity federation read the docs:&lt;br&gt;
&lt;a href="https://learn.microsoft.com/en-us/azure/active-directory/workload-identities/workload-identity-federation" target="_blank" rel="noopener noreffer"&gt;Workload identity federation - Microsoft Entra | Microsoft Learn&lt;/a&gt;&lt;/p&gt;
&lt;h2 id="prerequisites"&gt;Prerequisites&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Azure DevOps Org&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&amp;ldquo;Customer Azure Tenant&amp;rdquo;&lt;/strong&gt; with Subscription&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&amp;ldquo;Backend Azure Tenant&amp;rdquo;&lt;/strong&gt; with Subscription (can be in the same tenant - in our example we use different tenants)&lt;/li&gt;
&lt;li&gt;&lt;a href="https://learn.microsoft.com/en-us/powershell/azure/" target="_blank" rel="noopener noreffer"&gt;Azure Powershell Module&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="overview---setup-steps"&gt;Overview - Setup Steps&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;Create a &lt;strong&gt;storage account&lt;/strong&gt; that will store the Terraform state file&lt;/li&gt;
&lt;li&gt;Create a &lt;strong&gt;managed identity&lt;/strong&gt; which has contributor permissions on this storage account&lt;/li&gt;
&lt;li&gt;If not already the case, install the &lt;strong&gt;Terraform extension&lt;/strong&gt; for your Azure DevOps Org&lt;/li&gt;
&lt;li&gt;Create a new &lt;strong&gt;Azure DevOps Project&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Create a &lt;strong&gt;service connection&lt;/strong&gt; to the &amp;ldquo;backend tenant&amp;rdquo; using workload identity federation with your previously created managed identity&lt;/li&gt;
&lt;li&gt;Create a &lt;strong&gt;managed identity&lt;/strong&gt; in the customer tenant where you finally want to deploy Azure Resources using Terraform, with Contributor permission on the Subscription&lt;/li&gt;
&lt;li&gt;Create a &lt;strong&gt;service connection&lt;/strong&gt; to the customer tenant using workload identity federation with your previously created managed identity&lt;/li&gt;
&lt;li&gt;Create a &lt;strong&gt;repository&lt;/strong&gt; with basic Terraform files&lt;/li&gt;
&lt;li&gt;Create an &lt;strong&gt;Azure DevOps Pipeline&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;figure&gt;&lt;a class="lightgallery" href="https://nasan.ch/images/terraform-overview-Demo1.png" title="image" data-thumbnail="/images/terraform-overview-Demo1.png" data-sub-html="&lt;h2&gt;Preview&lt;/h2&gt;&lt;p&gt;image&lt;/p&gt;</description></item></channel></rss>