Skip to content

Commit 80d0428

Browse files
committed
Update configuration
1 parent f0054ae commit 80d0428

File tree

3 files changed

+162
-43
lines changed

3 files changed

+162
-43
lines changed
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
# -------------------------------------------------------------------------------------
2+
#
3+
# Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com) All Rights Reserved.
4+
#
5+
# WSO2 LLC. licenses this file to you under the Apache License,
6+
# Version 2.0 (the "License"); you may not use this file except
7+
# in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing,
13+
# software distributed under the License is distributed on an
14+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
# KIND, either express or implied. See the License for the
16+
# specific language governing permissions and limitations
17+
# under the License.
18+
#
19+
# --------------------------------------------------------------------------------------
20+
21+
resource "azurerm_traffic_manager_external_endpoint" "performance_based_external_endpoint" {
22+
count = var.routing_method == "Performance" ? 1 : 0
23+
name = var.endpoint_name
24+
profile_id = var.profile_id
25+
target = var.target
26+
endpoint_location = var.endpoint_location
27+
always_serve_enabled = var.always_serve_enabled
28+
enabled = var.enabled
29+
dynamic "custom_header" {
30+
for_each = var.custom_headers
31+
content {
32+
name = custom_header.value.header_name
33+
value = custom_header.value.header_value
34+
}
35+
}
36+
}
37+
38+
resource "azurerm_traffic_manager_external_endpoint" "weighted_based_external_endpoint" {
39+
count = var.routing_method == "Weighted" ? 1 : 0
40+
name = var.endpoint_name
41+
profile_id = var.profile_id
42+
target = var.target
43+
weight = var.weight
44+
always_serve_enabled = var.always_serve_enabled
45+
enabled = var.enabled
46+
dynamic "custom_header" {
47+
for_each = var.custom_headers
48+
content {
49+
name = custom_header.value.header_name
50+
value = custom_header.value.header_value
51+
}
52+
}
53+
}
54+
55+
resource "azurerm_traffic_manager_external_endpoint" "priority_based_external_endpoint" {
56+
count = var.routing_method == "Priority" ? 1 : 0
57+
name = var.endpoint_name
58+
profile_id = var.profile_id
59+
target = var.target
60+
priority = var.priority
61+
always_serve_enabled = var.always_serve_enabled
62+
enabled = var.enabled
63+
dynamic "custom_header" {
64+
for_each = var.custom_headers
65+
content {
66+
name = custom_header.value.header_name
67+
value = custom_header.value.header_value
68+
}
69+
}
70+
}
71+
72+
resource "azurerm_traffic_manager_external_endpoint" "geographic_based_external_endpoint" {
73+
count = var.routing_method == "Geographic" ? 1 : 0
74+
name = var.endpoint_name
75+
profile_id = var.profile_id
76+
target = var.target
77+
geo_mappings = var.geo_mappings
78+
always_serve_enabled = var.always_serve_enabled
79+
enabled = var.enabled
80+
dynamic "custom_header" {
81+
for_each = var.custom_headers
82+
content {
83+
name = custom_header.value.header_name
84+
value = custom_header.value.header_value
85+
}
86+
}
87+
}
88+
89+
resource "azurerm_traffic_manager_external_endpoint" "multivalue_based_external_endpoint" {
90+
count = var.routing_method == "Multivalue" ? 1 : 0
91+
name = var.endpoint_name
92+
profile_id = var.profile_id
93+
target = var.target
94+
always_serve_enabled = var.always_serve_enabled
95+
enabled = var.enabled
96+
dynamic "custom_header" {
97+
for_each = var.custom_headers
98+
content {
99+
name = custom_header.value.header_name
100+
value = custom_header.value.header_value
101+
}
102+
}
103+
}
104+
105+
resource "azurerm_traffic_manager_external_endpoint" "subnet_based_external_endpoint" {
106+
count = var.routing_method == "Subnet" ? 1 : 0
107+
name = var.endpoint_name
108+
profile_id = var.profile_id
109+
target = var.target
110+
always_serve_enabled = var.always_serve_enabled
111+
enabled = var.enabled
112+
dynamic "subnet" {
113+
for_each = var.subnets
114+
content {
115+
first = subnet.value.first
116+
last = subnet.value.last
117+
scope = subnet.value.scope
118+
}
119+
}
120+
dynamic "custom_header" {
121+
for_each = var.custom_headers
122+
content {
123+
name = custom_header.value.header_name
124+
value = custom_header.value.header_value
125+
}
126+
}
127+
}

modules/azurerm/Traffic-Manager-External-Endpoint/traffic_manager_priority_external_endpoint.tf

Lines changed: 0 additions & 36 deletions
This file was deleted.

modules/azurerm/Traffic-Manager-External-Endpoint/variables.tf

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,10 @@ variable "target" {
3434
}
3535

3636
variable "routing_method" {
37-
description = "Routing method for the Traffic Manager Profile. Valid values are 'Performance', 'Priority', 'Weighted', 'Geographic', 'Multivalue', 'Subnet'."
37+
description = "Routing method for the Traffic Manager Profile. Valid values are 'Performance', 'Priority', 'Weighted', 'Geographic', 'Multivalue', 'Subnet'"
3838
type = string
3939
}
4040

41-
variable "endpoint_location" {
42-
description = "Location of the endpoint. Required for Performance routing method."
43-
type = string
44-
default = ""
45-
}
46-
4741
variable "custom_headers" {
4842
description = "Custom headers for the endpoint"
4943
type = list(object({
@@ -64,3 +58,37 @@ variable "enabled" {
6458
type = bool
6559
default = true
6660
}
61+
62+
variable "weight" {
63+
description = "Weight of the endpoint. Required for Weighted routing method. Valid values are between 1 and 1000"
64+
type = number
65+
default = 1
66+
}
67+
68+
variable "priority" {
69+
description = "Priority of the endpoint. Required for Priority routing method. Valid values are between 1 and 1000"
70+
type = number
71+
default = 1
72+
}
73+
74+
variable "endpoint_location" {
75+
description = "Location of the endpoint. Required for Performance routing method. The location must be specified for endpoints of types: 'Performance'"
76+
type = string
77+
default = ""
78+
}
79+
80+
variable "geo_mappings" {
81+
description = "A list of Geographic Regions used to distribute traffic. Required for Geographic routing method."
82+
type = list(string)
83+
default = []
84+
}
85+
86+
variable "subnets" {
87+
description = "A list of subnets used to distribute traffic. Required for Subnet routing method."
88+
type = list(object({
89+
first = string
90+
last = optional(string)
91+
scope = optional(string)
92+
}))
93+
default = []
94+
}

0 commit comments

Comments
 (0)