I created a very simple project to test out the alpha release of OpenTofu using the Hetzner Cloud Provider. I figure many people are looking at the common providers like AWS and Azure, so I thought it would be interesting to check out something different.

The first alpha release installed from a .deb file on Ubuntu 22.04 without issue. This release references the new registry amongst other things.

I ran tofu init without any issues:

$ tofu init

Initializing the backend...

Initializing provider plugins...
- Finding latest version of hetznercloud/hcloud...
- Finding latest version of hashicorp/template...
- Installing hetznercloud/hcloud v1.44.0...
- Installed hetznercloud/hcloud v1.44.0. Signature validation was skipped due to the registry not containing GPG keys for this provider
- Installing hashicorp/template v2.2.0...
- Installed hashicorp/template v2.2.0 (signed, key ID 0DC64ED093B3E9FF)

Providers are signed by their developers.
If you'd like to know more about provider signing, you can read about it here:
https://www.placeholderplaceholderplaceholder.io/docs/cli/plugins/signing.html

OpenTofu has created a lock file .terraform.lock.hcl to record the provider
selections it made above. Include this file in your version control repository
so that OpenTofu can guarantee to make the same selections by default when
you run "tofu init" in the future.

OpenTofu has been successfully initialized!

You may now begin working with OpenTofu. Try running "tofu plan" to see
any changes that are required for your infrastructure. All OpenTofu commands
should now work.

If you ever set or change modules or backend configuration for OpenTofu,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary.

So, that seems like a pretty good start. However, tofu plan failed:

$ tofu plan
╷
│ Error: Failed to load plugin schemas
│
│ Error while loading schemas for plugin components: Failed to obtain provider schema: Could not load the
│ schema for provider registry.opentofu.org/hetznercloud/hcloud: failed to retrieve schema from provider
│ "registry.opentofu.org/hetznercloud/hcloud": Invalid Provider Server Combination: The combined provider has
│ differing provider schema implementations across providers. Provider schemas must be identical across
│ providers. This is always an issue in the provider implementation and should be reported to the provider
│ developers.
│
│ Provider schema difference:   &tfprotov6.Schema{
│   	Version: 0,
│   	Block: &tfprotov6.SchemaBlock{
│   		Version: 0,
│   		Attributes: []*tfprotov6.SchemaAttribute{
│   			&{Name: "endpoint", Type: s"tftypes.String", Description: "The Hetzner Cloud API endpoint, can be used to override the defa"..., Optional: true, ...},
│   			&{Name: "poll_interval", Type: s"tftypes.String", Description: "The interval at which actions are polled by the client. Default "..., Optional: true, ...},
│   			&{
│   				... // 2 identical fields
│   				NestedType:  nil,
│   				Description: "The Hetzner Cloud API token, can also be specified with the HCLO"...,
│ - 				Required:    true,
│ + 				Required:    false,
│ - 				Optional:    false,
│ + 				Optional:    true,
│   				Computed:    false,
│   				Sensitive:   true,
│   				... // 2 identical fields
│   			},
│   		},
│   		BlockTypes:  nil,
│   		Description: "",
│   		... // 2 identical fields
│   	},
│   }
│ ..
╵

It looks like something broke in the latest version of the provider. I’m not quite sure what version I used before, but the repo for the terraform-provider-hcloud had a change in the last 8 hours, so I figured I would try an earlier version to see if that works.

I updated the main.tf to have the following:

terraform {
    required_providers {
        hcloud = {
            source = "hetznercloud/hcloud"
            version = "1.43.0"
        }
    }
}

Then, ran $ tofu init -upgrade to update the version. The init worked fine and this time, plan gave me what I was hoping for:

$ tofu plan
data.template_file.cloud_init: Reading...
data.template_file.cloud_init: Read complete after 0s [id=0d8bbda003733cc26d6875817b179dd6160409e7eb008fa8a52e915cd25174c3]

OpenTofu used the selected providers to generate the following execution plan. Resource actions are indicated
with the following symbols:
  + create

OpenTofu will perform the following actions:

  # hcloud_server.foo will be created
  + resource "hcloud_server" "foo" {
      + allow_deprecated_images    = false
      + backup_window              = (known after apply)
      + backups                    = false
      + datacenter                 = (known after apply)
      + delete_protection          = false
      + firewall_ids               = (known after apply)
      + id                         = (known after apply)
      + ignore_remote_firewall_ids = false
      + image                      = "ubuntu-22.04"
      + ipv4_address               = (known after apply)
      + ipv6_address               = (known after apply)
      + ipv6_network               = (known after apply)
      + keep_disk                  = false
      + location                   = (known after apply)
      + name                       = "tiger"
      + rebuild_protection         = false
      + server_type                = "cx11"
      + shutdown_before_deletion   = false
      + ssh_keys                   = [
          + "id_hetzner",
        ]
      + status                     = (known after apply)
      + user_data                  = "C+Gt0B6awF2OvsFTpDW3EmEf2zE="
    }

Plan: 1 to add, 0 to change, 0 to destroy.

Changes to Outputs:
  + ipv4_address = (known after apply)

──────────────────────────────────────────────────────────────────────────────────────────────────────────────

Note: You didn't use the -out option to save this plan, so OpenTofu can't guarantee to take exactly these
actions if you run "tofu apply" now.

Given that, I ran tofu apply and it all worked out. The address of the server was returned and I was able to login with ssh and everything looked perfect.

It’s still alpha, but OpenTofu looks pretty good for simple use cases so far. I’m looking forward to a more stable release and will try a few more things in the meantime.