Skip to content
/ Terraform-Azure Public template

Contains Terraform code for Azure deployment - snippets, useful bits, samples, labs and more. All deployable in small instances with ready to go code. These are designed for training/learning and documentation on deployment using GitHub Actions and Terraform Cloud is included.

Notifications You must be signed in to change notification settings

jakewalsh90/Terraform-Azure

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Terraform-Azure

Check Links

This repository contains Terraform sample code for Azure - mostly smaller deployments, labs, test environments. These are environments I used to demonstrate/test. Feel free to use these as you wish! 😄

Due to the fact that some of the Terraform Projects in this Repository are unlikely to be used alone, the samples provided may also contain supporting elements. So in some cases, items like Resource Groups, VNETs, Subnets and more are deployed to support whatever is being demonstrated.

To utilise the code you may therefore just deploy as is and see the concept being demonstrated, without needing to adapt the code or rework it. You can then take any elements you require and work them into your code, to move forward from there.

New to Azure Terraform?

✔️ Check out my Getting Started Blog Series:

How to Deploy

✔️ Install the Right Tools First!

I have setup a Chocolatey script that will provide all the tools you need to work with Terraform on Azure - see here or use the Chocolatey install script below:

# Chocolatey setup and installation script for using Terraform
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
# Chocolatey apps
choco install vscode -y -no-desktopshortcuts
choco install terraform -y -no-desktopshortcuts
choco install azure-cli -y -no-desktopshortcuts
choco install az.powershell -y -no-desktopshortcuts
choco install github-desktop -y -no-desktopshortcuts

➡️ GitHub Actions

These projects can be deployed using GitHub Actions - for a full guide, please see here.

➡️ Terraform Cloud

These projects can be deployed using Terraform Cloud - for a prerequisite guide, please see here.

➡️ Manual Deployment

For most of the Projects the following files are provided:

  • azuredeploy.tf
  • variables.tf
  • terraform.tfvars
  • provider.tf

These should be placed into a directory, and then Terraform initialised and applied. Note that for some projects the TF Files are split out into seperate files for ease of use!

❓ Want to see new Projects in this Repository?

Please reach out to me via my Website - I am happy to create new projects or collaborate!

❓ Found an issue or Bug?

Please open an issue, or feel free to create a pull request. You can also reach out to me via my Website :)

✔️ Projects in this Repository

1. Automatic NSG based on the Client IP of the Machine running Terraform

This creates a data item that gets the external IP of the machine that is running Terraform. The IP is then used to create an inbound security rule inside a Network Security Group. See: Automatic-ClientIP-NSG

2. Azure KeyVault with Secret for Virtual Machine Password

This creates an Azure Key Vault using a random name like "keyvault##########", and then creates a password string, using the random_string resource, which is stored inside the KeyVault. This can then be used during the setup of VMs with Terraform . See: Azure-KeyVault-with-Secret

3. Single Region Base Lab Environment for Azure

Note: Now updated to V2 - see Single Region Azure Base Lab V2. This code creates a simple Lab environment within a Single Azure Region. The idea here is that it allows for quick deployment of VNETs, Subnets, and a Domain Controller to simulate smaller environments or provide a quick lab for any test requirements. See: Single-Region-Azure-BaseLab

4. Single Region Base Lab Environment for Azure - with Ansible VM

This code creates a simple Lab environment within a Single Azure Region, and also includes an Ubuntu VM with Ansible installed. The idea here is that it allows for quick deployment of VNETs, Subnets, and a Domain Controller to simulate smaller environments or provide a quick lab for any test requirements, and also to provide Ansible. See: Single-Region-Azure-BaseLab-with-Ansible

5. Ansible Quickstart Lab

This code creates a simple Azure Environment with an Ubuntu Server VM, and uses a Custom Script Extension to install Ansible. You can then use Ansible as you require. See Ansible-Quickstart

6. Dual Region Base Lab Environment for Azure

This code creates a simple Lab environment within two Azure Regions. The idea here is that it allows for quick deployment of VNETs, Subnets, and two Domain Controllers to simulate smaller environments or provide a quick lab for any test requirements. See: Dual-Region-Azure-BaseLab

7. Azure NetApp Files Cross Region Replication Base Lab

This code creates a simple Lab environment within two Azure Regions. A number of Azure NetApp Files Resources are also provisioned ready for setting up a basic Active Directory Domain, and then configuring Azure NetApp Files, with Cross Region Replication. This Lab is covered in detail on my blog, and was the subject of a user group talk, for which the slides are available in my events repo: See: Azure-NetApp-Files-CRR-BaseLab

8. Azure Firewall Demolab

This code sets up an Azure Base Lab, based on the Single Region Lab above, but also includes Azure Firewall. Firewall options, policies, and deployment settings can be tested using this lab. See: Azure-Firewall-Baselab

9. Azure Virtual WAN Demo Lab

This code sets up an Azure vWAN Demo Lab. Based on a two Region deployment, with documentation. See: Virtual-WAN-Demo Details of this Lab are also available on my blog here.

10. Web Server IIS Demo Lab

This code sets up an Azure Base Lab, based on the Single Region Lab above, but installs IIS onto the VM it creates using a Custom Script Extension. See: Web-Server-IIS-DemoLab

11. cidrsubnet Function Demo

This code demonstrates the use of the cidrsubnet function, and shows how it can be used to create an environment whereby network CIDR ranges can be specified once, and then Terraform used to do the splitting of networks easily. See: CIDRSubnet-Demo

12. cidrhost Function Demo

This code demonstrates the use of the cidrhost function, and shows how it can be used to create an environment whereby host IP addresses can be calculated from a network CIDR range. This demo includes showing usage within Virtual Network DNS Servers, Network Interfaces, NSGs, and Route Tables. See: CIDRHost-Demo

13. Chaos Studio Test Environment

This code sets up a demonstration environment to support a blog post around Azure Chaos Studio. It builds out a deployment of Windows Servers, running IIS, across two Regions. Azure Load Balancer, Firewall, and Traffic Manager are then used to provide Load Balancing and Failover. See: Chaos-Studio-Test. The blog post for this environment is also available here.

14. Single Region Base Lab Environment for Azure - V2

Updated from my Single Region Azure Base Lab - This V2 version creates a simple Lab environment within a Single Azure Region. The idea here is that it allows for quick deployment of VNETs, Subnets, Domain Controller/Additional VMs to simulate smaller environments or provide a quick lab for any test requirements. Now includes optional features, enabled/disabled via Variables; Azure Bastion, Azure Firewall, AVD Supporting Elements, and a Virtual Network Gateway. See: Single-Region-Azure-BaseLab-v2

15. Azure Automation Demo

This environment creates a simple Azure Automation Demo Environment, along with a PowerShell runbook. A schedule that is used to trigger the runbook is used - which then shuts down VMs based on a Tag. See: Azure-Automation-Demo

16. Cross-Region (Global) Azure Load Balancer Lab Environment

This environment creates a demo environment for the Azure Cross-Region (Global) Load Balancer. Using a mixture of Virtual Machines running IIS, and Regional Load Balancers as a foundation, a Cross-Region (Global) Load Balancer is then deployed to Load Balance between Regions. This can be used for basic testing and learning. See: Cross-Region-Load-Balancer-Lab

17. Cost Optimisation Example Lab

This environment creates a sample version of my Single Region Azure BaseLab V2, but with many unused resources (Disks, Public IPs, etc.) to allow cost management tooling to pick these up and recommend optimisations as a result. It is not recommended to use this environment for anything other than demonstrating cost management tooling. See: Cost-Optimisation-Example-Lab

18. Core Environment Demo Lab

This environment creates a simple Azure environment designed to be ready to deploy with Terraform Cloud, with the necessary provider.tf and variables.tf configuration to deploy using Terraform Cloud. This lab is based around Azure Virtual WAN, Firewall, and many more services - and can be quickly deployed to numerous regions with an integrated Virtual WAN Topology. This lab also includes a Point to Site VPN, and makes use of Map Variables, CIDR Subnet and many more interesting aspects. See: Core-Environment-DemoLab-v1

About

Contains Terraform code for Azure deployment - snippets, useful bits, samples, labs and more. All deployable in small instances with ready to go code. These are designed for training/learning and documentation on deployment using GitHub Actions and Terraform Cloud is included.

Topics

Resources

Stars

Watchers

Forks