Exercise: variables

  • Create a root module
  • Create a unique_id input variable
    • Give it a sensible default
  • Create a local variable
  • Create a message output variable
    • Use string interpolation to return a string composed of:
      • Your local variable
      • The var.unique_id class variable
      • The current terraform workspace ${terraform.workspace}
  • Run terraform apply
  • Re-run terraform but pass a different value for unique_id

The solution to the ‘variables’ exercise is available as part of our open-source Devops-Workstream.


Exercise: create Azure Resource Groups

Follow the Create Resource group tutorial to create resource groups with dynamic naming.

The solution to the ‘create Resource Group’ exercise is available as part of our open-source Devops-Workstream.


Exercise: create Azure Networks

  • Create a root module
    • Reuse the standard components (such as backend.tf and provider.tf from the previous tutorials
  • Create an azurerm_virtual_network
    • for 10.0.0.0/16
  • Create an azurerm_subnet
    • for some /24 subnet of that address space
    • e.g. 10.0.1.0/24
  • Create an azurerm_network_security_group
    • Open port 22 for inbound traffic from the Internet

The solution to the ‘create Azure Network’ exercise is available as part of our open-source Devops-Workstream.


Exercise: Network as a module

The solution to the ‘Network as a module’ exercise is available as part of our open-source Devops-Workstream.


Exercise: using the docs

  • Research on Terraform.io how to use the AzureRM provider to create a Linux Virtual Machine
  • Extend your solution to create virtual machines using a module
    • Instantiate your virtual machine module twice
    • Create two output resources that use string interpolation to compose an SSH command
      • One to SSH to each of your new hosts

The original solution used a now-deprecated resource type.network

The ‘referencing secrets’ exercise solution uses the more up-to-date azurerm_linux_virtual_machine resource type.


As with all exercises that involve Cloud provisioning, please ensure you terraform destroy all your Cloud resources after completing the exercise, in order to minimise your Cloud charges from Microsoft.

Further exercises were recently added to this series:

Leave a comment