From 5efc5cda8a26d4b5cb97d2b00745795f25c33920 Mon Sep 17 00:00:00 2001 From: Tom Archer Date: Tue, 14 Jan 2025 11:54:56 -0800 Subject: [PATCH] Initial put --- quickstart/101-azure-bastion-host/README.md | 19 ++++++++ quickstart/101-azure-bastion-host/main.tf | 47 +++++++++++++++++++ quickstart/101-azure-bastion-host/outputs.tf | 11 +++++ .../101-azure-bastion-host/providers.tf | 16 +++++++ .../101-azure-bastion-host/variables.tf | 11 +++++ 5 files changed, 104 insertions(+) create mode 100644 quickstart/101-azure-bastion-host/README.md create mode 100644 quickstart/101-azure-bastion-host/main.tf create mode 100644 quickstart/101-azure-bastion-host/outputs.tf create mode 100644 quickstart/101-azure-bastion-host/providers.tf create mode 100644 quickstart/101-azure-bastion-host/variables.tf diff --git a/quickstart/101-azure-bastion-host/README.md b/quickstart/101-azure-bastion-host/README.md new file mode 100644 index 000000000..0801b6812 --- /dev/null +++ b/quickstart/101-azure-bastion-host/README.md @@ -0,0 +1,19 @@ +# Azure Bastion + +This template deploys an Azure Bastion. + +## Terraform resource types + +- [random_pet](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/pet) +- [azurerm_resource_group](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group) +- [azurerm_virtual_network](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/virtual_network) +- [azurerm_subnet](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/subnet) +- [azurerm_public_ip](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/public_ip) +- [azurerm_bastion_host](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/bastion_host) + +## Variables + +| Name | Description | Default value | +|-|-|-| +| `resource_group_name_prefix` | Prefix of the resource group name that's combined with a random ID so name is unique in your Azure subscription. | rg | +| `resource_group_location` | Location of the resource group. | eastus | \ No newline at end of file diff --git a/quickstart/101-azure-bastion-host/main.tf b/quickstart/101-azure-bastion-host/main.tf new file mode 100644 index 000000000..35cb5bf0b --- /dev/null +++ b/quickstart/101-azure-bastion-host/main.tf @@ -0,0 +1,47 @@ +# Create Resource Group +resource "random_pet" "rg_name" { + prefix = var.resource_group_name_prefix +} + +resource "azurerm_resource_group" "rg" { + location = var.resource_group_location + name = random_pet.rg_name.id +} + +# Create Virtual Network +resource "azurerm_virtual_network" "vnet" { + name = "example-network" + address_space = ["10.0.0.0/16"] + location = azurerm_resource_group.rg.location + resource_group_name = azurerm_resource_group.rg.name +} + +# Create Subnet for Azure Bastion +resource "azurerm_subnet" "bastion_subnet" { + name = "AzureBastionSubnet" + resource_group_name = azurerm_resource_group.rg.name + virtual_network_name = azurerm_virtual_network.vnet.name + address_prefixes = ["10.0.1.0/24"] +} + +# Create Public IP for Azure Bastion +resource "azurerm_public_ip" "bastion_pip" { + name = "example-pip" + location = azurerm_resource_group.rg.location + resource_group_name = azurerm_resource_group.rg.name + allocation_method = "Static" + sku = "Standard" +} + +# Create Azure Bastion Host +resource "azurerm_bastion_host" "bastion" { + name = "example-bastion" + location = azurerm_resource_group.rg.location + resource_group_name = azurerm_resource_group.rg.name + + ip_configuration { + name = "configuration" + subnet_id = azurerm_subnet.bastion_subnet.id + public_ip_address_id = azurerm_public_ip.bastion_pip.id + } +} \ No newline at end of file diff --git a/quickstart/101-azure-bastion-host/outputs.tf b/quickstart/101-azure-bastion-host/outputs.tf new file mode 100644 index 000000000..03fa07782 --- /dev/null +++ b/quickstart/101-azure-bastion-host/outputs.tf @@ -0,0 +1,11 @@ +output "resource_group_name" { + value = azurerm_resource_group.rg.name +} + +output "bastion_host_name" { + value = azurerm_bastion_host.bastion.name +} + +output "bastion_host_ip" { + value = azurerm_public_ip.bastion_pip.ip_address +} \ No newline at end of file diff --git a/quickstart/101-azure-bastion-host/providers.tf b/quickstart/101-azure-bastion-host/providers.tf new file mode 100644 index 000000000..7261b1fb4 --- /dev/null +++ b/quickstart/101-azure-bastion-host/providers.tf @@ -0,0 +1,16 @@ +terraform { + required_providers { + azurerm = { + source = "hashicorp/azurerm" + version = "~>3.0" + } + random = { + source = "hashicorp/random" + version = "~>3.0" + } + } +} + +provider "azurerm" { + features {} +} \ No newline at end of file diff --git a/quickstart/101-azure-bastion-host/variables.tf b/quickstart/101-azure-bastion-host/variables.tf new file mode 100644 index 000000000..1a8c6abba --- /dev/null +++ b/quickstart/101-azure-bastion-host/variables.tf @@ -0,0 +1,11 @@ +variable "resource_group_location" { + type = string + default = "eastus" + description = "Location of the resource group." +} + +variable "resource_group_name_prefix" { + type = string + default = "rg" + description = "Prefix of the resource group name that's combined with a random ID so name is unique in your Azure subscription." +} \ No newline at end of file