Skip to content

Latest commit

 

History

History
111 lines (69 loc) · 3.62 KB

create-resource-group.md

File metadata and controls

111 lines (69 loc) · 3.62 KB
title description ms.topic service ms.service ms.date ms.custom adobe-target content_well_notification ai-usage
Quickstart: Create an Azure resource group using Terraform
In this article, you learn how to create an Azure resource group using Terraform
quickstart
azure
azure
10/26/2023
devx-track-terraform
true
AI-contribution
ai-assisted

Quickstart: Create an Azure resource group using Terraform

This article shows how to create an Azure resource group using Terraform.

[!INCLUDE Terraform abstract]

In this article, you learn how to:

[!div class="checklist"]

Prerequisites

Implement the Terraform code

  1. Create a directory in which to test the sample Terraform code and make it the current directory.

  2. Create a file named providers.tf and insert the following code:

    :::code language="Terraform" source="~/../terraform_samples/quickstart/101-resource-group/providers.tf":::

  3. Create a file named main.tf and insert the following code:

    :::code language="Terraform" source="~/../terraform_samples/quickstart/101-resource-group/main.tf":::

  4. Create a file named variables.tf and insert the following code:

    :::code language="Terraform" source="~/../terraform_samples/quickstart/101-resource-group/variables.tf":::

  5. Create a file named outputs.tf and insert the following code:

    :::code language="Terraform" source="~/../terraform_samples/quickstart/101-resource-group/outputs.tf":::

Initialize Terraform

[!INCLUDE terraform-init.md]

Create a Terraform execution plan

[!INCLUDE terraform-plan.md]

Apply a Terraform execution plan

[!INCLUDE terraform-apply-plan.md]

Verify the results

  1. Get the Azure resource group name.

    resource_group_name=$(terraform output -raw resource_group_name)
  2. Run az group show to display the resource group.

    az group show --name $resource_group_name
    
  1. Get the Azure resource group name.

    $resource_group_name=$(terraform output -raw resource_group_name)
  2. Run Get-AzResourceGroup to display the resource group.

    Get-AzResourceGroup -Name $resource_group_name
    

Clean up resources

[!INCLUDE terraform-plan-destroy.md]

Troubleshoot Terraform on Azure

Troubleshoot common problems when using Terraform on Azure

Next steps

[!div class="nextstepaction"] Learn more about using Terraform in Azure