Featured resource
2025 Tech Upskilling Playbook
Tech Upskilling Playbook

Build future-ready tech teams and hit key business milestones with seven proven plays from industry leaders.

Check it out
  • Lab
    • Libraries: If you want this lab, consider one of these libraries.
    • Cloud
Azure icon
Labs

Discover and Import Existing Resources

Welcome to the Discover and Import Existing Resources lab. In this lab, we will cover three objectives: 1. Explore existing resources in Azure 2. Install and use the Azure Export for Terraform tool 3. Refactor the produced configuration By the end of this lab you'll be ready to use the Azure Export for Terraform tool to bring existing resources under management by Terraform.

Azure icon
Lab platform
Lab Info
Level
Intermediate
Last updated
Sep 25, 2025
Duration
30m

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.
Table of Contents
  1. Challenge

    Explore existing resources in Azure

    In this objective, you'll use the Azure portal to explore the virtual network that you'll be importing into a Terraform configuration.

    1. Log into the Azure portal using the provided credentials and link
    2. Browse the contents of the resource group, noting the resource group name
    3. Examine the virtual network and note the settings
  2. Challenge

    Install and use the Azure Export for Terraform tool

    In this objective, you'll install the Azure Export for Terraform tool and use it to create a Terraform configuration to manage the virtual network. Note that you will not be managing the resource group that contains the virtual network.

    1. Install the Azure Export for Terraform tool following the installation instructions found at the link.
    2. Log into Azure using the Azure CLI and the provided lab credentials:
    az login
    
    1. Create a directory to hold the imported configuration and state
    2. In the directory, run the aztfexport tool and pass it the resource group name:
    aztfexport rg "RESOURCE_GROUP_NAME"
    
    1. Skip the resource group and import the rest of the resources
    2. Verify the created configuration and state data
  3. Challenge

    Refactor the produced configuration

    Although Azure Export for Terraform created the configuration for you and imported state, you still need to make some adjustments to the configuration to make it usable and more flexible. In this objective, you'll update the provider block, add the resource group as a data source, and replace hardcoded values with references.

    1. Update the azurerm provider block to include the skip_provider_registration = true argument
    2. Add an azurerm_resource_group data source that takes an input variable of resource_group_name
    3. Add the resource_group_name input variable
    4. Update the hardcoded resource group name and location values with a data source reference
    5. Update the subnets with resource references to the virtual network
    6. Remove the depends_on blocks
    7. Add a terraform.tfvars file with the resource_group_name variable value
    8. Run a terraform plan to confirm that no infrastructure changes are required
About the author

Pluralsight Skills gives leaders confidence they have the skills needed to execute technology strategy. Technology teams can benchmark expertise across roles, speed up release cycles and build reliable, secure products. By leveraging our expert content, skill assessments and one-of-a-kind analytics, keep up with the pace of change, put the right people on the right projects and boost productivity. It's the most effective path to developing tech skills at scale.

Real skill practice before real-world application

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.

Learn by doing

Engage hands-on with the tools and technologies you’re learning. You pick the skill, we provide the credentials and environment.

Follow your guide

All labs have detailed instructions and objectives, guiding you through the learning process and ensuring you understand every step.

Turn time into mastery

On average, you retain 75% more of your learning if you take time to practice. Hands-on labs set you up for success to make those skills stick.

Get started with Pluralsight