Setup Azure Cloud Shell Environment for Terraform Development

Setup Azure Cloud Shell Environment for Terraform Development

Login with your Azure Credentials

  1. Open the Azure Portal in your web browser.
  2. Click on the Cloud Shell icon in the top right corner of the portal.
  3. If prompted, click "Bash" to launch the Azure Cloud Shell.
  4. The first time you launch the Cloud Shell, you will be asked to create a storage account and file share. Follow the prompts to complete this setup.

Create Storage for Azure Cloud Shell

  1. If you haven't already, click on the "Create storage" button when prompted in the Cloud Shell.
  2. Select the Azure subscription you want to use.
  3. Choose the region where you want to create the storage resources.
  4. The Cloud Shell will automatically create a new resource group, storage account, and file share for you.

Verify Terraform is Installed

  1. Within the Azure Cloud Shell, run the command terraform version.
  2. This should output the version of Terraform that is pre-installed in the Cloud Shell environment.

Start using Terraform in the Azure Cloud Shell

  1. Create a new directory for your Terraform project: mkdir terraform-project && cd terraform-project.
  2. Initialize a new Terraform working directory: terraform init.
  3. Start building your Terraform configuration files, such as main.tfvariables.tf, and outputs.tf.
  4. Run terraform plan to preview the changes your configuration will make.
  5. If the plan looks good, run terraform apply to provision the resources in Azure.
  6. When you're done, you can run terraform destroy to remove the resources.

Read next

Terraform Modules

Terraform has emerged as a leading Infrastructure as Code (IaC) tool, enabling teams to define and manage cloud resources declaratively. As infrastructure grows in complexity, managing configurations in a single directory becomes more challenging. This is where Terraform modules come