|
| 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 | +} |
0 commit comments