- Lab
- A Cloud Guru
Deploy an Azure Storage Account with Terraform
In this lab, we will deploy a simple storage account and add some tagging. Setting up storage accounts is a routine task in Azure and is an integral part of storage-related activities. Automating its deployment with Terraform offers the Azure admin an easy way to duplicate accounts with static environment variables or business-related standards, necessitating only that the storage account's name is customized for each deployment. Storage accounts are also mandatory prerequisites for any new blob storage or file shares that may be created within the same Terraform deployment file.
Path Info
Table of Contents
-
Challenge
Log In to the Azure Portal and Set Up the Azure CLI for Use
- In the Azure portal, select the Command Line button at the top of the screen. Open the CLI. Here, select Bash when prompted. We then want to choose Show Advanced Settings. Use the same location as your lab provided resource group. Leave both the Resource Group and Storage Account as the provided defaults. In the File share section, enter a name for the account (for this example, we are using console) and click the Attach Storage button. Once finished, we can continue.
- Click the Create Storage button.
- Once the command prompt is initialized, proceed to the next task.
-
Challenge
Create an Azure Storage Account with Terraform via the Azure CLI
- Use the code block found in the Additional Information and Resources section to create a
lab.tf
file and upload it to the CLI. - In the
resource "azurerm_storage_account" "lab"
declaration, you'll need to edit theresource_group_name
value with the name generated by the lab. Additionally, you'll need to enter a unique name for the storage account that will be used for the file share. The"provider"
statement has been added to the code, so you won't need to create amain.tf
file to deploy the storage account. - Once the file has been uploaded, run
terraform init
. - Run
terraform plan
and review the output to confirm that Terraform will create the desired resource. Green plus signs will indicate the resources that need to be added. - Run
terraform apply
, answering yes to the prompt to continue. - Once Terraform completes the deployment, check the Azure Portal to confirm.
You're done! Go ahead and shut down the lab.
- Use the code block found in the Additional Information and Resources section to create a
What's a lab?
Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.
Provided environment for hands-on practice
We will provide the credentials and environment necessary for you to practice right within your browser.
Guided walkthrough
Follow along with the author’s guided walkthrough and build something new in your provided environment!
Did you know?
On average, you retain 75% more of your learning if you get time for practice.