opentofu tutorial - helloworld example to create resources in Azure

To install opentofu, please goto this link here.

I am using windows so i am downloading my windows binaries. We are going to use azurerm provider and to do that, we are going to authenticate using a service principal, but you can choose to use other methods as well. 

Open powershell terminal, fill in your azure service principal and other info and run the following command:

$env:ARM_CLIENT_ID=""
$env:ARM_CLIENT_SECRET=""
$env:ARM_TENANT_ID =""
$env:ARM_SUBSCRIPTION_ID=""

Create a main.tf file with the following contents

terraform {
  required_providers {
    azurerm = {
      source  = "hashicorp/azurerm"
      version = "4.0.1"
    }  
  }
}

provider "azurerm" {
  features {}
}

resource "azurerm_resource_group" "rg" {
  location = "australiaeast"
  name     = "mytestrg"
}

Then run the following 

tofu init 


Next, run 

tofu plan 

to see what opentofu is about to create. To finalize your deployment run 

tofu apply

That's it.

Additional references 

Opentofu registry 

https://github.com/opentofu/registry/tree/main/providers/m

cloud block here for example - allows integration to Terraform cloud by specifying the organization and workspace you will be connecting to. 

terraform {
  cloud {
    organization = "my-org"

    workspaces {
      project = "networking-development"
      tags = ["networking", "source:cli"]
    }
  }
}




Comments

Popular posts from this blog

The specified initialization vector (IV) does not match the block size for this algorithm