The Terraform Marketplace image makes it easy to get started using Terraform on Azure, without having to install and configure Terraform manually.

There are no software charges for this Terraform VM image. You pay only the Azure hardware usage fees that are assessed based on the size of the virtual machine that's provisioned. For more information about the compute fees, see the Linux virtual machines pricing page.

Create your Terraform virtual machine

In the Search the Marketplace search bar, search for Terraform. Select the Terraform template.

On the Terraform details tab on the lower right, select the Create button.

The following sections provide inputs for each of the steps in the wizard to create the Terraform Linux virtual machine. The following section lists the inputs that are needed to configure each of these steps.

Details on the Create Terraform tab

Enter the following details on the Create Terraform tab:

Basics

Name: The name of your Terraform virtual machine.

User Name: The first account sign-in ID.

Password: The first account password. (You can use an SSH public key instead of a password.)

Subscription: The subscription on which the machine is to be created and billed. You must have resource creation privileges for this subscription.

Resource group: A new or existing resource group.

Location: The datacenter that is most appropriate. Usually it's the datacenter that has most of your data, or the one that's closest to your physical location for fastest network access.

Additional settings

Size: Size of the virtual machine.

VM disk type: SSD or HDD.

Summary Terraform

Verify that all information that you entered is correct.

Buy

To start the provisioning process, select Buy. A link is provided to the terms of the transaction. The VM does not have any additional charges beyond the compute for the server size that you chose in the size step.

The Terraform VM image performs the following steps:

Creates a VM with system-assigned identity that's based on the Ubuntu 16.04 LTS image.

Installs the MSI extension on the VM to allow OAuth tokens to be issued for Azure resources.

Access and configure a Linux Terraform virtual machine

After you create the VM, you can sign in to it by using SSH. Use the account credentials that you created in the "Basics" section of step 3 for the text shell interface. On Windows, you can download an SSH client tool like Putty.

After you use SSH to connect to the virtual machine, you need to give contributor permissions for the entire subscription to managed identities for Azure resources on the virtual machine.

Contributor permission helps MSI on VM to use Terraform to create resources outside the VM resource group. You can easily achieve this action by running a script once. Use the following command:

The VM has a Terraform remote state back end. To enable it on your Terraform deployment, copy the remoteState.tf file from tfTemplate directory to the root of the Terraform scripts.

cp ~/tfTemplate/remoteState.tf .

For more information about Remote State Management, see this page about the Terraform remote state. The storage access key is exposed in this file and needs to be excluded before committing Terraform configuration files into source control.

Next steps

In this article, you learned how to set up a Terraform Linux virtual machine on Azure. Here are some additional resources to help you learn more about Terraform on Azure: