Skip to content

Commit fe53fb9

Browse files
Merge pull request #424 from Azure/101-virtual-network-public-ip
101-virtual-network-public-ip
2 parents 830634a + b2c18d3 commit fe53fb9

File tree

5 files changed

+117
-0
lines changed

5 files changed

+117
-0
lines changed
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
resource "random_pet" "rg_name" {
2+
prefix = var.resource_group_name_prefix
3+
}
4+
5+
resource "azurerm_resource_group" "example" {
6+
location = var.resource_group_location
7+
name = random_pet.rg_name.id
8+
}
9+
10+
resource "azurerm_public_ip" "myStandardPublicIP" {
11+
name = "myStandardPublicIP"
12+
resource_group_name = azurerm_resource_group.example.name
13+
location = azurerm_resource_group.example.location
14+
allocation_method = "Static"
15+
sku = "Standard"
16+
ip_version = "IPv4"
17+
zones = ["1", "2", "3"]
18+
}
19+
20+
resource "azurerm_public_ip" "myBasicPublicIP" {
21+
name = "myBasicPublicIP"
22+
resource_group_name = azurerm_resource_group.example.name
23+
location = azurerm_resource_group.example.location
24+
allocation_method = "Static"
25+
sku = "Basic"
26+
ip_version = "IPv4"
27+
}
28+
29+
resource "azurerm_public_ip" "myZonalStandardPublicIP" {
30+
name = "myZonalStandardPublicIP"
31+
resource_group_name = azurerm_resource_group.example.name
32+
location = azurerm_resource_group.example.location
33+
allocation_method = "Static"
34+
sku = "Standard"
35+
ip_version = "IPv4"
36+
zones = ["2"]
37+
}
38+
39+
resource "azurerm_public_ip" "myNonZonalStandardPublicIP" {
40+
name = "myNonZonalStandardPublicIP"
41+
resource_group_name = azurerm_resource_group.example.name
42+
location = azurerm_resource_group.example.location
43+
allocation_method = "Static"
44+
sku = "Standard"
45+
ip_version = "IPv4"
46+
}
47+
48+
resource "azurerm_public_ip" "myRoutingPreferenceStandardPublicIP" {
49+
name = "myRoutingPreferenceStandardPublicIP"
50+
resource_group_name = azurerm_resource_group.example.name
51+
location = azurerm_resource_group.example.location
52+
allocation_method = "Static"
53+
sku = "Standard"
54+
ip_version = "IPv4"
55+
56+
ip_tags = {
57+
RoutingPreference = "Internet"
58+
}
59+
60+
zones = ["1", "2", "3"]
61+
}
62+
63+
resource "azurerm_public_ip" "myGlobalTierStandardPublicIP" {
64+
name = "myGlobalTierStandardPublicIP-Global"
65+
resource_group_name = azurerm_resource_group.example.name
66+
location = azurerm_resource_group.example.location
67+
allocation_method = "Static"
68+
sku = "Standard"
69+
sku_tier = "Global"
70+
ip_version = "IPv4"
71+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
output "resource_group_name" {
2+
value = azurerm_resource_group.example.name
3+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
terraform {
2+
required_providers {
3+
azurerm = {
4+
source = "hashicorp/azurerm"
5+
version = "~>3.0"
6+
}
7+
random = {
8+
source = "hashicorp/random"
9+
version = "~>3.0"
10+
}
11+
}
12+
}
13+
14+
provider "azurerm" {
15+
features {}
16+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Azure Public IP Address
2+
3+
This template deploys several Azure public IP addresses with different settings.
4+
5+
## Terraform resource types
6+
7+
- [random_pet](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/pet)
8+
- [azurerm_resource_group](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group)
9+
- [azurerm_public_ip](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/public_ip)
10+
11+
## Variables
12+
13+
| Name | Description | Default |
14+
|-|-|-|
15+
| `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 |
16+
| `resource_group_location` | Location of the resource group. | eastus |
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
variable "resource_group_location" {
2+
type = string
3+
default = "West Europe"
4+
description = "Location of the resource group."
5+
}
6+
7+
variable "resource_group_name_prefix" {
8+
type = string
9+
default = "rg"
10+
description = "Prefix of the resource group name that's combined with a random ID so name is unique in your Azure subscription."
11+
}

0 commit comments

Comments
 (0)