<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>network &amp;mdash; Thoughts from a serf</title>
    <link>https://blog.durehed.se/tag:network</link>
    <description>Working in tech. Writing on different matters. Sometimes in Swedish other times in English.</description>
    <pubDate>Thu, 23 Apr 2026 13:19:31 +0000</pubDate>
    <item>
      <title>Creating a network in OpenStack with OpenTofu</title>
      <link>https://blog.durehed.se/creating-a-network-in-openstack-with-opentofu</link>
      <description>&lt;![CDATA[I really like that there is a free and Open Source fork of Terraform now. For me, the future is Open Source, and specifically Free and Open Source. &#xA;&#xA;I don&#39;t believe this because I like to not have to pay for software. I believe this because it is no other way to move forward with digital transformation at a high pace effectively. Very much so in the public sector, but also for organizations in general.&#xA;&#xA;OpenStack is my platform of choice. First off, it is Open Source, and second off, a lot of public cloud providers deploy OpenStack. So there are a lot of places to put your infrastructure. &#xA;&#xA;And this is where a cool thing about infrastructure as code comes through. It is so easy to deploy resources to different providers and platforms that it was almost lost on me. I had to try it out and then I started to get it. &#xA;&#xA;But, anyhow, lets do something with OpenTofu and OpenStack.&#xA;&#xA;The basic stuff first&#xA;We are doing this without extra tools like Terragrunt and Gitlab. &#xA;I usually create a variable to hold all parameters to connect to OpenStack. I keep the sensitive part, the application credential secret in a separate file called &#xA;But, when working in a team, this would preferably be read from a secret manager of some sort or in your build server so that you don&#39;t even need to store the secret locally.&#xA;&#xA;Below is the file I call main.tf because it is the starting point in my mind with the provider connection parameters and the OpenTofu configuration.&#xA;&#xA;terraform {&#xA;  requiredversion = &#34;  = 0.14.0&#34;&#xA;  requiredproviders {&#xA;    openstack = {&#xA;      source  = &#34;terraform-provider-openstack/openstack&#34;&#xA;      version = &#34;~  1.53.0&#34;&#xA;    }&#xA;  }&#xA;}&#xA;&#xA;provider &#34;openstack&#34; {&#xA;  applicationcredentialid     = var.connection.applicationcredentialid&#xA;  applicationcredentialsecret = var.applicationcredentialsecret&#xA;  authurl                      = var.connection.authurl&#xA;  region                        = var.connection.region&#xA;  endpointtype                 = var.connection.endpointtype&#xA;}&#xA;&#xA;To use the &#xA;I use Binero as the public cloud provider. Binero is based in Sweden, as am I. &#xA;&#xA;I use an application credential instead of a user account because I like to differentiate using user accounts from API oriented accounts. Application credentials were designed for this purpose.&#xA;&#xA;variable &#34;connection&#34; {&#xA;  type = object({&#xA;    applicationcredentialid = string&#xA;    authurl                  = string&#xA;    endpointtype             = string&#xA;    region                    = string&#xA;  })&#xA;&#xA;  default = {&#xA;    applicationcredentialid = &#34;applicationid&#34;&#xA;    authurl                  = &#34;https://auth.binero.cloud:5000/v3&#34;&#xA;    region                    = &#34;europe-se-1&#34;&#xA;    endpointtype             = &#34;public&#34;&#xA;  }&#xA;}&#xA;&#xA;variable &#34;applicationcredentialsecret&#34; {&#xA;  type      = string&#xA;  sensitive = true&#xA;}&#xA;&#xA;Create a network&#xA;So with a &#xA;In this case I will create a network and a subnet to that network.&#xA;&#xA;I add a variable for the network cidr in the variable &#34;mainnetworkcidr&#34; {&#xA;  type    = string&#xA;  default = &#34;10.10.10.0/24&#34;&#xA;}&#xA;&#xA;And we use the above variable in the resource declaration in resource &#34;openstacknetworkingnetworkv2&#34; &#34;main&#34; {&#xA;  name           = &#34;main&#34;&#xA;  description    = &#34;Main network for general purpose.&#34;&#xA;  adminstateup = &#34;true&#34;&#xA;}&#xA;&#xA;resource &#34;openstacknetworkingsubnetv2&#34; &#34;main&#34; {&#xA;  name        = &#34;main&#34;&#xA;  description = &#34;Main network subnet for general purpose.&#34;&#xA;  networkid  = openstacknetworkingnetworkv2.main.id&#xA;  cidr        = var.mainnetworkcidr&#xA;  ipversion  = 4&#xA;}&#xA;&#xA;I would normally create input variables for all the above arguments in the resource blocks. But again, this is just an example.&#xA;The idea of using a variable for each argument is that you then can re-use the resource block in other projects and create a module of it. And it makes it possible to add variables when performing tofu apply.&#xA;&#xA;The above should get you running with creating a network and subnet in OpenStack. Remember that the connection arguments might differ between OpenStack providers. &#xA;&#xA;Also, this is just an example, I will create more comprehensive projects in the future where I will gear towards something that is production ready. I will also share my code in a public repository (as soon as my public repository is ready for that)&#xA;&#xA;I hope you found this useful. As stated, more is to come.&#xA;&#xA;#terraform #opentofu #openstack #network&#xA;&#xA;Joakim Durehed&#xD;&#xA;]]&gt;</description>
      <content:encoded><![CDATA[<p>I really like that there is a free and Open Source fork of Terraform now. For me, the future is Open Source, and specifically Free and Open Source.</p>

<p>I don&#39;t believe this because I like to not have to pay for software. I believe this because it is no other way to move forward with digital transformation at a high pace effectively. Very much so in the public sector, but also for organizations in general.</p>

<p>OpenStack is my platform of choice. First off, it is Open Source, and second off, a lot of public cloud providers deploy OpenStack. So there are a lot of places to put your infrastructure.</p>

<p>And this is where a cool thing about infrastructure as code comes through. It is so easy to deploy resources to different providers and platforms that it was almost lost on me. I had to try it out and then I started to get it.</p>

<p>But, anyhow, lets do something with OpenTofu and OpenStack.</p>

<h2 id="the-basic-stuff-first">The basic stuff first</h2>

<p>We are doing this without extra tools like Terragrunt and Gitlab.
I usually create a variable to hold all parameters to connect to OpenStack. I keep the sensitive part, the application credential secret in a separate file called <code>connect.auto.tfvars</code>. This way, that file, containing the secret will be read by OpenTofu at plan, apply, destroy and so on.</p>

<p>But, when working in a team, this would preferably be read from a secret manager of some sort or in your build server so that you don&#39;t even need to store the secret locally.</p>

<p>Below is the file I call main.tf because it is the starting point in my mind with the provider connection parameters and the OpenTofu configuration.</p>

<pre><code class="language-json">terraform {
  required_version = &#34;&gt;= 0.14.0&#34;
  required_providers {
    openstack = {
      source  = &#34;terraform-provider-openstack/openstack&#34;
      version = &#34;~&gt; 1.53.0&#34;
    }
  }
}

provider &#34;openstack&#34; {
  application_credential_id     = var.connection.application_credential_id
  application_credential_secret = var.application_credential_secret
  auth_url                      = var.connection.auth_url
  region                        = var.connection.region
  endpoint_type                 = var.connection.endpoint_type
}

</code></pre>

<p>To use the <code>main.tf</code> file we also need a <code>variables.tf</code> file. You could call this whatever you want, but I will probably add more variables to this file, so instead of calling it connect.tf to categorize it with the <code>connect.auto.tfvars</code>file, I just call it <code>varibles.tf</code>.</p>

<p>I use <a href="https://binero.com/">Binero</a> as the public cloud provider. Binero is based in Sweden, as am I.</p>

<p>I use an application credential instead of a user account because I like to differentiate using user accounts from API oriented accounts. Application credentials were designed for this purpose.</p>

<pre><code class="language-json">variable &#34;connection&#34; {
  type = object({
    application_credential_id = string
    auth_url                  = string
    endpoint_type             = string
    region                    = string
  })

  default = {
    application_credential_id = &#34;application_id&#34;
    auth_url                  = &#34;https://auth.binero.cloud:5000/v3&#34;
    region                    = &#34;europe-se-1&#34;
    endpoint_type             = &#34;public&#34;
  }
}

variable &#34;application_credential_secret&#34; {
  type      = string
  sensitive = true
}

</code></pre>

<h1 id="create-a-network">Create a network</h1>

<p>So with a <code>main.tfvars</code> and <code>variables.tf</code> accompanied with the <code>connect.auto.tfvars</code> file we have all we need to make some resources with OpenTofu.</p>

<p>In this case I will create a network and a subnet to that network.</p>

<p>I add a variable for the network cidr in the <code>variables.tf</code>. This could be more comprehensive, but works for our example.</p>

<pre><code>variable &#34;main_network_cidr&#34; {
  type    = string
  default = &#34;10.10.10.0/24&#34;
}

</code></pre>

<p>And we use the above variable in the resource declaration in <code>network.tf</code>:</p>

<pre><code>resource &#34;openstack_networking_network_v2&#34; &#34;main&#34; {
  name           = &#34;main&#34;
  description    = &#34;Main network for general purpose.&#34;
  admin_state_up = &#34;true&#34;
}

resource &#34;openstack_networking_subnet_v2&#34; &#34;main&#34; {
  name        = &#34;main&#34;
  description = &#34;Main network subnet for general purpose.&#34;
  network_id  = openstack_networking_network_v2.main.id
  cidr        = var.main_network_cidr
  ip_version  = 4
}

</code></pre>

<p>I would normally create input variables for all the above arguments in the resource blocks. But again, this is just an example.
The idea of using a variable for each argument is that you then can re-use the resource block in other projects and create a module of it. And it makes it possible to add variables when performing tofu apply.</p>

<p>The above should get you running with creating a network and subnet in OpenStack. Remember that the connection arguments might differ between OpenStack providers.</p>

<p>Also, this is just an example, I will create more comprehensive projects in the future where I will gear towards something that is production ready. I will also share my code in a public repository (as soon as my public repository is ready for that)</p>

<p>I hope you found this useful. As stated, more is to come.</p>

<p><a href="https://blog.durehed.se/tag:terraform" class="hashtag"><span>#</span><span class="p-category">terraform</span></a> <a href="https://blog.durehed.se/tag:opentofu" class="hashtag"><span>#</span><span class="p-category">opentofu</span></a> <a href="https://blog.durehed.se/tag:openstack" class="hashtag"><span>#</span><span class="p-category">openstack</span></a> <a href="https://blog.durehed.se/tag:network" class="hashtag"><span>#</span><span class="p-category">network</span></a></p>

<p>Joakim Durehed</p>
]]></content:encoded>
      <guid>https://blog.durehed.se/creating-a-network-in-openstack-with-opentofu</guid>
      <pubDate>Sat, 11 May 2024 14:56:13 +0000</pubDate>
    </item>
  </channel>
</rss>