Sign in during Public Preview to get the Team plan free, plus an early-adopter discount when we launch. Sign in
OpenTofu is an infrastructure as code tool which uses providers to interact with different clouds - and Locally supports the opentofu/azurerm provider.
This guide was tested using the following versions of OpenTofu and the opentofu/azurerm provider, but newer versions should work too:
tofu - v1.12.6
opentofu/azurerm provider - v5.6.0
In this example we're going to provision a Resource Group within the First Subscription.
We first need to define a provider block for the opentofu/azurerm provider in a file named main.tf:
provider "azurerm" {
features {}
}
Note that we haven't specified any credentials for the opentofu/azurerm provider, as Locally will automatically configure the provider for you to run against Locally rather than Azure when you run locally run tofu [command].
Next we need to add the OpenTofu resource to provision a Resource Group - in this case with the name rg-from-tofu in the location berlin:
provider "azurerm" {
features {}
}
resource "azurerm_resource_group" "example" {
name = "rg-from-tofu"
location = "berlin"
}
Now that we've created our OpenTofu configuration, we need to download the opentofu/azurerm provider by running:
$
tofu init
If Locally isn't already running, we'll need to start it by running:
$
locally build
At which point we can deploy this OpenTofu configuration against Locally by running:
$
locally run tofu apply
Once that's applied, if we open the First Subscription within the Locally Dashboard, and view the Resource Groups then we should see our newly created Resource Group.
If you have an existing OpenTofu configuration that already targets Azure and you'd like to point it at Locally, see the Existing AzureRM Configuration guide. To run tofu apply against Locally in your pipeline, see Using Locally in CI.
Should you encounter any issues, please take a look at the troubleshooting section.
You can find more examples of how to use OpenTofu with Locally in the Examples in the Documentation.
Sign in during Public Preview to get the Team plan free, plus an early-adopter discount when we launch. Sign in
Your Azure infrastructure, running on your machine. Deploy in seconds, break things freely, and ship to Azure when you're ready.