Using the Hetzner Cloud Terraform Provider

I’m currently in the process of setting up several cloud servers for a new project. The whole infrastructure will run on Hetzner Cloud and be codified. Since it’s the first time I’m using the Terraform provider for Hetzner Cloud, I want to write down some of the notes I took. I’ll focus on creating a small, simplified, self-contained example to create a server, set up a firewall, and get a public IP assigned (no private network). If you want to manage multiple stacks and/or multiple projects, it generally makes sense to create your own modules and shared configurations. This is, however, out of scope for this post and not really any different when using Hetzner Cloud vs. other providers. ...

January 21, 2026 · David Hamann

Terraform: Change EC2 user_data without recreating instance

When you have set up your infrastructure with Terraform and then do any change to the user_data of a EC2 instance, Terraform will detect the change and generally do a force-replacement of the instance. In the planning stage this could look something like this: # aws_instance.web_backend must be replaced -/+ resource "aws_instance" "web_backend" { [...] ~ user_data = "1c4e236bd5dec74fecc99d3a3d57679b9b12a927" -> "f8d9add08d4ead74d44af35452c6070dbfcb1576" # forces replacement + user_data_base64 = (known after apply) [...] So what can you do when you want to make changes to user_data but don’t want to destroy your instance and create a new one? ...

June 9, 2022 · David Hamann

Getting started with Terraform and Infrastructure as Code

I recently worked with Terraform to codify IT infrastructure, i.e. server deployments, network configurations and other resources. Based on my working notes, I want to give an introduction on how to write infrastructure resource definitions and execute them using Terraform. I’ll be using AWS as a cloud provider in my examples, but many more providers are available. In fact, one of the advantages of using a platform agnostic tool is that you can manage all your infrastructure in one place – not individually for every provider or on-premise platform you use. ...

May 20, 2020 · David Hamann