-->
This article walks you through creating a resource group with the Terraform AzureRM provider.
Hashicorp Terraform is an open source tool that codifies APIs into declarative configuration files that can be shared amongst team members to be edited, reviewed, and versioned. The Microsoft AzureRM provider is used to interact with resources supported by Azure Resource Manager via the AzureRM APIs.
Automatic authentication
Can be one of ide, lsiLogic, or busLogic. Default: lsiLogic. NOTE: adapter_type is deprecated: it does not dictate the type of controller that the virtual disk will. Nov 12, 2018 - Terraform doesn't seem to be highlighting in the web editor (not the IDE) like it used to. But other languages seem to highlight just fine.
Terraform is installed in Bash in Cloud Shell by default. Additionally, Cloud Shell automatically authenticates your default Azure CLI subscription to deploy resources through the Terraform Azure modules.
Terraform uses the default Azure CLI subscription that is set. To update default subscriptions, run:
Walkthrough
Launch Bash in Cloud Shell
- Launch Cloud Shell from your preferred location
- Verify your preferred subscription is set
Create a Terraform template
Create a new Terraform template named main.tf with your preferred text editor.
Copy/paste the following code into Cloud Shell.
Mac lethal 27 styles. Save your file and exit your text editor.
Terraform init
Begin by running
terraform init
.The terraform init command is used to initialize a working directory containing Terraform configuration files. The
terraform init
command is the first command that should be run after writing a new Terraform configuration or cloning an existing one from version control. It is safe to run this command multiple times.Terraform plan
Preview the resources to be created by the Terraform template with
terraform plan
.The terraform plan command is used to create an execution plan. Terraform performs a refresh, unless explicitly disabled, and then determines what actions are necessary to achieve the desired state specified in the configuration files. The plan can be saved using -out, and then provided to terraform apply to ensure only the pre-planned actions are executed.
Terraform apply
Provision the Azure resources with
terraform apply
.The terraform apply command is used to apply the changes required to reach the desired state of the configuration.
Verify deployment with Azure CLI
Run
az group show -n myRgName
to verify the resource has succeeded provisioning.Clean up with terraform destroy
Clean up the resource group created with the Terraform destroy command to clean up Terraform-created infrastructure.
You have successfully created an Azure resource through Terraform. Visit next steps to continue learning about Cloud Shell.
Next steps
Learn about the Terraform Azure provider
Bash in Cloud Shell quickstart
Bash in Cloud Shell quickstart