Code Monkey home page Code Monkey logo

jakewalsh90 / terraform-azure Goto Github PK

View Code? Open in Web Editor NEW
107.0 9.0 138.0 1.97 MB

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.

HCL 94.16% PowerShell 5.65% Shell 0.18%
terraform azure github-actions devops demo learning-resources labs terraform-cloud

terraform-azure's Introduction

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

terraform-azure's People

Contributors

jakewalsh90 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

terraform-azure's Issues

More of a question...

In azuredeploy.tf in the resource windows virtual machine you have:
protected_settings = <<PROTECTED_SETTINGS
{
"commandToExecute": "powershell.exe -Command "./baselab_DCSetup.ps1; exit 0;""
}
PROTECTED_SETTINGS

settings = <<SETTINGS
{
"fileUris": [
"https://raw.githubusercontent.com/jakewalsh90/Terraform-Azure/main/Single-Region-Azure-BaseLab/PowerShell/baselab_DCSetup.ps1"
]
}
SETTINGS

Why? The files are listed in the "powershell" folder. Are they not copied to the VM during deployment? Or are they just there for reference?

If the file is downloaded from github, what tells the vm where to copy the file to?

Single Region Base Lab Environment for Azure

I am very grateful to you for your code
I'm just trying to deploy the single region base lab environment via terraform and git hub actions
I'm still there after 30 minutes:

image
Should the code still work?
Thank you so much!

Best Regards
Florian

Missing required argument - sku_name (Azure Firewall)

So when deploying the Azure-Firewall-DemoLab Im getting an error stating its missing an argument. Just messing around and familiarizing myself with terraform so wondering if you could point me in the right direction with this one.

Out of all the terraform firewall examples this one seems the most thorough so any help you could provide would be most appriciated. Thank you!

Below is the snippet.

Error: Missing required argument
โ”‚
โ”‚ on azuredeploy.tf line 334, in resource "azurerm_firewall" "region1-fw01":
โ”‚ 334: resource "azurerm_firewall" "region1-fw01" {
โ”‚
โ”‚ The argument "sku_name" is required, but no definition was found.

Terraform Destroy (No changes. No objects need to be destroyed.)

Hello Jake,
Thank you for the Interstate Meeting last week. ๐Ÿฅ‡

I have now copied your Git repo and executed the Git action "Terraform Validate, Plan, and Apply" for the Single-Region-Azure-BaseLab-v2.
The Azure resources were successfully provisioned.
Cool, thanks! ๐Ÿ‘

Now, when I try to delete the resources using the "Terraform Destroy" action,
I receive the following message: "No changes. No objects need to be destroyed."

Do you have any ideas or tips on what to do?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.