Hands-On LabBeginner

Understanding Terraform Resources and Data Sources on Azure

Create Azure resources with Terraform, query existing infrastructure using data sources, and combine both patterns in a single configuration.

45 minEstimated time
4Guided steps
AutoVerification
IsolatedSandbox
Understanding Terraform Resources and Data Sources on Azure

Lab overview

Terraform manages cloud infrastructure through two complementary mechanisms - resources and data sources. A resource block declares infrastructure that Terraform creates, updates, and destroys as part of its lifecycle, while a data source queries existing infrastructure that was provisioned outside of the current configuration. Combining both patterns in a single project lets you deploy new components that reference pre-existing resources, such as attaching a network security group to a subnet that was created by a different team or an ARM template deployment.

In this lab, you will create Azure resources using Terraform resource blocks, query a pre-provisioned virtual network and subnet using data sources, and then combine both patterns by deploying a network security group that references the existing subnet through a data source. The lab environment provides a resource group with a VNet and subnet already provisioned, so you can focus on the Terraform workflow of creating new resources alongside existing ones.

Objectives

Upon completion of this beginner level lab, you will be able to:

  • Configure the AzureRM Terraform provider and initialize a project
  • Create Azure resources such as storage accounts using Terraform resource blocks
  • Query existing Azure infrastructure using data source blocks for virtual networks and subnets
  • Reference data source attributes in resource definitions to link new and existing infrastructure
  • Deploy a network security group associated with a pre-existing subnet using terraform apply

Who is this lab for?

This lab is designed for:

  • Cloud engineers learning how Terraform differentiates between managed and read-only infrastructure
  • DevOps practitioners who need to integrate Terraform with environments that contain pre-existing resources
  • Terraform Associate candidates preparing for exam objectives covering resources and data sources

Verified against your live environment

An automated validation engine inspects your actual resources and configurations as you work. Completion means the task was performed — not multiple choice, real-world proficiency.

[CHECK] validation_activelive
Inspecting deployed resources...
Verifying configuration state...
✓ Step requirements satisfied

More labs like this

Related reading

PremiumIncluded in Premium
Duration
45 min
Steps
4

Environment

Live Cloud EnvironmentBrowser Code IDE

Every lab includes

  • Real environment, pre-credentialed
  • Automated checks on every step
  • Isolated sandbox, auto cleanup
  • AI-recommended next steps

Lab curriculum

  1. 01

    Logging into Azure CLI

  2. 02

    Creating Azure Resources with Terraform Resource Blocks

    1 automated check

  3. 03

    Querying Existing Infrastructure with Data Sources

    1 automated check

  4. 04

    Combining Resources and Data Sources Together

    1 automated check

Skills validated

Terraform

Not the lab you were looking for?

Browse 150+ hands-on labs across AWS, Azure, Kubernetes, Docker, and cloud security.

Explore the catalog