Skip to content

Commit

Permalink
Initial put
Browse files Browse the repository at this point in the history
  • Loading branch information
TomArcherMsft committed Feb 18, 2025
1 parent fe53fb9 commit 71763eb
Show file tree
Hide file tree
Showing 5 changed files with 173 additions and 0 deletions.
126 changes: 126 additions & 0 deletions quickstart/101-virtual-network-public-ip-prefix/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
# Random pet resource to generate a unique name for the resource group
resource "random_pet" "rg_name" {
prefix = var.resource_group_name_prefix
}

# Create a resource group
resource "azurerm_resource_group" "example" {
location = var.resource_group_location
name = random_pet.rg_name.id
}

# Create a public IP prefix: IPv4 Zone redundant
resource "azurerm_public_ip_prefix" "my_ipv4" {
name = "myIPv4"
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name

prefix_length = 28
ip_version = "IPv4"
zones = ["1", "2", "3"]
}

# Create a public IP prefix: IPv4 Zonal
resource "azurerm_public_ip_prefix" "my_ipv4_zonal" {
name = "myIPv4Zonal"
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name

prefix_length = 28
ip_version = "IPv4"
zones = ["2"]
}

# Create a public IP prefix: IPv4 Non-Zonal
resource "azurerm_public_ip_prefix" "my_ipv4_non_zonal" {
name = "myIPv4NonZonal"
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name

prefix_length = 28
ip_version = "IPv4"
}

# Create a public IP prefix: IPv4 with Routing Preference set to Internet
resource "azurerm_public_ip_prefix" "my_ipv4_rp_internet" {
name = "myIPv4RPInternet"
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name

prefix_length = 28

tags = {
RoutingPreference = "Internet"
}
}

# Create a public IP prefix: IPv4 Zone redundant
resource "azurerm_public_ip_prefix" "my_ipv6" {
name = "myIpv6"
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name

prefix_length = 124
ip_version = "IPv6"
zones = ["1", "2", "3"]
}

# Create a public IP prefix: IPv6 Zonal
resource "azurerm_public_ip_prefix" "my_ipv6_zonal" {
name = "myIpv6Zonal"
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name

prefix_length = 124
ip_version = "IPv6"
zones = ["2"]
}

# Create a public IP prefix: IPv6 Non-Zonal
resource "azurerm_public_ip_prefix" "my_ipv6_non_zonal" {
name = "myIpv6NonZonal"
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name

prefix_length = 124
ip_version = "IPv6"
}

# Create a public IP (IPv4) and specify the public IP prefix
resource "azurerm_public_ip" "my_public_ip_ipv4" {
name = "myPublicIPIPv4"
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name
allocation_method = "Static"
sku = "Standard"
ip_version = "IPv4"
public_ip_prefix_id = azurerm_public_ip_prefix.my_public_ip_prefix_ipv4.id
}

# Create a public IP prefix: IPv4
resource "azurerm_public_ip_prefix" "my_public_ip_prefix_ipv4" {
name = "myPublicIpPrefix1"
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name
prefix_length = 28
}

# Create a public IP (IPv4) and specify the public IP prefix
resource "azurerm_public_ip" "my_public_ip_ipv6" {
name = "myPublicIPIPv6"
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name
allocation_method = "Static"
public_ip_prefix_id = azurerm_public_ip_prefix.my_public_ip_prefix_ipv6.id
sku = "Standard"
ip_version = "IPv6"
}

# Create a public IP prefix: IPv6
resource "azurerm_public_ip_prefix" "my_public_ip_prefix_ipv6" {
name = "myPublicIpPrefix2"
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name
prefix_length = 28
sku = "Standard"
}
3 changes: 3 additions & 0 deletions quickstart/101-virtual-network-public-ip-prefix/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
output "resource_group_name" {
value = azurerm_resource_group.example.name
}
16 changes: 16 additions & 0 deletions quickstart/101-virtual-network-public-ip-prefix/providers.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "~>3.0"
}
random = {
source = "hashicorp/random"
version = "~>3.0"
}
}
}

provider "azurerm" {
features {}
}
17 changes: 17 additions & 0 deletions quickstart/101-virtual-network-public-ip-prefix/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Azure Public IP Prefix

This template deploys several Azure public IP prefixes with different settings.

## 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_public_ip](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/public_ip)
- [azurerm_public_ip_prefix](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/public_ip_prefix)

## Variables

| Name | Description | Default |
|-|-|-|
| `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 |
11 changes: 11 additions & 0 deletions quickstart/101-virtual-network-public-ip-prefix/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
variable "resource_group_location" {
type = string
default = "West Europe"
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."
}

0 comments on commit 71763eb

Please sign in to comment.