Skip to content

Terraform example for provisioning a workshop environment on Azure

Notifications You must be signed in to change notification settings

btungut/terraform-azure-workshop-lab-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

An Example for Azure Workshop Lab Provisioning with Terraform

Assume you are a workshop instructor who needs to quickly set up the lab environments for the attendees. Without a doubt, you should have experience with IaaC tools in order to standardize your environment requirements in manifests.


Motivation and comments from author

As a consultant who has been presenting and performing PoCs with clients, I recognized a need for IaaC to provision the environments. This is the motivation of this repository.

I really hope that you will be able to find some helpful techniques and knowledge in this repository.


Context

This repository includes an implementation of Terraform manifests that responsible to create;

  • Common VNET
    • devtest subnet
    • preprod subnet
    • prod subnet
    • VPN subnets
  • VPN for created VNET
  • Lab environment for attendees as much as demanded (e.g.: contoso and four attendees)
    • rg-contoso-01-infra Resource Group
      • acrworkshopbtcontoso01 Azure Container Registry
      • vm-k3s-contoso-01-devtest Virtual Machine
        • nic
        • os disk
      • vm-k3s-contoso-01-preprod Virtual Machine
        • nic
        • os disk
      • vm-k3s-contoso-01-prod Virtual Machine
        • nic
        • os disk
    • rg-contoso-01-devtest Resource Group
      • kv-contoso-01-devtest Azure KeyVault
      • arc-k3s-contoso-01-devtest TODO Arc-Enabled Kubernetes Cluster
    • rg-contoso-01-preprod Resource Group
      • kv-contoso-01-preprod Azure KeyVault
      • arc-k3s-contoso-01-preprod TODO Arc-Enabled Kubernetes Cluster
    • rg-contoso-01-prod Resource Group
      • kv-contoso-01-prod Azure KeyVault
      • arc-k3s-contoso-01-prod TODO Arc-Enabled Kubernetes Cluster

1. Create Self Signed Certificate for VPN

  1. To complete this task, please cd to root directory then run the following snippet:
    chmod +x ./01-create-cert.sh
    ./01-create-cert.sh

Once the execution is complete, three files should be created in .assets directory.

  • BT-WORKSHOP-ROOT.key
  • BT-WORKSHOP-ROOT.cer
  • BT-WORKSHOP-ROOT.b64

2. Create the common resources

You will provision the following resources in this step:

  • Common Resource Group
    • Common VNet
      • Subnets
      • VPN Public IP
      • VPN

NOTE THAT This task may take longer than twenty minutes to complete due to the VPN provisioning time.

  1. Please cd to root directory, then run the bash script with your unique name:

    chmod +x ./02-install-common.sh
    ./02-install-common.sh "contoso"
  2. You will be prompted for Execute 01-common step which is responsible for common resource group, vnet and subnet creations.

    • Type Y and press ENTER to continue.

    • Once the terraform plan execution is completed, you will be informed about the resources to be created. Again,

      • Type Y and press ENTER to continue.

    • Visit the Azure Portal once you see the terraform apply is succeeded message for this step. Below resources should be created in your Azure subscription.

  3. Once the execution is completed, you will be again prompted for a task. This is for Execute 02-common-vpn step which is responsible for creation of VPN. This step may take several times to complete but also it is crucial for accessing the VM and VNET hosted on Azure.

    • This task is utilizing the certificate that located in .assets directory.

    • Type Y and press ENTER to continue both for plan and execution.

    • As it mentioned before, creation of the VPN may take more than twenty minutes.

3. Provision the resources per attendee

In this task, you will execute the 03-provision-lab.sh bash script which required two arguments;

  1. Unique name (e.g.: contoso)

  2. Indice of attendee, it should be unique also for per attendee (e.g..: 8 for 8th people)

  3. Please cd to root directory, then run the following script with two arguments that suitable for your environment

    chmod +x ./03-provision-lab.sh
    ./02-install-common.sh "contoso" 8
    • Type Y and press ENTER to continue once the terraform plan is completed

    • While the execution is progressing, you will see the results like below:

  4. Once the execution is completed, you will see the terraform apply is succeeded for 8 output from script, after that, please visit the Azure Portal.

    • Your infra and environment resource groups should be created like below

    • infra namespace should includes the VMs and its dependencies

Connect to VPN

  1. Before installing and connection to VPN you created, you should install the self signed certificate you created in first step.
    1. Navigate to .assets directory

SSH into one of the VM

TODO

Ensure Kubernetes is working

TODO

About

Terraform example for provisioning a workshop environment on Azure

Topics

Resources

Stars

Watchers

Forks